Bug 1835886 - Cancel outstanding load requests when a document is detached from a global r=smaug
Also cancel module load requests when cancelling requests generally. What was happening here was that a previous load was completing and calling into the wrong module loader, because the loader to use is determined via the current global, and this was now associated with a different document / script loader / module loader. Differential Revision: https://phabricator.services.mozilla.com/D179787
This commit is contained in:
@@ -258,19 +258,21 @@ ScriptLoader::~ScriptLoader() {
|
||||
void ScriptLoader::SetGlobalObject(nsIGlobalObject* aGlobalObject) {
|
||||
if (!aGlobalObject) {
|
||||
// The document is being detached.
|
||||
CancelAndClearScriptLoadRequests();
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!HasPendingRequests());
|
||||
|
||||
if (mModuleLoader) {
|
||||
MOZ_ASSERT(mModuleLoader->GetGlobalObject() == aGlobalObject);
|
||||
return;
|
||||
if (!mModuleLoader) {
|
||||
// The module loader is associated with a global object, so don't create it
|
||||
// until we have a global set.
|
||||
mModuleLoader = new ModuleLoader(this, aGlobalObject, ModuleLoader::Normal);
|
||||
}
|
||||
|
||||
// The module loader is associated with a global object, so don't create it
|
||||
// until we have a global set.
|
||||
mModuleLoader = new ModuleLoader(this, aGlobalObject, ModuleLoader::Normal);
|
||||
MOZ_ASSERT(mModuleLoader->GetGlobalObject() == aGlobalObject);
|
||||
MOZ_ASSERT(aGlobalObject->GetModuleLoader(dom::danger::GetJSContext()) ==
|
||||
mModuleLoader);
|
||||
}
|
||||
|
||||
void ScriptLoader::RegisterContentScriptModuleLoader(ModuleLoader* aLoader) {
|
||||
@@ -1428,6 +1430,10 @@ void ScriptLoader::CancelAndClearScriptLoadRequests() {
|
||||
mXSLTRequests.CancelRequestsAndClear();
|
||||
mOffThreadCompilingRequests.CancelRequestsAndClear();
|
||||
|
||||
if (mModuleLoader) {
|
||||
mModuleLoader->CancelAndClearDynamicImports();
|
||||
}
|
||||
|
||||
for (ModuleLoader* loader : mWebExtModuleLoaders) {
|
||||
loader->CancelAndClearDynamicImports();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user