From c5833155583739be9335a036a4d72bcdc1ad19c4 Mon Sep 17 00:00:00 2001 From: Jon Coppeard Date: Sat, 22 Aug 2020 18:35:57 +0000 Subject: Issue #618 - Fix processing of non-parser-generated module scripts. --- dom/script/ScriptLoader.cpp | 55 ++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 23 deletions(-) (limited to 'dom') 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 mLoader; + RefPtr 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 mLoader; - RefPtr 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(), -- cgit v1.2.3