Commit graph

10979 commits

Author SHA1 Message Date
Tim van der Lippe
680a780552
Implement fetchLater (#39547)
Allows fetches to be deferred, only in a secure context. It does not yet
implement quota computation, since we don't have a concept of document
quota yet.

Also update the `fetch/api/idlharness` test to run in a secure context,
since this API is only available there.

Positive Mozilla position:
https://github.com/mozilla/standards-positions/issues/703
Positive WebKit position:
https://github.com/WebKit/standards-positions/issues/85

Closes whatwg/fetch#1858

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-10-02 07:51:19 +00:00
Ashwin Naren
65588cd5df
script: Stubs for geolocation interfaces (#39584)
Needed for #39526; stubs out all the necessary interface from
https://www.w3.org/TR/geolocation/.

Testing: WPT

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-10-02 04:17:36 +00:00
minghuaw
bcd8bbb142
fonts: Initial draft of synthetic bold face for FreeType (#39519)
This is an initial attempt at implementing synthetic bold face for font
families that lack actual bold faces. The overall approach borrowed
implementations from Chromium and FireFox. WPT expectations will be
updated after https://github.com/servo/stylo/pull/244 lands

Testing: There are existing WPT testcases for font synthesis
(`wpt/css/css-fonts/font-synthesis-*`)

Depends on: https://github.com/servo/stylo/pull/244

---------

Signed-off-by: Minghua Wu <michael.wu1107@gmail.com>
Signed-off-by: minghuaw <michael.wu1107@gmail.com>
2025-10-01 21:54:12 +00:00
atbrakhi
4ea363277e
script: Support keyCode, charCode in KeyboardEvent constructor (#39590)
Support `keyCode` and `charCode` fields in KeyboardEventInit for
Speedometer 3.0

Speedometer 3.0 fails because Servo's KeyboardEvent constructor ignores 
keyCode and charCode parameters, hardcoding them to 0. This breaks
frameworks
that check `event.keyCode === 13` for Enter key detection.  This is how
[Speedometer 3.0 dispatches key
events](8d67f28d02/resources/benchmark-runner.mjs (L166))
vs [Speedometer 2.0
triggerEnter](491acc2d64/resources/tests.mjs (L60)).

Speedometer 3.0 uses the modern KeyboardEvent constructor but passes 
[legacy fields like keyCode and
charCode](https://w3c.github.io/uievents/#legacy-dictionary-KeyboardEventInit)
in the init dictionary for backwards
compatibility with older frameworks(for example: backbone.js)

This change uncomments the legacy KeyboardEventInit fields and updates 
the constructor to read them from the init dictionary instead of 
hardcoding to 0.

Testing: No new tests added. 
Fixes: part of https://github.com/servo/servo/issues/16719

Servo running Speedometer3.0 successfully
<img width="1136" height="880" alt="speedometer 3 0"
src="https://github.com/user-attachments/assets/cf5199a5-d88d-4495-ae96-05fa6332b97e"
/>

---------

Signed-off-by: atbrakhi <atbrakhi@igalia.com>
2025-10-01 14:45:33 +00:00
Martin Robinson
e49fcdeffd
servodriver: Use the wpt-prefs.json file when running servoshell (#39605)
These preferences are necessary in order for tests to run properly in
servodriver.

Testing: This causes more tests to pass when WPT is run with `--product
servodriver`

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-10-01 13:25:07 +00:00
shuppy
cfa9e711c5
webdriver: Use take_screenshot() API in Take (Element) Screenshot (#39587)
WPT tests require us to reliably take screenshots when test pages are
fully loaded and testing is complete, and the WPT runner uses
[test-wait.js](a2f551eb2d/tests/wpt/tests/tools/wptrunner/wptrunner/executors/test-wait.js)
to do this in userland. when testing Servo with [--product
servo](a2f551eb2d/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorservo.py),
we use servoshell’s --output option, which backs that up with more
reliable waiting in Servo. but when testing Servo with [--product
servodriver](a2f551eb2d/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorservodriver.py),
we use the WebDriver Take Screenshot action, which currently takes the
screenshot immediately. we think this might be a source of regressions.

this patch makes the WebDriver actions Take Screenshot and Take Element
Screenshot use the same new WebView::take_screenshot() API as
servoshell’s --output option, such that those actions now wait for [a
variety of
conditions](a2f551eb2d/components/servo/webview.rs (L596-L602))
that may affect test output. it’s not clear if this is
[conformant](https://w3c.github.io/webdriver/#screen-capture), so we may
want to refine this to only wait when running tests at some point. other
changes:

- we remove the retry loop where we try to take a screenshot every
second for up to 30 seconds
- we send the result as a image::RgbaImage over crossbeam without shared
memory (it’s not cross-process)
- we now handle the zero-sized element case directly in the WebDriver
server

Testing: This should fix some flaky tests.
Fixes: #36715.
Fixes: (partially) #39180.
Fixes: (partially) #34683.

Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-10-01 12:37:00 +00:00
shuppy
cd80d2724d
Update expectations for --product servodriver (#39603)
this patch updates the expectations for tests that use testdriver.js,
which currently only work with `--product servodriver` (#34683), running
the tests with #39587.

expectations for all other tests, which don’t use testdriver.js, are
unaffected.

Testing: this patch updates test expectations, though the tests are not
yet run in CI

Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-10-01 10:43:11 +00:00
Simon Wülker
5510ea91b3
xpath: Remove XML QName validation (#39594)
*Most* of the properties that were verified here were already verified
by the xpath parser before. I have not found any evidence that other
browsers do the remaining checks. There are web platform tests that
expect contradicting behavior (which pass in other browsers).

Additionally, this change switches `xpath` to use `markup5ever` instead
of `html5ever` - this is a drop-in replacement. I thought I did this as
part of https://github.com/servo/servo/pull/39546 but apparently the
change got lost in the rebasing.


Testing: A new web platform test starts to pass.
Fixes https://github.com/servo/servo/issues/39442
Part of #34527

cc @minghuaw

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-10-01 07:41:56 +00:00
dependabot[bot]
4dfad0effd
build(deps): bump keyboard-types from 0.8.1 to 0.8.2 (#39599)
Bumps [keyboard-types](https://github.com/rust-windowing/keyboard-types)
from 0.8.1 to 0.8.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/rust-windowing/keyboard-types/releases">keyboard-types's
releases</a>.</em></p>
<blockquote>
<h2>v0.8.2</h2>
<h2>Added</h2>
<ul>
<li>Added convenience constructors <code>KeyboardEvent::key_down</code>
and <code>KeyboardEvent::key_up</code>: <a
href="https://redirect.github.com/rust-windowing/keyboard-types/issues/89">#89</a></li>
</ul>
<h2>Fixed</h2>
<ul>
<li>Fixed <code>NumpadEqual</code> and <code>Pause</code> code and
<code>Numpad</code> location for WebDriver: <a
href="https://redirect.github.com/rust-windowing/keyboard-types/issues/87">#87</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/rust-windowing/keyboard-types/compare/v0.8.1...v0.8.2">https://github.com/rust-windowing/keyboard-types/compare/v0.8.1...v0.8.2</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="1581323887"><code>1581323</code></a>
Release v0.8.2</li>
<li><a
href="3c6c17e9ee"><code>3c6c17e</code></a>
Add <code>KeyboardEvent::key_down</code> and
<code>KeyboardEvent::key_up</code> constructors.</li>
<li><a
href="4ef7eb287f"><code>4ef7eb2</code></a>
Split <code>lib.rs</code> into multiple files</li>
<li><a
href="417aaf84ab"><code>417aaf8</code></a>
Fix NumpadEqual and Pause code and location</li>
<li><a
href="df9265a15a"><code>df9265a</code></a>
Update URLs</li>
<li>See full diff in <a
href="https://github.com/rust-windowing/keyboard-types/compare/v0.8.1...v0.8.2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=keyboard-types&package-manager=cargo&previous-version=0.8.1&new-version=0.8.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-10-01 05:07:23 +00:00
Martin Robinson
d0dd9d7e3a
servoshell: Do not override HiDPI ratio when taking screenshots (#39501)
This override is meant to force reftests to always run with a device
pixel ratio of 1.0. Reftests are always run in headless mode which uses
a device pixel ratio of 1.0 regardless (unless you override it).
Removing this particular override allows taking screenshots in the
system DPI when taking them in headed mode, which is actually a bit
useful.

Testing: A test verifying the old behavior is removed. This causes 
`/css/pixel_snapping_position_a.html` to start passing.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-09-30 17:44:14 +00:00
Oriol Brufau
f724651e1a
layout: Let min/max constraints avoid collapsing bottom margins (#36322)
When `block-size` was intrinsic and there was no block-end padding or
margin, we were allowing the block-end margin of the box to collapse
with the block-end margin of its contents.

However, due to `min-block-size` or `max-block-size`, the final size can
be different than the intrinsic size of the contents. In that case it
didn't make any sense to collapse end margins, only WebKit does it too.

This patch takes the final size into account, like Gecko and Blink. This
is under discussion in https://github.com/w3c/csswg-drafts/issues/12218,
but for now we will match Blink.

Testing: 2 tests are now passing. There is also 1 new failure, but that
test only passes in WebKit and I don't agree with it.

Fixes: #36321

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-09-30 16:12:31 +00:00
Oriol Brufau
0c22f784bb
layout: Avoid negative corner radii values for border-radius (#39571)
The `border-radius` property provides the radii for the border box. For
the curvature of the padding and content boxes, we then subtract the
border and padding sizes. However, we weren't flooring the result by
zero, which could make the background completely disappear when using
`background-clip: padding-box` or `background-clip: content-box`.

Testing: Adding 4 new tests, but 2 of them fail in both Servo and
Firefox.
Fixes: #39540

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-09-30 10:37:44 +00:00
Rocketjumper
91e4188a64
script: Add line number argument to module script compilation functions (#39544)
Script: added ```line_no``` as argument to both
```fetch_inline_module_script()``` & ```compile_module_script()``` to
fix the inline script reporting wrong line issue
([#39415](https://github.com/servo/servo/issues/39415)).

Originally, the function ```compile_module_script()``` hardwires the
value 1 when invoking ```CompileOptionsWrapper::new()```. This is fine
if the script is written in separate JS file, but for inline scripts, it
will cause confusion if the ```<script>``` tag doesn't start from line
#1.

```line_no``` is obtained from ```line_number```, a member variable from ```HTMLScriptElement```. 

Credits to @jdm for actually pointing out which functions to fix.

Testing: Created a WPT test for this change, specifically: ```tests/wpt/tests/html/semantics/scripting-1/the-script-element/module/evaluation-error-5.html```.

Fixes: issue [#39415](https://github.com/servo/servo/issues/39415)

---------

Signed-off-by: RichardTjokroutomo <richard.tjokro2@gmail.com>
Signed-off-by: Rocketjumper <112361665+RichardTjokroutomo@users.noreply.github.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-09-30 05:42:32 +00:00
Kingsley Yung
34979c8b71
script: Return cached object from CryptoKey.usages getter (#39564)
Create and store a cached object in `CryptoKey` for the `[[usages]]`
internal slot when the key is created or when its `[[usages]]` internal
slot is updated. The getter can then return the cached object as
specified in https://w3c.github.io/webcrypto/#dom-cryptokey-usages,
instead of creating a new object on each call.

Testing: Pass WPT tests that were expected to fail.

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-09-30 03:56:12 +00:00
Rodion Borovyk
5b1fe60277
script: Empty pending mutation observers when notifying mutation observers (#39456)
Empty the surrounding agent’s pending mutation observers when notifying
mutation observers according to the spec. Also, the code in the method
MutationObserver::queue_a_mutation_record and the corresponding
specification have diverged over the years. These changes bring the code
into conformity with the specification.

Testing: Added a new crash test
Fixes: #39434 #39531

---------

Signed-off-by: Rodion Borovyk <rodion.borovyk@gmail.com>
2025-09-29 14:15:07 +00:00
webbeef
47382e0c2c
script: display top-level SVG image documents. (#39494)
SVG images served with the image/svg+xml mime type were recognized as
XML documents instead of images, so were not displayed.

Testing: compare the results of `./mach run
https://raw.githubusercontent.com/servo/servo/467821598b59bd84273d91c9d8a33651e10578b8/resources/resource_protocol/servo-color-negative-no-container.svg`

Signed-off-by: webbeef <me@webbeef.org>
2025-09-29 09:16:22 +00:00
Gae24
7a7129edd7
script: when fetching a worker script abort if response status is not ok (#39468)
According to
[spec](https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-classic-worker-script)
we should abort if the response status is not ok.

Testing: Check tests listed inside issue are not intermittent anymore
Fixes: #39413
Fixes: #22991

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2025-09-29 09:08:12 +00:00
Andrei Volykhin
af74db4e92
html: Count <image> attributes state changes as the relevant mutations (#39483)
Follow the HTML specification and take into account that state changes
of the <image> 'crossorigin' and 'referrerpolicy' content attributes
(not 'crossOrigin' and 'referrerPolicy' IDL attributes) should be
counted as relevant mutations.

See https://html.spec.whatwg.org/multipage/#relevant-mutations

Testing: Improvements in the following tests
- html/dom/reflection-embedded.html
-
html/semantics/embedded-content/the-img-element/relevant-mutations.html

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-09-29 09:00:51 +00:00
Tim van der Lippe
ba5f36b671
script: Implement parsing of Link HTTP headers (#39052)
The Link HTTP header can do the same as link elements,
in that they can preload/prefetch/etc... This implements
the basics of header parsing and hooks it up for preload.

Note that we use a new nom-rfc8288 crate that implements
the parsing behavior. However, that crate is too strict
in that empty attributes (;; as part of the header) are
discarded and resulting in a parsing failure. Therefore,
we use its lenient parsing mode.

Part of #35035

---------

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
2025-09-28 07:22:09 +00:00
Servo WPT Sync
660f90f687
Sync WPT with upstream (28-09-2025) (#39541)
Automated downstream sync of changes from upstream as of 28-09-2025
[no-wpt-sync]

Signed-off-by: WPT Sync Bot <ghbot+wpt-sync@servo.org>
2025-09-28 01:59:05 +00:00
Martin Robinson
55d094a871
script: Make stylesheets loaded via <link> elements block the rendering (#39536)
Stylesheets loaded via the `<link>` element should block the rendering
of the page according to the HTML specification [1]. This change makes
it so that they do this and, in addition, we do not take reftest
screenshots until all no element is blocking the rendering.

This change does not add support for the `blocking` attribute of
`<link>`, but that can be added in a follow change. In addition to
fixing a few tests, this change likely makes other tests no longer
intermittent. We will need to watch CI runs after this lands in order to
verify that though.

Testing: This change fixes at least two WPT tests.
Fixes: #26424.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-09-27 13:32:26 +00:00
Euclid Ye
6aa82309c3
webdriver: Wait animation frame callbacks before taking (element) screenshot (#39539)
According to spec, we should wait animation frame callbacks before
taking (element) screenshot. As "element screenshot" would automatically
scroll into view, this solves intermittency.

Testing: Manually tested on pages, and
`take_element_screenshot/scroll_into_view.py` passes stably now.
Fixes: #39306

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-09-27 13:29:44 +00:00
Josh Matthews
3f68bdacfe
Revert "Add abort signal preference to experimental web features" (#39538)
Reverts servo/servo#39421 . There are too many new intermittent
failures.

Fixes: https://github.com/servo/servo/issues/39516 
Fixes: https://github.com/servo/servo/issues/39521 
Fixes: https://github.com/servo/servo/issues/39522 
Fixes: https://github.com/servo/servo/issues/39523 
Fixes: https://github.com/servo/servo/issues/39524 
Fixes: https://github.com/servo/servo/issues/39527 
Fixes: https://github.com/servo/servo/issues/39532 
Fixes: https://github.com/servo/servo/issues/39512 
Fixes: https://github.com/servo/servo/issues/39503
2025-09-27 12:42:15 +00:00
Tim van der Lippe
4c25039d35
Fully implement request constructor body handling (#39514)
This aligns the implementation with the spec, where both input body and
init body are now set. In doing so, it fixes a fetch abort test, since
the stream was missing for the input body.

It also introduces the `unusable` method, as that's the one the spec
uses. The other two getters no longer exist in the spec.

Fixes #39448

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-09-27 01:52:01 +00:00
batu_hoang
043425cae5
Establish baselines for testdriver.js infrastructure tests (#39496)
Update testdriver infrastructure test expectation.
For now, most failures of testdriver tests are caused by missing
implementation or issue in Servo.

Signed-off-by: batu_hoang <hoang.binh.trong@huawei.com>
2025-09-27 01:51:18 +00:00
Oriol Brufau
89293995f0
script: Chain up scrollIntoView() scrolling to parent <iframe>s (#39475)
Calling `scrollIntoView()` on an element within an `<iframe>` will now
scroll scrolling boxes from the parent document(s), as long as they have
the same origin.

Testing: One existing subtest passes, and adding a new test.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-09-26 22:12:37 +00:00
Tim van der Lippe
b38bf3e606
Avoid crash when non-trusted-script object is passed into Function constructor (#39451)
It is possible to pass in objects that are not trusted scripts into the
Function constructor. Rather than crashing, we now treat these as
untrusted. `can_compile_string_with_trusted_type` doesn't need to know
the contents of a string, as it always marks it as untrusted.

We can make the same optimization in the string case, where we no longer
need to convert the string.

Testing: This change adds a WPT crash test.
Fixes #39436

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-09-26 18:33:56 +00:00
Tim van der Lippe
461c2427f3
Add abort signal preference to experimental web features (#39421)
This way we have full coverage on WPT rather than the
specific folders with tests.

Part of #34866

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-09-26 14:41:53 +00:00
Oriol Brufau
38a63a7977
stylo: Add support for -webkit-fill-available sizing keyword (#39492)
This keyword is de-facto required for web compatibility, Firefox is also
enabling it (https://bugzil.la/1988938).

This patch just aliases it to `stretch`.

Stylo PR: https://github.com/servo/stylo/pull/243

Testing: Various tests pass

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-09-26 10:45:56 +00:00
Oriol Brufau
858208bd25
layout: Align table-cell contents safely (#39491)
As resolved in https://github.com/w3c/csswg-drafts/issues/12220, when
resolving `align-content: normal` on a table cell, we will now use safe
alignment.

The difference only matters when the contents of the cell are taller
than the cell, which doesn't typically happen. But in Servo it's
observable when there are collapsed rows.

Testing: Adding new tests. Some fail because we don't support
`align-content` yet.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-09-26 07:44:23 +00:00
Oriol Brufau
7a3a28c7f1
layout: Correctly handle margins in sticky positioning (#39393)
This fixes the logic that computes sticky offset bounds in order to
correctly take margins into account.

Testing: One test passes
Fixes: #39389

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-09-25 16:27:10 +00:00
Martin Robinson
ffdb7d3663
script: Chain up keyboard scrolling to parent <iframe>s (#39469)
When an `<iframe>` cannot scroll because the size of the frame is
greater than or
equal to the size of page contents, chain up the keyboard scroll
operation to the parent frame.

Testing: A new Servo-only WPT tests is added, though needs to be
manually
run with `--product servodriver`.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Delan Azabani <dazabani@igalia.com>
2025-09-25 11:16:41 +00:00
Gae24
75e32ba5a4
script: implement ClipboardItem getType and supports (#39296)
Implement ClipboardItem's getType and supports

Testing: covered by existing tests

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2025-09-25 08:05:01 +00:00
Oriol Brufau
454d6052b4
layout: Avoid fixed table layout when inline-size is max-content (#39474)
This undoes #35882 according to the last CSSWG resolution, since this is
required by web compat.

Testing: Modifying the relevant test

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-09-24 18:21:04 +00:00
Simon Wülker
2ccaf86ff6
Invalidate iterator over elements of a XPathResult when the document changes (#39411)
Also includes a fix to not throw a type error in
`XPathResult.invalidIteratorState`.

Testing: Includes a new web platform test
Part of https://github.com/servo/servo/issues/34527

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-24 16:39:38 +00:00
Kingsley Yung
9d7b438d6b
script: Enable crypto task source at task manager (#39453)
The Web Cryptography API has the "crypto task source"
(https://w3c.github.io/webcrypto/#dfn-crypto-task-source-0) to queue
tasks to resolve or reject promises created in response to calls to
methods of `SubtleCrypto`.

This patch enables this task source at the script task manager, and
queue tasks on this task source from existing steps.

A few WPT error expectations are also added to WPT meta. The related
cryptographic algorithms have not yet implemented, so the errors are
expected. I don't know why WPT test did not capture them before.

Testing: Existing tests suffice.

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-09-24 16:21:03 +00:00
Andrei Volykhin
f91dc33350
html: Add the reflected 'sizes' IDL attribute for <image> (#39466)
Add the reflected 'sizes' IDL attribute for <image> element's DOM
interface which defines image sizes for different page layouts.

See https://html.spec.whatwg.org/multipage/#dom-img-sizes

Testing: Improvements in the following tests
- custom-elements/reactions/customized-builtins/HTMLImageElement.html
- html/dom/idlharness.https.html
-
html/semantics/embedded-content/the-img-element/relevant-mutations.html

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-09-24 09:29:44 +00:00
Simon Wülker
72555de341
Never disconnect shadow roots from their hosts (#39459)
Regular shadow roots can never be detached once they are created.
However we were specifically detaching shadow roots from media elements
when they were disconnected. This is actually one of the very few
aspects of shadow roots that predate the implementation work I did
earlier this year.

I'm not sure why we ever did this. Maybe its for efficiency reasons,
because keeping the shadow tree around is not necessary when the media
element is not connected. But I can't imagine this yields any benefits,
especially since you would have to reconstruct the shadow tree when the
media element is re-connected (as is the case in the crash we observe).

For simplicities sake, I have completely removed this functionality.
Doing so ends up simplifying the code quite a bit.

Testing: This change adds a new crashtest
Fixes https://github.com/servo/servo/issues/36722

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-24 08:04:56 +00:00
Simon Wülker
206dcff080
Assert that style element has an owner in parse_own_css (#39458)
The existing `assert!(node.is_connected())` is wrong. What it *wants* to
assert is that the style element has an owner, which is either a
Document or a ShadowRoot that the element is a descendant of. However,
if the element is descendant of a ShadowRoot which is itself not
connected to a document then the assertion would fail.

Instead, we use `node.is_in_a_document_tree() ||
node.is_in_a_shadow_tree()`, which more accurately reflects the intent.

Testing: This change adds the test case from
https://github.com/servo/servo/issues/37781 as a crashtest
Fixes https://github.com/servo/servo/issues/39457
Fixes https://github.com/servo/servo/issues/37781

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-23 23:00:11 +00:00
shuppy
ac8895c3ae
script: Move keyboard scrolling to script (#39371)
Instead of having every single embedder implement keyboard scrolling,
handle it in script in the default key event handler. This allows
properly targeting the scroll events to their scroll containers as well
as appropriately sizing "page up" and "page down" scroll deltas.

This change means that when you use the keyboard to scroll, the focused
or most recently clicked `<iframe>` or overflow scroll container is
scrolled, rather than the main frame.

In addition, when a particular scroll frame is larger than its content
in the axis of the scroll, the scrolling operation is chained to
the parent (as in other browsers). One exception is for `<iframe>`s,
which will be implemented in a followup change.

Testing: automated tests runnable locally with `mach test-wpt --product
servodriver`

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-09-23 20:35:08 +00:00
Andrei Volykhin
99fbd36b5d
html: Properly count <image>/<source> insertion/removal steps as the relevant mutations (#39452)
Follow the HTML specification and take into account that the HTML
`<image>/<source>` element inserting/removal steps should only be
counted as relevant mutations for `<image>` element if the parent of the
inclusive ancestor that was inserted/removed is the parent `<picture>`
element.

See <https://html.spec.whatwg.org/multipage/#relevant-mutations>.

Testing: Improvements in the following tests
-
html/semantics/embedded-content/the-img-element/relevant-mutations.html

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-09-23 12:40:03 +00:00
Martin Robinson
c63311af02
script: Remove absolute positioning workaround from scrollIntoView implementation (#39441)
This isn't needed as the border box query already takes into account the
containing block chain. Instead, consistently calculate the new
scroll position for a scroller relative to its current scroll offset.

In addition, fix a small bug where the border of a scroll container was
considered part of scrollport.

Testing: A new WPT test is added.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-09-23 10:10:00 +00:00
Oriol Brufau
16d2e030eb
layout: Clamp sticky positioning offset bounds by zero (#39443)
Sticky positioning tries to keep an element visible within the nearest
scrollport. However, the element can't be offset to go beyond its
containing block. We implement this as offset bounds.

The problem was that, if the element would already be overflowing its
containing block before applying the sticky positioning, then we were
forcing it to move inside the containing block. That was wrong, and is
solved by flooring or ceiling the offset bounds by zero.

Testing: Adding new tests

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-09-23 07:22:10 +00:00
Tim van der Lippe
02aab33987
Add AbortSignal support for event listeners (#39406)
Also fixes several issues with code generation when a dom type is part
of a dictionary.

Part of #34866
Fixes #39398

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-09-21 18:57:10 +00:00
Tim van der Lippe
7abc813fc3
Abort fetch controller when signal is aborted (#39374)
Does not all tests pass because of a mismatch in microtask timing. The
promises are resolved/rejected in the wrong order.

Part of #34866

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-09-21 12:33:03 +00:00
Servo WPT Sync
016524bd3c
Sync WPT with upstream (21-09-2025) (#39414)
Automated downstream sync of changes from upstream as of 21-09-2025
[no-wpt-sync]

---------

Signed-off-by: WPT Sync Bot <ghbot+wpt-sync@servo.org>
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Co-authored-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-09-21 05:47:33 +00:00
Simon Wülker
2c8533f38e
Parse qualified names with non-alpha characters in xpath (#39409)
The existing parsing rules are too strict and only allow alpha and
alphanumeric characters. Instead, we should follow the production
defined in https://www.w3.org/TR/REC-xml-names/#NT-NCName.

Testing: New tests start to pass
Part of https://github.com/servo/servo/issues/34527

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-21 03:45:04 +00:00
Simon Wülker
bbceb0faa4
Allow whitespace around path expressions in xpath (#39410)
Previously servo would allow whitespace in between components of an
xpath expression, but not around it.

Testing: New web platform tests start to pass 
Part of https://github.com/servo/servo/issues/34527

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-20 22:38:24 +00:00
Simon Wülker
bdf630563c
script: Don't try to evaluate xpath variable references (#39395)
Variables in xpath via the javascript bindings are a bit mysterious, as
there is no way that a variable can be specified. We currently panic
when encountering a variable, which is not good. Instead we now throw an
error.

We keep parsing the variables because the code is already there and it
seems realistic that their behaviour will be specified in the future.
I'm fine with removing them too if that is preferred.

Testing: This behaviour is unspecified and different browser produce
different results. There is no "correct" way to do this, but we should
not crash
Part of: https://github.com/servo/servo/issues/34527

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-20 12:36:54 +00:00
Ashwin Naren
8c45428760
Enable credential management wpt tests (#39327)
Enabling them early to prevent intermittent failures.


Fixes: Partially #38788

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-09-20 07:24:32 +00:00