[webkit-changes] [WebKit/WebKit] 9fb359: [Navigation] Navigation.navigate() should trigger ...

Chris Dumez noreply at github.com
Thu Dec 19 10:54:20 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 9fb3593f38c1583f0c6e91bae3090262b7445a20
      https://github.com/WebKit/WebKit/commit/9fb3593f38c1583f0c6e91bae3090262b7445a20
  Author: Chris Dumez <cdumez at apple.com>
  Date:   2024-12-19 (Thu, 19 Dec 2024)

  Changed paths:
    M LayoutTests/TestExpectations
    M LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/back-beforeunload-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/forward-beforeunload-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/navigate-beforeunload-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/navigate-rejection-order-beforeunload-unserializablestate-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/navigate-rejection-order-invalidurl-beforeunload-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/reload-beforeunload-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/reload-rejection-order-beforeunload-unserializablestate-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/traverseTo-beforeunload-expected.txt
    M Source/WebCore/loader/FrameLoadRequest.h
    M Source/WebCore/loader/FrameLoader.cpp
    M Source/WebCore/loader/FrameLoader.h
    M Source/WebCore/loader/NavigationAction.h
    M Source/WebCore/page/Navigation.cpp
    M Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
    M Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.cpp

  Log Message:
  -----------
  [Navigation] Navigation.navigate() should trigger the 'beforeunload' event synchronously
https://bugs.webkit.org/show_bug.cgi?id=282593
rdar://139628818

Reviewed by Rob Buis.

Navigation.navigate() should trigger the 'beforeunload' event synchronously, even for non
same-document navigation and quite a few WPT tests were relying on this. In order to achieve
this, it means we need to do the decidePolicyForNavigationAction check with the client
*synchronously*.

* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/back-beforeunload-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/forward-beforeunload-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/navigate-beforeunload-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/navigate-rejection-order-beforeunload-unserializablestate-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/navigate-rejection-order-invalidurl-beforeunload-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/reload-beforeunload-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/reload-rejection-order-beforeunload-unserializablestate-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/traverseTo-beforeunload-expected.txt:
Unskip and rebaseline tests that are now passing.

* Source/WebCore/loader/FrameLoadRequest.h:
(WebCore::FrameLoadRequest::isFromNavigationAPI const):
(WebCore::FrameLoadRequest::setIsFromNavigationAPI):
* Source/WebCore/loader/NavigationAction.h:
(WebCore::NavigationAction::isFromNavigationAPI const):
(WebCore::NavigationAction::setIsFromNavigationAPI):
Add flag to keep track of whether or not a navigation was started by the Navigation API.

* Source/WebCore/loader/FrameLoader.h:
* Source/WebCore/loader/FrameLoader.cpp:
(WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
(WebCore::FrameLoader::stopLoading):
Now that the navigation policy decision happens synchronously for the navigation API navigations,
continueLoadAfterNavigationPolicy() would mistakenly cancel the pending navigation API navigation
when calling stopLoading(). Make sure it doesn't.

(WebCore::FrameLoader::loadURL):
(WebCore::FrameLoader::loadWithDocumentLoader):
Set the isFromNavigationAPI flag.

(WebCore::FrameLoader::stopForUserCancel):
When the JS calls `window.stop()`, make sure it aborts any pending navigation API
navigation, as is expected by:
imported/w3c/web-platform-tests/navigation-api/navigate-event/signal-abort-window-stop.html

* Source/WebCore/page/Navigation.cpp:
(WebCore::Navigation::navigate):
Set the isFromNavigationAPI flag.

* Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
Make sure we do the decidePolicyForNavigationAction synchronously when the navigation is
triggered by the Navigation API. This is required since WPT tests expect the `beforeunload`
event to fire synchronously when doing a navigation, even if not same-document.

* Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.cpp:
(WebKit::WebLocalFrameLoaderClient::dispatchDidFailProvisionalLoad):
Some of the tests abort the navigation during the provisional stage. This was hitting
an assertion in `WebLocalFrameLoaderClient::dispatchDidReachLayoutMilestone()`:
`ASSERT(!m_frame->isMainFrame() || webPage->corePage()->settings().suppressesIncrementalRendering() || m_didCompletePageTransition);`
The reason was the m_didCompletePageTransition wasn't reset to true and provisional load failure.
To address this issue, I now make sure to call `completePageTransitionIfNeeded()` in `dispatchDidFailProvisionalLoad()`.

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



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


More information about the webkit-changes mailing list