tor-browser

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

commit 3389f230998da55459ef92b1dec3c99500f5f333
parent 3e04ec90d3f80e83da814b0908370dc44e51f47e
Author: Adam Vandolder <avandolder@mozilla.com>
Date:   Tue, 14 Oct 2025 14:21:10 +0000

Bug 1966674 - Part 7: Add the destinationNavigationAPIState to the newly-created session history entry. r=dom-core,jjaschke

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

Diffstat:
Mdocshell/base/nsDocShell.cpp | 21+++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp @@ -8957,19 +8957,20 @@ nsresult nsDocShell::HandleSameDocumentNavigation( return NS_OK; } + // https://html.spec.whatwg.org/#navigate-fragid + // Step 2 + RefPtr<nsIStructuredCloneContainer> destinationNavigationAPIState = + mActiveEntry ? mActiveEntry->GetNavigationState() : nullptr; + // Step 3 + if (auto* navigationAPIState = aLoadState->GetNavigationAPIState()) { + destinationNavigationAPIState = navigationAPIState; + } + if (nsCOMPtr<nsPIDOMWindowInner> window = doc->GetInnerWindow(); window && !aState.mHistoryNavBetweenSameDoc) { // https://html.spec.whatwg.org/#navigate-fragid // Step 1 if (RefPtr<Navigation> navigation = window->Navigation()) { - // Step 2 - RefPtr<nsIStructuredCloneContainer> destinationNavigationAPIState = - mActiveEntry ? mActiveEntry->GetNavigationState() : nullptr; - // Step 3 - if (aLoadState->GetNavigationAPIState()) { - destinationNavigationAPIState = aLoadState->GetNavigationAPIState(); - } - AutoJSAPI jsapi; if (jsapi.Init(window)) { RefPtr<Element> sourceElement = aLoadState->GetSourceElement(); @@ -9318,6 +9319,10 @@ nsresult nsDocShell::HandleSameDocumentNavigation( scrollRestorationIsManual.value()); } + if (destinationNavigationAPIState) { + mActiveEntry->SetNavigationState(destinationNavigationAPIState); + } + if (LOAD_TYPE_HAS_FLAGS(mLoadType, LOAD_FLAGS_REPLACE_HISTORY)) { mBrowsingContext->ReplaceActiveSessionHistoryEntry(mActiveEntry.get()); } else {