iframe-append.https.html (706B)
1 <!DOCTYPE html> 2 <html class="test-wait"> 3 <meta charset="utf-8"> 4 <iframe id="id_0"></iframe> 5 <script> 6 /** @param {HTMLIFrameElement} iframe */ 7 function waitForLoad(iframe) { 8 // iframe is initialized immediately on Chrome while it needs some time on Firefox 9 if (iframe.contentDocument.readyState === "complete") { 10 return; 11 } 12 return new Promise(r => iframe.onload = r); 13 } 14 15 const iframe = document.getElementById("id_0"); 16 iframe.contentWindow.navigator.locks.request("weblock_0", async () => { 17 await waitForLoad(iframe); 18 document.body.append(iframe); // discards the document and destroys locks 19 document.documentElement.classList.remove("test-wait"); 20 }); 21 </script>