commit eb1df5971c888e15dc9d581a1ed15fb7e25ff954
parent 7557fe41b5d2e7c7441f49fe88cef9ff5b5b58ae
Author: Andreas Farre <farre@mozilla.com>
Date: Fri, 7 Nov 2025 07:23:37 +0000
Bug 1998680 - Make sure to preserve navigationKey on replace. r=smaug,avandolder
Differential Revision: https://phabricator.services.mozilla.com/D271604
Diffstat:
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp
@@ -9302,6 +9302,9 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
}
if (LOAD_TYPE_HAS_FLAGS(mLoadType, LOAD_FLAGS_REPLACE_HISTORY)) {
+ if (previousActiveEntry) {
+ mActiveEntry->NavigationKey() = previousActiveEntry->NavigationKey();
+ }
mBrowsingContext->ReplaceActiveSessionHistoryEntry(mActiveEntry.get());
} else {
mBrowsingContext->IncrementHistoryEntryCountForBrowsingContext();
@@ -12554,6 +12557,7 @@ void nsDocShell::UpdateActiveEntry(
mActiveEntry->SetScrollRestorationIsManual(aScrollRestorationIsManual);
if (replace) {
+ mActiveEntry->NavigationKey() = previousActiveEntry->NavigationKey();
mBrowsingContext->ReplaceActiveSessionHistoryEntry(mActiveEntry.get());
} else {
mBrowsingContext->IncrementHistoryEntryCountForBrowsingContext();
diff --git a/dom/navigation/Navigation.cpp b/dom/navigation/Navigation.cpp
@@ -381,7 +381,9 @@ void Navigation::UpdateEntriesForSameDocumentNavigation(
return;
}
disposedEntries.AppendElement(oldCurrentEntry);
- aDestinationSHE->NavigationKey() = oldCurrentEntry->Key();
+ MOZ_DIAGNOSTIC_ASSERT(
+ aDestinationSHE->NavigationKey() ==
+ oldCurrentEntry->SessionHistoryInfo()->NavigationKey());
mEntries[*mCurrentEntryIndex] = MakeRefPtr<NavigationHistoryEntry>(
GetOwnerGlobal(), aDestinationSHE, *mCurrentEntryIndex);
break;