summaryrefslogtreecommitdiffstats
path: root/js/loader/ModuleLoadRequest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'js/loader/ModuleLoadRequest.cpp')
-rw-r--r--js/loader/ModuleLoadRequest.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/js/loader/ModuleLoadRequest.cpp b/js/loader/ModuleLoadRequest.cpp
index d90d41da58..7e188160fc 100644
--- a/js/loader/ModuleLoadRequest.cpp
+++ b/js/loader/ModuleLoadRequest.cpp
@@ -27,6 +27,9 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(ModuleLoadRequest)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(ModuleLoadRequest,
ScriptLoadRequest)
+ if (tmp->mWaitingParentRequest) {
+ tmp->mWaitingParentRequest->ChildModuleUnlinked();
+ }
NS_IMPL_CYCLE_COLLECTION_UNLINK(mLoader, mRootModule, mModuleScript, mImports,
mWaitingParentRequest,
mDynamicReferencingScript)
@@ -230,6 +233,18 @@ void ModuleLoadRequest::LoadFinished() {
mLoader->OnModuleLoadComplete(request);
}
+void ModuleLoadRequest::ChildModuleUnlinked() {
+ // This module was waiting for a child request, but the child reqeust
+ // got unlinked by CC and will never complete.
+ // It also means this module itself is also in the cycle, and will be
+ // unlinked or has already been unlinked, and will be collected.
+ // There's no need to normally finish the module request.
+ // Just reflect the awaiting imports count, so that the assertion in the
+ // destructor passes.
+ MOZ_ASSERT(mAwaitingImports > 0);
+ mAwaitingImports--;
+}
+
void ModuleLoadRequest::SetDynamicImport(LoadedScript* aReferencingScript,
JS::Handle<JSString*> aSpecifier,
JS::Handle<JSObject*> aPromise) {