tor-browser

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

document-readyState.html (1222B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <title>document.readyState</title>
      4 <link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org">
      5 <link rel=help href="https://html.spec.whatwg.org/multipage/#resource-metadata-management">
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <div id="log"></div>
      9 <script>
     10  var t1 = async_test("readyState equals 'complete' when the document has loaded"),
     11      t2 = async_test("readyState equals 'interactive' when the document is finished parsing"),
     12      t3 = async_test("readystatechange event is fired each time document.readyState changes");
     13 
     14  window.onload = t1.step_func_done(function(){
     15    assert_equals(document.readyState, "complete");
     16  });
     17 
     18  document.addEventListener("DOMContentLoaded", function(event) {
     19    t2.step(function() {
     20      assert_equals(document.readyState, "interactive")
     21    });
     22    t2.done();
     23  });
     24 
     25  var states = [document.readyState];
     26  document.onreadystatechange = t3.step_func(function(){
     27    states.push(document.readyState);
     28    if (document.readyState === "complete") {
     29      assert_array_equals(states, ["loading", "interactive", "complete"]);
     30      t3.done();
     31    }
     32  })
     33 </script>