Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / responseURL.html
blob333e3e4ac750b5f9ede11921a5fcd74c422d1478
1 <html>
2 <head></head>
3 <body>
5 <script src="/js-test-resources/js-test.js"></script>
6 <script>
7 description('Test XMLHttpRequest.responseURL');
8 window.jsTestIsAsync = true;
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', '');
16 xhr.open('GET', url);
17 xhr.responseType = type;
18 window.responseURL = xhr.responseURL;
19 shouldBeEqualToString('responseURL', '');
21 xhr.onreadystatechange = function() {
22 debug('xhr.readyState = ' + xhr.readyState + ': responseURL = ' + xhr.responseURL);
23 if (xhr.readyState === 4) {
24 resolve(xhr);
27 xhr.send();
28 });
31 get('resources/reply2.txt', 'text').then(function(xhr) {
32 window.status = xhr.status;
33 shouldBeEqualToString('status', '200');
34 window.responseURL = xhr.responseURL;
35 shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/resources/reply2.txt');
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/resources/reply2.xml');
44 return get('resources/navigation-target.html#foobar', 'text');
45 }).then(function(xhr) {
46 window.status = xhr.status;
47 shouldBeEqualToString('status', '200');
48 window.responseURL = xhr.responseURL;
49 shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/resources/navigation-target.html');
51 return get('resources/redirect.php?url=not-found.txt', 'text');
52 }).then(function(xhr) {
53 window.status = xhr.status;
54 shouldBeEqualToString('status', '404');
55 window.responseURL = xhr.responseURL;
56 shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/resources/not-found.txt');
58 xhr.open('GET', xhr.responseURL);
59 }).catch(function(reason) {
60 testFailed(String(reason));
61 }).then(finishJSTest, finishJSTest);
63 </script>
64 </body>
65 </html>