tor-browser

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

commit d7a6ef996dd69a3c32a6f95d24bd8fae8df64355
parent 8cd5d52a46f898a44589239a49ec90aec22a6e18
Author: Adam Vandolder <avandolder@mozilla.com>
Date:   Tue, 28 Oct 2025 19:10:54 +0000

Bug 1996896 - Keep Navigation Key/IDs stable across session restores. r=dom-core,core-sessionstore-reviewers,farre

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

Diffstat:
Mdocshell/shistory/SessionHistoryEntry.cpp | 24++++++++++++++++++++++++
Mdocshell/shistory/nsISHEntry.idl | 11+++++++++++
Mdocshell/shistory/nsSHEntry.cpp | 18++++++++++++++++++
Mtoolkit/modules/sessionstore/SessionHistory.sys.mjs | 10++++++++++
4 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/docshell/shistory/SessionHistoryEntry.cpp b/docshell/shistory/SessionHistoryEntry.cpp @@ -949,6 +949,30 @@ SessionHistoryEntry::SetDocshellID(const nsID& aDocshellID) { } NS_IMETHODIMP +SessionHistoryEntry::GetNavigationKey(nsID& aNavigationKey) { + aNavigationKey = mInfo->NavigationKey(); + return NS_OK; +} + +NS_IMETHODIMP +SessionHistoryEntry::SetNavigationKey(const nsID& aNavigationKey) { + mInfo->mNavigationKey = aNavigationKey; + return NS_OK; +} + +NS_IMETHODIMP +SessionHistoryEntry::GetNavigationId(nsID& aNavigationId) { + aNavigationId = mInfo->NavigationId(); + return NS_OK; +} + +NS_IMETHODIMP +SessionHistoryEntry::SetNavigationId(const nsID& aNavigationId) { + mInfo->mNavigationId = aNavigationId; + return NS_OK; +} + +NS_IMETHODIMP SessionHistoryEntry::GetIsSrcdocEntry(bool* aIsSrcdocEntry) { *aIsSrcdocEntry = mInfo->mSrcdocData.isSome(); return NS_OK; diff --git a/docshell/shistory/nsISHEntry.idl b/docshell/shistory/nsISHEntry.idl @@ -478,4 +478,15 @@ interface nsISHEntry : nsISupports * what a Wireframe is. */ [implicit_jscontext] attribute jsval wireframe; + + /** + * https://html.spec.whatwg.org/#she-navigation-api-key + * Only used with SHIP enabled. + */ + attribute nsIDRef navigationKey; + /** + * https://html.spec.whatwg.org/#she-navigation-api-id + * Only used with SHIP enabled. + */ + attribute nsIDRef navigationId; }; diff --git a/docshell/shistory/nsSHEntry.cpp b/docshell/shistory/nsSHEntry.cpp @@ -847,6 +847,24 @@ nsSHEntry::SetDocshellID(const nsID& aID) { } NS_IMETHODIMP +nsSHEntry::GetNavigationKey(nsID& aNavigationKey) { + aNavigationKey.Clear(); + return NS_OK; +} + +NS_IMETHODIMP +nsSHEntry::SetNavigationKey(const nsID& aNavigationKey) { return NS_OK; } + +NS_IMETHODIMP +nsSHEntry::GetNavigationId(nsID& aNavigationId) { + aNavigationId.Clear(); + return NS_OK; +} + +NS_IMETHODIMP +nsSHEntry::SetNavigationId(const nsID& aNavigationId) { return NS_OK; } + +NS_IMETHODIMP nsSHEntry::GetLastTouched(uint32_t* aLastTouched) { *aLastTouched = mShared->mLastTouched; return NS_OK; diff --git a/toolkit/modules/sessionstore/SessionHistory.sys.mjs b/toolkit/modules/sessionstore/SessionHistory.sys.mjs @@ -328,6 +328,9 @@ var SessionHistoryInternal = { entry.transient = shEntry.isTransient(); + entry.navigationKey = shEntry.navigationKey.toString(); + entry.navigationId = shEntry.navigationId.toString(); + return entry; }, @@ -603,6 +606,13 @@ var SessionHistoryInternal = { shEntry.wireframe = entry.wireframe; } + if (entry.navigationKey) { + shEntry.navigationKey = Components.ID(entry.navigationKey); + } + if (entry.navigationId) { + shEntry.navigationId = Components.ID(entry.navigationId); + } + if (entry.children) { for (var i = 0; i < entry.children.length; i++) { // XXXzpao Wallpaper patch for bug 514751