blob: 5d79f6a85e7c695565d56f3e23625fa5b9d2b191 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../js/resources/js-test-pre.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';");
evalAndLog("xhr.open('GET', window.location.href, false);");
shouldBeEqualToString('xhr.responseType', 'document');
// 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';");
evalAndLog("xhr.open('GET', dataUrl, false);");
shouldBeEqualToString('xhr.responseType', 'document');
</script>
<script src="../js/resources/js-test-post.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
</body>
</html>