1
0
mirror of https://github.com/roytam1/UXP.git synced 2026-05-26 13:58:49 +00:00

Issue #3020 - Clear currentScript after running microtasks

Per HTML spec:

`document.currentScript` Returns null if the Document is not currently
executing a script or SVG script element (e.g., because the running
script is an event handler, or a timeout), or if the currently executing
script or SVG script element represents a module script.
This commit is contained in:
Moonchild
2026-03-24 15:59:11 +01:00
committed by roytam1
parent eee99b32cc
commit fdee9737a8
+7 -4
View File
@@ -2315,8 +2315,14 @@ ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest)
return NS_ERROR_FAILURE;
}
// Update our current script.
// This must be destroyed after destroying nsAutoMicroTask.
nsIScriptElement* currentScript =
aRequest->IsModuleRequest() ? nullptr : aRequest->Element();
AutoCurrentScriptUpdater scriptUpdater(this, currentScript);
// New script entry point required, due to the "Create a script" sub-step of
// http://www.whatwg.org/specs/web-apps/current-work/#execute-the-script-block
// http://html.spec.whatwg.org/multipage/#execute-the-script-block
nsAutoMicroTask mt;
AutoEntryScript aes(globalObject, "<script> element", true);
JSContext* cx = aes.cx();
@@ -2374,9 +2380,6 @@ ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest)
FinishDynamicImport(cx, request, rv);
}
} else {
// Update our current script.
AutoCurrentScriptUpdater scriptUpdater(this, aRequest->Element());
JS::CompileOptions options(cx);
rv = FillCompileOptionsForRequest(aes, aRequest, global, &options);