Closed Bug 2089400 Opened 13 days ago Closed

[wpt-sync] Sync PR 64427 - WebKit export of https://bugs.webkit.org/show_bug.cgi?id=325553

Categories

(Core :: DOM: Navigation, task, P4)

task

Tracking

()

RESOLVED FIXED
162 Branch
Tracking Status
firefox162 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 64427 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/64427
Details from upstream follow.

Basuke Suzuki <basuke@apple.com> wrote:

WebKit export of https://bugs.webkit.org/show_bug.cgi?id=325553

WebKit export from bug: [<!---->Navigation API]<!----> preventDefault(<!---->)<!----> does not cancel a cross-<!---->site navigation.<!---->navigate(<!---->)<!----> that swaps processes

<pre>
[Navigation API] preventDefault() does not cancel a cross-site navigation.navigate() that swaps processes

navigation.navigate() used a synchronous navigation policy check (<a href="https://commits.webkit.org/288106@main">288106@main</a>), whose reply falls
back to Use before the UI process decides on a process swap. The source process then loaded the
destination as well as the process the UI process chose, so preventDefault() could not cancel it,
and under Site Isolation the source process was killed or committed a cross-site document in the
embedder's process (<a href="https://rdar.apple.com/188750371">rdar://188750371</a>).

Cross-document navigation.navigate() now uses the asynchronous policy check like other
cross-document navigations. FrameLoader::shouldCheckNavigationPolicyAfterDispatchingEvents()
first fires the events navigate() needs, the navigate event and then beforeunload, which is the
order the HTML spec uses for push, replace and reload navigations, and then tells whether the
navigation should still go on to the policy check. A navigate() whose navigate event is
intercepted therefore no longer fires beforeunload. The events run after the load being replaced
is stopped and after scheduled navigations are cancelled, as they did when they ran after the
synchronous policy decision.

Since these events already ran, the rest of the navigation treats them as done:

  • continueLoadAfterNavigationPolicy() does not dispatch beforeunload again.
  • If the policy check denies the navigation, the navigate event is aborted (navigateerror and
    AbortError). The abort is queued and only applies while that event is still the ongoing one,
    because a newer navigation cancels this policy check as it starts and aborts the event itself.
    To recognize it, every NavigateEvent now has a NavigateEventIdentifier, which
    NavigateEventDispatchResult carries back to the navigation that fired it.
  • LoadWillContinueInAnotherProcess does not abort it, since the navigation carries on elsewhere.

When the other process commits the navigation, the old frame or page is torn down through
FrameLoader::detachFromParent(). Its closeURL() unloads the document without aborting the
Navigation API, but the stopAllLoaders() that followed aborted the ongoing navigation whenever
the document was still loading, so the document got navigateerror for a navigation that had
committed. navigate() now leaves that navigation ongoing until then, which made this reachable.
detachFromParent() no longer aborts after unloading; removing an iframe still aborts, through
FrameLoader::frameDetached(), as the spec requires for a destroyed child navigable.

The asynchronous check also lets a client that decides late deny navigate(); before, its answer
arrived after the synchronous fallback had already allowed the load.

Two tentative deferPageSwap tests call navigate() while their popup is still parsing. The load
used to start inside that script and stop the parser, so pagehide never fired and they timed out.
They now reach their assertions: one passes and the other fails because WebKit does not
implement deferPageSwap.

fast/canvas/offscreen-webgl-transfer-after-navigation-crash.html relied on
navigation.navigate("about:blank") committing before its next line ran, which tore down the
document and lost the WebGL context. It now navigates an iframe that owns the canvas and calls
transferToImageBitmap() once the iframe has loaded; without the fix from <a href="https://commits.webkit.org/309187@main">309187@main</a> it still
crashes.

WebKit-Bug: <a href="https://bugs.webkit.org/show_bug.cgi?id=325553">https://bugs.webkit.org/show_bug.cgi?id=325553</a>
WebKit-Canonical-Link: <a href="https://commits.webkit.org/322591@main">https://commits.webkit.org/322591@main</a>
</pre>

Whiteboard: [wptsync downstream] → [wptsync downstream error]
Component: web-platform-tests → DOM: Navigation
Product: Testing → Core
Whiteboard: [wptsync downstream error] → [wptsync downstream]

CI Results

Ran 11 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI

Total 148 tests and 1 subtests

Status Summary

Firefox

OK : 2[GitHub] 131[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview, Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
PASS : 2[Gecko-linux2204-64-wayland-debug, Gecko-linux2204-64-wayland-opt, GitHub] 146[Gecko-android-em-14-x86_64-opt-geckoview, Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt] 147[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview]
FAIL : 2
TIMEOUT: 2
ERROR : 1

Chrome

OK : 2
PASS : 2
TIMEOUT: 2

Safari

OK : 3
PASS : 3

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Details

New Tests That Don't Pass

Tests Disabled in Gecko Infrastructure

Status: NEW → RESOLVED
Closed: 5 days ago
Closed: 5 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch
You need to log in before you can comment on or make changes to this bug.