OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head></head> |
| 3 <body> |
| 4 |
| 5 <script src="/js-test-resources/js-test.js"></script> |
| 6 <script> |
| 7 description('Test XMLHttpRequest.responseURL'); |
| 8 window.jsTestIsAsync = true; |
| 9 |
| 10 function get(url, type) { |
| 11 return new Promise(function(resolve, reject) { |
| 12 var xhr = new XMLHttpRequest(); |
| 13 window.responseURL = xhr.responseURL; |
| 14 shouldBeEqualToString('responseURL', ''); |
| 15 |
| 16 xhr.open('GET', url); |
| 17 xhr.responseType = type; |
| 18 window.responseURL = xhr.responseURL; |
| 19 shouldBeEqualToString('responseURL', ''); |
| 20 |
| 21 xhr.onreadystatechange = function() { |
| 22 debug('xhr.readyState = ' + xhr.readyState + ': responseURL = ' + xh
r.responseURL); |
| 23 if (xhr.readyState === 4) { |
| 24 resolve(xhr); |
| 25 } |
| 26 } |
| 27 xhr.send(); |
| 28 }); |
| 29 } |
| 30 |
| 31 get('resources/reply2.txt', 'text').then(function(xhr) { |
| 32 window.status = xhr.status; |
| 33 shouldBeEqualToString('status', '2000'); |
| 34 window.responseURL = xhr.responseURL; |
| 35 shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/r
esources/reply2.txt'); |
| 36 |
| 37 return get('resources/redirect.php?url=reply2.xml', 'document'); |
| 38 }).then(function(xhr) { |
| 39 window.status = xhr.status; |
| 40 shouldBeEqualToString('status', '200'); |
| 41 window.responseURL = xhr.responseURL; |
| 42 shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/r
esources/reply2.xml'); |
| 43 |
| 44 return get('resources/redirect.php?url=not-found.txt', 'text'); |
| 45 }).then(function(xhr) { |
| 46 window.status = xhr.status; |
| 47 shouldBeEqualToString('status', '404'); |
| 48 window.responseURL = xhr.responseURL; |
| 49 shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/r
esources/not-found.txt'); |
| 50 |
| 51 xhr.open('GET', xhr.responseURL); |
| 52 }).catch(function(reason) { |
| 53 testFailed(String(reason)); |
| 54 }).then(finishJSTest, finishJSTest); |
| 55 |
| 56 </script> |
| 57 </body> |
| 58 </html> |
OLD | NEW |