iframe-loading-lazy-nav-location-replace-set-src.html (1016B)
1 <!DOCTYPE html> 2 <title>Navigating iframe loading='lazy' and then setting src: location.replace</title> 3 <iframe data-src="support/blank.htm?nav" loading="lazy" hidden></iframe> 4 <script> 5 const iframe = document.querySelector('iframe'); 6 const iframeLoaded = new Promise(resolve => { 7 iframe.onload = resolve; 8 }); 9 iframe.contentWindow.location.replace(iframe.dataset.src); 10 // Setting src invokes https://html.spec.whatwg.org/C#process-the-iframe-attributes 11 iframe.src = 'support/blank.htm?src'; 12 iframe.hidden = false; 13 </script> 14 <!-- Loading testharness.js here is intentional to reproduce a bug in WebKit. --> 15 <script src="/resources/testharness.js"></script> 16 <script src="/resources/testharnessreport.js"></script> 17 <script> 18 setup({single_test: true}); 19 iframeLoaded.then(() => { 20 // Need a timeout to detect failure when there are two navigations. 21 step_timeout(() => { 22 assert_equals(iframe.contentWindow.location.href, new URL("support/blank.htm?src", location.href).href); 23 done(); 24 }, 1000); 25 }); 26 </script>