RESOLVED FIXED 282593
[Navigation] Navigation.navigate() should trigger the 'beforeunload' event synchronously
https://bugs.webkit.org/show_bug.cgi?id=282593
Summary [Navigation] Navigation.navigate() should trigger the 'beforeunload' event sy...
Rob Buis
Reported 2024-11-05 01:37:19 PST
Support beforeunload on subframes.
Attachments
Rob Buis
Comment 1 2024-11-05 01:42:38 PST
This is blocking many navigation-api WPT tests, for example: navigation-api/navigate-event/navigate-navigation-back-cross-document.html navigation-api/navigation-methods/return-value/back-beforeunload.html navigation-api/navigation-methods/return-value/forward-beforeunload.html navigation-api/navigation-methods/return-value/navigate-beforeunload.html navigation-api/navigation-methods/return-value/navigate-rejection-order-beforeunload-unserializablestate.html navigation-api/navigation-methods/return-value/navigate-rejection-order-invalidurl-beforeunload.html navigation-api/navigation-methods/return-value/reload-beforeunload.html navigation-api/navigation-methods/return-value/reload-rejection-order-beforeunload-unserializablestate.html navigation-api/navigation-methods/return-value/traverseTo-beforeunload.html
Rob Buis
Comment 2 2024-11-05 13:19:05 PST
Note that this is not just for the benefit of navigation api though, it should allow interoperability with Chrome and gecko too.
Radar WebKit Bug Importer
Comment 3 2024-11-10 22:06:02 PST
Chris Dumez
Comment 4 2024-11-18 16:03:38 PST
We do dispatch beforeunload in subframes. The issue is that the tests seem to expect the beforeunload event to get fired *synchronously* when calling `navigate()`. In WebKit, it gets called asynchronously since there is a navigation policy decision that happens before we navigate and this policy decision is normally async.
Rob Buis
Comment 5 2024-11-19 05:56:31 PST
(In reply to Chris Dumez from comment #4) > We do dispatch beforeunload in subframes. The issue is that the tests seem > to expect the beforeunload event to get fired *synchronously* when calling > `navigate()`. In WebKit, it gets called asynchronously since there is a > navigation policy decision that happens before we navigate and this policy > decision is normally async. Thanks Chris, I renamed the bug so it reflects it is a problem with Navigation API + beforeunload on subframes, not beforeunload on subframes by itself.
Chris Dumez
Comment 6 2024-11-19 07:47:41 PST
BTW, I tried making the policy decision synchronous but it caused other issues. If the navigation happens synchronously, then it ends up canceling the *current* navigation (triggered by Navigation API) and we fire the navigateerror event. This doesn't happen when the navigation happens asynchronously.
Chris Dumez
Comment 7 2024-11-20 14:00:32 PST
EWS
Comment 8 2024-11-21 11:48:22 PST
Committed 286919@main (4c2147c4b2aa): <https://commits.webkit.org/286919@main> Reviewed commits have been landed. Closing PR #36915 and removing active labels.
Chris Dumez
Comment 9 2024-12-13 12:01:55 PST
Re-opening since the patch got reverted because of a Speedometer regression.
Chris Dumez
Comment 10 2024-12-16 10:07:03 PST
EWS
Comment 11 2024-12-19 10:54:01 PST
Committed 288106@main (9fb3593f38c1): <https://commits.webkit.org/288106@main> Reviewed commits have been landed. Closing PR #38019 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.