Skip to content

Sync WPT with upstream (01-11-2026) - #49485

Merged
jdm merged 1 commit into
mainfrom
wpt_update_01-11-2026
Nov 1, 2026
Merged

jdm merged 1 commit into
mainfrom
wpt_update_01-11-2026

Conversation

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

Automated downstream sync of changes from upstream as of 01-11-2026
[no-wpt-sync]

@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Nov 1, 2026
@servo-bot
servo-bot enabled auto-merge November 1, 2026 01:36
@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Nov 1, 2026
@servo-bot
servo-bot added this pull request to the merge queue Nov 1, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Nov 1, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 1, 2026
@servo-highfive servo-highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Nov 1, 2026
@jdm
jdm added this pull request to the merge queue Nov 1, 2026
@servo-highfive servo-highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Nov 1, 2026
Merged via the queue into main with commit e75353e Nov 1, 2026
44 checks passed
@jdm
jdm deleted the wpt_update_01-11-2026 branch November 1, 2026 05:46
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Nov 1, 2026
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Nov 9, 2026
Every @font-face rule was fetched, sanitised and kept in memory as soon as
its stylesheet applied, even when no style used its family or its
unicode-range covered no character on the page. CSS Fonts 4 requires user
agents to only download fonts that are used.

A new rule now only registers an unloaded face, matched by its descriptors.
Font matching asks for the face once it selects it for a character, and the
loads it asked for start after layout. `FontFace.load()` and
`FontFaceSet.load()` ask for faces the same way. Faces whose sources are all
`local()` are still loaded right away.

Because matching now decides which faces load, adding @font-face rules
dirties the document so that text is matched again, `document.fonts.ready`
flushes layout, and a reflow that starts loads makes it pending again.

The font store now holds templates for faces whose data has not been
downloaded. `FontGroupFamilyTemplate::font_if_matches` skips them, but
`FontContext::matching_templates` and `FontContext::font` are also used
directly by the SVG font resolver, which would hit the "Should never create
a web font without data" panic in `PlatformFont::new_from_template` for any
SVG `<text>` using a web font. `FontContext::font` returns `None` for a web
font template without data, without caching the failure, so the face can be
used once it has loaded. The SVG font resolver asks for the face to be
loaded, like layout does when it matches one, and falls back to the next
family in the meantime.

An element whose font-family names a web font but that has no text never
picks the font for a character, but its first available font is needed
too, for instance for `line-height: normal` and font-relative lengths, and
Chrome and Firefox load it. After an element is restyled, layout asks for
the first available font of its style to be loaded if it is a web font that
has not been fetched. Only elements whose font differs from their parent's
are looked at, nothing is done while the document has no web fonts, and the
lookup runs once per font group. It does not create fonts, so system fonts
are not loaded for elements that never draw text.

Testing: A new WPT test checks that unused faces stay "unloaded". A canvas
test that expected a font not used by the page to be loaded now fails, as it
does in Chrome, Firefox and Safari. svg/painting/svg-with-outline.html,
css/css-transforms/transform-box/view-box-mutation-002.html and
resize-observer/svg.html keep their expected results instead of crashing,
and content-security-policy/font-src/font-stylesheet-font-blocked.sub.html
(a body without text) and preload/preload-resource-match.https.html (an
empty paragraph) still see the font fetched.

Fork note: second of four patches, meant for upstream. The upstream-based
version (branch lazy-webfonts) does not have the two fixes for SVG text and
for elements without text yet, which the servo-ohos PR 12 try run found.
Motivation: generated-UI pages that link Google Fonts CJK families declare
hundreds of unicode-range subsets (441 @font-face rules on the "keai"
concert-article test page), and Servo downloaded all of them (437 files,
10.5 MiB) where ArkWeb downloads 64.

Relies on: the previous patch (the load state on `FontFaceRuleInfo`, which is
how matching tells unloaded faces apart and how `FontFace.status` shows it);
upstream a8d5fda (servo#47564, its `FontFaceSet.load` font query is what makes
`document.fonts.load()` ask for faces); matching going through
`FontGroupFamilyTemplate::font_if_matches` and `char_in_unicode_range`
(components/shared/fonts/font_template.rs); `LayoutThread::reflow` returning a
`ReflowResult` and `can_skip_reflow_request_entirely` gating it; and the
readiness checks in `Document::maybe_fulfill_font_ready_promise` and
`Window::maybe_resolve_pending_screenshot_readiness_requests` reading
`FontContext::web_fonts_still_loading`.

Drop when upstream loads @font-face rules lazily: the test this patch adds,
css/css-font-loading/fontface-unused-stays-unloaded.html, passes on plain
upstream.

Two of upstream's MathML reftests, mo-lspace-rspace-dynamic and
operator-dictionary-empty-and-three-chars, pass on plain upstream and
fail with this patch. Their screenshots differ from the references only
in the red square that
`ensure_for_match_reftest("has_operator_spacing")` of
mathml/support/feature-detection.js adds when it measures no operator
spacing, which Servo doesn't implement. Why the check passes on plain
upstream wasn't traced; since servo#49485, upstream expects
operator-dictionary-empty-and-three-chars to fail as well.

Validation: `./mach test-wpt --release --processes 1 css/css-font-loading css/css-fonts html/canvas/element/text html/canvas/offscreen/text` (948 tests): the new fontface-unused-stays-unloaded passes; 2d.text.draw.fontface.notinpage now fails as in Chrome/Firefox/Safari; six "(drawing text in a canvas)" subtests of generic-family-keywords-003 failed with this patch on base/2026-08-29 (Chrome and Firefox pass them) and pass again since base/2026-10-08, so their expectations were dropped; the two @font-face layer-override subtests of css/css-cascade/layer-font-face-override (FAIL on plain upstream) pass with this patch, so their expectations were dropped too; matching/font-unicode-PUA subtests are intermittent (test race, both results seen); the only other unexpected result, font-variant-emoji-1 FAIL, also happens on plain ohos-main. `./mach test-wpt --release svg resize-observer css/css-transforms/transform-box` (1355 tests): all as expected (svg-with-outline, view-box-mutation-002 and resize-observer/svg crash without the SVG font resolver change). `./mach test-wpt --release css/css-fonts css/css-font-loading css/css-flexbox css/css-grid css/cssom-view css/css-inline css/css-text html/canvas/element/text html/canvas/offscreen/text content-security-policy/font-src preload svg` (8650 tests): no new unexpected results besides font-variant-emoji-1 and the known intermittent grid-self-alignment-fit-content-001; font-stylesheet-font-blocked.sub.html and preload-resource-match.https.html pass, and fail without the first-available-font change. Host release build, keai page served locally over HTTP/1.1 keep-alive (3 runs each): font files fetched 437 -> 66, RSS 525.3 -> 471.6 MiB, heap 340.1 -> 286.4 MiB, `--exit -o` screenshot byte-identical to ohos-main. The servo-webfont-eager-download reproducer (6 @font-face rules, 1 needed) fetches 1 font instead of 6. On a HarmonyOS phone, production build with `--features tracing-hitrace`, the keai page served from the host through `hdc rport`, measured with this patch and the next two applied (they change invalidation, not which fonts load): 437 -> 66 font files per load in each of 5 `servoperf page` loads, and PSS 30 s after launch 507.6 -> 467.9 MB (-7.8%, 4 interleaved loads each, every pair 35-49 MB apart). 2026-11-09 sync: `./mach test-wpt --processes 8 --timeout-multiplier 2 mathml` with release builds (2026-10-29): both reftests pass with the stack up to the previous patch and fail from this one on, with SpiderMonkey and QuickJS. Release builds of this sync's stack: font-face-unicode-range-no-match-no-download.html passes in the full QuickJS run and three runs with each engine, and fails on plain 0.8.0; the table-cell subtest of first-baseline-block-in-inline-001.html passes on plain 0.8.0, passes 3 of 3 times with the stack up to the previous patch and fails 3 of 3 times with this one, and passes 3 of 3 times when it measures after the load event.
AI-assisted: Yes (agent session; designed with the maintainer, written and tested by the agent, ported from upstream main to ohos-main's Rc<Promise> API)
AI-assisted: Yes (agent session; root-caused from the servo-ohos PR 12 try run and written by the agent)
AI-assisted: Yes (agent session; 2026-10-08 sync -- conflict resolution for upstream's RootedPromise and `icu_locale_core` changes, resolved to the code of the upstream-bound lazy-webfonts branch; MANIFEST.json entry re-inserted; dropped the generic-family-keywords-003 and layer-font-face-override FAIL expectations that now pass)
AI-assisted: Yes (agent session; 2026-10-09 restack -- folded in "fonts: Do not create fonts for web font faces that are not loaded yet" and "fonts: Load the first available web font of elements without text", which fixed regressions of this patch; the upstream FontFaceSet.load change replaces the dropped backport placeholder in "Relies on")
AI-assisted: Yes (agent session; 2026-11-09 sync -- folded in "fixup! fonts: Only load @font-face fonts that the page uses" (bisected and written by the agent between syncs): the expectations of two MathML reftests that fail with this patch, of which upstream's WPT sync (servo#49485) now has the same for operator-dictionary-empty-and-three-chars; upstream's WPT sync (servo#49485) added font-face-unicode-range-no-match-no-download.html with a FAIL expectation, and it passes with this patch, so the expectation goes; the same sync added first-baseline-block-in-inline-001.html, whose table-cell subtest passes on plain 0.8.0 and fails with this patch (bisected): the test measures while parsing, before Ahem, which this patch only fetches on use, has loaded; upstream's test fix servo#49502 (bisected) makes it wait, backported at the end of the stack)
Signed-off-by: Jonathan Schwender <[email protected]>
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Nov 9, 2026
Upstream servo#48979 keeps a media element alive through its owner document
while it plays or is eligible for autoplay, and servo#49367 lets it go after
it has ended. An element that delays the load event or seeks is still
collected at the next garbage collection once script drops it, which
stops it and lets the load event fire early, and the keep-alive is only
updated at a few points of the media element's algorithms.

Like Gecko, and Blink apart from autoplay, also keep a media element
alive while it delays the load event and, with a resource and no error,
while it seeks. Don't keep an element without a resource alive, and
keep one that is eligible for autoplay only until it has enough data:
then it either plays or never will. Update the keep-alive whenever the
network state, paused, seeking, the can autoplay flag, the error, the
ready state or the delaying-the-load-event flag changes.

Fork note: meant for upstream; found with the QuickJS backend, which
frees such elements as soon as script drops them, but SpiderMonkey loses
them too once a GC runs. Until the 2026-10-29 sync this patch had its
own keep-alive set; it now extends upstream's. Besides the upstream
change, this drops the QuickJS conditions in the expectations of
autoplay-disabled-by-permissions-policy; patch 49 dropped the others.
Drop once upstream has it.

Testing: Adds a WPT test that unreferenced media elements keep playing
across a garbage collection.

Validation: Release builds of upstream f040186 with SpiderMonkey, with and without the series, `./mach test-wpt --processes 4` of html/semantics/embedded-content/media-elements, the-video-element, the-audio-element, infrastructure/assumptions/allowed-to-play.html, webaudio/the-audio-api/the-mediaelementaudiosourcenode-interface and 2 _mozilla media tests: the new test passes 7 of 7 (harness timeout without), autoplay-disabled-by-permissions-policy and played-loop as in the updated expectations (autoplay-disabled timed out intermittently before, upstream issues servo#46012 and servo#46804); the remaining differences are track timeouts and track-cues-sorted-before-dispatch failures that both builds show intermittently, and one seek-to-max-value failure in 7 runs with the series (`currentTime` 0 right after setting it), not reproduced in 6 reruns, apart from load-removes-queued-error-event, which now hangs whenever GStreamer 1.24.2's playbin3 stalls on a `<video>` with an audio-only MP3: 4 of 6 runs on this host without the series too; the stalled element delays the load event, and before, only a garbage collection that freed it let the load event fire (upstream's intermittent tracker has 9 unexpected results for that test in total). The three tests that fail on QuickJS CI pass with forced GCs every 20 ms too. With logging of the keep-alive updates, every element in direct checks stopped being kept alive once it had been loaded and never played, played to the end, paused, replayed after the end without a seekable range, or played backwards to the start. An independent agent review found no blockers; its two should-fix findings for this patch (ended but unpaused elements were kept alive; changes of the error went through no hook) are fixed. QuickJS release build of this stack: the new tests and the media tests that had QuickJS expectations (autoplay.html, allowed-to-play.html, resource-selection-candidate-moved.html and the three autoplay permissions policy tests) give SpiderMonkey's results in 2 of 2 runs; without the series they time out as the dropped expectations said. 2026-10-29 sync, reworked onto upstream's keep-alive: release builds of this sync's stack and of plain upstream ed6a924, `./mach test-wpt --release` of the media-elements, the-video-element and the-audio-element directories with fetch, xhr, eventsource, cors, subresource-integrity, resource-timing, canvas image drawing and _mozilla/memory (2,247 tests), then 3 reruns on both of every test whose results differed: the same results on both except for intermittent ones, gc-unreferenced-media-element and upstream's playing_media_no_gc pass; a playing element's back/forward cache restore fails on both (upstream servo#48979 pauses it at unload). DAYU200 (OpenHarmony 7.0), headless release builds with SpiderMonkey and with QuickJS, `./mach test-wpt --ohos --processes 1 --timeout-multiplier 2` of the media series' tests, loading-the-media-resource, error-codes and playing-the-media-resource (75 tests): all as expected but the two autoplay permissions policy tests that pass where a timeout is expected, on both engines; no crash.
AI-assisted: Yes (agent session; root-caused, written and tested by the agent)
AI-assisted: Yes (agent session; 2026-10-22 sync -- mechanical conflict resolution: the `HTMLMediaElement` import next to upstream's `TracedScriptResult` (servo#48855), and the patch's +8 bytes of `HTMLVideoElement` applied to upstream's new sizes (servo#48082))
AI-assisted: Yes (agent session; 2026-10-29 sync -- upstream servo#48979 and servo#49367 landed a keep-alive set of their own: the patch now extends upstream's `should_keep_alive` with its rules (load event delay, seeking, resource and HAVE_ENOUGH_DATA conditions) and keeps its setter hooks; its own set, flag and duplicate hooks are gone, as is its +8 bytes of `HTMLVideoElement`; subject and message rewritten)
AI-assisted: Yes (agent session; 2026-11-09 sync -- upstream's WPT sync (servo#49485) now expects what this patch made autoplay-disabled-by-permissions-policy.https.sub.html do (FAIL instead of TIMEOUT), so of this patch's hunk only the removal of the QuickJS conditions remains)
Signed-off-by: Jonathan Schwender <[email protected]>
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Nov 10, 2026
Every @font-face rule was fetched, sanitised and kept in memory as soon as
its stylesheet applied, even when no style used its family or its
unicode-range covered no character on the page. CSS Fonts 4 requires user
agents to only download fonts that are used.

A new rule now only registers an unloaded face, matched by its descriptors.
Font matching asks for the face once it selects it for a character, and the
loads it asked for start after layout. `FontFace.load()` and
`FontFaceSet.load()` ask for faces the same way. Faces whose sources are all
`local()` are still loaded right away.

Because matching now decides which faces load, adding @font-face rules
dirties the document so that text is matched again, `document.fonts.ready`
flushes layout, and a reflow that starts loads makes it pending again.

The font store now holds templates for faces whose data has not been
downloaded. `FontGroupFamilyTemplate::font_if_matches` skips them, but
`FontContext::matching_templates` and `FontContext::font` are also used
directly by the SVG font resolver, which would hit the "Should never create
a web font without data" panic in `PlatformFont::new_from_template` for any
SVG `<text>` using a web font. `FontContext::font` returns `None` for a web
font template without data, without caching the failure, so the face can be
used once it has loaded. The SVG font resolver asks for the face to be
loaded, like layout does when it matches one, and falls back to the next
family in the meantime.

An element whose font-family names a web font but that has no text never
picks the font for a character, but its first available font is needed
too, for instance for `line-height: normal` and font-relative lengths, and
Chrome and Firefox load it. After an element is restyled, layout asks for
the first available font of its style to be loaded if it is a web font that
has not been fetched. Only elements whose font differs from their parent's
are looked at, nothing is done while the document has no web fonts, and the
lookup runs once per font group. It does not create fonts, so system fonts
are not loaded for elements that never draw text.

Testing: A new WPT test checks that unused faces stay "unloaded". A canvas
test that expected a font not used by the page to be loaded now fails, as it
does in Chrome, Firefox and Safari. svg/painting/svg-with-outline.html,
css/css-transforms/transform-box/view-box-mutation-002.html and
resize-observer/svg.html keep their expected results instead of crashing,
and content-security-policy/font-src/font-stylesheet-font-blocked.sub.html
(a body without text) and preload/preload-resource-match.https.html (an
empty paragraph) still see the font fetched.

Fork note: second of four patches, meant for upstream. The upstream-based
version (branch lazy-webfonts) does not have the two fixes for SVG text and
for elements without text yet, which the servo-ohos PR 12 try run found.
Motivation: generated-UI pages that link Google Fonts CJK families declare
hundreds of unicode-range subsets (441 @font-face rules on the "keai"
concert-article test page), and Servo downloaded all of them (437 files,
10.5 MiB) where ArkWeb downloads 64.

Relies on: the previous patch (the load state on `FontFaceRuleInfo`, which is
how matching tells unloaded faces apart and how `FontFace.status` shows it);
upstream a8d5fda (servo#47564, its `FontFaceSet.load` font query is what makes
`document.fonts.load()` ask for faces); matching going through
`FontGroupFamilyTemplate::font_if_matches` and `char_in_unicode_range`
(components/shared/fonts/font_template.rs); `LayoutThread::reflow` returning a
`ReflowResult` and `can_skip_reflow_request_entirely` gating it; and the
readiness checks in `Document::maybe_fulfill_font_ready_promise` and
`Window::maybe_resolve_pending_screenshot_readiness_requests` reading
`FontContext::web_fonts_still_loading`.

Drop when upstream loads @font-face rules lazily: the test this patch adds,
css/css-font-loading/fontface-unused-stays-unloaded.html, passes on plain
upstream.

Two of upstream's MathML reftests, mo-lspace-rspace-dynamic and
operator-dictionary-empty-and-three-chars, pass on plain upstream and
fail with this patch. Their screenshots differ from the references only
in the red square that
`ensure_for_match_reftest("has_operator_spacing")` of
mathml/support/feature-detection.js adds when it measures no operator
spacing, which Servo doesn't implement. Why the check passes on plain
upstream wasn't traced; since servo#49485, upstream expects
operator-dictionary-empty-and-three-chars to fail as well.

Validation: `./mach test-wpt --release --processes 1 css/css-font-loading css/css-fonts html/canvas/element/text html/canvas/offscreen/text` (948 tests): the new fontface-unused-stays-unloaded passes; 2d.text.draw.fontface.notinpage now fails as in Chrome/Firefox/Safari; six "(drawing text in a canvas)" subtests of generic-family-keywords-003 failed with this patch on base/2026-08-29 (Chrome and Firefox pass them) and pass again since base/2026-10-08, so their expectations were dropped; the two @font-face layer-override subtests of css/css-cascade/layer-font-face-override (FAIL on plain upstream) pass with this patch, so their expectations were dropped too; matching/font-unicode-PUA subtests are intermittent (test race, both results seen); the only other unexpected result, font-variant-emoji-1 FAIL, also happens on plain ohos-main. `./mach test-wpt --release svg resize-observer css/css-transforms/transform-box` (1355 tests): all as expected (svg-with-outline, view-box-mutation-002 and resize-observer/svg crash without the SVG font resolver change). `./mach test-wpt --release css/css-fonts css/css-font-loading css/css-flexbox css/css-grid css/cssom-view css/css-inline css/css-text html/canvas/element/text html/canvas/offscreen/text content-security-policy/font-src preload svg` (8650 tests): no new unexpected results besides font-variant-emoji-1 and the known intermittent grid-self-alignment-fit-content-001; font-stylesheet-font-blocked.sub.html and preload-resource-match.https.html pass, and fail without the first-available-font change. Host release build, keai page served locally over HTTP/1.1 keep-alive (3 runs each): font files fetched 437 -> 66, RSS 525.3 -> 471.6 MiB, heap 340.1 -> 286.4 MiB, `--exit -o` screenshot byte-identical to ohos-main. The servo-webfont-eager-download reproducer (6 @font-face rules, 1 needed) fetches 1 font instead of 6. On a HarmonyOS phone, production build with `--features tracing-hitrace`, the keai page served from the host through `hdc rport`, measured with this patch and the next two applied (they change invalidation, not which fonts load): 437 -> 66 font files per load in each of 5 `servoperf page` loads, and PSS 30 s after launch 507.6 -> 467.9 MB (-7.8%, 4 interleaved loads each, every pair 35-49 MB apart). 2026-11-09 sync: `./mach test-wpt --processes 8 --timeout-multiplier 2 mathml` with release builds (2026-10-29): both reftests pass with the stack up to the previous patch and fail from this one on, with SpiderMonkey and QuickJS. Release builds of this sync's stack: font-face-unicode-range-no-match-no-download.html passes in the full QuickJS run and three runs with each engine, and fails on plain 0.8.0; the table-cell subtest of first-baseline-block-in-inline-001.html passes on plain 0.8.0, passes 3 of 3 times with the stack up to the previous patch and fails 3 of 3 times with this one, and passes 3 of 3 times when it measures after the load event.
AI-assisted: Yes (agent session; designed with the maintainer, written and tested by the agent, ported from upstream main to ohos-main's Rc<Promise> API)
AI-assisted: Yes (agent session; root-caused from the servo-ohos PR 12 try run and written by the agent)
AI-assisted: Yes (agent session; 2026-10-08 sync -- conflict resolution for upstream's RootedPromise and `icu_locale_core` changes, resolved to the code of the upstream-bound lazy-webfonts branch; MANIFEST.json entry re-inserted; dropped the generic-family-keywords-003 and layer-font-face-override FAIL expectations that now pass)
AI-assisted: Yes (agent session; 2026-10-09 restack -- folded in "fonts: Do not create fonts for web font faces that are not loaded yet" and "fonts: Load the first available web font of elements without text", which fixed regressions of this patch; the upstream FontFaceSet.load change replaces the dropped backport placeholder in "Relies on")
AI-assisted: Yes (agent session; 2026-11-09 sync -- folded in "fixup! fonts: Only load @font-face fonts that the page uses" (bisected and written by the agent between syncs): the expectations of two MathML reftests that fail with this patch, of which upstream's WPT sync (servo#49485) now has the same for operator-dictionary-empty-and-three-chars; upstream's WPT sync (servo#49485) added font-face-unicode-range-no-match-no-download.html with a FAIL expectation, and it passes with this patch, so the expectation goes; the same sync added first-baseline-block-in-inline-001.html, whose table-cell subtest passes on plain 0.8.0 and fails with this patch (bisected): the test measures while parsing, before Ahem, which this patch only fetches on use, has loaded; upstream's test fix servo#49502 (bisected) makes it wait, backported at the end of the stack)
Signed-off-by: Jonathan Schwender <[email protected]>
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Nov 10, 2026
Upstream servo#48979 keeps a media element alive through its owner document
while it plays or is eligible for autoplay, and servo#49367 lets it go after
it has ended. An element that delays the load event or seeks is still
collected at the next garbage collection once script drops it, which
stops it and lets the load event fire early, and the keep-alive is only
updated at a few points of the media element's algorithms.

Like Gecko, and Blink apart from autoplay, also keep a media element
alive while it delays the load event and, with a resource and no error,
while it seeks. Don't keep an element without a resource alive, and
keep one that is eligible for autoplay only until it has enough data:
then it either plays or never will. Update the keep-alive whenever the
network state, paused, seeking, the can autoplay flag, the error, the
ready state or the delaying-the-load-event flag changes.

Fork note: meant for upstream; found with the QuickJS backend, which
frees such elements as soon as script drops them, but SpiderMonkey loses
them too once a GC runs. Until the 2026-10-29 sync this patch had its
own keep-alive set; it now extends upstream's. Besides the upstream
change, this drops the QuickJS conditions in the expectations of
autoplay-disabled-by-permissions-policy; patch 49 dropped the others.
Drop once upstream has it.

Testing: Adds a WPT test that unreferenced media elements keep playing
across a garbage collection.

Validation: Release builds of upstream f040186 with SpiderMonkey, with and without the series, `./mach test-wpt --processes 4` of html/semantics/embedded-content/media-elements, the-video-element, the-audio-element, infrastructure/assumptions/allowed-to-play.html, webaudio/the-audio-api/the-mediaelementaudiosourcenode-interface and 2 _mozilla media tests: the new test passes 7 of 7 (harness timeout without), autoplay-disabled-by-permissions-policy and played-loop as in the updated expectations (autoplay-disabled timed out intermittently before, upstream issues servo#46012 and servo#46804); the remaining differences are track timeouts and track-cues-sorted-before-dispatch failures that both builds show intermittently, and one seek-to-max-value failure in 7 runs with the series (`currentTime` 0 right after setting it), not reproduced in 6 reruns, apart from load-removes-queued-error-event, which now hangs whenever GStreamer 1.24.2's playbin3 stalls on a `<video>` with an audio-only MP3: 4 of 6 runs on this host without the series too; the stalled element delays the load event, and before, only a garbage collection that freed it let the load event fire (upstream's intermittent tracker has 9 unexpected results for that test in total). The three tests that fail on QuickJS CI pass with forced GCs every 20 ms too. With logging of the keep-alive updates, every element in direct checks stopped being kept alive once it had been loaded and never played, played to the end, paused, replayed after the end without a seekable range, or played backwards to the start. An independent agent review found no blockers; its two should-fix findings for this patch (ended but unpaused elements were kept alive; changes of the error went through no hook) are fixed. QuickJS release build of this stack: the new tests and the media tests that had QuickJS expectations (autoplay.html, allowed-to-play.html, resource-selection-candidate-moved.html and the three autoplay permissions policy tests) give SpiderMonkey's results in 2 of 2 runs; without the series they time out as the dropped expectations said. 2026-10-29 sync, reworked onto upstream's keep-alive: release builds of this sync's stack and of plain upstream ed6a924, `./mach test-wpt --release` of the media-elements, the-video-element and the-audio-element directories with fetch, xhr, eventsource, cors, subresource-integrity, resource-timing, canvas image drawing and _mozilla/memory (2,247 tests), then 3 reruns on both of every test whose results differed: the same results on both except for intermittent ones, gc-unreferenced-media-element and upstream's playing_media_no_gc pass; a playing element's back/forward cache restore fails on both (upstream servo#48979 pauses it at unload). DAYU200 (OpenHarmony 7.0), headless release builds with SpiderMonkey and with QuickJS, `./mach test-wpt --ohos --processes 1 --timeout-multiplier 2` of the media series' tests, loading-the-media-resource, error-codes and playing-the-media-resource (75 tests): all as expected but the two autoplay permissions policy tests that pass where a timeout is expected, on both engines; no crash.
AI-assisted: Yes (agent session; root-caused, written and tested by the agent)
AI-assisted: Yes (agent session; 2026-10-22 sync -- mechanical conflict resolution: the `HTMLMediaElement` import next to upstream's `TracedScriptResult` (servo#48855), and the patch's +8 bytes of `HTMLVideoElement` applied to upstream's new sizes (servo#48082))
AI-assisted: Yes (agent session; 2026-10-29 sync -- upstream servo#48979 and servo#49367 landed a keep-alive set of their own: the patch now extends upstream's `should_keep_alive` with its rules (load event delay, seeking, resource and HAVE_ENOUGH_DATA conditions) and keeps its setter hooks; its own set, flag and duplicate hooks are gone, as is its +8 bytes of `HTMLVideoElement`; subject and message rewritten)
AI-assisted: Yes (agent session; 2026-11-09 sync -- upstream's WPT sync (servo#49485) now expects what this patch made autoplay-disabled-by-permissions-policy.https.sub.html do (FAIL instead of TIMEOUT), so of this patch's hunk only the removal of the QuickJS conditions remains)
Signed-off-by: Jonathan Schwender <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants