tor-browser

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

not-rendered-image-loading-lazy.html (2083B)


      1 <!DOCTYPE html>
      2 <head>
      3  <title>In-viewport loading=lazy not-rendered images should never load</title>
      4  <link rel="author" title="Rob Buis" href="mailto:rbuis@igalia.com">
      5  <link rel="author" title="Dom Farolino" href="mailto:dom@chromium.org">
      6  <script src="/resources/testharness.js"></script>
      7  <script src="/resources/testharnessreport.js"></script>
      8  <script src="../resources/common.js"></script>
      9 </head>
     10 
     11 <body>
     12  <!-- These images must not attempt to load -->
     13  <img id="display_none" style="display:none;" src="resources/image.png?not-rendered-image-loading-lazy-2" loading="lazy"
     14       onload="display_none_img.resolve();" onerror="display_none_img.reject();">
     15  <img id="attribute_hidden" hidden src="resources/image.png?not-rendered-image-loading-lazy-3" loading="lazy"
     16       onload="attribute_hidden_img.resolve();" onerror="attribute_hidden_img.reject();">
     17  <img id="js_display_none" src="resources/image.png?not-rendered-image-loading-lazy-4" loading="lazy"
     18       onload="js_display_none_img.resolve();" onerror="js_display_none_img.reject();">
     19  <script>
     20    document.getElementById("js_display_none").style = 'display:none;';
     21  </script>
     22 </body>
     23 
     24 <script>
     25  const display_none_img = new ElementLoadPromise("display_none");
     26  const attribute_hidden_img = new ElementLoadPromise("attribute_hidden");
     27  const js_display_none_img = new ElementLoadPromise("js_display_none");
     28 
     29  async_test(t => {
     30    const unreached_not_rendered_img_func =
     31      t.unreached_func("The not-rendered in-viewport loading=lazy images " +
     32                       "should not attempt to load.");
     33 
     34    display_none_img.promise
     35      .then(unreached_not_rendered_img_func)
     36      .catch(unreached_not_rendered_img_func);
     37 
     38    attribute_hidden_img.promise
     39      .then(unreached_not_rendered_img_func)
     40      .catch(unreached_not_rendered_img_func);
     41 
     42    js_display_none_img.promise
     43      .then(unreached_not_rendered_img_func)
     44      .catch(unreached_not_rendered_img_func);
     45 
     46    t.step_timeout(t.done, 2000);
     47  }, "In-viewport loading=lazy not-rendered images should never load");
     48 </script>