Commit graph

29467 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
Kingsley Yung
19c498af16
script: Migrate digest operation to use new normalization (#39477)
Refactoring of the algorithm normalization in #39431 introduces a new
algorithm normalization procedure to replace the existing one.

This patch migrates the `digest` operation from using existing
`normalize_algorithm_for_digest` function to using the new
`normalize_algorithm` function.

Note that the custom type `DigestAlgorithm` has not yet completely
removed since other operations like `get key length` (not migrated yet)
depend on it. It will be removed when those operations are also
migrated.

A minor bug (missing a step) in `normalize_algorithm` is also fixed.

Testing: Refactoring. Existing WPT tests are enough.
Fixes: Part of #39368

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-10-02 07:50:01 +00:00
Ashwin Naren
1448fd5967
Remove test_mapping.json and python/servo/mutation (#39617)
As per #39585.

>It used to run on our old buildbot CI for a couple years. It was never
migrated, and we should clean it up.

_Originally posted by @jdm in
https://github.com/servo/servo/issues/39585#issuecomment-3351054660_

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-10-02 04:31:54 +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
César Danilo Pedraza Montoya
9e380614ee
unit test: Remove unused import in fonts (#39614)
Remove unused import (`use base::generic_channel;`)

Testing: Clippy ran successfully, no tests added
Fixes: #39609

Signed-off-by: César Pedraza <cpedraza@unal.edu.co>
2025-10-02 02:46:31 +00:00
Oriol Brufau
df9902e4d0
Upgrade Stylo to 2025-10-01 (#39612)
This continues #39150

Changelog:
- Upstream:
fd700321cc...b98470a5cb
- Servo fixups:
1040a20611...4ba7bdb404

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

---------

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-10-02 01:23:05 +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
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
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
Martin Robinson
a2f551eb2d
layout: Clone static position rectangles when caching in IndependentFormattingContext (#39591)
Hoisted absolutes that are cached in IndependentFormattingContexts may
have their HoistedSharedFragment reused between layouts. This means
that the original value of the adjusted static positioning rectangles
need to be preserved in cache. This change makes it so that these values
are cloned when being retrieved from the cache. Further adjustments up
the tree will now no longer affected the version in teh cache.

Testing: This should cause `/_mozilla/css/stacked_layers.html` to no
longer
be flaky.
Fixes: #39548.
Fixes: #39439.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-10-01 06:50:54 +00:00
Simon Wülker
e5017b1b50
Move XPath implementation into its own crate (#39546)
XPath (and, in the future, XSLT) is only loosely coupled to `script`. As
`script` is already very large, I'd like to move the xpath parser and
evaluator into a seperate crate. Doing so allows us to iterate on it
more easily, without having to recompile `script`. Abstracting over the
concrete DOM implementation could also allow us to write some more
comprehensive unit tests.

Testing: Covered by existing web platform tests
Part of https://github.com/servo/servo/issues/34527
Fixes https://github.com/servo/servo/issues/39551

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-30 19:55:10 +00:00
Martin Robinson
e9d0a8f95d
libservo: Re-export types that are used by servoshell (#39586)
servoshell should not depend on internal Servo crates. Instead,
`libervo` should re-export any types that are used by embedders. This
change does that re-export for private types currently used by
servoshell.

Testing: This just changes the way types are imported, so curent tests
should suffice.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-09-30 16:36:05 +00:00
Andrei Volykhin
6a1a3aea08
html: Allow legacy referrer policies only for <meta> referrer (#39506)
Follow the HTML specification and allow to use legacy referrer policies
(never/default/always/origin-when-crossorigin) only with 'meta'
referrer.

See https://html.spec.whatwg.org/multipage/#meta-referrer (step 5)

While for another HTML elements with 'referrerpolicy' content attribute
(https://html.spec.whatwg.org/multipage/#referrer-policy-attribute)
and for 'Referrer-Policy' HTTP header

(https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-header-dfn)
the referrer policy should be determine from the standard policy tokens
(https://w3c.github.io/webappsec-referrer-policy/#referrer-policy).

So unknown policy values (legacy from meta-referrer) will be ignored
and determine as 'ReferrerPolicy::EmptyString'.

Testing: No changes

Fixes: #36833

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-09-30 16:29:24 +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
Martin Robinson
439558133f
script: Use conditional_malloc_size_of for Rc types on Window (#39589)
This allows measuring the size of these types conditionally rather than
ignoring them.

Testing: This modifies which things are measured by `MallocSizeOf` which
isn't covered by tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-09-30 16:03:34 +00:00
Simon Wülker
0a1633c52a
script: Remove unreachable assertions in xpath parser (#39588)
`relative_path_expr` can only ever return `Expr::Path`. If we make it
return a `PathExpr` then callers can rely on this invariant.

Testing: There's only limited testing for this change due to
https://github.com/servo/servo/issues/39551. But I think that's okay,
since the change is fairly trivial.
Part of https://github.com/servo/servo/issues/34527

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-30 13:20:31 +00:00
Martin Robinson
6ffc0cd482
libservo: Add a WebView::take_screenshot() API and use it for reftests (#39583)
This change adds a new API to the `WebView` for capturing screenshots.
This makes it possible to:

 - use the reftest waiting infrastructure via the API
   easily.
 - take more than a single screenshot in one Servo run.
 - take screenshots, but still paint the `WebView` normally prior
   to the moment that the screenshot is ready, instead of preventing
   all non-screenshot-ready paints while taking a screenshot.

In addition, the previous infrastructure, the `wait_for_stable_image`
option is removed completely.

Testing: This change is tested by the passing of the WPT tests,
as they commonly use the screenshot feature.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Delan Azabani <dazabani@igalia.com>
2025-09-30 11:39:47 +00:00
Shubham Gupta
6995e60ee1
compositor: Add Paint Metric events to Perfetto Traces (#39502)
> Some metrics like TimeToFirstPaint and TimeToFirstContentfulPaint are
only in the HTML traces. [See
this](https://github.com/servo/perf-analysis-tools?tab=readme-ov-file#how-to-analyse-a-single-servo-sample)

In order to analyse the performance and refine
[perf-analysis-tools](https://github.com/servo/perf-analysis-tools) we
need these metrics to be added to Perfetto also.

<img width="993" height="359" alt="Screenshot from 2025-09-26 15-00-00"
src="https://github.com/user-attachments/assets/9755f344-a98e-4671-b347-d76cd6311afe"
/>

<img width="1186" height="359" alt="Screenshot from 2025-09-26 15-00-42"
src="https://github.com/user-attachments/assets/a25e3a5f-eef0-45b7-be69-5de919bfb663"
/>

Testing: Verified by using Perfetto traces

Signed-off-by: Shubham Gupta <shubham.gupta@chromium.org>
2025-09-30 11:07:35 +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
Gae24
5442302f8b
script: move testbinding DOM interfaces to script/dom/test (#39585)
Move testbinding interfaces to it's own module, to avoid cluttering dom
folder.

Testing: A successful build is enough
Part of #38901

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2025-09-30 10:17:09 +00:00
Martin Robinson
6a2a9a6e33
layout: Ensure that the Epoch stored in layout is accurate (#39568)
The first epoch is 0 as that is the one used in the initial transaction,
but the code was setting the first `Epoch` to `Epoch(1)`. This means
that
when layout advanced the epoch, the `Epoch` of the first produced
display list was `Epoch(2)`.

This change makes the value reflected in `current_epoch` actually match
the index of the display list produced. In addition, we always store
this epoch in `PipelineDetails` in the renderer. This will be important
when adding the `WebView::take_screenshot` API.

Testing: This should not change behavior, so is covered by existing
tests which
rely on proper `Epoch` advancement.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-09-30 06:42:58 +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
webbeef
55facf7b15
script: Cache the current favicon on the document (#39575)
This allows us to notify the embedder when navigating back and forth.

Testing: Manual testing following the steps in issue #39529 
Fixes: https://github.com/servo/servo/issues/39529

Signed-off-by: webbeef <me@webbeef.org>
2025-09-30 02:35:49 +00:00
Ashwin Naren
fef56fcc47
Consistently rename storage to webstorage to prevent confusion (#39550)
Add the prefix of "WebStorage" instead of "Storage" for all webstorage
spec related things. For example, a `struct` called `StorageManager`:
this could refer to either webstorage's thread manager or to the backend
for [the storage manager
interface](https://storage.spec.whatwg.org/#storagemanager). webstorage
is the full name of the spec, so I chose to keep that in the names of
files/structs to prevent confusion when storage manager is implemented.

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-09-29 17:13:34 +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
Narfinger
e64f021550
Allow WebViews and fonts to have a RenderingGroupId. (#39140)
Motivation: The font cache currently has to store a cache of Keys which
need to be given by the webrender instance.
Having a cache for every WebViewId in the future when we have every
webview have the different webrender::DocumentId might be too wasteful
to store this key cache per DocumentId. This proposes to include in the
WebViewId another id, the RenderingGroupId. This id can be easily
changed
to be equivalent to the DocumentId when we support multiple DocumentIds
for a unique Webrender instance.
Additionally this will keep it easier to integrate the currently out of
tree patches for multiple rendering contexts with different webrenders.


Change:
We introduce the RenderingGroupId in the WebViewId and allow a method to
extract it. The font key cache uses this cache
and forwards it to the Compositor when requesting new changes. The
compositor currently ignores this id.
Additionally, the WebView can return the RenderingGroupId. The WebViewId
also has an appropiate constructor for specifying a RenderingGroupId.
Because there currently will be only one RenderingGroupId the
performance will be minimal.


Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>

Testing: This should be covered by WPT tests and normal browsing
behavior works fine.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-09-29 10:01:56 +00:00
Narfinger
32b656adf4
More changes to HashMap/HashSet to use fxhash (#39244)
Moved more functions to fxhash. And provide comments about the choices
when necessary.


Testing: Hash functions shouldn't change functionality.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-09-29 09:51:17 +00:00
Narfinger
389f0d4cc2
Split WindowProxies in script to own struct and allow to get an Rc to it. (#39274)
Split the window_proxies in script thread into its own struct with
appropiate methods. ScriptThread allows to get an Rc to it.
HtmlIFrameElement, Window and WindowProxy now get the Rc on construction
from ScriptThread.


Testing: Just a refactor so should not change any behavior.
Fixes: Addresses part of https://github.com/servo/servo/issues/37969

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-09-29 09:46:49 +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
Sam
aaa7f83176
crown: Check closure bodies for unrooted types and fix root TransmitBodyPromise* (#39534)
We should also check closure bodies for unrooted expressions. 

Testing: New crown tests
Fixes: #37331
Fixes (partial): #37330

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-09-29 08:57:23 +00:00
Ashwin Naren
d12dc23083
storage: Move storage related backend threads to their own crate (#39418)
This PR moves storage related APIs (currently just webstorage and
indexeddb) into their own crate. This reduces the congestion in the net
thread.

Related Zulip thread:
https://servo.zulipchat.com/#narrow/channel/263398-general/topic/indexedDB.20location/with/535911631

Sub PRs:
- [x] Move shared storage/net stuff to base (`IpcSend` and
`CoreResourcePool`) #39419

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-09-28 08:00:20 +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
Euclid Ye
41b1a8706b
webdriver: Safely converting to OpenGL coordinates when taking (element) screenshot (#39543)
When taking element screenshot, we need to convert y-coordinates to
comply with OpenGL. With dpi > 1, sometimes y can be -1 due to rounding,
resulting in panic when
660f90f687/components/shared/compositing/rendering_context.rs (L655)

This PR safely converts.

Testing: When running in headed mode with dpi > 1,
`/webdriver/tests/classic/take_element_screenshot/scroll_into_view.py`
always passes locally now without panic.
Fixes the panic:
https://github.com/servo/servo/issues/39306#issuecomment-3342204869

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-09-28 04:50:16 +00:00
Narfinger
3ccb7540c0
net: Do not send data scheme requests to DevTools (#39318)
Simple check to not send data urls to devtools.


Testing: Looked at reddit.com which sends data url and tested it with
this fix.
Fixes: Should fix https://github.com/servo/servo/issues/39127.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-09-27 21:46:17 +00:00
Excitable Snowball
601ad7e5c6
script: Add message to InvalidStateError (#39535)
Adding an optional message to be attached to an InvalidStateError.

Testing: Only a refactor, no behavior change
Fixes: Partially #39053

Signed-off-by: Excitable Snowball <excitablesnowball@gmail.com>
2025-09-27 19:23: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
Martin Robinson
5f5f2abc0f
script: Rename StylesheetLoader to ElementStylesheetLoader (#39537)
`StylesheetLoader` implements the `StylesheetLoader` trait from Stylo.
This is pretty confusing as the names are the same. This change renames
the Servo version to `ElementStyleSheet` loader so that it's clearer
from reading the code what each of these things are.

Testing: This change just makes a few renames so shouldn't change test
results.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-09-27 13:04:46 +00:00
Euclid Ye
2e8fac9395
webdriver: Elegantly handle "element screenshot" when bounding box has area zero (#39499)
It is possible that the bounding rectangle of an element has area 0.
This PR avoids panic in this case.

It is worth to mention that the panic itself won't kill the entire
program for interaction, but only the webdriver thread.

Testing: Manually tested on the case of #39495

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-09-27 02:20:35 +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
Narfinger
18a1da0d80
Script: Remove last instances of Deref<str> and DerefMut<str> used for DOMString (#39504)
This removes the last instances of Deref<str> and DerefMut<str> used for
DOMString.
The goal is outlined in https://github.com/servo/servo/issues/39479.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>

Testing: Compilation is the test as it just changes function names
essentially.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-09-27 01:48:24 +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
Oriol Brufau
d29ad5b9c3
compositing: Don't reset scroll positions when receiving a new frame tree (#39515)
In the past, all scroll offsets were reset when navigating between
pages,
and layouts probably didn't preserve their scroll positions between back
and forward operations. Whatever the reason, the compositor was still
trying to
reset these positions right after a load.

This is an issue, because a page can request a scroll during a load, and
this
scroll might be requested from `<iframe>` content. In that case, the
scroll
positions should be the ones that layout reflects and not cleared from
the
Compositor. This reset operation had the potential to stomp on scroll
positions
set during load.

It's quite likely that the Compositor shouldn't be trying to reset them
at all,
so just stop doing that. This removes a source of intermittency when
running
tests that set scroll positions.

Testing: Once #39475 lands after this, its test should always pass.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-09-26 17:14:45 +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