| Boris Zbarsky | 27817b7 | 2016-05-09 20:46:40 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>XMLHttpRequest: open() in document that is not fully active (but may be active) should throw</title> |
| 5 | <script src="/resources/testharness.js"></script> |
| 6 | <script src="/resources/testharnessreport.js"></script> |
| 7 | <link rel="help" href="https://xhr.spec.whatwg.org/#the-open()-method"> |
| 8 | </head> |
| 9 | <body> |
| 10 | <div id="log"></div> |
| 11 | <script> |
| 12 | var test = async_test(), |
| 13 | client, |
| 14 | count = 0, |
| 15 | win = window.open("resources/init.htm"); |
| 16 | test.add_cleanup(function() { win.close(); }); |
| 17 | function init() { |
| 18 | test.step(function() { |
| 19 | if(0 == count) { |
| 20 | var doc = win.document; |
| 21 | var ifr = document.createElement("iframe"); |
| 22 | ifr.onload = function() { |
| 23 | // Again, do things async so we're not doing loads from inside |
| 24 | // load events. |
| 25 | setTimeout(function() { |
| 26 | client = new ifr.contentWindow.XMLHttpRequest(); |
| 27 | count++; |
| 28 | // Important to do a normal navigation, not a reload. |
| Andreas Farre | 81f2e88 | 2017-01-03 14:39:40 | [diff] [blame] | 29 | win.location.href = "resources/init.htm?avoid-replace"; |
| 30 | }, 0); |
| Boris Zbarsky | 27817b7 | 2016-05-09 20:46:40 | [diff] [blame] | 31 | } |
| 32 | doc.body.appendChild(ifr); |
| 33 | } else if(1 == count) { |
| 34 | assert_throws("InvalidStateError", function() { client.open("GET", "...") }) |
| 35 | test.done() |
| 36 | } |
| 37 | }) |
| 38 | } |
| 39 | </script> |
| 40 | </body> |
| 41 | </html> |