summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Coppeard <jcoppeard@mozilla.com>2020-08-22 10:13:37 +0000
committerMoonchild <moonchild@palemoon.org>2020-08-30 09:39:23 +0000
commit834ecdc59a084d0ccafa17ccc0e4801115935295 (patch)
tree7b91fc95a2088f451d3c2796cfdfc307bf8d3245
parent798c2ed4f8d1685df5ef53ea2fef09669d30ed36 (diff)
downloadUXP-834ecdc59a084d0ccafa17ccc0e4801115935295.tar
UXP-834ecdc59a084d0ccafa17ccc0e4801115935295.tar.gz
UXP-834ecdc59a084d0ccafa17ccc0e4801115935295.tar.lz
UXP-834ecdc59a084d0ccafa17ccc0e4801115935295.tar.xz
UXP-834ecdc59a084d0ccafa17ccc0e4801115935295.zip
Issue #618 - Handle errors for inline module scripts and ensure we update the
module map after fetch errors.
-rw-r--r--dom/script/ScriptLoader.cpp30
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());