blob: a585858f3f3935bb44ba778496e63ae0dd3ef091 [file] [log] [blame]
<html>
<head></head>
<body>
<script src="/js-test-resources/js-test.js"></script>
<script>
description('Test XMLHttpRequest responseURL.');
window.jsTestIsAsync = true;
function runTest(url, type) {
return new Promise(function(resolve, reject) {
var req = new XMLHttpRequest();
window.responseURL = req.responseURL;
debug('req.readyState = ' + req.readyState + ': responseURL = ' + req.responseURL);
shouldBeEqualToString('responseURL', '');
req.open('GET', url);
req.responseType = type;
debug('req.readyState = ' + req.readyState + ': responseURL = ' + req.responseURL);
window.responseURL = req.responseURL;
shouldBeEqualToString('responseURL', '');
req.onreadystatechange = function() {
debug('req.readyState = ' + req.readyState + ': responseURL = ' + req.responseURL);
if (req.readyState == req.DONE)
resolve(req);
}
req.send();
debug('req.readyState = ' + req.readyState + ': responseURL = ' + req.responseURL);
window.responseURL = req.responseURL;
shouldBeEqualToString('responseURL', '');
});
}
runTest('resources/reply.txt', 'text').then(function(req) {
window.responseURL = req.responseURL;
shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/resources/reply.txt');
return runTest('resources/redirect_methods.php?url=reply.xml', 'document');
}).then(function(req) {
window.responseURL = req.responseURL;
shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/resources/reply.xml');
return runTest('resources/redirect_methods.php?url=not-found.txt', 'text');
}).then(function(req) {
window.responseURL = req.responseURL;
shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/resources/not-found.txt');
return runTest('resources/cross-site-progress-events.cgi', 'text');
}).then(function(req) {
window.responseURL = req.responseURL;
shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/resources/cross-site-progress-events.cgi');
return runTest("supported-xml-content-types.cgi?type=foo#bar/baz+xml", 'xml');
}).then(function(req) {
window.responseURL = req.responseURL;
shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/supported-xml-content-types.cgi?type=foo');
req.open('GET', 'http://127.0.0.1:8000/xmlhttprequest/resources/not-found.txt');
}).catch(function(reason) {
testFailed(String(reason));
}).then(finishJSTest, finishJSTest);
</script>
</body>
</html>