Closed Bug 2072955 Opened 2 months ago Closed 12 days ago

[wpt-sync] Sync PR 62754 - Prevent premature stylesheet completion in script tests

Categories

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

task

Tracking

()

RESOLVED FIXED
163 Branch
Tracking Status
firefox163 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

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

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

Domenic Denicola <d@domenic.me> wrote:

Prevent premature stylesheet completion in script tests

These tests check that a parser-inserted inline script executes the source captured during preparation, even if its text changes before execution. The CSP variant additionally checks that the source approved by CSP is the source that executes.

To create a gap between preparation and execution, the tests put a pending stylesheet before the target script and schedule a timer to mutate its text. Previously, the mutation waited 500 ms and the stylesheet response waited one second. Those delays do not start together: speculative loading can request and finish the stylesheet while the parser is still waiting for testharness.js, before the mutation timer is even scheduled. The target script then executes before its text changes, producing a failure unrelated to the behavior under test.

Keep the stylesheet response pending until the mutation callback explicitly releases it. This guarantees that stylesheet completion follows the mutation, regardless of when the stylesheet request starts. Use XHR for the release because Firefox explicitly exempts it from scheduling behind blocking CSS/JS loads; fetch() can instead deadlock this arrangement. Release the response even if the mutation step fails, so document loading can finish.

This removes the premature-stylesheet-completion race, not every timing assumption. The existing 500 ms timer still assumes the parser has reached and prepared the target script before the mutation runs.

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 516 tests and 3 subtests

Status Summary

Firefox

OK : 2[GitHub] 503[Gecko-android-em-14-x86_64-debug-geckoview] 504[Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview] 507[Gecko-linux2404-64-debug] 508[Gecko-windows11-32-25h2-debug] 509[Gecko-windows11-64-25h2-debug] 512[Gecko-windows11-32-25h2-opt] 513[Gecko-linux2404-64-opt, Gecko-windows11-64-25h2-opt]
PASS : 3209[Gecko-android-em-14-x86_64-debug-geckoview] 3213[Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview] 3227[Gecko-windows11-32-25h2-debug] 3228[Gecko-windows11-64-25h2-debug] 3232[Gecko-linux2404-64-debug] 3249[Gecko-windows11-32-25h2-opt] 3250[Gecko-linux2404-64-opt, Gecko-windows11-64-25h2-opt]
FAIL : 2[GitHub] 63[Gecko-linux2404-64-opt, Gecko-windows11-32-25h2-opt, Gecko-windows11-64-25h2-opt] 79[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] 81[Gecko-linux2404-64-debug, Gecko-windows11-32-25h2-debug, Gecko-windows11-64-25h2-debug]
ERROR: 3[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-linux2404-64-debug, Gecko-windows11-32-25h2-debug, Gecko-windows11-64-25h2-debug] 4[Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview]

Chrome

OK : 2
PASS : 2

Safari

OK : 2
FAIL : 2

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Details

New Tests That Don't Pass

Tests Disabled in Gecko Infrastructure

Pushed by wptsync@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/8a355dd89e13 https://hg.mozilla.org/integration/autoland/rev/477bf0b96d0e [wpt PR 62754] - Prevent premature stylesheet completion in script tests, a=testonly
Status: NEW → RESOLVED
Closed: 12 days ago
Resolution: --- → FIXED
Target Milestone: --- → 163 Branch
You need to log in before you can comment on or make changes to this bug.