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>
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>
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>
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>
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>
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>
*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>
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 />
[](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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Also fixes several issues with code generation when a dom type is part
of a dictionary.
Part of #34866Fixes#39398
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
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>
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>
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>
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>