diff options
-rw-r--r-- | dom/script/ScriptLoader.cpp | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp index 1ee50ccfc..d994acc22 100644 --- a/dom/script/ScriptLoader.cpp +++ b/dom/script/ScriptLoader.cpp @@ -856,6 +856,23 @@ ScriptLoader::CheckModuleDependenciesLoaded(ModuleLoadRequest* aRequest) } } +class ScriptRequestProcessor : public Runnable +{ +private: + RefPtr<ScriptLoader> mLoader; + RefPtr<ScriptLoadRequest> mRequest; +public: + ScriptRequestProcessor(ScriptLoader* aLoader, + ScriptLoadRequest* aRequest) + : mLoader(aLoader) + , mRequest(aRequest) + {} + NS_IMETHOD Run() override + { + return mLoader->ProcessRequest(mRequest); + } +}; + void ScriptLoader::ProcessLoadedModuleTree(ModuleLoadRequest* aRequest) { @@ -866,8 +883,17 @@ ScriptLoader::ProcessLoadedModuleTree(ModuleLoadRequest* aRequest) aRequest->mModuleScript = nullptr; } } - MaybeMoveToLoadedList(aRequest); - ProcessPendingRequests(); + + if (aRequest->mIsInline && + aRequest->mElement->GetParserCreated() == NOT_FROM_PARSER) + { + MOZ_ASSERT(!aRequest->isInList()); + nsContentUtils::AddScriptRunner( + new ScriptRequestProcessor(this, aRequest)); + } else { + MaybeMoveToLoadedList(aRequest); + ProcessPendingRequests(); + } } if (aRequest->mWasCompiledOMT) { @@ -1093,23 +1119,6 @@ ScriptLoader::PreloadURIComparator::Equals(const PreloadInfo &aPi, same; } -class ScriptRequestProcessor : public Runnable -{ -private: - RefPtr<ScriptLoader> mLoader; - RefPtr<ScriptLoadRequest> mRequest; -public: - ScriptRequestProcessor(ScriptLoader* aLoader, - ScriptLoadRequest* aRequest) - : mLoader(aLoader) - , mRequest(aRequest) - {} - NS_IMETHOD Run() override - { - return mLoader->ProcessRequest(mRequest); - } -}; - static inline bool ParseTypeAttribute(const nsAString& aType, JSVersion* aVersion) { @@ -2325,10 +2334,10 @@ ScriptLoader::HandleLoadError(ScriptLoadRequest *aRequest, nsresult aResult) { mDocument->AddBlockedTrackingNode(cont); } - if (aRequest->IsModuleRequest() && !aRequest->mIsInline) {
- auto request = aRequest->AsModuleRequest();
- SetModuleFetchFinishedAndResumeWaitingRequests(request, aResult);
- }
+ if (aRequest->IsModuleRequest() && !aRequest->mIsInline) { + auto request = aRequest->AsModuleRequest(); + SetModuleFetchFinishedAndResumeWaitingRequests(request, aResult); + } if (aRequest->mIsDefer) { MOZ_ASSERT_IF(aRequest->IsModuleRequest(), |