during-readystatechange.window.js (1259B)
1 // This tests whether the insertion point gets reset before or after the readystatechange event. 2 // See https://github.com/whatwg/html/pull/6613#discussion_r620171070. 3 // Recall that resetting the insertion point means that document.write() performs the document open 4 // steps and blows away previous content in the document. 5 6 async_test(t => { 7 const frame = document.body.appendChild(document.createElement("iframe")); 8 t.add_cleanup(() => { frame.remove(); }); 9 frame.src = "../opening-the-input-stream/resources/dummy.html"; 10 frame.onload = t.step_func_done(() => { 11 const states = []; 12 frame.contentDocument.onreadystatechange = t.step_func(() => { 13 if (frame.contentDocument.readyState === "interactive") { 14 assert_not_equals(frame.contentDocument.textContent, "", "Precondition check: dummy document is not empty"); 15 16 frame.contentDocument.write("Some text"); 17 18 // If the insertion point is reset before the readystatechange handler, then the 19 // document.write() call above will blow away the text originally in dummy.html, leaving only what we wrote. 20 assert_equals(frame.contentDocument.textContent, "Some text"); 21 } 22 }); 23 }); 24 }, "document.write() during readystatechange to interactive");