Closed Bug 2079103 Opened 1 month ago Closed 1 month ago

[wpt-sync] Sync PR 63336 - Fix timeout flake in focus-pseudo-matches-on-shadow-host.html

Categories

(Core :: DOM: Core & HTML, task, P4)

task

Tracking

()

RESOLVED FIXED
160 Branch
Tracking Status
firefox160 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

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

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

Joey Arhar <jarhar@chromium.org> wrote:

Fix timeout flake in focus-pseudo-matches-on-shadow-host.html

In focus-pseudo-matches-on-shadow-host.html, \<input id="defaultFocus"
autofocus> appears in \<body> before the \<script> element that registers
defaultFocus.addEventListener('focus', handleFocus) and calls
testInMode().

Once HTMLDocumentParser::PumpTokenizer() exits \<head> and parses the
\<input autofocus> element, the parser can yield before parsing \<script>
(for example, when scheduler_->ShouldYieldForHighPriorityWork() returns
true for a pending BeginMainFrame, or when the parser time budget
expires). During that yield, BeginMainFrame runs
PageAnimator::ServiceScriptedAnimations() and calls
Document::FlushAutofocusCandidates(), which focuses defaultFocus and
dispatches its focus event before \<script> executes. When \<script>
subsequently runs and registers handleFocus(), the focus event has
already fired, so handleFocus() never runs, no promise_test() subtests
are registered, and the test times out.

Reproduce the timeout deterministically by forcing HTML parser yields
with HTMLParserYieldAndDelayOftenForTesting:
third_party/blink/tools/run_wpt_tests.py -t Default
--additional-driver-flag=--enable-blink-features=HTMLParserYieldAndDelayOftenForTesting
external/wpt/shadow-dom/focus/focus-pseudo-matches-on-shadow-host.html

Initialize focusedDefault to (document.activeElement == defaultFocus) so
prepare() resolves immediately if autofocus already completed before
\<script> execution. Call testInMode() synchronously at the top level of
\<script>, and use step_timeout(didFocusDefault, 0) in handleFocus() to
avoid nested focusing steps when autofocus runs after \<script>.

Fixed: 567076198
Change-Id: I0cd06c03e90cc0bcc99523543247aaa5590b3907
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8498979
Reviewed-by: Joey Arhar \<jarhar@chromium.org>
Commit-Queue: Joey Arhar \<jarhar@chromium.org>
Reviewed-by: David Grogan \<dgrogan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1712699}

Component: web-platform-tests → DOM: Core & HTML
Product: Testing → Core

CI Results

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

Total 40 tests and 2 subtests

Status Summary

Firefox

OK : 1[GitHub] 37[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: 20[GitHub] 108[Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt] 111[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-64-25h2-debug, Gecko-windows11-64-25h2-opt]
FAIL: 1

Chrome

OK : 1
PASS: 20

Safari

OK : 1
PASS: 20

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Details

New Tests That Don't Pass

Pushed by wptsync@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/1599a5592fd3 https://hg.mozilla.org/integration/autoland/rev/7317637e07da [wpt PR 63336] - Fix timeout flake in focus-pseudo-matches-on-shadow-host.html, a=testonly
Status: NEW → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 160 Branch
You need to log in before you can comment on or make changes to this bug.