module-tla-immediate-promise.html (1059B)
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 11 const iframe = document.createElement("iframe"); 12 iframe.onerror = t.unreached_func("Error loading iframe"); 13 14 let onLoadWasCalled = false; 15 iframe.onload = t.step_func(() => { 16 onLoadWasCalled = true; 17 assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n"); 18 // Don't call the event handler another time after document.write. 19 iframe.onload = null; 20 }); 21 document.addEventListener("documentWriteDone", t.step_func_done(() => { 22 assert_false(onLoadWasCalled, "onload must not be called yet"); 23 assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n"); 24 })); 25 26 iframe.src = "module-tla-immediate-promise-iframe.html"; 27 document.body.appendChild(iframe); 28 }); 29 </script>