tor-browser

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

element-only-when-fully-active.html (1658B)


      1 <!doctype html>
      2 <!--
      3 The soft navigation version of the identically named test in
      4 /largest-contentful-paint/element-only-when-fully-active.html
      5 Notes:
      6 - Triggers trivial soft navigation with same page contents as original test.
      7 -->
      8 <meta charset="utf-8" />
      9 <title>
     10  Largest Contentful Paint after soft navigation: element is only exposed for fully active
     11  documents.
     12 </title>
     13 <script src="/resources/testharness.js"></script>
     14 <script src="/resources/testharnessreport.js"></script>
     15 <script src="/resources/testdriver.js"></script>
     16 <script src="/resources/testdriver-vendor.js"></script>
     17 <script src="/soft-navigation-heuristics/resources/soft-navigation-test-helper.js"></script>
     18 <script>
     19  function clickHandler() {
     20    document.body.innerHTML = `<iframe src="/largest-contentful-paint/resources/iframe-stores-entry.html" id="ifr"></iframe>`;
     21    history.pushState({}, "", "/test");
     22  }
     23 </script>
     24 <body>
     25  <div id="click-target" onclick="clickHandler()">Click!</div>
     26 </body>
     27 <script>
     28  setup({ hide_test_state: true });
     29  let t = async_test(
     30    "Only expose element attribute for fully active documents (after soft navigation)",
     31  );
     32  const softNavigationPromise =
     33      SoftNavigationTestHelper.getPerformanceEntries("largest-contentful-paint");
     34  if (test_driver) {
     35    test_driver.click(document.getElementById("click-target"));
     36  }
     37  window.triggerTest = t.step_func_done(async (entry) => {
     38    assert_not_equals(entry.element, null);
     39    assert_equals(entry.element.innerHTML, "Text");
     40    const iframe = document.getElementById("ifr");
     41    iframe.remove();
     42    assert_equals(entry.element, null);
     43    await softNavigationPromise;
     44  });
     45 </script>