tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit aab59189a2c2b0063e121dcfdf4113d6e1a53631
parent 08904835b890fdee01976450b0c5ae62844fafd5
Author: Yoshi Cheng-Hao Huang <allstars.chh@gmail.com>
Date:   Fri,  3 Oct 2025 20:53:30 +0000

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

Diffstat:
Mdom/base/test/jsmodules/chrome.toml | 1+
Adom/base/test/jsmodules/import_404.mjs | 2++
Mdom/base/test/jsmodules/test_dynamicImportErrorMessage.html | 17++++++++++++++++-
3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/dom/base/test/jsmodules/chrome.toml b/dom/base/test/jsmodules/chrome.toml @@ -1,6 +1,7 @@ [DEFAULT] support-files = [ "ambiguous_export.mjs", + "import_404.mjs", "import_ambiguous.mjs", "import_ambiguous_indirect_export.mjs", "import_ambiguous_export.mjs", diff --git a/dom/base/test/jsmodules/import_404.mjs b/dom/base/test/jsmodules/import_404.mjs @@ -0,0 +1,2 @@ +/* eslint-disable import/no-unresolved */ +import { A } from "./404.js"; diff --git a/dom/base/test/jsmodules/test_dynamicImportErrorMessage.html b/dom/base/test/jsmodules/test_dynamicImportErrorMessage.html @@ -5,12 +5,27 @@ <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."); - SimpleTest.finish(); + 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>