history-frame.html (684B)
1 <script> 2 function queueTest() { 3 // The timeout is necessary to avoid the parser still being active when 4 // `document.open()` is called and becoming a no-op. 5 // 6 // We also cannot use setTimeout(..., 0), as the parser is terminated in a 7 // task with DOM manipulation task source while the timeout is run in a task 8 // on the timer task source. The order is therefore not guaranteed. Let's 9 // play it safer and use some actual timeout. 10 setTimeout(() => { 11 document.open(); 12 document.write("<p>New content</p>"); 13 document.close(); 14 opener.onDocumentOpen(); 15 }, 200); 16 } 17 </script> 18 <body onload="opener.onFrameLoaded(); queueTest();"> 19 <p>Old content</p> 20 </body>