<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script>
description('This tests that XMLHttpRequest open() disallows synchronous HTTP(S) requests when a non-default responseType is set.');
var xhr;
// HTTP
xhr = new XMLHttpRequest();
evalAndLog("xhr.responseType = 'document';");
shouldThrow("xhr.open('GET', 'http://mydomain/', false);");
// HTTPS
xhr = new XMLHttpRequest();
evalAndLog("xhr.responseType = 'document';");
shouldThrow("xhr.open('GET', 'https://mysecuredomain/', false);");
// FILE
shouldBeEqualToString('window.location.protocol', 'file:');
xhr = new XMLHttpRequest();
evalAndLog("xhr.responseType = 'document';");
shouldThrow("xhr.open('GET', window.location.href, false);");
// DATA
var dataUrl = 'data:text/html;charset=utf-8,%3C%21DOCTYPE%20' +
'html%3E%0D%0A%3Chtml%20lang%3D%22en%22%3E%0D%0A%3Chead%' +
'3E%3Ctitle%3EEmbedded%20Window%3C%2Ftitle%3E%3C%2Fhead%' +
'3E%0D%0A%3Cbody%3E%3Ch1%3E42%3C%2Fh1%3E%3C%2Fbody%3E%0A' +
'%3C%2Fhtml%3E%0A%0D%0A';
xhr = new XMLHttpRequest();
evalAndLog("xhr.responseType = 'document';");
shouldThrow("xhr.open('GET', dataUrl, false);");
</script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
</body>
</html>