Commit Graph

12398 Commits

Author SHA1 Message Date
César Danilo Pedraza Montoya
6e8384896a script: add error messages (#41039)
script: add error messages for conditions in `encrypt_aes_ctr`

Testing: No tests needed (?) let me know if I should add tests for this
somewhere.
Fixes: #40756

Followed the
[MDN](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/encrypt#aes-ctr)
and [w3c](https://w3c.github.io/webcrypto/#aes-ctr-operations-encrypt)
docs to write the messages.

I'm thinking on adding more messages, so any feedback would be
appreciated! :)

---------

Signed-off-by: César Pedraza <cpedraza@unal.edu.co>
2025-12-05 09:20:50 +00:00
Anonmiraj
b207be05d9 change some allows to expects (#41040)
Changed some allow to expects and removed the unfulfilled expectations.

Testing: Refactor
Part of: #40383

Signed-off-by: anonmiraj <nabilmalek48@gmail.com>
2025-12-05 07:23:32 +00:00
Andrei Volykhin
9a1d86cc88 html: Change the play state of the media player if the old is opposite (#41027)
It's important to check the media player's `paused` state to avoid
unnecessary changes to its internal state (via `play`, `pause`),
including configuration the `playback rate` and `volume` properties.

Depends on https://github.com/servo/media/pull/467

Testing: The expected test results are unchanged because it is the
implicit performance improvements of the media stack, with the exception
of the following test, which is affected by the `playback rate` state
caching mechanism (the `seek` position is not overridden for default
playback rate (1.0)).
- html/semantics/embedded-content/media-elements/preserves-pitch.html

See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4762

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-12-04 12:19:48 +00:00
Andrei Volykhin
f935174981 html: Enhance image update the image data, environment changes algorithms (#41046)
The following image processing algorithms were updated (with
description)
- https://html.spec.whatwg.org/multipage/#update-the-image-data
- https://html.spec.whatwg.org/multipage/#img-environment-changes

Added missing `image request phase` switching cases and non-spec
handling of the `last selected source`.

Testing: Improvements in the following tests
-
html/semantics/embedded-content/the-img-element/current-pixel-density/error.html
-
html/semantics/embedded-content/the-img-element/environment-changes/viewport-change.html

Fixes: https://github.com/servo/servo/issues/38777

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-12-04 12:18:41 +00:00
batu_hoang
1aab8186b7 selectors::Element::parent() shouldn't cross shadow tree boundary (#40977)
ServoLayoutElement::parent_element() method shouldn't cross shadow tree
boundary.
`inheritance_parent` uses `traversal_parent`

Testing: 
`tests/wpt/meta/css/css-lists/counter-list-item-slot-order.html.ini`
`tests/wpt/meta/css/css-nesting/host-nesting-003.html.ini`
`tests/wpt/meta/css/selectors/is-where-shadow.html.ini`
and manual test in the below issue
The regression in
`tests/wpt/meta/html/rendering/the-details-element/details-blockification.html.ini`
has 1 more cause
https://github.com/servo/servo/pull/40977#issuecomment-3608471378

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

cc: @xiaochengh

---------

Signed-off-by: batu_hoang <longvatrong111@gmail.com>
2025-12-04 05:57:34 +00:00
Narfinger
a841eb49d5 IndexedDB: Use GenericSender, GenericReceiver and GenericCallback for IndexedDB (#41031)
Moving IndexedDB to use the generic channel methods.

Of note is the change in 'IDBRequest::execute_async'. This method
previously added a channel that was constructed from the callsite in put
into the AsyncOperation. Now we do not take a function but take a
'FnOnce(GenericCallback<BackendResult<T>>) -> AsyncOperation'. With this
the callsite can construct the AsyncOperation to give in the
'IndexedDBThreadMsg::Async'.

The rest are mostly just type changes.

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

Testing: WPT tests on the IndexedDB subset still pass.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-12-04 05:25:17 +00:00
webbeef
27a776b060 script: shorten script thread name (#41033)
On Linux thread names are limited to 15 characters: that caused all the
script threads to be named 'ScriptScriptEve' and show up with the same
name in tooling.

That changes turns the name to 'Script#{script id}' instead.

Testing: No test coverage for that very internal detail.

Signed-off-by: webbeef <me@webbeef.org>
2025-12-03 19:43:04 +00:00
Taym Haddadi
94e09277e2 Script Implement ReadableByteStreamTee (#35991)
<!-- Please describe your changes on the following line: -->


---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by
`[X]` when the step is complete, and replace `___` with appropriate
data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #35678

<!-- Either: -->
All stream tee tests are passing now.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox
is checked, so that we can help you if you get stuck somewhere along the
way.-->

<!-- Pull requests that do not address these steps are welcome, but they
will require additional verification as part of the review process. -->

---------

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2025-12-03 13:19:21 +00:00
Kingsley Yung
f19bffd186 script: Add error messages to operations of ChaCha20-Poly1305 (#41030)
Error messages in the import/export key operations of ChaCha20-Poly1305
are missing. This patch adds those error messages.

Testing: No behavioral change. Existing tests suffice.

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-12-03 12:59:35 +00:00
Narfinger
b102434ce0 Use 'GenericSender' and 'GenericReceiver' for bluetooth main component (#41008)
Using generic channel for bluetooth module.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>

Testing: This should not change functionality.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-12-02 18:13:31 +00:00
Andrei Volykhin
d539ac8cf3 html: Track the script/UA initiated media seek request (#40981)
The low-level media `seek` request could be initiated by script (DOM
method call or setting of an IDL attribute), by the user agent (seeking
data) or by the media engine itself (e.g. gst_play_set_rate()).
And to distinguish between them we will use the latest seek position (in
seconds) to be able abort processing the `seek` algorithm steps (13-17)
for a `seek` request initiated by the media engine.

See https://html.spec.whatwg.org/multipage/#dom-media-seek

If the `seeking` is in progress, any callback which affects the current
playback position (`position changed`, `end of the playback`) shouldn't
be processed (event marshalling over IPC router is non-state
conditional).

Testing: Regression in the following test causes by gstreamer issue when
the `gst_play_set_rate()` overrides the latest seek requested position
unconditionally and the user agent receives the `seek completion` event
with the unexpected seek position (0.5+ instead of 0.0).
- html/semantics/embedded-content/media-elements/preserves-pitch.html

See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4762

Fixes: https://github.com/servo/servo/issues/37057

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-12-02 11:27:21 +00:00
Oriol Brufau
02ed2af193 script: Don't dirty with ContentOrHeritage damage when changing state (#40902)
When for example changing the hover state of an element, we were
dirtying it with ContentOrHeritage damage, which forced it to be laid
out again.

This was added in #39102 in order to fix #38989, but for the most part
it's no longer needed.

However, we will now dirty when a `<textarea>` or `<input>` which can be
selected gets or loses focus. This is to ensure that the caret or
selections get correctly updated.

Testing: Manually tested that #38989 is not regressing

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-12-02 10:19:50 +00:00
Martin Robinson
cf8c67df92 libservo: Finish the SimpleDialog API (#40982)
Finish exposing the `SimpleDialog` API in libservo, abstracting away the
response senders into structures with methods. In addition, add a
default behavior so that embedders do not have to explicitly send a
reponse when dialogs are ignored. This makes the API much harder to
misuse.

Finally, the WebDriver API for setting the prompt dialog entry
field is corrected to actually set that value rather than the message.
This makes sense as part of this change as the type safety of the
structures makes setting the message (the old, wrong behavior) harder
 to implement.

Testing: This causes a WebDriver conformance test to start passing.

---------

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2025-12-02 08:20:49 +00:00
Kingsley Yung
ff8211275d script: Implement encrypt/decrypt operation of ChaCha20-Poly1305 (#41003)
Finish adding ChaCha20-Poly1305 support to WebCrypto API.

This patch implements encrypt operation and decrypt operation of
ChaCha20-Poly1305, using the crate `chacha20poly1305` to support the
cryptographic calculation. The get key length operation of
ChaCha20-Poly1305 is also included in this patch.

Testing: Pass some WPT tests that were expected to fail.
Fixes: Part of #40687

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-12-02 07:42:51 +00:00
Oriol Brufau
2fdc18c48b script: Reconstruct box tree when order changes (#40994)
The CSS `order` property affects the order of boxes in the box tree.
Therefore, when it changes, we need to reconstruct it.

Testing: Adding new test
Fixes: #40813

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-12-02 06:57:05 +00:00
dyegoaurelio
194875ee35 Block and report CSP violations for javascript: URLs in window.open (#40997)
Previously, when window.open() was called with a javascript: URL, the
script would execute unconditionally without any CSP enforcement. The
CSP list was not propagated from the opener to the newly opened
document.

This commit fixes two issues:

1. Propagate CSP from opener to new document The CSP list from the
existing (opener) document is now copied to the target document before
navigation, ensuring CSP policies are enforced.

2. Report CSP violations to the correct window Per the CSP spec,
violations should be reported to the navigation request's client (the
opener window), not the target window. To achieve this, we check CSP
early in window.open() while both windows are accessible, before
entering the normal navigation flow where only the target window is
available.


Testing: new wpt successes:
-
`content-security-policy/script-src/javascript-window-open-blocked.html`
-
`content-security-policy/unsafe-hashes/javascript_src_denied_missing_unsafe_hashes-window_open.html`
-
`content-security-policy/unsafe-hashes/javascript_src_denied_wrong_hash-window_open.html`


Fixes: part of #36437

Signed-off-by: Dyego Aurélio <dyegoaurelio@gmail.com>
2025-12-02 06:23:36 +00:00
Martin Robinson
385a4bf64b script: Make a Layout-safe version of Element::each_custom_state (#40743)
`Element::each_custom_state` is called from Layout, but it creates
`DomRef` types on the stack, which can only be done on the main script
thread. Since layout might be doing styling and element consultation on
workers threads, expose a Layout-safe version of this change, which
doesn't have this issue.

Testing: This fixes two panics encountered during WPT tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-12-01 22:33:27 +00:00
Taym Haddadi
e3ffa7c7c5 Fix crash when creating an AudioNode from a closed AudioContext (#40954)
Fix crash when creating an AudioNode from a closed AudioContext

Testing: added crash test.
Fixes: #36856

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2025-12-01 21:39:34 +00:00
Kingsley Yung
c30e1126d8 script: Implement generate key operation of ChaCha20-Poly1305 (#40978)
Continue on adding ChaCha20-Poly1305 support to WebCrypto API.

This patch implements generate key operation of ChaCha20-Poly1305, using
the crate `chacha20poly1305` to support the cryptographic calculation.

Testing: Pass some WPT tests that were expected to fail.
Fixes: Part of #40687

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-12-01 09:34:51 +00:00
dependabot[bot]
dbbe78a469 build(deps): bump the servo-media-related group with 12 updates (#40965)
Bumps the servo-media-related group with 12 updates:

| Package | From | To |
| --- | --- | --- |
| [servo-media](https://github.com/servo/media) | ``2c036f2`` |
``fb304a8`` |
| [servo-media-dummy](https://github.com/servo/media) | ``2c036f2`` |
``fb304a8`` |
| [servo-media-gstreamer](https://github.com/servo/media) | ``2c036f2``
| ``fb304a8`` |
| servo-media-audio | ``2c036f2`` | ``fb304a8`` |
| servo-media-derive | ``2c036f2`` | ``fb304a8`` |
| servo-media-gstreamer-render | ``2c036f2`` | ``fb304a8`` |
| servo-media-gstreamer-render-android | ``2c036f2`` | ``fb304a8`` |
| servo-media-gstreamer-render-unix | ``2c036f2`` | ``fb304a8`` |
| servo-media-player | ``2c036f2`` | ``fb304a8`` |
| servo-media-streams | ``2c036f2`` | ``fb304a8`` |
| servo-media-traits | ``2c036f2`` | ``fb304a8`` |
| servo-media-webrtc | ``2c036f2`` | ``fb304a8`` |

Updates `servo-media` from `2c036f2` to `fb304a8`
<details>
<summary>Commits</summary>
<ul>
<li><a
href="fb304a885a"><code>fb304a8</code></a>
Don't allow node creation once the context is closed (<a
href="https://redirect.github.com/servo/media/issues/475">#475</a>)</li>
<li>See full diff in <a
href="2c036f20bb...fb304a885a">compare
view</a></li>
</ul>
</details>
<br />

Updates `servo-media-dummy` from `2c036f2` to `fb304a8`
<details>
<summary>Commits</summary>
<ul>
<li><a
href="fb304a885a"><code>fb304a8</code></a>
Don't allow node creation once the context is closed (<a
href="https://redirect.github.com/servo/media/issues/475">#475</a>)</li>
<li>See full diff in <a
href="2c036f20bb...fb304a885a">compare
view</a></li>
</ul>
</details>
<br />

Updates `servo-media-gstreamer` from `2c036f2` to `fb304a8`
<details>
<summary>Commits</summary>
<ul>
<li><a
href="fb304a885a"><code>fb304a8</code></a>
Don't allow node creation once the context is closed (<a
href="https://redirect.github.com/servo/media/issues/475">#475</a>)</li>
<li>See full diff in <a
href="2c036f20bb...fb304a885a">compare
view</a></li>
</ul>
</details>
<br />

Updates `servo-media-audio` from `2c036f2` to `fb304a8`

Updates `servo-media-derive` from `2c036f2` to `fb304a8`

Updates `servo-media-gstreamer-render` from `2c036f2` to `fb304a8`

Updates `servo-media-gstreamer-render-android` from `2c036f2` to
`fb304a8`

Updates `servo-media-gstreamer-render-unix` from `2c036f2` to `fb304a8`

Updates `servo-media-player` from `2c036f2` to `fb304a8`

Updates `servo-media-streams` from `2c036f2` to `fb304a8`

Updates `servo-media-traits` from `2c036f2` to `fb304a8`

Updates `servo-media-webrtc` from `2c036f2` to `fb304a8`


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 <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</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-12-01 09:34:32 +00:00
Andrei Volykhin
155dc71a65 script: Fire the video resize event in the expected order (#40940)
Queuing a media element task given the media element to fire an event
named `resize` at the media element shoud be done:
- upon the initial `metadata` event from the media engine

https://html.spec.whatwg.org/multipage/#loading-the-media-resource:event-media-resize
- whenever the video dimensions are changed (readyState is not
`HAVE_NOTHING`)

https://html.spec.whatwg.org/multipage/#the-video-element:event-media-resize

See https://html.spec.whatwg.org/multipage/#event-media-resize

Testing: Added new test to confirm `resize` event ordering
-
html/semantics/embedded-content/media-elements/event_order_durationchange_resize_loadedmetadata.html

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-12-01 08:17:35 +00:00
Josh Matthews
91a73c4f86 script: Reverse retargeting algorithm for ShadowRoot.element[s]FromPoint. (#40975)
This implementation is not actually specified (see #40973 and
https://github.com/w3c/csswg-drafts/issues/556), but the implementation
that we have is backwards. Other retargeting uses that describe
"retarget _something_ against _another thing_" map to
`something.retarget(another_thing)`, but what the current code was doing
for element[s]FromPoint was the equivalent of "retarget _this_ against
each element", which is obviously wrong.

Testing: Newly-passing tests.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-12-01 05:13:55 +00:00
WaterWhisperer
119f1d2311 script: Reflect infallible Streams operation in spec (#40949)
updates several methods in `ReadableByteStream` to use `.expect()`
instead of `?` where the spec indicates an infallible operation (denoted
by `!`).

Testing: `./mach test-wpt /streams/readable-byte-streams`
Fixes: part of #36906

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2025-11-29 23:56:24 +00:00
Martin Robinson
2503684d84 constellation: Break the EventLoop dependency on the initial Pipeline (#40944)
Currently starting a script `EventLoop` depends on sending data about
the initial `Pipeline`. This change breaks this dependency. The goal
here is to:

1. Allow `ScriptThread`s to be shared between `WebView`s. This will
   allow more flexiblity with the way that `ScriptThread`s are created,
   which should allow us to perserve system resources by allowing them
   to be shared between `WebView`s. With this change, we can do away
   with the `InitialPipelineState` entirely, which was gather
   information necessary for both a new `EventLoop` and a new
   `Pipeline`. We no longer have to do many clones when reusing an
   existing even loop.
1. Simplify the way that `EventLoop`s and `Pipeline`s are spawned. Now
   `Pipeline`s are spawned in the same way no matter what.

Now the general order of operations when starting a pipeline is:

1. Get or create an event loop for the pipeline:
    - If the event loop needs to be spawn, spawned it in a new thread or
      process.
2. Send the spawn pipeline message to the event loop (kept alive via an
   `Rc`.

Testing: This should not change behavior in a way that is observable, so
should
be covered by existing tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-29 23:30:17 +00:00
Kingsley Yung
b5e78199a1 script: Implement import/export key operation of ChaCha20-Poly1305 (#40948)
Start adding ChaCha20-Poly1305 support to WebCrypto API.

This patch implements "import key" operation and "export key" operation
of ChaCha20-Poly1305, using the crate `chacha20poly1305` to support the
cryptographic calculation.

Testing: Pass some WPT tests that were expected to fail.
Fixes: Part of #40687

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-11-29 05:52:35 +00:00
Ignacio Casal Quinteiro
b00a76427a Fix various typos throughout the code base (#40934)
Signed-off-by: Ignacio Casal Quinteiro <qignacio@amazon.com>
2025-11-28 15:00:56 +00:00
Jan Varga
1d0540810e storage: Introduce storage coordination thread and infrastructure for parallel next-generation IndexedDB implementation (#40661)
This PR introduces a new storage coordination thread, intended to serve
as the central point for managing all current and future storage
endpoints in Servo.

In addition to the new coordination thread, this PR also lays the
infrastructure required to develop a parallel, next-generation IndexedDB
implementation under the indexeddb_next feature flag living on a
separate branch.

Testing: Unit and WPT tests continue to pass

---------

Signed-off-by: Jan Varga <jvarga@igalia.com>
2025-11-28 10:40:02 +00:00
Kingsley Yung
a15861cb41 script: Finishing implementation of Argon2 in WebCrypto (#40936)
Finish adding Argon2 support to WebCrypto API, using the crate `argon2`
to support the cryptographic calculation.

This patch implements "derive bits" operation and the "get key length"
operation of Argon2. Actual error messages are also provided for the
existing "import key" operation of Argon2.

Testing: Pass some WPT tests that were expected to fail.
Fixes: Part of #40687

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-11-28 10:18:25 +00:00
webbeef
d7354191d2 dom: avoid short lived rooting in Node::is_ancestor_of (#40776)
When using the iterator nodes are rooted but they are dropped
immediately.

Testing: Green wpt run:
https://github.com/webbeef/servo/actions/runs/19560383039/job/56012660243

Signed-off-by: webbeef <me@webbeef.org>
2025-11-28 07:40:49 +00:00
Josh Matthews
acbeb25f0b servodriver: Clear cookies between tests. (#40709)
To ensure that tests that modify cookies but don't finish cleanly don't
leave cookie values that interfere with subsequent tests, we need to
clear the cookie storage in between each test that's run.

Testing: Can't test the test runner, just have to watch the patterns in
our test runs.
Fixes: #40668
Fixes: #40672
Fixes: #40673
Fixes: #40674
Fixes: #40695
Fixes: #40697

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-11-28 06:46:52 +00:00
Kingsley Yung
ceee556e89 script: Implement import key operation of Argon2 (#40932)
Start adding Argon2 support to WebCrypto API.

This patch implements import key operation of Argon2.

Testing:
- Pass some WPT tests that were expected to fail.
- Some new FAIL expectations are added to
`argon2.tentative.https.any.js.ini`, which require the
not-yet-implemented derive bits operation of Argon2. These tests were
skipped by WPT when the import key operation of Argon2 had not been
implemented at the time.

Fixes: Part of #40687

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-11-28 06:23:59 +00:00
Kingsley Yung
2982929210 script: Add new KeyFormat and KeyUsage for modern algorithms (#40857)
The specification of Modern Algorithms in the Web Cryptography API
(https://wicg.github.io/webcrypto-modern-algos/) adds new key formats
and key usages to support modern cryptographic algorithms.

This patch adds those new key formats and key usages, preparing for the
implementation of the new algorithms.

Testing: No behavioral changes in existing cryptographic algorithms.
Existing tests suffice.
Fixes: Part of #40687

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-11-28 03:55:10 +00:00
Steven Novaryo
e05e9730e7 dom: Focus scroll to the element only if it is not visible (#40447)
Currently when we call a `Focus` we always scroll a focusable element to
the center of the container. However, this would causes a different
behavior where UAs wouldn't scroll when a focus is called to a visible
element. This PR add implementations following the behavior of Firefox
[nsFocusManager::ScrollIntoView](e613f4df35/dom/base/nsFocusManager.cpp (L3121)),
where we are scrolling to the element if it is not visible.

This would enhance the user experience of focusing an input element,
where we should avoid moving the element if it is visible.

Incidentally fix a calculation bug for the calculation of
`ScrollIntoView` with `nearest` block or inline option.

Testing: Private WPT for the implementation defined behavior and public
WPT for the bug.

---------

Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>
2025-11-28 01:52:21 +00:00
Andrei Volykhin
a516b74ffa html: Update the media player state without delays (#40898)
Currently the sequence order of the DOM method calls and the media
player API calls is mismatched because some media player operations (*)
posted to media task with delayed processing (while should be processed
immediately).
- DOM (script): pause -> seek -> play
- Media: seek -> pause* -> play*

Also the associated queued media events can be fired and processed by
script somehow (e.g. by calling `seek` in event listener handler) even
before the calling of the media player `play/pause` API.

To handle it the application will try to update media state (by calling
media player API) on each DOM `play, pause` method calls and on some
`ready state` changes with checking if the media element can be
potencially playing.

See https://html.spec.whatwg.org/multipage/#potentially-playing

Testing: No expected testing results changes because there are
unexpected `seek completion` signals from the media engine with invalid
time positions which are affecting passing test score (by masking false
positive results).
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4762

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-27 20:06:40 +00:00
Josh Matthews
c2bfb1c6c5 script_bindings: Disallow manual Drop implementations for DOM interfaces. (#40919)
This implements the solution from #26488 that prevents implementing Drop
manually for DOM interfaces, which is very easy to write in a way that
can cause memory safety errors during JS runtime teardown. Since we have
a bunch of pre-existing implementations that we are working on removing,
this PR adds an opt-out mechanism that those interfaces use.

Testing: Compile-time code generation; not possible to test.
Fixes: part of #26488

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-11-27 19:53:59 +00:00
Oriol Brufau
c6c0f75452 script: Stop assuming that previous dirty root is still connected (#40922)
We were trying to update the dirty root to be the common ancestor of the
old dirty root and the element noted with dirty descendants. But that
would panic if when the old dirty root had been disconnected.

In that case, just set the dirty root to be the element, as if the old
dirty root was None.

Testing: Adding a crashtest, and one existing test now fails instead of
crashing
Fixes: #40920

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-11-27 14:40:12 +00:00
Martin Robinson
08aad55ef7 script: Break the ScriptThread dependency on the initial Pipeline (#40918)
`ScriptThread`s start with an initial `Pipeline`, but that `Pipeline`
should not be used for any `ScriptThread` global data as a
`ScriptThread` can have any number of `Pipeline`s that come and go.
There's no architectural reason why a `ScriptThread` should be
associated with only a single `WebView`.

This change makes it so that the `ScriptThread` no longer uses the
`PipelineId` and the `WebViewId` of the initial `Pipeline` to initialize
itself. Instead a `ScriptEventLoopId` is used to uniquely identify every
`ScriptThread` in both the `ScriptThread` and the `Constellation`.
The remaining use was for crash reporting. Now when a crash happens, it
launches the sad tab in all `WebView`s that depeneded on that
`ScriptThread`.

This is a change which should allow simplifying the way that
`EventLoop`s/`ScriptThread`s are started in the `Constellation`, which
will be handled in a followup.

Testing: This shouldn't change behavior except in the case where a
`ScriptThread` is used in more than a single `WebView`, which should
work
properly now. I tested this change manually by running servoshell in
multiprocess mode while causing a panic to happen due to a null pointer
dereference. The sad tab appeared after this change, so things seem to
work
properly still. Testing crashes is tricky with the way we test servo
now.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-27 13:34:57 +00:00
Taym Haddadi
8e04f8ffae fix RefCell already borrowed panic in readablestream (#40911)
fixes an intermittent RefCell already borrowed panic in the
ReadableStream implementation by tightening the borrow scope of
ReadableStream::reader in the error and cancel.

Testing: super hard to make crash test for this.

Fixes: #40894

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2025-11-27 08:29:43 +00:00
Andrei Volykhin
87e8e1ac50 html: Add new media tracks when receiving the initial media metadata event (#40917)
The new audio/video tracks should be added to the media element from the
initial `metadata` event from the media engine because there are
possibility of the multiple `metadata` events without any associated
`media track` state changes and previously the application added new
tracks into lists unconditionally.

The registered issue to handle possible dynamic `media track` state
changes from the media engine gracefully.
https://github.com/servo/media/issues/473

Testing: Improvements in the following tests
-
html/semantics/embedded-content/the-video-element/video_size_preserved_after_ended.html

Fixes: https://github.com/servo/servo/issues/32623

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-27 07:45:59 +00:00
Jan Varga
0899b87dd4 Fix inconsistent strum dependencies and imports (#40907)
The `scripts_traits` crate was the only crate depending on `strum` with
the
`derive` feature. This accidentally allowed other crates to import strum
macros via `strum::` without declaring their own dependency on
`strum_macros`,
causing compilation issues when running `./mach test-unit -p net`.

This PR makes the imports consistent across the code base by:
- replacing all `strum_macro::` imports with `strum::` imports
- removing strum_macro dependencies
- adding derive feature to the strum workspace

Testing: Unit tests continue to pass

Signed-off-by: Jan Varga <jvarga@igalia.com>
2025-11-26 21:37:55 +00:00
Taym Haddadi
f6bb1a4187 Fixes ByteLengthQueuingStrategy.size WPTs that were previously marked as TIMEOUT/CRASH (#40890)
I got trigged by this:

<img width="1589" height="919" alt="image"
src="https://github.com/user-attachments/assets/ad827309-551a-452a-9af3-b857b71dc4cd"
/>



Servo is the only one TIMEOUT on this test, but we don't have a
`tests/wpt/meta/streams/queuing-strategies.any.js.ini`, when I run it
locally I get one test TIMEOUT and another one CRASH, this should fix
it.


Before this fix:
```
[queuing-strategies.any.worker.html]
  expected: CRASH

[queuing-strategies.any.html]
  expected: TIMEOUT
  [ByteLengthQueuingStrategy: size behaves as expected with strange arguments]
    expected: TIMEOUT

```

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2025-11-26 06:44:57 +00:00
Andrei Volykhin
a5a475cfd8 html: Fix handling of the media playback EnoughData event (#40881)
The media engine signals with the `PlayerEvent::EnoughData` event that
the media source has enough data and the application should stop pushing
more data to avoid excessive buffer queueing and wait
`PlayerEvent::NeedData` event to continue.

Note that the source buffer size - MAX_SRC_QUEUE_SIZE (50MB).

This event is reflecting the state of the media source so the
application shouldn't change the media element ready state somehow.

Testing: No expected testing results changes

Fixes (partially): https://github.com/servo/servo/issues/40740

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-25 16:14:26 +00:00
Andrei Volykhin
cdb6c5c851 html: Use WeakRef for the MediaSession media element (#40875)
The media session is allowed to control the state of the media element
(play, pause) and is holding DOM reference, so the latest registered
media element is not be able to be GCed, so let's use the weak reference
to break this dependency.

Note that `weakReference` property was added to interfaces
- HTMLMediaElement: The `Mutable/WeakRef` requires T to be bound by
`WeakReferenceable`
- HTMLAudio/VideoElement: The `DOM_WEAK_SLOT` must be reserved by
concrete DOM JS class

Testing: No expected testing results changes

The media session UI functionality is implemented for Android and didn't
test due lack of testing sample.

Fixes: https://github.com/servo/servo/issues/40854

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-25 07:11:15 +00:00
Yerkebulan Tulibergenov
d0ce02a860 script: add CanGc as argument to methods in HTMLOptionElement (#40873)
script: add CanGc as argument to methods in HTMLOptionElement

Testing: These changes do not require tests because they are a refactor.
Addresses part of https://github.com/servo/servo/issues/34573

Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
2025-11-25 04:41:39 +00:00
Taym Haddadi
42ea5360e0 Implement brotli support for CompressionStream and DecompressionStream (#40842)
Implement brotli support for CompressionStream and DecompressionStream

Testing: brotli test should pass
Fixes: #40831

---------

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2025-11-25 02:04:14 +00:00
Oriol Brufau
631edfe6e4 script: Don't use named fields for StylesheetContextSource::Import (#40866)
After #40639, this variant holds a single value, and I don't think think
using named fields was providing much extra clarity.

Testing: not needed, no behavior change

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-11-24 22:44:15 +00:00
d-kraus
0a0a20a9c6 Replace some #[allow] with #[expect] (#40865)
Replaces some #[allow] with #[expect]. In case where the lint
expectation was unfulfilled, I removed it.


Testing: Refactor
Part of: https://github.com/servo/servo/issues/40383

Signed-off-by: Dennis Kraus <kraus@posteo.de>
2025-11-24 22:41:45 +00:00
WaterWhisperer
687ba76207 script: Align Streams implementation with spec step calls (#40856)
updates several methods in `ReadableStream` to use `.expect()` instead
of `?` where the spec indicates an infallible operation (denoted by
`!`).

Testing: `mach test-wpt /streams/`
Fixes: part of #36906

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2025-11-24 18:01:11 +00:00
Andrei Volykhin
2937300a9e html: Update MediaSession setPositionState method (#40793)
The MediaSession `setPositionState` method should only update the
position state and propagate it to the platform media session UI
controller and shouldn't change somehow the properties of the media
element directly (duration, playback rate or position).
    
See
https://w3c.github.io/mediasession/#dom-mediasession-setpositionstate
    
Testing: Improvements in the following tests
- /mediasession/positionstate.html
    
The media session UI functionality is implemented for Android and didn't
test due lack of testing sample.

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-24 16:47:36 +00:00
Luke Warlow
64a3abfe67 Add CommandEvent (#40413)
Add CommandEvent

This is behind the new dom_command_invokers_enabled pref.

Testing: Existing WPTs

---------

Signed-off-by: Luke Warlow <lwarlow@igalia.com>
2025-11-24 13:49:51 +00:00