diff options
-rw-r--r-- | dom/script/ScriptLoader.cpp | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp index c94966169..1ee50ccfc 100644 --- a/dom/script/ScriptLoader.cpp +++ b/dom/script/ScriptLoader.cpp @@ -486,8 +486,6 @@ ScriptLoader::ProcessFetchedModuleSource(ModuleLoadRequest* aRequest) nsresult rv = CreateModuleScript(aRequest); MOZ_ASSERT(NS_FAILED(rv) == !aRequest->mModuleScript); - SetModuleFetchFinishedAndResumeWaitingRequests(aRequest, rv); - free(aRequest->mScriptTextBuf); aRequest->mScriptTextBuf = nullptr; aRequest->mScriptTextLength = 0; @@ -497,6 +495,10 @@ ScriptLoader::ProcessFetchedModuleSource(ModuleLoadRequest* aRequest) return rv; } + if (!aRequest->mIsInline) { + SetModuleFetchFinishedAndResumeWaitingRequests(aRequest, rv); + } + if (!aRequest->mModuleScript->HasParseError()) { StartFetchingModuleDependencies(aRequest); } @@ -1457,20 +1459,19 @@ ScriptLoader::ProcessScriptElement(nsIScriptElement *aElement) if (request->IsModuleRequest()) { ModuleLoadRequest* modReq = request->AsModuleRequest(); modReq->mBaseURL = mDocument->GetDocBaseURI(); - rv = CreateModuleScript(modReq); - MOZ_ASSERT(NS_FAILED(rv) == !modReq->mModuleScript); - if (NS_FAILED(rv)) { - modReq->LoadFailed(); - return false; - } + if (aElement->GetScriptAsync()) { - mLoadingAsyncRequests.AppendElement(request); + modReq->mIsAsync = true; + mLoadingAsyncRequests.AppendElement(modReq); } else { - AddDeferRequest(request); + AddDeferRequest(modReq); } - if (!modReq->mModuleScript->HasParseError()) { - StartFetchingModuleDependencies(modReq); + + nsresult rv = ProcessFetchedModuleSource(modReq); + if (NS_FAILED(rv)) { + HandleLoadError(modReq, rv); } + return false; } request->mProgress = ScriptLoadRequest::Progress::Ready; @@ -2324,6 +2325,11 @@ ScriptLoader::HandleLoadError(ScriptLoadRequest *aRequest, nsresult aResult) { mDocument->AddBlockedTrackingNode(cont); } + if (aRequest->IsModuleRequest() && !aRequest->mIsInline) {
+ auto request = aRequest->AsModuleRequest();
+ SetModuleFetchFinishedAndResumeWaitingRequests(request, aResult);
+ }
+ if (aRequest->mIsDefer) { MOZ_ASSERT_IF(aRequest->IsModuleRequest(), aRequest->AsModuleRequest()->IsTopLevel()); |