From b35db1ba18e5bd912dce773eadbecd906a21dc84 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Thu, 23 Dec 2021 16:27:21 +0000 Subject: [PATCH] Bug 1539884 - Part 24: Mark nsIContentViewer::pageHide as can_run_script r=masayuki Differential Revision: https://phabricator.services.mozilla.com/D134388 --- docshell/base/nsDocShell.h | 8 +++++--- docshell/base/nsIContentViewer.idl | 2 +- layout/base/nsDocumentViewer.cpp | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 5ed508d6bde5..331afbecd1e1 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -958,11 +958,13 @@ class nsDocShell final : public nsDocLoader, // If aSkipCheckingDynEntries is true, it will not try to remove dynamic // subframe entries. This is to avoid redundant RemoveDynEntries calls in all // children docshells. - void FirePageHideNotificationInternal(bool aIsUnload, - bool aSkipCheckingDynEntries); + // TODO: Convert this to MOZ_CAN_RUN_SCRIPT (bug 1415230) + MOZ_CAN_RUN_SCRIPT_BOUNDARY void FirePageHideNotificationInternal( + bool aIsUnload, bool aSkipCheckingDynEntries); void ThawFreezeNonRecursive(bool aThaw); - void FirePageHideShowNonRecursive(bool aShow); + // TODO: Convert this to MOZ_CAN_RUN_SCRIPT (bug 1415230) + MOZ_CAN_RUN_SCRIPT_BOUNDARY void FirePageHideShowNonRecursive(bool aShow); nsresult Dispatch(mozilla::TaskCategory aCategory, already_AddRefed&& aRunnable); diff --git a/docshell/base/nsIContentViewer.idl b/docshell/base/nsIContentViewer.idl index 0a385a6d7b76..feb97f461f2f 100644 --- a/docshell/base/nsIContentViewer.idl +++ b/docshell/base/nsIContentViewer.idl @@ -113,7 +113,7 @@ interface nsIContentViewer : nsISupports */ readonly attribute boolean beforeUnloadFiring; - void pageHide(in boolean isUnload); + [can_run_script] void pageHide(in boolean isUnload); /** * All users of a content viewer are responsible for calling both diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index f30e2b34f8f4..a8e323ee2439 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -1400,7 +1400,7 @@ nsDocumentViewer::PageHide(bool aIsUnload) { NS_ENSURE_STATE(mDocument); // First, get the window from the document... - nsPIDOMWindowOuter* window = mDocument->GetWindow(); + RefPtr window = mDocument->GetWindow(); if (!window) { // Fail if no window is available... @@ -1427,7 +1427,8 @@ nsDocumentViewer::PageHide(bool aIsUnload) { Document::PageUnloadingEventTimeStamp timestamp(mDocument); - EventDispatcher::Dispatch(window, mPresContext, &event, nullptr, &status); + RefPtr presContext = mPresContext; + EventDispatcher::Dispatch(window, presContext, &event, nullptr, &status); } // look for open menupopups and close them after the unload event, in case