[webkit-changes] [WebKit/WebKit] c1305a: imported/w3c/web-platform-tests/navigation-api/nav...

Chris Dumez noreply at github.com
Thu Jan 2 13:02:28 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c1305a23bb3a86fbaa930c27caa4b3a4eb2b5222
      https://github.com/WebKit/WebKit/commit/c1305a23bb3a86fbaa930c27caa4b3a4eb2b5222
  Author: Chris Dumez <cdumez at apple.com>
  Date:   2025-01-02 (Thu, 02 Jan 2025)

  Changed paths:
    M LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigation-traverseTo-in-iframe-same-document-preventDefault-expected.txt
    M Source/WebCore/bindings/js/JSDOMPromiseDeferred.h
    M Source/WebCore/loader/HistoryController.cpp
    M Source/WebCore/loader/HistoryController.h
    M Source/WebCore/loader/NavigationScheduler.cpp
    M Source/WebCore/page/Navigation.cpp
    M Source/WebCore/page/Navigation.h
    M Source/WebCore/page/Page.cpp
    M Source/WebCore/page/Page.h

  Log Message:
  -----------
  imported/w3c/web-platform-tests/navigation-api/navigate-event/navigation-traverseTo-in-iframe-same-document-preventDefault.html is failing
https://bugs.webkit.org/show_bug.cgi?id=285045

Reviewed by Rob Buis.

When doing same-document navigations using the Navigation API, several frames can be
navigated. If the navigation in a parent frame gets aborted (e.g. by the JS calling
`preventDefault()` on the navigate event), we should not proceed with navigations in
subframes and we should reject the finished promise for the overall navigation.

I attempted to implement this in an earlier PR but the logic was flawed and would
prevent us from passing this test. To detect in the navigation in a frame failed,
I used to rely on the Navigation object's apiMethodTracker finished promise being
rejected or not. However, when `Navigation.traverseTo()` is called in a subframe
and the JS abort the navigation in a parent frame, the parent frame's navigation
object doesn't have a apiMethodTracker (the subframe does). As a result, we were
unable to detect that the navigation had been aborted. To make this more robust,
I added a `registerAbortHandler()` member function to Navigation so we can easily
track if the navigation in a given frame was aborted or not, without relying on
the apiMethodTracker's finished promise.

I also pass the apiMethodTracker to goToItemForNavigationAPI(), so we can
properly reject its finished promise if the navigation is aborted by another
frame. This is expected by the test.

* LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigation-traverseTo-in-iframe-same-document-preventDefault-expected.txt:
* Source/WebCore/bindings/js/JSDOMPromiseDeferred.h:
(WebCore::DeferredPromise::wasRejected const): Deleted.
* Source/WebCore/loader/HistoryController.cpp:
(WebCore::HistoryController::goToItemForNavigationAPI):
* Source/WebCore/loader/HistoryController.h:
* Source/WebCore/loader/NavigationScheduler.cpp:
* Source/WebCore/page/Navigation.cpp:
(WebCore::Navigation::rejectFinishedPromise):
(WebCore::Navigation::registerAbortHandler):
(WebCore::Navigation::abortOngoingNavigation):
* Source/WebCore/page/Navigation.h:
* Source/WebCore/page/Page.cpp:
(WebCore::Page::goToItemForNavigationAPI):
* Source/WebCore/page/Page.h:

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