reload-failed-module-script.html (1034B)
1 <!doctype html> 2 <meta charset=utf-8> 3 <title>Insert non-async module script</title> 4 <script src=/resources/testharness.js></script> 5 <script src=/resources/testharnessreport.js></script> 6 <script> 7 setup({allow_uncaught_exception: true}); 8 9 var test = async_test("Reload failed module script"); 10 11 var errorCount = 0; 12 window.addEventListener("error", handleError); 13 14 function handleError() { 15 errorCount++; 16 17 if (errorCount == 1) { 18 reloadModule(); 19 return; 20 } 21 22 test.step(() => assert_equals(errorCount, 2)); 23 test.done(); 24 } 25 26 function reloadModule() { 27 var script = document.createElement("script"); 28 script.onerror = testNoError; 29 script.type = "module"; 30 script.src = "support/missing_import.js"; 31 script.async = false; 32 document.documentElement.appendChild(script); 33 } 34 35 function testNoError() { 36 test.step(() => assert_unreached("No event expect here")); 37 test.done(); 38 } 39 40 </script> 41 <script type="module" src="support/missing_import.js" onerror="testNoError()"></script>