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-16 14:27:48 +00:00
parent 1b7f31569f
commit f6db7b0433
5 changed files with 75 additions and 8 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;
}