iframe-loading-lazy-in-scroller-far.html (909B)
1 <!DOCTYPE html> 2 <link rel="help" href="https://html.spec.whatwg.org/#lazy-load-root-margin"> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 6 <style> 7 #scroller { 8 width: 100px; 9 height: 100px; 10 overflow: scroll; 11 background-color: gray; 12 } 13 14 #spacer { 15 width: 130px; 16 height: 10000vh; 17 } 18 19 #target { 20 width: 100px; 21 height: 100px; 22 } 23 </style> 24 25 <div id="scroller"> 26 <div id="spacer"></div> 27 <iframe 28 id="target" 29 src="resources/subframe.html" 30 loading="lazy" 31 onload="iframe_onload();" 32 ></iframe> 33 </div> 34 35 <script> 36 const t = async_test( 37 "Test that lazy-loaded iframes do not load when far from viewport." 38 ); 39 40 function iframe_onload() { 41 t.unreached_func( 42 "Lazy-loading iframe far from viewport should not load." 43 )(); 44 } 45 46 t.step_timeout(() => { 47 t.done(); 48 }, 2000); 49 </script>