tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 8c62080bf9bedf16720925863ba72a47be072c79
parent b180a2213ed62ad35eb058d0689de6523122267f
Author: Andreas Farre <farre@mozilla.com>
Date:   Wed, 22 Oct 2025 10:07:18 +0000

Bug 1995693 - Make sure NotifiedBeforeUnloadListeners is sent over IPC. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D269547

Diffstat:
Mdocshell/base/nsDocShell.cpp | 9++++++---
Mdocshell/base/nsDocShell.h | 2+-
Mdocshell/base/nsDocShellLoadState.cpp | 2++
Mdom/ipc/DOMTypes.ipdlh | 1+
4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp @@ -805,7 +805,8 @@ nsresult nsDocShell::LoadURI(nsDocShellLoadState* aLoadState, // FIXME Null check aLoadState->GetLoadingSessionHistoryInfo()? return LoadHistoryEntry(*aLoadState->GetLoadingSessionHistoryInfo(), aLoadState->LoadType(), - aLoadState->HasValidUserGestureActivation()); + aLoadState->HasValidUserGestureActivation(), + aLoadState->NotifiedBeforeUnloadListeners()); } // On history navigation via Back/Forward buttons, don't execute @@ -12628,8 +12629,8 @@ nsresult nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType, } nsresult nsDocShell::LoadHistoryEntry(const LoadingSessionHistoryInfo& aEntry, - uint32_t aLoadType, - bool aUserActivation) { + uint32_t aLoadType, bool aUserActivation, + bool aNotifiedBeforeUnloadListeners) { RefPtr<nsDocShellLoadState> loadState = aEntry.CreateLoadInfo(); loadState->SetHasValidUserGestureActivation( loadState->HasValidUserGestureActivation() || aUserActivation); @@ -12637,6 +12638,8 @@ nsresult nsDocShell::LoadHistoryEntry(const LoadingSessionHistoryInfo& aEntry, loadState->SetTextDirectiveUserActivation( loadState->GetTextDirectiveUserActivation() || aUserActivation); + loadState->SetNotifiedBeforeUnloadListeners(aNotifiedBeforeUnloadListeners); + return LoadHistoryEntry(loadState, aLoadType, aEntry.mLoadingCurrentEntry); } diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h @@ -1039,7 +1039,7 @@ class nsDocShell final : public nsDocLoader, bool aUserActivation); nsresult LoadHistoryEntry( const mozilla::dom::LoadingSessionHistoryInfo& aEntry, uint32_t aLoadType, - bool aUserActivation); + bool aUserActivation, bool aNotifiedBeforeUnloadListeners); MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult LoadHistoryEntry(nsDocShellLoadState* aLoadState, uint32_t aLoadType, bool aLoadingCurrentEntry); diff --git a/docshell/base/nsDocShellLoadState.cpp b/docshell/base/nsDocShellLoadState.cpp @@ -66,6 +66,7 @@ nsDocShellLoadState::nsDocShellLoadState( mLoadReplace = aLoadState.LoadReplace(); mInheritPrincipal = aLoadState.InheritPrincipal(); mPrincipalIsExplicit = aLoadState.PrincipalIsExplicit(); + mNotifiedBeforeUnloadListeners = aLoadState.NotifiedBeforeUnloadListeners(); mForceAllowDataURI = aLoadState.ForceAllowDataURI(); mIsExemptFromHTTPSFirstMode = aLoadState.IsExemptFromHTTPSFirstMode(); mOriginalFrameSrc = aLoadState.OriginalFrameSrc(); @@ -1395,6 +1396,7 @@ DocShellLoadStateInit nsDocShellLoadState::Serialize( loadState.LoadReplace() = mLoadReplace; loadState.InheritPrincipal() = mInheritPrincipal; loadState.PrincipalIsExplicit() = mPrincipalIsExplicit; + loadState.NotifiedBeforeUnloadListeners() = mNotifiedBeforeUnloadListeners; loadState.ForceAllowDataURI() = mForceAllowDataURI; loadState.IsExemptFromHTTPSFirstMode() = mIsExemptFromHTTPSFirstMode; loadState.OriginalFrameSrc() = mOriginalFrameSrc; diff --git a/dom/ipc/DOMTypes.ipdlh b/dom/ipc/DOMTypes.ipdlh @@ -217,6 +217,7 @@ struct DocShellLoadStateInit bool LoadReplace; bool InheritPrincipal; bool PrincipalIsExplicit; + bool NotifiedBeforeUnloadListeners; bool ForceAllowDataURI; bool IsExemptFromHTTPSFirstMode; bool OriginalFrameSrc;