tor-browser

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

commit 9981cd676ae09c7a0e662f86911c1ba01e85fe6c
parent 8802e882022e2522a3e0a0d277c9b8ccbe0e6fd4
Author: Adam Vandolder <avandolder@mozilla.com>
Date:   Mon, 20 Oct 2025 16:49:52 +0000

Bug 1994553 - Fix session restore of top-level contiguous entries that have navigated subframes. r=dom-core,sessionstore-reviewers,sthompson,smaug

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

Diffstat:
Mbrowser/components/sessionstore/test/browser_navigation_api_restore.js | 13++++++++-----
Mdocshell/shistory/nsSHistory.cpp | 5+++--
2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/browser/components/sessionstore/test/browser_navigation_api_restore.js b/browser/components/sessionstore/test/browser_navigation_api_restore.js @@ -42,7 +42,7 @@ add_task(async function test_toplevel_fragment_navigations() { content.history.back(); }); - let expectedUrls = [EMPTY_URL, ...hashes.map(hash => `${EMPTY_URL}${hash}`)]; + let expectedUrls = ["", ...hashes].map(hash => `${EMPTY_URL}${hash}`); await checkNavigationEntries(browser, expectedUrls); await TabStateFlusher.flush(browser); @@ -74,7 +74,7 @@ add_task(async function test_frame_fragment_navigations() { content.history.back(); }); - let expectedUrls = [EMPTY_URL, ...hashes.map(hash => `${EMPTY_URL}${hash}`)]; + let expectedUrls = ["", ...hashes].map(hash => `${EMPTY_URL}${hash}`); await checkNavigationEntries(browser, expectedUrls, true); await TabStateFlusher.flush(browser); @@ -105,8 +105,10 @@ add_task(async function test_mixed_fragment_navigations() { content.frames[0].history.pushState(null, "", "#frame3"); }); - let expectedUrls = [EMPTY_URL, ...hashes.map(hash => `${EMPTY_URL}${hash}`)]; - await checkNavigationEntries(browser, expectedUrls, true); + let expectedTopUrls = ["", "#top"].map(hash => `${EMPTY_FRAME_URL}${hash}`); + await checkNavigationEntries(browser, expectedTopUrls); + let expectedFrameUrls = ["", ...hashes].map(hash => `${EMPTY_URL}${hash}`); + await checkNavigationEntries(browser, expectedFrameUrls, true); await TabStateFlusher.flush(browser); let { entries } = JSON.parse(ss.getTabState(tab)); @@ -117,7 +119,8 @@ add_task(async function test_mixed_fragment_navigations() { await promiseTabRestored(tab); browser = tab.linkedBrowser; - await checkNavigationEntries(browser, expectedUrls, true); + await checkNavigationEntries(browser, expectedTopUrls); + await checkNavigationEntries(browser, expectedFrameUrls, true); gBrowser.removeTab(tab); }); diff --git a/docshell/shistory/nsSHistory.cpp b/docshell/shistory/nsSHistory.cpp @@ -2485,8 +2485,9 @@ mozilla::dom::SessionHistoryEntry* nsSHistory::FindAdjacentContiguousEntryFor( GetEntryAtIndex(i, getter_AddRefs(nextEntry)); foundParent = FindParent( ancestors, static_cast<SessionHistoryEntry*>(nextEntry.get())); - if (!foundParent || !foundParent->Children().Contains( - aEntry, SessionHistoryEntryIDComparator())) { + if ((!foundParent && nextEntry->GetID() != aEntry->GetID()) || + (foundParent && !foundParent->Children().Contains( + aEntry, SessionHistoryEntryIDComparator()))) { break; } rootEntry = nextEntry;