load-event-after-location-set-during-write.window.js (792B)
1 // Make sure that the load event for an iframe doesn't fire at the 2 // point when a navigation triggered by document.write() starts in it, 3 // but rather when that navigation completes. 4 5 async_test(t => { 6 const frame = document.body.appendChild(document.createElement("iframe")); 7 const doc = frame.contentDocument; 8 const url = URL.createObjectURL(new Blob(["PASS"], { type: "text/html"})); 9 10 frame.onload = t.step_func_done(() => { 11 assert_equals(frame.contentDocument.body.textContent, "PASS", 12 "Why is our load event firing before the new document loaded?"); 13 }); 14 15 doc.open(); 16 doc.write(`FAIL<script>location = "${url}"</` + "script>"); 17 doc.close(); 18 }, "Setting location from document.write() call should not trigger load event until that load completes");