Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a58aaf679b9152e0fefe7090bd78eec266acb105
      
https://github.com/WebKit/WebKit/commit/a58aaf679b9152e0fefe7090bd78eec266acb105
  Author: Basuke Suzuki <[email protected]>
  Date:   2026-03-02 (Mon, 02 Mar 2026)

  Changed paths:
    M Source/WebKit/Shared/SessionState.cpp
    M Source/WebKit/Shared/SessionState.h
    M Source/WebKit/Shared/SessionState.serialization.in
    M Source/WebKit/UIProcess/API/glib/WebKitWebViewSessionState.cpp
    M Source/WebKit/UIProcess/WebBackForwardList.cpp
    M Source/WebKit/UIProcess/mac/LegacySessionStateCoding.cpp
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/SiteIsolation.mm

  Log Message:
  -----------
  Preserve navigatedFrameID in session state for correct child frame 
back/forward navigation .
https://bugs.webkit.org/show_bug.cgi?id=308939
rdar://149987127

Reviewed by Sihui Liu.

When session state is restored via _restoreSessionState:andNavigate:NO, the 
BackForwardList is
rebuilt from serialized FrameState data. However, the navigatedFrameID — which 
tracks which
frame was navigated to create each back/forward entry — was not preserved. 
restoreFromState()
always set it to the main frame's FrameIdentifier, causing goBack()/goForward() 
to reload the
entire page instead of navigating only the child frame.

This patch introduces BackForwardListItemState, which pairs a FrameState with 
its navigatedFrameID,
and uses it as the element type of BackForwardListState::items. The 
navigatedFrameID is now
serialized in the legacy session state format under the 
"SessionHistoryEntryNavigatedFrameID"
key, with backward compatibility: older data lacking this key decodes as 
nullopt, falling back
to the existing main-frame behavior.

Test: Tools/TestWebKitAPI/Tests/WebKitCocoa/SiteIsolation.mm

* Source/WebKit/Shared/SessionState.cpp:
(WebKit::BackForwardListState::isEqualForTesting const):
(WebKit::BackForwardListItemState::isEqualForTesting const):
* Source/WebKit/Shared/SessionState.h:
* Source/WebKit/Shared/SessionState.serialization.in:
* Source/WebKit/UIProcess/API/glib/WebKitWebViewSessionState.cpp:
(encodeBackForwardListState):
(decodeBackForwardListItemStateV1):
(decodeBackForwardListItemState):
* Source/WebKit/UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::backForwardListState const):
(WebKit::WebBackForwardList::restoreFromState):
* Source/WebKit/UIProcess/mac/LegacySessionStateCoding.cpp:
(WebKit::encodeSessionHistory):
(WebKit::decodeSessionHistoryEntries):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/SiteIsolation.mm:
(TestWebKitAPI::testNavigateIframeBackForward):
(TestWebKitAPI::TEST(SiteIsolation, NavigateIframeSameOriginBackForward)):
(TestWebKitAPI::TEST(SiteIsolation, 
NavigateIframeSameOriginBackForwardAfterSessionRestore)):
(TestWebKitAPI::TEST(SiteIsolation, 
NavigateIframeSameOriginBackForwardAfterSessionRestoreToNewWebView)):
(TestWebKitAPI::TEST(SiteIsolation, NavigateIframeCrossOriginBackForward)):
(TestWebKitAPI::TEST(SiteIsolation, 
NavigateIframeCrossOriginBackForwardAfterSessionRestore)):
(TestWebKitAPI::TEST(SiteIsolation, 
NavigateIframeCrossOriginBackForwardAfterSessionRestoreToNewWebView)):
(TestWebKitAPI::TEST(SiteIsolation, 
DISABLED_NavigateIframeSameOriginBackForwardAfterSessionRestore)): Deleted.
(TestWebKitAPI::TEST(SiteIsolation, 
DISABLED_NavigateIframeCrossOriginBackForwardAfterSessionRestore)): Deleted.

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



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

Reply via email to