tor-browser

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

iframe-loading-lazy-multiple-queued-navigations.html (2189B)


      1 <!DOCTYPE html>
      2 <head>
      3  <title>Multiple queued lazy load navigations do not crash the page</title>
      4  <link rel="author" title="Dom Farolino" href="mailto:dom@chromium.org">
      5  <link rel="help" href="https://html.spec.whatwg.org/multipage/urls-and-fetching.html#lazy-loading-attributes">
      6  <script src="/resources/testharness.js"></script>
      7  <script src="/resources/testharnessreport.js"></script>
      8 </head>
      9 
     10 <script>
     11  const t = async_test('Multiple queued lazy load navigations do not crash ' +
     12                       'the page');
     13 
     14  let has_below_viewport_loaded = false;
     15 
     16  window.addEventListener("load", t.step_func(() => {
     17    assert_false(has_below_viewport_loaded,
     18                "The below_viewport element should not have loaded before " +
     19                "window.load().");
     20 
     21    // Queue another lazy load navigation on the iframe. This should not result
     22    // in multiple internal intersection observers being created for the iframe
     23    // element, but instead should result in only one intersection observer
     24    // associated with the iframe element, and the resulting navigation should
     25    // be for the latest `src` attribute mutation.
     26    const target = document.querySelector('#below_viewport');
     27    target.src = 'resources/subframe.html?new-src';
     28    target.scrollIntoView();
     29  }));
     30 
     31  const below_viewport_iframe_onload = t.step_func_done(() => {
     32    const target = document.querySelector('#below_viewport');
     33    // We check both of these to ensure that the `src` attribute and actual
     34    // navigated resource do not get out-of-sync when navigating to lazy loaded
     35    // resources.
     36    assert_true(
     37      target.src.includes('new-src'),
     38      "The iframe's src should be updated to reflect the latest `src` " +
     39      "mutation");
     40    assert_true(
     41      target.contentDocument.location.href.includes('new-src'),
     42      'The iframe should be navigated to the resource provided by the latest ' +
     43      '`src` mutation');
     44  });
     45 </script>
     46 
     47 <body>
     48  <div style="height:3000vh;"></div>
     49  <iframe id="below_viewport" src="resources/subframe.html?old-src"
     50          loading="lazy" width="200px" height="100px"
     51          onload="below_viewport_iframe_onload();"></iframe>
     52 </body>