tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

open-url-multi-window-6.htm (1449B)


      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              test.step_timeout(function() {
     26                client = new ifr.contentWindow.XMLHttpRequest();
     27                count++;
     28                // Important to do a normal navigation, not a reload.
     29                win.location.href = "resources/init.htm?avoid-replace";
     30              }, 0);
     31            }
     32            doc.body.appendChild(ifr);
     33          } else if(1 == count) {
     34            assert_throws_dom("InvalidStateError", function() { client.open("GET", "...") })
     35            test.done()
     36          }
     37        })
     38      }
     39    </script>
     40  </body>
     41 </html>