Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2234866e77d326892e39c0f2c50d250d214a68e4
      
https://github.com/WebKit/WebKit/commit/2234866e77d326892e39c0f2c50d250d214a68e4
  Author: Rupin Mittal <[email protected]>
  Date:   2026-03-19 (Thu, 19 Mar 2026)

  Changed paths:
    M Source/WebCore/loader/HistoryController.cpp
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/NavigationAPI.mm

  Log Message:
  -----------
  [Navigation API] navigation.currentEntry.id doesn't change in private windows 
after history.replaceState
https://bugs.webkit.org/show_bug.cgi?id=310256
rdar://172897962

Reviewed by Basuke Suzuki.

When history.replaceState() is called, we call 
HistoryController::replaceState(),
which updates the current entry held by the Navigation object by calling
Navigation::updateForNavigation().

For private windows, replaceState returns early before calling 
updateForNavigation()
because canRecordHistoryForFrame() returns false. Private windows use an 
ephemeral
data store and set allowPrivacySensitiveOperationsInNonPersistentDataStores to 
false.

To ensure that updateForNavigation() is called and the current entry is updated,
we now call updateForNavigation() before canRecordHistoryForFrame().

This is identical to https://commits.webkit.org/309489@main with once caveat:
Unlike with pushState, replaceState does not cause the 
navigation.currentEntry.key
to change. That's because we aren't making a new HistoryItem with replaceState.
(NavigationHistoryEntry's key is tied to HistoryItem's UUID). replaceState 
simply
changes some properties of the existing HistoryItem. But we are making a new
NavigationHistoryEntry, so it will have a new id. We use the id to check if the
current entry is updated.

This is tested by a new API test:
TEST(NavigationAPI, 
ReplaceStateUpdatesCurrentEntryIDWithoutAllowPrivacySensitiveOperationsInNonPersistentDataStores)

* Source/WebCore/loader/HistoryController.cpp:
(WebCore::HistoryController::replaceState):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/NavigationAPI.mm:
(TestWebKitAPI::TEST(NavigationAPI, 
ReplaceStateUpdatesCurrentEntryIDWithoutAllowPrivacySensitiveOperationsInNonPersistentDataStores)):

Canonical link: https://commits.webkit.org/309560@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to