Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 8c2414bf6f23eb558767447d83e80e81855bfbb5
      
https://github.com/WebKit/WebKit/commit/8c2414bf6f23eb558767447d83e80e81855bfbb5
  Author: Basuke Suzuki <[email protected]>
  Date:   2025-07-24 (Thu, 24 Jul 2025)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-navigation-back-cross-document-expected.txt
    M Source/WebCore/loader/FrameLoader.cpp
    M Source/WebCore/loader/FrameLoader.h
    M Source/WebCore/page/Navigation.cpp

  Log Message:
  -----------
  [Navigation API] Fix beforeunload event timing and info parameter for 
cross-document traversals.
https://bugs.webkit.org/show_bug.cgi?id=296349
rdar://156446875

Reviewed by Chris Dumez.

This commit resolves two critical issues with the Navigation API's navigate 
event handling
for cross-document traversals:
- Navigate events were firing before beforeunload events that is violating the 
HTML spec.
- `navigation.back({ info: "hi" })` info parameter wasn't reaching navigate 
events.

The first issue was in `loadItem()`, navigate events were dispatched 
immediately for all
navigation types, occurring before `shouldClose()` executed beforeunload 
handlers.

- For same-document navigation: Dispatch navigate events immediately (no 
beforeunload)
- For cross-document navigation: Store HistoryItem in 
`m_pendingNavigationAPIItem` and
  defer dispatch until after `shouldClose()` in 
`continueLoadAfterNavigationPolicy()`

The second issue was due to `promoteUpcomingAPIMethodTracker()` failed to 
handle cases where
`destinationKey` was an empty string, preventing API method tracker promotion.

To solve this, enhanced the promotion logic to use any available traverse 
method tracker
when the destination key is empty, ensuring info parameters are properly 
propagated.

* 
LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-navigation-back-cross-document-expected.txt:
* Source/WebCore/loader/FrameLoader.cpp:
(WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
(WebCore::FrameLoader::dispatchNavigateEvent):
(WebCore::FrameLoader::loadItem):
* Source/WebCore/loader/FrameLoader.h:
* Source/WebCore/page/Navigation.cpp:
(WebCore::Navigation::promoteUpcomingAPIMethodTracker):

Canonical link: https://commits.webkit.org/297824@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