Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 94abc6b8f69e64cc9eabcb628c5fee25b4c3e93e
      
https://github.com/WebKit/WebKit/commit/94abc6b8f69e64cc9eabcb628c5fee25b4c3e93e
  Author: Chris Dumez <[email protected]>
  Date:   2026-03-13 (Fri, 13 Mar 2026)

  Changed paths:
    M LayoutTests/platform/mac-wk2/TestExpectations
    M Source/WebCore/loader/NavigationScheduler.cpp

  Log Message:
  -----------
  
imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/form-requestsubmit.html
 is a flaky text failure.
https://bugs.webkit.org/show_bug.cgi?id=307351
rdar://169977453

Reviewed by Basuke Suzuki.

Navigations initiated during document loading (e.g., form.requestSubmit(),
location.assign() called during parsing) can race with the current
document's load event. This is because 
NavigationScheduler::scheduleFormSubmission()
uses !stateMachine().committedFirstRealDocumentLoad() to determine if a
navigation is happening "during load." This check only returns true when
the frame is still on its initial empty document — by the time a script
runs in the actual document being loaded, the first real document has
already been committed, so the check returns false.

When duringLoad is false, the schedule() method skips the synchronous
abort of the current document load, and instead just starts a 0-delay
timer for the new navigation. This creates a race between the current
document's load event and the timer, causing flaky test failures where
the load event fires before the scheduled navigation starts.

To address the issue, change the duringLoad check in
scheduleFormSubmission() to also include `!loader().isComplete()`. This
correctly identifies any navigation scheduled while the current document
is still loading, ensuring schedule() synchronously aborts the current
load and prevents the load event from racing with the new navigation.

The original `!committedFirstRealDocumentLoad()` check is preserved
alongside the new `!isComplete()` check (combined with ||) because it
serves a different purpose: when a popup is created via window.open(url),
the initial empty document is already complete (isComplete() returns true)
but committedFirstRealDocumentLoad() is still false. A form.submit()
in this state must be marked as duringLoad so that
redirectScheduledDuringLoad() returns true in didOpenURL(). Otherwise,
when the window.open navigation's async policy check completes and
didOpenURL() is called, it would cancel the pending form submission,
causing the popup to navigate to the window.open URL instead of the
form's action URL.

Also add a targetIsCurrentFrame() check to the wasDuringLoad condition
in schedule(). When a form submission targets a new window (e.g.,
target=_blank), the submission is scheduled on the submitter's frame but
should not abort the submitter's current load — only form submissions
that navigate the current frame should do so.

* LayoutTests/platform/mac-wk2/TestExpectations:
* Source/WebCore/loader/NavigationScheduler.cpp:
(WebCore::NavigationScheduler::scheduleFormSubmission):
(WebCore::NavigationScheduler::schedule):

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



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

Reply via email to