From d5c873e8f49b7f65d16e0ab7af8b8da8d685ed84 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Fri, 17 Dec 2021 13:27:52 +0000 Subject: [PATCH] Bug 1539884 - Part 17: Mark nsIScriptLoaderObserver::scriptEvaluated as can_run_script r=masayuki Depends on D134107 Differential Revision: https://phabricator.services.mozilla.com/D134108 --- dom/script/ScriptLoadRequest.h | 6 ++++-- dom/script/ScriptLoader.cpp | 4 ++-- dom/script/ScriptLoader.h | 4 +++- dom/script/nsIScriptLoaderObserver.idl | 1 + 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/dom/script/ScriptLoadRequest.h b/dom/script/ScriptLoadRequest.h index 83911785af84..29fa74f9df01 100644 --- a/dom/script/ScriptLoadRequest.h +++ b/dom/script/ScriptLoadRequest.h @@ -111,8 +111,10 @@ class ScriptLoadRequest GetScriptElement()->ScriptAvailable(aResult, GetScriptElement(), isInlineClassicScript, mURI, mLineNo); } - void FireScriptEvaluated(nsresult aResult) { - GetScriptElement()->ScriptEvaluated(aResult, GetScriptElement(), mIsInline); + // TODO: Convert this to MOZ_CAN_RUN_SCRIPT (bug 1415230) + MOZ_CAN_RUN_SCRIPT_BOUNDARY void FireScriptEvaluated(nsresult aResult) { + RefPtr scriptElement = GetScriptElement(); + scriptElement->ScriptEvaluated(aResult, scriptElement, mIsInline); } bool IsPreload() const { diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp index 0e865338504d..47117487ff00 100644 --- a/dom/script/ScriptLoader.cpp +++ b/dom/script/ScriptLoader.cpp @@ -2099,8 +2099,8 @@ void ScriptLoader::FireScriptEvaluated(nsresult aResult, ScriptLoadRequest* aRequest) { for (int32_t i = 0; i < mObservers.Count(); i++) { nsCOMPtr obs = mObservers[i]; - obs->ScriptEvaluated(aResult, aRequest->GetScriptElement(), - aRequest->mIsInline); + RefPtr scriptElement = aRequest->GetScriptElement(); + obs->ScriptEvaluated(aResult, scriptElement, aRequest->mIsInline); } aRequest->FireScriptEvaluated(aResult); diff --git a/dom/script/ScriptLoader.h b/dom/script/ScriptLoader.h index 9672568cb253..69fc727b28b4 100644 --- a/dom/script/ScriptLoader.h +++ b/dom/script/ScriptLoader.h @@ -552,7 +552,9 @@ class ScriptLoader final : public ScriptLoaderInterface { nsresult ProcessRequest(ScriptLoadRequest* aRequest) override; nsresult CompileOffThreadOrProcessRequest(ScriptLoadRequest* aRequest); void FireScriptAvailable(nsresult aResult, ScriptLoadRequest* aRequest); - void FireScriptEvaluated(nsresult aResult, ScriptLoadRequest* aRequest); + // TODO: Convert this to MOZ_CAN_RUN_SCRIPT (bug 1415230) + MOZ_CAN_RUN_SCRIPT_BOUNDARY void FireScriptEvaluated( + nsresult aResult, ScriptLoadRequest* aRequest); // Implements https://html.spec.whatwg.org/#execute-the-script-block nsresult EvaluateScriptElement(ScriptLoadRequest* aRequest); diff --git a/dom/script/nsIScriptLoaderObserver.idl b/dom/script/nsIScriptLoaderObserver.idl index 8fafa201cc03..211e97405823 100644 --- a/dom/script/nsIScriptLoaderObserver.idl +++ b/dom/script/nsIScriptLoaderObserver.idl @@ -41,6 +41,7 @@ interface nsIScriptLoaderObserver : nsISupports { * @param aElement The element being processed. * @param aIsInline Is this an inline script or externally loaded? */ + [can_run_script] void scriptEvaluated(in nsresult aResult, in nsIScriptElement aElement, in boolean aIsInline);