module-static-import-delayed.html (1056B)
1 <!doctype html> 2 <title>document.write in an imported module</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <div id="log"></div> 6 <script> 7 async_test(t => { 8 // Expose {test} in the iframe for using the step_timeout helper. 9 document.test = t; 10 const iframe = document.createElement("iframe"); 11 iframe.onerror = t.unreached_func("Error loading iframe"); 12 13 let onLoadWasCalled = false; 14 iframe.onload = t.step_func(() => { 15 onLoadWasCalled = true; 16 assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n"); 17 // Don't call the event handler another time after document.write. 18 iframe.onload = null; 19 }); 20 document.addEventListener("documentWriteDone", t.step_func_done(() => { 21 assert_true(onLoadWasCalled, "onload must be called"); 22 assert_equals(iframe.contentDocument.body.textContent, "document.write body contents\n"); 23 })); 24 25 iframe.src = "module-static-import-delayed-iframe.html"; 26 document.body.appendChild(iframe); 27 }); 28 </script>