Commit graph

8272 commits

Author SHA1 Message Date
Kenzie Raditya Tirtarahardja
d33ae1549d
script(webdriver): Fix element clear for file (#38536)
When clearing input file with WebDriver, we should set input's filelist
with empty list instead of setting it with None.

Testing:
`./tests/wpt/tests/webdriver/tests/classic/element_send_keys/file_upload.py`

Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
2025-08-08 18:38:35 +00:00
Oriol Brufau
93c9fc14f1
layout: Let stretch on flex item cross size stretch to the line (#38526)
We were instead stretching to the containing block, which implied that
the behaviors of a `stretch` size and `stretch` alignment weren't
consistent.

As resolved by the CSSWG, the behavior will now be:
 - If the cross size of the line is known, stretch to the line.
 - Otherwise, stretch to the containing block.

See https://github.com/w3c/csswg-drafts/issues/11784

This aligns us with Blink, which has already shipped this new behavior.

Testing: Improves existing WPT and adds a new test.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-08-08 15:45:30 +00:00
Martin Robinson
4257db643b
Revert "Include the scrollable overflow of a child box if either its parent or child has overflow: visible (#38443)" (#38546)
This reverts commit dcb90bb85e.

This broke scrollable overflow calculation in the following case:

```
<div id="foo" style="width: 200px; height: 200px; outline: solid; overflow: auto;">
    <div style="height: 5000px; background: pink;">hello</div>
</div>
```

In this case the overflow is propagating through the `overflow: auto`
`<div>` and into the parents. When dumping the flow tree I see the root
node being 5000 pixels tall. It's unclear why this change didn't break
any tests, so it's likely that we need to add a test for this case.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-08-08 13:37:14 +00:00
Oriol Brufau
87538282db
layout: Floor content-box size by zero when stretching flex item (#38521)
When stretching the cross size of a flex item to its flex line, we were
computing the stretch size by subtracting padding, border and margin
from the line size. However, this could result in a negative amount for
the content-box cross size. Therefore, this floors it by zero.

Testing: Adding new tests
Fixes: #38517

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-08-07 18:19:22 +00:00
Josh Matthews
842dd99698
Update to SpiderMonkey 137. (#37077)
Incorporates the updates from https://github.com/servo/mozjs/pull/584.

Testing: Existing WPT coverage is enough.
Fixes: Part of #36258

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-08-07 16:47:27 +00:00
Nico Burns
fd20a5df42
layout(grid): implement named grid lines and areas (#38306)
### Changes made

This implements named grid lines (line names in `grid-template-*`),
named grid areas (`grid-template-areas`), and the ability to target
those using `grid-{row,column}-{start,end}`. It also includes a bunch of
miscelaneous fixes for `repeat(auto-fill | auto-fit, ...)` syntax as
that interacts with the specification of line names.

The actual layout implementation is in Taffy. The bulk of this PR is
updating Servo to translate (CSS Grid-related) Stylo types into Taffy
types using a new iterator-based API which uses iterators and lazy
translation for efficiency (which is more important now that we're
dealing with string data, even though they're `Atom`s).

### Testing

This functionality has lots of WPT tests. It fixes some seemingly random
CSS Grid tests that use named lines/areas even though that's not what
they're testing.

### Screenshots

wikipedia.org

<img width="1624" height="1056" alt="Screenshot 2025-07-27 at 20 03 16"
src="https://github.com/user-attachments/assets/2c50b96f-ae36-4405-ac48-b771bfdcb515"
/>

bbc.co.uk:

<img width="1624" height="1056" alt="Screenshot 2025-07-27 at 20 32 57"
src="https://github.com/user-attachments/assets/ba84e211-65d2-4411-95fb-7b9b91bea31c"
/>

theguardian.com:

<img width="1624" height="1056" alt="Screenshot 2025-07-27 at 20 33 29"
src="https://github.com/user-attachments/assets/e85daaa6-5fb0-45d4-b9ec-b22b38b087ec"
/>

---------

Signed-off-by: Nico Burns <nico@nicoburns.com>
2025-08-07 14:41:19 +00:00
Nico Burns
52ba8facc2
stylo: use simplified restyle damage macros (#38465)
Servo PR for https://github.com/servo/stylo/pull/222

Fixes: #38506
Testing: adding new tests

---------

Signed-off-by: Nico Burns <nico@nicoburns.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-08-07 10:41:22 +00:00
Euclid Ye
616b86fb6d
webdriver: Check if container is obscured for "Element Click" (#38497)
Implement step 7 of [Element
Click](https://w3c.github.io/webdriver/#element-click): check whether
container is obscured.

Testing: `/webdriver/tests/classic/element_click/interactability.py` can
now fully pass. Other changes are combined effect with
17a269a8ad due to script execution, and
exposes new problem:
https://github.com/servo/servo/pull/38497#discussion_r2257866612

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
2025-08-07 09:16:50 +00:00
sagudev
c0cc8484f8
canvas: pop many clips on restore (#38496)
When restoring context/state we need to pop all clips from current
state, before we just poped one (even if there was none).

Testing: Added new WPT tests

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-08-07 08:23:09 +00:00
Martin Robinson
44a11a7c6c
script/layout: Ensure a StackingContextTree before IntersectionObserver geometry queries (#38473)
IntersectionObserver needs to be able to query node geometry without
forcing a layout. A previous layout could have run without needing a
`StackingContextTree`. In that case the layout-less query should finish
building the `StackingContextTree` before doing the query.  Add a new
type of layout API which requests that layout finishes building the
StackingContextTree.

This change also slightly simplifies and corrects the naming of
`Element` APIs around client box queries.

Testing: This should fix intermittent failures in WPT tests.
Fixes: #38380.
Fixes: #38390.
Closes: #38400.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-08-06 13:46:43 +00:00
Euclid Ye
98522db8be
webdriver: Search ancestors instead of preceding nodes when computing container for option&optgroup (#38491)
Fix the bug from 6 years ago https://github.com/servo/servo/pull/24090.

According to [spec](https://w3c.github.io/webdriver/#dfn-container), we
should search ancestor instead of preceding nodes (which is reverse
order of pre-order DFS and can end up weird places) when computing
container for `option`&`optgroup`.


Testing: Update WPT.
Fixes: https://github.com/servo/servo/pull/36467#discussion_r2255834497.

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
2025-08-06 08:54:45 +00:00
Abdelrahman Hossam
17a269a8ad
script: Implement scrollIntoView (#38230)
This is an implementation for `scrollIntoView`. For now, it is called
when a certain element gains focus.

Testing: Existing WPT tests
Fixes: #24059

Signed-off-by: abdelrahman1234567 <abdelrahman.hossameldin.awadalla@huawei.com>
2025-08-06 08:08:25 +00:00
Shubham Gupta
dcb90bb85e
Include the scrollable overflow of a child box if either its parent or child has overflow: visible (#38443)
Include the scrollable overflow of a child box if either its parent or
child has `overflow: visible`

**Issue**: For the blocks having property `overflow:hidden`, their
scroll overflow is not added to parent's scroll overflow.
Causing unable to scroll the parent block aka `Root` block in our Issue
#38248 .

**Testing**: css/cssom-view/scrolling-quirks-vs-nonquirks.html
**Fixes**: #38248

Signed-off-by: Shubham Gupta <shubham13297@gmail.com>
2025-08-06 07:46:54 +00:00
Euclid Ye
62b181dc85
webdriver: Simplify get_element_pointer_interactable_paint_tree (#38469)
Add step 1 and simplify step 2 - 5 to remove duplicate `GetClientRects`
call.

There is some issue with spec to be updated later.

Testing: No behaviour change.

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
2025-08-06 05:36:34 +00:00
Martin Robinson
11844ca5af
layout: Add a layout hit test and use it for document.elementsFromPoint (#38463)
In #18933, hit testing was moved from layout to WebRender. This presents
some issues. For instance, the DOM can change at the same time that hit
test is happening. This can mean that hit test returns references to
defunct DOM nodes, introducing memory safety issues. Currently, Servo
will try to ensure that the epochs used for testing and those recorded
in the DOM match, but this is not very reliable and has led to code that
retries failed hit tests.

This change reintroduces (8 years later) a layout hit tester and turns
it on for `document.elementFromPoint` and `document.elementsFromPoint`.
The idea is that this hit tester will gradually replace the majority of
the WebRender hit testing happening in the renderer.

Testing: This shouldn't really change the behavior hit testing, but it
seems to improve one WPT test.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: kongbai1996 <1782765876@qq.com>
2025-08-05 09:48:21 +00:00
Oriol Brufau
b01bb462b6
layout: Recreate lazy block size when re-doing layout to avoid floats (#38366)
Block-level boxes that establish an independent formatting context need
to avoid overlapping floats. If their inline size stretches, then we may
need to lay out multiple times.

The problem was that when trying with a different inline size, the
intrinsic block size can change, but we were using the cached final
block size from the previous attempt.

Testing: Adding new test
Fixes: #38365

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-08-04 17:07:10 +00:00
Martin Robinson
9416251cab
script: Unify script-based "update the rendering" and throttle it to 60 FPS (#38431)
Instead of running "update the rendering" at every IPC message, only run
it when a timeout has occured in script. In addition, avoid updating the
rendering if a rendering update isn't necessary. This should greatly
reduce the amount of processing that has to happen in script.

Because we are running many fewer calls to "update the rendering" it is
reasonable now to ensure that these always work the same way. In
particular, we always run rAF and update the animation timeline when
updating the ernder

In addition, pull the following things out of reflow:

 - Code dealing with informing the Constellation that a Pipeline has
   become Idle when waiting for a screenshot.
 - Detecting when it is time to fulfill the `document.fonts.ready`
   promise.

The latter means that reflow can never cause a garbage collection,
making timing of reflows more consistent and simplifying many callsites
that need to do script queries.

Followup changes will seek to simplify the way that ScriptThread-driven
animation timeouts happen even simpler.

Testing: In general, this should not change testable behavior so much,
though it
does seem to fix one test.  The main improvement here should be that
the ScriptThread does less work.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-08-04 16:27:00 +00:00
Euclid Ye
c59ee57b5d
webdriver: Improve "element click" by using container + Upgrade outdated test (#38436)
- According to
[spec](https://w3c.github.io/webdriver/#ref-for-dfn-in-view-3), we
should use container instead of element itself to determine "in-view".
- Updated `test_element_intercepted_no_pointer_events` in
`element_click/interactability.py` to expect "element not interactable".
This was outdated with spec as original test was written 7 years ago
https://github.com/web-platform-tests/wpt/pull/11453.


Testing: new passing cases for `<option>`, `<select>`.

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
2025-08-04 08:12:50 +00:00
Leo Ring
79a45c7da3
Implement HTMLDocument API (#38433)
This updates the pull request from here
https://github.com/servo/servo/pull/32553 that looks to be dormant. The
main change is that I've switched out `reflector` with `document` based
off this suggestion
https://github.com/servo/servo/pull/32553#issuecomment-2179568743, and
the `GetLocation` and `SupportedPropertyNames` methods pass through the
values from `Document`.

The implementation details are otherwise the same as the original PR

Testing: I don't see any WPT tests for this feature, I could make a
custom test if desired
Fixes: https://github.com/servo/servo/issues/32536

---------

Signed-off-by: Leo Ring <leoring03@gmail.com>
2025-08-04 03:42:54 +00:00
sagudev
fe9341dd46
canvas: Use OptimizeSpeed in vello_cpu (#38437)
According to my tests `OptimizeSpeed` slight improves performance and it
does NOT affect WPT results in negative way.

Testing: Tested by existing WPT tests.

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-08-03 12:12:08 +00:00
Servo WPT Sync
fed1953198
Sync WPT with upstream (03-08-2025) (#38434)
Automated downstream sync of changes from upstream as of 03-08-2025
[no-wpt-sync]

Signed-off-by: WPT Sync Bot <ghbot+wpt-sync@servo.org>
2025-08-03 01:48:15 +00:00
Oriol Brufau
76e5758ab9
Upgrade Stylo to 2025-08-01 (#38429)
This continues #37822

Changelog:
- Upstream:
fe9eadf47b...ec21cec41c
- Servo fixups:
29052e550f...7f8df16fdd

Stylo tracking issue: https://github.com/servo/stylo/issues/220

---------

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-08-02 21:48:33 +00:00
Tim van der Lippe
dbb886fad2
Implement initial version of navigator.sendBeacon (#38301)
Gated behind the feature flag `dom_navigator_sendbeacon_enabled` as the
`keep-alive` fetch parameter is crucial for real-life use cases such as
analytics requests.

Part of #4577
Part of #38302

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-08-02 15:14:07 +00:00
Martin Robinson
181f97879d
wpt: Ensure that faulty JSON testharness output does not crash the Python test harness (#38420)
When a testharness test also prints debugging output, sometimes the
output can be mixed with the JSON output printed via an alert. This
causes a JSON decoding error in the output. Instead of crashing the
harness and printing many lines of Python stack trace output, print a
nice error. This makes the test output easier to read.

Testing: This is a change to the test harness itself, so no tests
necessary.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-08-02 13:04:17 +00:00
lumiscosity
5e89f79abe
layout: Fix negative outline offset (#38418)
Properly caps the minimum offset on each side as recommended by the
standards: https://drafts.csswg.org/css-ui-3/#outline-offset

Testing: Covered by WPT tests. (3 new passing!)
Fixes: #19508

---------

Signed-off-by: lumiscosity <averyrudelphe@gmail.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-08-01 20:43:04 +00:00
sagudev
413fd15264
canvas: prune vello scene on each render and make rendering cacheable (#38406)
As noted in #38345, vello scenes only grow. While we can reset them when
clearing viewport (#38356) that is not enough. We need to reset scene on
each render (~each frame) and providing old frame as backdrop to new
scene. Be do this lazily so multiple rendering without any changes
should be cheaper, we still do GPUBuffer mapping, because that would
require more complex work.

Testing: Code functionality is covered by existing WPT tests, but we do
not have any performance test.

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-08-01 13:48:44 +00:00
Kingsley Yung
5e8754bb1d
webdriver: consider boolean attribute when get element attribute (#38401)
The function handle_get_attribute should act differently when the
attribute is a boolean attribute.

The full list of attributes can be found in [1]. All attributes marked
as "Boolean attribute" in the "Value" column are boolean attributes.
Note that "hidden" is effectively treated as a boolean attribute,
according to WPT test "test_global_boolean_attributes" in
webdriver/tests/classic/get_element_attribute/get.py

[1] https://html.spec.whatwg.org/multipage/#attributes-3

Testing: Updated WPT test expectation
Fixes: #38353

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-08-01 08:44:26 +00:00
Jo Steven Novaryo
a063b5e78a
script: Fire scroll event whenever JS scrolled (#38321)
Implement JS scroll event firing compliant to
https://drafts.csswg.org/cssom-view/#scrolling-events. Basically
whenever, the an element or the viewport is scrolled, we will fire a
scroll event. The changes push a scroll event whenever an API causes a
scroll position to change.

Testing: New WPT tests for basic APIs.
Part of: https://github.com/servo/servo/issues/31665

---------

Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
2025-08-01 07:30:22 +00:00
Euclid Ye
372e5eae59
webdriver: Fix "element in view" by correctly computing resolved PointerEvents style (#38383)
Testing: `element_click/interactability.py`. For some other tests in
headed window, even tho the target is in view it falsely claim not in
view previously.

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
2025-08-01 07:08:28 +00:00
batu_hoang
929fd0aa3c
webdriver: improve session commands (#38397)
Add timeout and strictFileInteractability capabilities to response of
new session command.
Allow delete session command to run without a session.

Testing: Clear some unexpected results of session tests in webdriver CI
and
`tests/wpt/meta/webdriver/tests/classic/delete_session/delete.py.ini`

---------

Signed-off-by: batu_hoang <hoang.binh.trong@huawei.com>
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
2025-08-01 06:39:03 +00:00
sagudev
09f0e20e29
canvas: Clear vello scene if possible (#38356)
Vello scene only ever grows, so we need to clear it as soon as it's
possible (in clear rect). This PR also adds ignore_clips to
vello_backend (already exists in vello_cpu_backend).

Testing: Behavior is verified by existing tests, as this is mainly a
change for performance. There are currently no performance tests. This
makes bunnymark actually playable (from 3 FPS to 20 FPS on vello_cpu).

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-08-01 05:05:15 +00:00
Martin Robinson
5da55adfd3
layout: Account for sticky nodes in ScrollTree transforms and cache transforms (#38391)
When calculating the node to world transform for use in bounding box
queries, cache the values of the transform. In addition, when scroll
offsets change, ensure that the cached values are invalided properly.
This change necessitated the storage of children for each node in the
tree, so that we can walk both up and down the tree. The purpose of this
part of the change is to increase performance when doing multiple
queries and prepare the tree for hit testing.

In addition, this change also tries to take into account sticky offsets,
using the algorithm from WebRender to calculate sticky offsets. This is
also going to be important for hit testing.

Testing: Newly passing tests:
 - /css/css-position/position-sticky-dynamic-ancestor-001.html
 - /css/css-tables/tentative/position-sticky-container.html

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-07-31 13:36:32 +00:00
batu_hoang
8e27fd48cc
Implement webdriver element in view (#38329)
Implement step 6 of `ElementClick`:
https://w3c.github.io/webdriver/#dfn-element-click

Tests:
`tests/wpt/tests/webdriver/tests/classic/element_click/interactability.py`

cc: @xiaochengh

Signed-off-by: batu_hoang <hoang.binh.trong@huawei.com>
2025-07-31 04:27:02 +00:00
sagudev
5c42a113bd
chore: Update vello to fix radials in vello_cpu (#38338)
This update includes a fix for
https://github.com/linebender/vello/issues/1124.

Testing: Existing WPT tests
try run: https://github.com/sagudev/servo/actions/runs/16599834725

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-07-30 17:49:41 +00:00
lumiscosity
e5334a64c4
layout: respect image-rendering on border images (#38346)
Properly passes `image-rendering` down to border images.

Testing: Covered by WPT tests.

---------

Signed-off-by: lumiscosity <averyrudelphe@gmail.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-07-30 12:57:10 +00:00
Jo Steven Novaryo
900dd8d191
layout: Consider transform for bounding box queries (#37871)
The recent changes that cached the Scroll Tree present an opportunity to
calculate the queries that consider transform and scroll (dubbed as post
composite queries) accurately.

This PR propose a solution for this calculation by noting the lowest
scroll tree nodes that would affect a fragment. To do this, each
fragment would store a new attribute `spatial_tree_node` -- scroll tree
node id that we could use for the query. This referencing is considered
because the scroll tree node construction is managed by the fragment
itself. Therefore it would ease the managing the possibly stale
reference and future query cache invalidation considering the
development of incremental layout.

The bounding box query then could transform the bounding content rect of
a fragment using the computed current transformation matrix.

Fixes: https://github.com/servo/servo/issues/35768
Testing: Existing and new WPT

---------

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-07-30 08:13:54 +00:00
batu_hoang
37ac4ffeb4
Rework on webdriver wait for navigation complete (#38234)
For current implementation, when a command may trigger a navigation,
webdriver only waits for document readiness state.
However, not all navigations make change in document.
This PR handles more cases for waiting for a navigation, and apply to
`element_click`.

- Before sending a command which may trigger a navigation, `webdriver`
sets `load status send` to `embedder`, `constelltation` and `script
thread` to listen to `navigation events`.
- Webdriver check if there is a navigation with `script thread`.
- If the navigation is loading a new url, webdriver checks if the
request is approved with `constellation`, then waits for document
readiness state.
- If the navigation is a hashchange, webdriver waits untill all new
generated dom events have been processed.

Testing: 
`tests/wpt/tests/webdriver/tests/classic/element_click/navigate.py`
`tests/wpt/tests/webdriver/tests/classic/element_click/user_prompts.py`
https://github.com/longvatrong111/servo/actions/runs/16488690749

cc: @xiaochengh

---------

Signed-off-by: batu_hoang <hoang.binh.trong@huawei.com>
2025-07-30 07:24:07 +00:00
Euclid Ye
8b3e7b1c6a
webdriver: Keep constellation alive and Open new top-level browsing context with new session request when none is open (#37410)
Keep Constellation alive even when all browsing context closed in
WebDriver mode. In this case, when creating a new session, we would open
a new top-level browsing context.

Fixes: #37408
Testing: `./mach test-wpt -r
.\tests\wpt\tests\webdriver\tests\classic\close_window\close.py
--product servodriver`

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
2025-07-30 06:41:58 +00:00
Oriol Brufau
3d2f0d1be5
layout: Fix depends_on_block_constraints logic (#38318)
The logic was wrong, sometimes we weren't setting it to true on flex
containers that needed it, and then as a workaround we were setting it
to to true on flex items that didn't need it.

For example, this testcase had 5 cache misses when stretching the items,
now we will avoid laying them out again:
```html
<div style="display: flex">
  <div></div>  <div></div>  <div></div>  <div></div>  <div></div>
</div>
```

Also, the workaround wasn't always working, e.g. it failed to stretch
the green element here:
```html
<div style="display: flex; min-height: 200px">
  <div>
    <div style="display: flex; height: 100%; background-color: red">
      <div style="width: 200px; background-color: green;"></div>
    </div>
  </div>
</div>
```

Testing: Adding new test
Fixes: #38023

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-07-29 09:59:54 +00:00
Oriol Brufau
7ce5de4e2d
layout: Include spanned gutters when laying out contents of table cell (#38290)
If a cell would e.g. span 2 columns, each 50px wide, separated by a 10px
gutter, then we used to lay out the contents of the cell with a 100px
wide containing block. Now we will include the size of the gutter.

Testing: Adding new test
Fixes: #38277

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-07-29 08:57:22 +00:00
minghuaw
554b2da1ad
Script: Implement TextDecoderStream (#38112)
This PR implements the `TextDecoderStream`. Other than introducing the
necessary mod and webidl files corresponding to `TextDecoderStream`,
this PR also involves some changes in `TextDecoder` and
`TrasnformStream`:

- The common part that can be shared between `TextDecoder` and
`TextDecoderStream` are extracted into a separate type
`script::dom::textdecodercommon::TextDecoderCommon`. This type could
probably use a different name because there is an interface called
`TextDecoderCommon` in the spec
(https://encoding.spec.whatwg.org/#textdecodercommon) which just gets
included in `TextDecoder` and `TextDecoderStream`.
- The three algorithms in `TransformStream` (`cancel`, `flush`, and
`transform`) all have become `enum` that has a `Js` variant for a JS
function object and a `Native` variant for a rust trait object. Whether
the cancel algorithm needs this enum type is debatable as I did not find
any interface in the spec that explicitly sets the cancel algorithm.

Testing: Existing WPT tests `tests/wpt/tests/encoding/stream` should be
sufficient
Fixes: #37723

---------

Signed-off-by: minghuaw <michael.wu1107@gmail.com>
Signed-off-by: minghuaw <wuminghua7@huawei.com>
Signed-off-by: Minghua Wu <michael.wu1107@gmail.com>
2025-07-29 04:18:15 +00:00
Josh Matthews
02297791c8
chore: Add test for synthesized image documents with CSP headers. (#38191)
Adds a regression test for https://github.com/servo/servo/pull/38186,
verifying that the CSP header on the image is ignored when it's loaded
as a document.

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-07-28 13:45:54 +00:00
batu_hoang
f5ee72f89a
Rework webdriver session (#38225)
Reimplement webdriver session for better match to spec:

- Add `create_session`:
[spec](https://www.w3.org/TR/webdriver2/#dfn-create-a-session)
- Refactor `handle_new_session`
- Replace `PageLoadStrategy` string by enum

---------

Signed-off-by: batu_hoang <hoang.binh.trong@huawei.com>
2025-07-28 10:14:14 +00:00
sagudev
ae69646371
canvas: Make 2D context state creation failable and use dom_canvas_backend pref for backend selection (#38310)
Before script just crashed in those cases because IPCSender was dropped,
now we send `None` to tell script about the failure and fail getContext
or registerPainter accordingly.
This PR also unifies `dom_canvas_{backends}_enabled` prefs into
`dom_canvas_backend` which is more flexible in multi-backends scenarios.

Reviewable per commit.

Testing: Added servo specific WPT test.

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-07-28 09:13:07 +00:00
sagudev
056b1538c0
canvas: Add vello_cpu backend (#38282)
vello_cpu does not have any tests timeouts, because we do not need
download stuff from GPU as all work happens on CPU. So performance wise
it's better then classic vello at least for our usecase. There are some
vello bugs, but I think we will be able to sort them out within
upstream, eventually. Interestingly enough there are no new PASS like
they were with classic vello.

Difference with raqote can be observed here:
https://github.com/sagudev/servo/actions/runs/16549241085/attempts/1#summary-46802486798

## Known vello problems:

- https://github.com/linebender/vello/issues/1119
- https://github.com/linebender/vello/issues/1056
-
`/html/canvas/element/fill-and-stroke-styles/2d.gradient.interpolate.coloralpha.html`
- `kurbo::Cap::Butt` is defect (only visible with big lineWidth)
https://github.com/linebender/vello/issues/1063
  - `/html/canvas/element/line-styles/2d.line.cross.html`
  - `/html/canvas/element/line-styles/2d.line.miter.acute.html`
- other lack of strong correct problems
(https://github.com/linebender/vello/issues/1063#issuecomment-2998084736):
  - `/html/canvas/element/path-objects/2d.path.rect.selfintersect.html`
- `putImageData(getImageData(...), ...)` is lossy (precision problems,
might be due to ImageData being unmultiplied)
-
`/html/canvas/element/pixel-manipulation/2d.imageData.put.unchanged.html`

Testing: Tested using vello_cpu_canvas subsuite

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-07-27 19:56:38 +00:00
Servo WPT Sync
633d746e2f
Sync WPT with upstream (27-07-2025) (#38296)
Automated downstream sync of changes from upstream as of 27-07-2025
[no-wpt-sync]

Signed-off-by: WPT Sync Bot <ghbot+wpt-sync@servo.org>
2025-07-27 01:45:05 +00:00
sagudev
bc71fb8c0d
canvas: Respect FillRule (#38294)
We just need to pass user provided FillRule via IPC to canvas paint
thread, then pass it all down to backend, which will handle it.

Testing: Added WPT tests.

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-07-26 17:20:04 +00:00
Ashwin Naren
4188852963
script: Don't panic on IndexedDB put operation structured clone (#38280)
Fixes panic by rethrowing exceptions.

Testing: Covered by WPT
Fixes: #38075

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-07-26 16:35:10 +00:00
Kingsley Yung
4d899ecba5
webdriver: configure Expires and SameSite in handle_add_cookie (#38285)
Handler::handle_add_cookie did not configure the attributes "Expires"
and "SameSite". This patch adds them.

Testing: Passing WPT tests that were expected to fail.
Fixes: https://github.com/servo/servo/pull/37715#issuecomment-3069734014

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-07-26 12:23:24 +00:00
Euclid Ye
a3de3ffa75
webdriver: Implement maximize window for both headless&headed window (#38271)
- Implement [Maximize
Window](https://w3c.github.io/webdriver/#maximize-window)
- Previously, headless window screen size is same as inner size if not
specified in preference. We make it double as required by the test to
not have max window initially.
- Some other random cleanup.

Testing: webdriver Stress test for maximize window (headed + headless).

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
2025-07-26 12:21:17 +00:00