diff --git a/dom/base/nsScriptLoader.cpp b/dom/base/nsScriptLoader.cpp index de2726ca5367..0ac40117da39 100644 --- a/dom/base/nsScriptLoader.cpp +++ b/dom/base/nsScriptLoader.cpp @@ -1030,7 +1030,7 @@ nsScriptLoader::StartFetchingModuleAndDependencies(nsModuleLoadRequest* aRequest RefPtr ready = childRequest->mReady.Ensure(__func__); - nsresult rv = StartLoad(childRequest, false); + nsresult rv = StartLoad(childRequest); if (NS_FAILED(rv)) { childRequest->mReady.Reject(rv, __func__); return ready; @@ -1178,7 +1178,7 @@ nsScriptLoader::InstantiateModuleTree(nsModuleLoadRequest* aRequest) } nsresult -nsScriptLoader::StartLoad(nsScriptLoadRequest *aRequest, bool aScriptFromHead) +nsScriptLoader::StartLoad(nsScriptLoadRequest *aRequest) { MOZ_ASSERT(aRequest->IsLoading()); NS_ENSURE_TRUE(mDocument, NS_ERROR_NULL_POINTER); @@ -1251,7 +1251,7 @@ nsScriptLoader::StartLoad(nsScriptLoadRequest *aRequest, bool aScriptFromHead) nsCOMPtr cos(do_QueryInterface(channel)); if (cos) { - if (aScriptFromHead && + if (aRequest->mScriptFromHead && !(script && (script->GetScriptAsync() || script->GetScriptDeferred()))) { // synchronous head scripts block loading of most other non js/css // content such as images @@ -1535,10 +1535,10 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement) request->mURI = scriptURI; request->mIsInline = false; request->mReferrerPolicy = ourRefPolicy; + // keep request->mScriptFromHead to false so we don't treat non preloaded + // scripts as blockers for full page load. See bug 792438. - // set aScriptFromHead to false so we don't treat non preloaded scripts as - // blockers for full page load. See bug 792438. - rv = StartLoad(request, false); + rv = StartLoad(request); if (NS_FAILED(rv)) { // Asynchronously report the load failure NS_DispatchToCurrentThread( @@ -2805,8 +2805,9 @@ nsScriptLoader::PreloadURI(nsIURI *aURI, const nsAString &aCharset, request->mURI = aURI; request->mIsInline = false; request->mReferrerPolicy = aReferrerPolicy; + request->mScriptFromHead = aScriptFromHead; - nsresult rv = StartLoad(request, aScriptFromHead); + nsresult rv = StartLoad(request); if (NS_FAILED(rv)) { return; } diff --git a/dom/base/nsScriptLoader.h b/dom/base/nsScriptLoader.h index a0a7f08daaaf..16b3be94c014 100644 --- a/dom/base/nsScriptLoader.h +++ b/dom/base/nsScriptLoader.h @@ -74,6 +74,7 @@ public: const mozilla::dom::SRIMetadata &aIntegrity) : mKind(aKind), mElement(aElement), + mScriptFromHead(false), mProgress(Progress::Loading), mIsInline(true), mHasSourceMapURL(false), @@ -167,6 +168,7 @@ public: const nsScriptKind mKind; nsCOMPtr mElement; + bool mScriptFromHead; // Synchronous head script block loading of other non js/css content. Progress mProgress; // Are we still waiting for a load to complete? bool mIsInline; // Is the script inline or loaded? bool mHasSourceMapURL; // Does the HTTP header have a source map url? @@ -519,7 +521,7 @@ private: /** * Start a load for aRequest's URI. */ - nsresult StartLoad(nsScriptLoadRequest *aRequest, bool aScriptFromHead); + nsresult StartLoad(nsScriptLoadRequest *aRequest); /** * Process any pending requests asynchronously (i.e. off an event) if there