Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: fa68546060593a1cffebe2dbc2dec3d5edc20eeb
      
https://github.com/WebKit/WebKit/commit/fa68546060593a1cffebe2dbc2dec3d5edc20eeb
  Author: Basuke Suzuki <[email protected]>
  Date:   2026-06-10 (Wed, 10 Jun 2026)

  Changed paths:
    M Source/WebCore/page/Navigation.cpp
    M Source/WebCore/page/Navigation.h

  Log Message:
  -----------
  NavigationAPIMethodTracker should manage its own promise settlement
https://bugs.webkit.org/show_bug.cgi?id=316812
rdar://179261686

Reviewed by Anne van Kesteren.

NavigationAPIMethodTracker exposed all of its state through getters and
setters, and the spec algorithms that operate on it ("notify about the
committed-to entry", "resolve/reject the finished promise") lived in
Navigation, probing committedToEntry() and a finishedBeforeCommit flag
from the outside. Several call sites also settled the tracker's promises
by hand, each with a slightly different recipe (the rate limiter path,
the navigate() path for loads that never reach the navigate event, the
intercept-handler failure path, and the traversal cancellation callback).

Move those algorithms into the tracker as commitTo(), resolveFinished()
and rejectFinished(), driven by an internal state enum (Pending /
FinishedBeforeCommit / Committed / Settled) that replaces the
finishedBeforeCommit bool. The tracker now guarantees its own invariants:
each promise settles at most once, a finish signal that arrives before
commit is held until commitTo() runs, and an uncommitted navigation
rejects both promises while a committed one only rejects the finished
promise. This also removes the redundant re-resolution of the committed
promise that resolveFinishedPromise used to perform, which relied on
DeferredPromise ignoring a second resolve.

Navigation's notifyCommittedToEntry / resolveFinishedPromise /
rejectFinishedPromise become thin wrappers that delegate to the tracker
and handle tracker cleanup, and all remaining settlement paths are
routed through them.

One behavior fix: when NavigationScheduler cancelled a scheduled key
traversal, the completion callback rejected the tracker's promises but
never removed the tracker from m_upcomingTraverseMethodTrackers. A later
traverseTo(), back() or forward() to the same key would then be
deduplicated against the stale tracker and receive the already-rejected
promises instead of starting a new traversal. The callback now goes
through rejectFinishedPromise, which also cleans up the upcoming map.

This is preparation for implementing NavigationInterceptOptions'
precommitHandler, which adds another commit-timing state and would
otherwise have to thread more flags through Navigation.

No new tests. Covered by existing imported/w3c/web-platform-tests/
navigation-api tests, which pass in both release and debug.

* Source/WebCore/page/Navigation.h:
(WebCore::NavigationAPIMethodTracker::hasCommitted const):
(WebCore::NavigationAPIMethodTracker::isSettled const):
(WebCore::NavigationAPIMethodTracker::committedToEntry const): Deleted.
(WebCore::NavigationAPIMethodTracker::setCommittedToEntry): Deleted.
(WebCore::NavigationAPIMethodTracker::finishedBeforeCommit const): Deleted.
(WebCore::NavigationAPIMethodTracker::setFinishedBeforeCommit): Deleted.
(WebCore::NavigationAPIMethodTracker::setSerializedState): Deleted.
(WebCore::NavigationAPIMethodTracker::takeSerializedState): Deleted.
* Source/WebCore/page/Navigation.cpp:
(WebCore::NavigationAPIMethodTracker::NavigationAPIMethodTracker):
(WebCore::NavigationAPIMethodTracker::commitTo):
(WebCore::NavigationAPIMethodTracker::resolveFinished):
(WebCore::NavigationAPIMethodTracker::rejectFinished):
(WebCore::Navigation::maybeSetUpcomingNonTraversalTracker):
(WebCore::Navigation::addUpcomingTraverseAPIMethodTracker):
(WebCore::Navigation::navigate):
(WebCore::Navigation::performTraversal):
(WebCore::Navigation::notifyCommittedToEntry):
(WebCore::Navigation::resolveFinishedPromise):
(WebCore::Navigation::rejectFinishedPromise):
(WebCore::Navigation::handleSameDocumentNavigation):
(WebCore::Navigation::innerDispatchNavigateEvent):

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



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

Reply via email to