Bug 1820119 - import() should throw a TypeError in a worklet script. r=jonco,yulia

Differential Revision: https://phabricator.services.mozilla.com/D171563
This commit is contained in:
Yoshi Cheng-Hao Huang
2023-03-19 20:39:02 +00:00
parent d703fc9cff
commit 73636438f3
6 changed files with 76 additions and 9 deletions

View File

@@ -318,7 +318,10 @@ bool ModuleLoaderBase::HostImportModuleDynamically(
aCx, uri, script, aReferencingPrivate, specifierString, aPromise);
if (!request) {
JS_ReportErrorASCII(aCx, "Dynamic import not supported in this context");
// Throws TypeError if CreateDynamicImport returns nullptr.
JS_ReportErrorNumberASCII(aCx, js::GetErrorMessage, nullptr,
JSMSG_DYNAMIC_IMPORT_NOT_SUPPORTED);
return false;
}