| <html> |
| <head></head> |
| <body> |
| |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script> |
| |
| function get(url, type) { |
| return new Promise(function(resolve, reject) { |
| var xhr = new XMLHttpRequest(); |
| |
| xhr.open('GET', url); |
| xhr.responseType = type; |
| |
| xhr.onreadystatechange = function() { |
| if (xhr.readyState === 4) { |
| resolve(xhr); |
| } |
| } |
| xhr.send(); |
| }); |
| } |
| |
| promise_test(t => { |
| return get('resources/reply2.txt', 'text').then(xhr => { |
| assert_equals(xhr.status, 200); |
| assert_equals(xhr.responseURL, |
| 'http://127.0.0.1:8000/xmlhttprequest/resources/reply2.txt'); |
| }); |
| }, 'no redirect, text'); |
| |
| promise_test(t => { |
| return get('resources/redirect.php?url=reply2.xml', 'document').then(xhr => { |
| assert_equals(xhr.status, 200); |
| assert_equals(xhr.responseURL, |
| 'http://127.0.0.1:8000/xmlhttprequest/resources/reply2.xml'); |
| assert_equals(xhr.response.URL, |
| 'http://127.0.0.1:8000/xmlhttprequest/resources/reply2.xml'); |
| }); |
| }, 'with redirect, document'); |
| |
| promise_test(t => { |
| return get('resources/navigation-target.html#foobar', 'text').then(xhr => { |
| assert_equals(xhr.status, 200); |
| assert_equals(xhr.responseURL, |
| 'http://127.0.0.1:8000/xmlhttprequest/resources/navigation-target.html'); |
| }); |
| }, 'no redirect, text, with fragments'); |
| |
| promise_test(t => { |
| return get('resources/redirect.php?url=not-found.txt', 'text').then(xhr => { |
| assert_equals(xhr.status, 404); |
| assert_equals(xhr.responseURL, |
| 'http://127.0.0.1:8000/xmlhttprequest/resources/not-found.txt'); |
| }); |
| }, 'with redirect, text, not found'); |
| |
| </script> |
| </body> |
| </html> |