test_fetchedModuleHasErrorToRethrow_dynamic.html (784B)
1 <!DOCTYPE html> 2 <meta charset=utf-8> 3 <title>Test an imported module has an error to rethrow when import()</title> 4 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 5 <script type="module" src="./import_parse_error.mjs"></script> 6 <script> 7 SimpleTest.waitForExplicitFinish(); 8 9 let hasErrorToRethrow = false; 10 window.onerror = (e) => { 11 hasErrorToRethrow = true; 12 }; 13 14 function testLoaded() { 15 is(hasErrorToRethrow, true, "hasErrorToRethrow should be set to true"); 16 import("./import_parse_error_3.mjs").then(() => { 17 ok(false, "Should have thrown SyntaxError"); 18 }).catch((e) => { 19 ok(e instanceof SyntaxError , "Should throw a SyntaxError"); 20 SimpleTest.finish(); 21 }); 22 } 23 </script> 24 <body onload='testLoaded()'></body>