import from UXP: Issue #3058 - Try to deal with bad website scripting loading/unloading modules. (19e2f0fb)

This commit is contained in:
2022-04-29 22:16:31 +08:00
parent 993b776bb2
commit 1649cd88a9
+8
View File
@@ -814,6 +814,10 @@ HostResolveImportedModule(JSContext* aCx, JS::Handle<JSObject*> aModule,
if (!string.init(aCx, aSpecifier)) {
return nullptr;
}
if (!aModule || !aCx) {
// Our module context was ripped out from under us...
return nullptr;
}
nsCOMPtr<nsIURI> uri = ResolveModuleSpecifier(script, string);
@@ -826,6 +830,10 @@ HostResolveImportedModule(JSContext* aCx, JS::Handle<JSObject*> aModule,
ModuleScript* ms = script->Loader()->GetFetchedModule(uri);
MOZ_ASSERT(ms, "Resolved module not found in module map");
if (!ms) {
// Already-resolved module has been removed from the map/unloaded...
return nullptr;
}
MOZ_ASSERT(!ms->HasParseError());
MOZ_ASSERT(ms->ModuleRecord());