module-tla-delayed.html (1067B)
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 13 iframe.onunhandledrejection = t.unreached_func("Unhandled promise rejection detected"); 14 iframe.onerror = t.unreached_func("Error loading iframe"); 15 16 let onLoadWasCalled = false; 17 iframe.onload = t.step_func(() => { 18 onLoadWasCalled = true; 19 assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n"); 20 iframe.onload = null; 21 }); 22 document.addEventListener("documentWriteDone", t.step_func_done(() => { 23 assert_true(onLoadWasCalled, "onload must be called"); 24 assert_equals(iframe.contentDocument.body.textContent, "document.write body contents\n"); 25 })); 26 27 iframe.src = "module-tla-delayed-iframe.html"; 28 document.body.appendChild(iframe); 29 }); 30 </script>