tor-browser

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

move-element-and-scroll.html (1448B)


      1 <!DOCTYPE html>
      2 <head>
      3  <title>Images with loading='lazy' load being moved to another document
      4         and then scrolled to</title>
      5  <script src="/resources/testharness.js"></script>
      6  <script src="/resources/testharnessreport.js"></script>
      7  <script src="common.js"></script>
      8 </head>
      9 
     10 <body>
     11  <div id="tall_div" style="height:1000vh"></div>
     12  <div id="below_viewport_div"></div>
     13  <img id="below_viewport" src='resources/image.png?below_viewport' loading="lazy">
     14 
     15  <script>
     16    const tall_div = document.getElementById("tall_div");
     17    const below_viewport_element = document.getElementById("below_viewport");
     18    const below_viewport_div = document.getElementById("below_viewport_div");
     19 
     20    async_test(function(t) {
     21      below_viewport_element.onload =
     22        t.unreached_func("The below viewport image should not load");
     23      t.step_timeout(t.step_func_done(), 1000);
     24      const iframe = document.createElement('iframe');
     25      iframe.setAttribute("style", "display:none");
     26      iframe.srcdoc = "<body></body>";
     27      iframe.onload = () => {
     28        const adopted_img = iframe.contentDocument.adoptNode(below_viewport_element);
     29        iframe.contentDocument.body.appendChild(adopted_img);
     30        below_viewport_div.scrollIntoView();
     31      };
     32      document.body.insertBefore(iframe, tall_div);
     33    }, "Test that <img> below viewport is not loaded when moved to another " +
     34       "document and then scrolled to");
     35 </script>
     36 </body>