tor-browser

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

readiness.window.js (1121B)


      1 // This tests the behavior of dynamic markup insertion APIs with a document's
      2 // readiness.
      3 
      4 async_test(t => {
      5  const frame = document.body.appendChild(document.createElement("iframe"));
      6  t.add_cleanup(() => { frame.remove(); });
      7  frame.src = "/common/blank.html";
      8  frame.onload = t.step_func_done(() => {
      9    const states = [];
     10    frame.contentDocument.onreadystatechange = t.step_func(() => {
     11      states.push(frame.contentDocument.readyState);
     12    });
     13    assert_equals(frame.contentDocument.readyState, "complete");
     14    assert_array_equals(states, []);
     15 
     16    // When open() is called, it first removes the event listeners and handlers
     17    // from all nodes in the DOM tree. Then, after a new parser is created and
     18    // initialized, it changes the current document readiness to "loading".
     19    // However, because all event listeners are removed, we cannot observe the
     20    // readystatechange event fired for "loading" inside open().
     21    frame.contentDocument.open();
     22    assert_equals(frame.contentDocument.readyState, "loading");
     23    assert_array_equals(states, []);
     24  });
     25 }, "document.open() and readiness");