Bug 1767829 - Part 4: Throw an error if CreateDynamicImport returns null r=yulia

This allows derived loaders not to support dynamic import if they don't want to.

Module loading for in mozJSComponentLoader will not initially support this.

Differential Revision: https://phabricator.services.mozilla.com/D145491
This commit is contained in:
Jon Coppeard
2022-05-09 11:06:26 +00:00
parent 0da6dce1b2
commit 9c2a55b7b0

View File

@@ -222,6 +222,11 @@ bool ModuleLoaderBase::HostImportModuleDynamically(
RefPtr<ModuleLoadRequest> request = loader->CreateDynamicImport(
aCx, uri, script, aReferencingPrivate, specifierString, aPromise);
if (!request) {
JS_ReportErrorASCII(aCx, "Dynamic import not supported in this context");
return false;
}
loader->StartDynamicImport(request);
return true;
}