| <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, async, user, pwd) { |
| 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, async, user, pwd); |
| 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/basic-auth-default/dir1/basic-auth.php', true, "test", "test", 'text').then(function(req) { |
| window.responseURL = req.responseURL; |
| shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/resources/basic-auth-default/dir1/basic-auth.php'); |
| |
| return runTest('resources/basic-auth-default/dir2/basic-auth.php', true, 'text'); |
| }).then(function(req) { |
| window.responseURL = req.responseURL; |
| shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/resources/basic-auth-default/dir2/basic-auth.php'); |
| |
| 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> |