tor-browser

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

test_bug688580.html (2107B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=688580
      5 -->
      6 <head>
      7  <meta charset="utf-8">
      8  <title>Test for Bug 688580</title>
      9  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     11  <script type="application/javascript">
     12 
     13  /** Test for Bug 688580 */
     14 
     15  // Expected order:
     16  // Test starting
     17  // readyState interactive
     18  // defer
     19  // DOMContentLoaded
     20  // readyState complete
     21  // load
     22 
     23  var state = "Test starting";
     24  var readyStateCall = 0;
     25  SimpleTest.waitForExplicitFinish();
     26  is(document.readyState, "loading", "Document should have been loading.");
     27  document.addEventListener("DOMContentLoaded", function() {
     28    is(document.readyState, "interactive", "readyState should be interactive during DOMContentLoaded.");
     29    is(state, "defer", "Bad state upon DOMContentLoaded");
     30    state = "DOMContentLoaded";
     31  });
     32  document.addEventListener("readystatechange", function() {
     33    readyStateCall++;
     34    if (readyStateCall == 1) {
     35      is(document.readyState, "interactive", "readyState should have changed to interactive.");
     36      is(state, "Test starting", "Bad state upon first readystatechange.");
     37      state = "readyState interactive";
     38    } else if (readyStateCall == 2) {
     39      is(document.readyState, "complete", "readyState should have changed to complete.");
     40      is(state, "DOMContentLoaded", "Bad state upon second readystatechange.");
     41      state = "readyState complete";
     42    } else {
     43      ok(false, "Too many readystatechanges");
     44    }
     45  });
     46  window.addEventListener("load", function() {
     47    is(document.readyState, "complete", "readyState should be complete during load.");
     48    is(state, "readyState complete", "Bad state upon load");
     49    state = "load";
     50    SimpleTest.finish();
     51  });
     52  </script>
     53  <script defer src="file_bug688580.js"></script>
     54 </head>
     55 <body>
     56 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=688580">Mozilla Bug 688580</a>
     57 <p id="display"></p>
     58 <div id="content" style="display: none">
     59 
     60 </div>
     61 <pre id="test">
     62 </pre>
     63 </body>
     64 </html>