Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 855821352f744e79f32c3246ba82010994d965a3
      
https://github.com/WebKit/WebKit/commit/855821352f744e79f32c3246ba82010994d965a3
  Author: Rupin Mittal <[email protected]>
  Date:   2025-10-09 (Thu, 09 Oct 2025)

  Changed paths:
    A 
LayoutTests/http/tests/navigation-api/different-origin-entries-removed-after-bfcache-expected.txt
    A 
LayoutTests/http/tests/navigation-api/different-origin-entries-removed-after-bfcache.html
    A LayoutTests/http/tests/navigation-api/resources/page-that-goes-back.html
    M LayoutTests/platform/mac-wk1/TestExpectations
    M Source/WebCore/history/BackForwardController.cpp
    M Source/WebCore/history/BackForwardController.h
    M Source/WebCore/history/CachedPage.cpp
    M Source/WebCore/history/CachedPage.h
    M Source/WebCore/page/Navigation.cpp
    M Source/WebCore/page/Navigation.h

  Log Message:
  -----------
  [Navigation API] dispose-after-bfcache.html and entries-after-bfcache.html 
fail on WPT
https://bugs.webkit.org/show_bug.cgi?id=299918
rdar://161694156

Reviewed by Chris Dumez.

When a restoring a Page from the bfcache, we must also restore the Navigation
object's list of HistoryItems.

This happens in CachedPage::restore. For each frame, we get all of its 
HistoryItems
from the UIProcess and send them to Navigation::updateForReactivation. But the
Navigation API's list can only contain sequential items of the same origin as 
the
current item.

For example, consider this UI Process b/f list:

1. foo.com
2. bar.com
3. foo.com
4. bar.com
5. bar.com#1  <-- currentItem
6. bar.com#2
7. foo.com
8. bar.com

The Navigation object's list must be: { 4, 5, 6 } in that order and nothing 
more.

This means that once we get the b/f list from the UI Process, we must filter it
before giving it Navigation::updateForReactivation.

BackForwardController::reachableItemsForFrame claimed to have this logic, but 
it's
logic was wrong. It was not filtering out non-same-origin entries, but rather
getting *all* of the items across a frame's lifetime.

To fix this, we remove BackForwardController::reachableItemsForFrame and 
replace it
with Navigation::filterHistoryItemsForNavigationAPI (since this filtering is 
specific
to the Navigation API). We also refactor the Navigation API restoring code in
CachedPage::restore to be cleaner.

This change will make dispose-after-bfcache.html and entries-after-bfcache.html
pass on WPT. I have manually verified this. They already pass locally. They were
failing on WPT because when the test is run on WPT, an extra item is present in
the b/f list initially, This item wasn't getting filtered out and was causing 
the
test to fail. This item is not present when the test is run locally, and so the
test is passing. To simulate this difference, we add a new test:

LayoutTests/http/tests/navigation-api/different-origin-entries-removed-after-bfcache.html

* 
LayoutTests/http/tests/navigation-api/different-origin-entries-removed-after-bfcache-expected.txt:
 Added.
* 
LayoutTests/http/tests/navigation-api/different-origin-entries-removed-after-bfcache.html:
 Added.
* LayoutTests/http/tests/navigation-api/resources/page-that-goes-back.html: 
Added.
* LayoutTests/platform/mac-wk1/TestExpectations:
* Source/WebCore/history/BackForwardController.cpp:
(WebCore::BackForwardController::allItems):
(WebCore::BackForwardController::reachableItemsForFrame): Deleted.
* Source/WebCore/history/BackForwardController.h:
* Source/WebCore/history/CachedPage.cpp:
(WebCore::CachedPage::restore):
(WebCore::CachedPage::restoreNavigationAPIHistoryItems):

For each frame, obtain send the filtered list to the Navigation object.

* Source/WebCore/history/CachedPage.h:
* Source/WebCore/page/Navigation.cpp:
(WebCore::Navigation::filterHistoryItemsForNavigationAPI):

Filter the list in the way described above.

* Source/WebCore/page/Navigation.h:

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to