image-loading-lazy-available.html (1241B)
1 <!doctype html> 2 <title>The list of available images gets checked before deciding to make a load lazy</title> 3 <link rel="help" href="https://html.spec.whatwg.org/multipage/images.html#update-the-image-data"> 4 <link rel="help" href="https://html.spec.whatwg.org/multipage/images.html#will-lazy-load-image-steps"> 5 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1709577"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 9 <img src="/images/green-256x256.png"> 10 <div style="height:1000vh;"></div> 11 <script> 12 promise_test(async t => { 13 await new Promise(resolve => { 14 window.addEventListener("load", resolve); 15 }); 16 let nonLazy = document.querySelector("img"); 17 assert_equals(nonLazy.width, 256); 18 assert_equals(nonLazy.height, 256); 19 20 let lazy = document.createElement("img"); 21 lazy.loading = "lazy"; 22 lazy.src = nonLazy.src; 23 document.body.appendChild(lazy); 24 25 await new Promise(resolve => setTimeout(resolve)); 26 27 assert_equals(lazy.width, 256, "The list of available images should be checked before delaying the image load"); 28 assert_equals(lazy.height, 256, "The list of available images should be checked before delaying the image load"); 29 }); 30 </script>