diff options
author | Moonchild <moonchild@palemoon.org> | 2020-08-23 14:08:32 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-08-23 14:08:32 +0000 |
commit | c5ab17748567a64c63d0b99f311046cc674a44d0 (patch) | |
tree | 498155434a49418c4ea39e32c8d6a08066e9e426 /dom | |
parent | 76e5f863aa265af843e4075175703e43aa2266fc (diff) | |
download | uxp-c5ab17748567a64c63d0b99f311046cc674a44d0.tar.gz |
Issue #618 - Make document.currentScript null in modules.
Because the spec says so.
Diffstat (limited to 'dom')
-rw-r--r-- | dom/script/ScriptLoader.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp index d994acc22e..afda82da03 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<AutoCurrentScriptUpdater> masterScriptUpdater; nsCOMPtr<nsIDocument> 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<AutoCurrentScriptUpdater> masterScriptUpdater; nsCOMPtr<nsIDocument> 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); |