Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 4c2147c4b2aa67d561ab0b50feeefb8dc677cd35
      
https://github.com/WebKit/WebKit/commit/4c2147c4b2aa67d561ab0b50feeefb8dc677cd35
  Author: Chris Dumez <[email protected]>
  Date:   2024-11-21 (Thu, 21 Nov 2024)

  Changed paths:
    M LayoutTests/TestExpectations
    M 
LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/intercept-handler-throws-expected.txt
    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/loader/NavigationScheduler.cpp
    M Source/WebCore/page/LocalDOMWindow.cpp
    M Source/WebCore/page/NavigateEvent.cpp
    M Source/WebCore/page/Navigation.cpp
    M Source/WebCore/page/Navigation.h
    M Source/WebCore/page/NavigationHistoryEntry.cpp
    M Source/WebCore/page/NavigationHistoryEntry.h
    M Source/WebCore/page/NavigationHistoryEntry.idl
    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 and 
quite
a few WPT tests were relying on this.

Fixing this enabled some more tests which exposed some pre-existing bugs that 
I'm
fixing in the same PR so it doesn't look like regressions.

In particular, we dispatch events at NavigationHistoryEntry objects but the 
class
doesn't subclass ActiveDOMObject to keep the JS wrapper alive. We were also 
failing
to grab the JSLock in one place, which was causing assertions.

* LayoutTests/TestExpectations:
Unskip some tests that are now passing.

* 
LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/intercept-handler-throws-expected.txt:
The output looks a bit worse but I don't think this is a regression. Rather, 
this looks like a timing change because
the navigation now happens sooner. I will investigate separately how to make 
this test fully pass.

* 
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:
Rebaseline tests that are now passing.

* Source/WebCore/loader/FrameLoadRequest.h:
(WebCore::FrameLoadRequest::isFromNavigationAPI const):
(WebCore::FrameLoadRequest::setIsFromNavigationAPI):
* Source/WebCore/loader/FrameLoader.cpp:
(WebCore::FrameLoader::stopLoading):
(WebCore::FrameLoader::loadURL):
(WebCore::FrameLoader::loadWithDocumentLoader):
(WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
* Source/WebCore/loader/FrameLoader.h:
* Source/WebCore/loader/NavigationAction.h:
(WebCore::NavigationAction::isFromNavigationAPI const):
(WebCore::NavigationAction::setIsFromNavigationAPI):
* Source/WebCore/loader/NavigationScheduler.cpp:
(WebCore::ScheduledHistoryNavigationByKey::findBackForwardItemByKey):
Make the navigation policy decision synchronous when the navigation is 
triggered via the navigation API.
This is the only way the navigation can proceed synchronously and fire the 
beforeunload event right away.

* Source/WebCore/page/LocalDOMWindow.cpp:
(WebCore::LocalDOMWindow::stop):
When calling `window.stop()`, abort the pending navigation API navigation as 
tests are expecting this.

* Source/WebCore/page/NavigateEvent.cpp:
(WebCore::NavigateEvent::NavigateEvent):
(WebCore::NavigateEvent::create):
* Source/WebCore/page/NavigateEvent.h:
* Source/WebCore/page/NavigateEvent.idl:
Make sure the grab the JSLock before initializing m_info. Without this, I was 
seeing assertions
in the layout tests.

* Source/WebCore/page/Navigation.cpp:
* Source/WebCore/page/Navigation.h:
* Source/WebCore/page/NavigationHistoryEntry.cpp:
(WebCore::NavigationHistoryEntry::NavigationHistoryEntry):
(WebCore::NavigationHistoryEntry::create):
* Source/WebCore/page/NavigationHistoryEntry.h:
* Source/WebCore/page/NavigationHistoryEntry.idl:
Make NavigationHistoryEntry an ActiveDOMObject and keep its JS wrapper alive as 
long as the
NavigationHistoryEntry is held by the navigation object. This is important 
since the navigation
object may dispatch events at the NavigationHistoryEntry. Without this change, 
some of the tests
were asserting that the JS wrapper was missing during the event dispatching.

* Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
Obey the policyDecisionMode being PolicyDecisionMode::Synchronous and use the 
DecidePolicyForNavigationActionSync
synchronous IPC when the navigation is triggered by the Navigation API so that 
the navigation can
start synchronously and yet still obey the policy decision from the client.

* 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/286919@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