Files
sousa-gecko/dom/base/test/jsmodules/test_dynamicImportErrorMessage.html
Yoshi Cheng-Hao Huang aab59189a2 Bug 1968890 - Part 9: Add test for dynamic import. r=jonco
This test checks that the TypeError from fetching the sub-modules will
be forwarded to the reject handler of the promise of the dynamic import.

Differential Revision: https://phabricator.services.mozilla.com/D264811
2025-10-03 21:52:40 +00:00

33 lines
910 B
HTML

<!DOCTYPE html>
<meta charset=utf-8>
<title>Test the error message from import()</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
SimpleTest.waitForExplicitFinish();
let count = 0;
function maybeFinish() {
count++;
if (count == 2) {
SimpleTest.finish();
}
}
// eslint-disable-next-line no-unused-vars
async function testLoaded() {
await import("./404.js").catch((error) => {
ok(error instanceof TypeError, "Should be a TypeError.");
ok(error.message.match(/404.js/), "Should have the filename.");
maybeFinish();
});
await import("./import_404.mjs").catch((error) => {
ok(error instanceof TypeError, "Should be a TypeError.");
ok(error.message.match(/404.js/), "Should have the filename from sub-modules");
maybeFinish();
});
}
</script>
<body onload='testLoaded()'></body>