From aefb293793a4278d53d39e346aaa1178975aada1 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Sun, 23 Aug 2020 14:08:32 +0000 Subject: Issue #618 - Make document.currentScript null in modules. Because the spec says so. --- dom/script/ScriptLoader.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'dom/script') diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp index d994acc22..afda82da0 100644 --- a/dom/script/ScriptLoader.cpp +++ b/dom/script/ScriptLoader.cpp @@ -534,7 +534,6 @@ ScriptLoader::CreateModuleScript(ModuleLoadRequest* aRequest) nsresult rv; { // Update our current script. - AutoCurrentScriptUpdater scriptUpdater(this, aRequest->mElement); Maybe masterScriptUpdater; nsCOMPtr master = mDocument->MasterDocument(); if (master != mDocument) { @@ -1456,7 +1455,7 @@ ScriptLoader::ProcessScriptElement(nsIScriptElement *aElement) return false; } - // Inline scripts ignore ther CORS mode and are always CORS_NONE. + // Inline scripts ignore their CORS mode and are always CORS_NONE. request = CreateLoadRequest(scriptKind, mDocument->GetDocumentURI(), aElement, version, CORS_NONE, SRIMetadata(), // SRI doesn't apply @@ -1959,8 +1958,6 @@ ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest) context->SetProcessingScriptTag(true); nsresult rv; { - // Update our current script. - AutoCurrentScriptUpdater scriptUpdater(this, aRequest->mElement); Maybe masterScriptUpdater; nsCOMPtr master = mDocument->MasterDocument(); if (master != mDocument) { @@ -1974,6 +1971,9 @@ ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest) } if (aRequest->IsModuleRequest()) { + // For modules, currentScript is set to null. + AutoCurrentScriptUpdater scriptUpdater(this, nullptr); + EnsureModuleResolveHook(cx); ModuleLoadRequest* request = aRequest->AsModuleRequest(); @@ -1998,6 +1998,9 @@ ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest) rv = NS_OK; // An error is reported by AutoEntryScript. } } else { + // Update our current script. + AutoCurrentScriptUpdater scriptUpdater(this, aRequest->mElement); + JS::CompileOptions options(cx); rv = FillCompileOptionsForRequest(aes, aRequest, global, &options); -- cgit v1.2.3