blob: e4f0aee60ecf31c07ff807e5ba774ac9ea287b7b [file] [log] [blame]
Boris Zbarsky27817b72016-05-09 20:46:401<!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 Farre81f2e882017-01-03 14:39:4029 win.location.href = "resources/init.htm?avoid-replace";
30 }, 0);
Boris Zbarsky27817b72016-05-09 20:46:4031 }
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>