Files
sousa-gecko/dom/base/test/jsmodules/test_fetchedModuleHasErrorToRethrow.html
Yoshi Cheng-Hao Huang 4e61329ac0 Bug 1992588 - Align error handling with the HTML spec when loading imported module scripts. r=jonco,frontend-codestyle-reviewers
According to the spec, a ThrowCompletion should be performed if the module
script is null or has a parse error.
See https://html.spec.whatwg.org/#hostloadimportedmodule:fetch-a-single-imported-module-script
Step 14.

So this patch reverts ModuleLoadRequest::IsErrored() update in https://phabricator.services.mozilla.com/D264807

Additionally, a spec issue has been filed to clarify whether an error to
rethrow should also be treated as a ThrowCompletion:
https://github.com/whatwg/html/issues/11755

Differential Revision: https://phabricator.services.mozilla.com/D267603
2025-10-08 08:37:57 +00:00

24 lines
720 B
HTML

<!DOCTYPE html>
<meta charset=utf-8>
<title>Test an imported module has an error to rethrow</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
SimpleTest.waitForExplicitFinish();
let count = 0;
let hasErrorToRethrow = false;
window.onerror = (e) => {
hasErrorToRethrow = true;
count++;
};
function testLoaded() {
is(hasErrorToRethrow, true, "hasErrorToRethrow should be set to true");
is(count, 2, "window.onerror should be called twice");
SimpleTest.finish();
}
</script>
<script type="module" src="./import_parse_error.mjs"></script>
<script type="module" src="./import_parse_error_1.mjs"></script>
<body onload='testLoaded()'></body>