1
0
mirror of https://github.com/roytam1/UXP.git synced 2026-05-26 23:18:26 +00:00

Issue #3058 - Try to deal with bad website scripting loading/unloading modules.

Apparently Bing does rapid-fire loading/unloading of module scripts that causes
our attempts at resolving and initializing them to end up with null fetched
modules. Returning null is probably a better way to handle this than crashing
on ms->ModuleRecord().
This commit is contained in:
Moonchild
2022-01-30 16:16:39 +00:00
committed by roytam1
parent bca191c2b9
commit 19e2f0fbf9
+8
View File
@@ -812,6 +812,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);
@@ -824,6 +828,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());