Commit Graph

213 Commits

Author SHA1 Message Date
TIN TUN AUNG
0fa52e7791 script_bindings: add generic type to webidl record typedefs containing dom interfaces (#42388)
when generating rust bindings for webidl typedef, the `<D>` generic Type
would not be added for record<Key, DomInterface> because
`containsDomInterface` does not take record into account. This change
add the is_Record check in `containsDomInterface`, so `typedef
record<Key, DomInterface>` can be successfully build.

Testing: Manually tested with
https://github.com/servo/servo/issues/42362, and building from scratch
with `./mach build` is successful.
Fixes: https://github.com/servo/servo/issues/42362

---------

Signed-off-by: rayguo17 <rayguo17@gmail.com>
2026-02-06 16:41:50 +00:00
pralkarz
9e02b0ce65 script: use &mut JSContext in Window::PostMessage (#42370)
Replace `crate::script_runtime::JSContext` with `js::context::JSContext`
in `Window::PostMessage`'s API.

Testing: Builds and runs locally.
Part of: https://github.com/servo/servo/issues/42347

Signed-off-by: pralkarz <pralkarz@tuta.com>
2026-02-05 20:13:11 +00:00
Gae24
97aac6e70a script: use &mut JSContext inside workers PostMessage api (#42342)
Switch `PostMessage` of `Worker`, `DedicatedWorkerGlobalScope` and
`ServiceWoker` to use `&mut JSContext`, propagating it to
`post_message_impl`.

Testing: A successful build is enough

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-02-04 18:40:32 +00:00
Steven Novaryo
42359b26a2 script: Impl UserActivation interface (#42060)
User activation is a concept used to prevents annoying usage of specific
API (Fullscreen API, Virtual Keyboard) to the user by states that the
API needs to have in order to process. This PR implements the
`UserActivation` interface and keep track of the last user interaction.
Each `Window` will keep track the [last activation time
stamp](https://html.spec.whatwg.org/multipage/interaction.html#last-activation-timestamp),
which will be set if there are a triggering input event firing in the
`Window` and propagating across the browsing contexts ancestors and
descendants. These timestamp could be consumed, and the timestamp will
be set to negative infinite.

It is then used to gate some APIs within browser that is determined as
transient activation consuming-gated APIs, which needs transient
activation to be true and consumes the activation. For the purpose of
testing, this PR would implement this behavior on fullscreen API which
is used to test activation consuming behavior.

Spec:
https://html.spec.whatwg.org/multipage/interaction.html#the-useractivation-interface

Testing: Existing WPT

---------

Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>
2026-02-03 23:20:54 +00:00
Ashwin Naren
2c96178ff1 geolocation: Support errorCallback (#42295)
Support `errorCallback` in geolocation position request functions and
throw the necessary errors.

Testing: Passes 3 more WPT tests
Fixes: Partially #38903

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2026-02-03 02:33:39 +00:00
Sam
0f9f601eb9 script: Correctly handle Reflector with AssociatedMemory and remove associated memory in finalize instead of drop (#42271)
Reviewable per commits:

As noted in
https://github.com/servo/servo/pull/42180#discussion_r2749861902
transmuting `&Reflector<AssociatedMemory>` to `&Reflector<()>` will
ignore AssociatedMemory information and thus it will not remove extra
associated memory. By returning `&Reflector<Self::ReflectorType>` from
`DomObject::reflector()` we will preserve this information and thus
correctly handle cases with associated memory. We also do not need
`overrideMemoryUsage` in bindings.conf anymore. 🎉

Instead of removing associated memory in drop code we should do it as
part of finalizers, otherwise we have problems in nested (inherited)
structs, where drop is run for both parent and child, but we only added
associated memory for child (on init_reflector) which already included
size of parent. The only exception here is promise, because it is RCed
and not finalized.

Testing: Tested locally that it fixes speedometer.
Fixes #42269

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-02-01 10:57:08 +00:00
Sam
8ed35f1ce9 script: Add basic memory pressure reporting to SpiderMonkey (#42180)
By reporting memory usage of rust objects back to SM it can trigger GC
sooner and release more memory (I hope that we could use this to avoid
OOB in webgpu in the future).

Currently we use simple `size_of::<DomStruct>() +
size_of::<Box<DomStruct>>()` but it's possible to override reported
memory with `update_memory_size(self, nbytes);` on reflector. This is
mostly useful for canvases and buffers which usually have large
associated data.

Testing: None, but I am wondering if we can connect this to
`about:memory`.
Fixes: #42168

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-01-30 18:11:06 +00:00
Domenico Rizzo
2c770c162c [26488] Refactors GPUCanvasContext to manage context dropping. (#42243)
Moves the `Drop` implementation for `GPUCanvasContext` to a new
`DroppableGPUCanvasContext` struct.

This ensures the context destruction logic is correctly handled, as the
`GPUCanvasContext` struct itself is a DOM struct and should not have a
drop implementation. This change aligns with the requirement that DOM
types should not implement Drop.

Testing: No tests added
Fixes: #26488

Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
2026-01-29 18:02:31 +00:00
Steven Novaryo
45c39d7496 script: Notify PinchZoom resizes to ScriptThread's VisualViewport (#41754)
Continuing the implementation of `VisualViewport`, the resizing of
`PinchZoom` should be notified to `ScriptThread` to update the
`VisualViewport` interface and to fire the appropriate JS event. Top
level `Window`/`Pipeline` would have a `VisualViewport` interface that
mirrors the `PinchZoom` viewport, while nested `Window` would have a
default value that represent layout viewport of the relevant iframe. The
`VisualViewport` of an iframe is updated after each reflow that
calculate the rectangle of the iframe.

The updates of DOM's `VisualViewport` occurs immediately (instead of
waiting for the event loop like the viewport) but integrates with the
event loop for the JS events. This behavior would helps with the fact
that `VisualViewport` needs to be updated both when it is scrolled or
resized.

Testing: Existing WPTs and new unit test.
Part of: https://github.com/servo/servo/issues/41341

---------

Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>
2026-01-28 09:33:55 +00:00
Sam
3047b9946f script: Remove AsVoidPtr and AsCCharPtrPtr traits (#42153)
We migrated most uses some years ago, so let's finally remove them. It's
more clear what we are doing if we inline stuff then hiding dangerous
cast behind trait.

Testing: Covered by WPT, try run:
https://github.com/sagudev/servo/actions/runs/21350967668

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-01-26 10:47:35 +00:00
Tim van der Lippe
13472304a5 script: Support blocking attribute for style and link elements (#42096)
Testing: WPT

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
2026-01-26 09:12:38 +00:00
Sam
2503cc2ab7 script: Pass &CStr insted of &str in {set,get}_dictionary_property (#42125)
It's stupid to create rust strings in the first place to only convert
them into C-style for SM anyway. Furthermore most of those strings are
const literals (comp time strings), so now we will just store additional
null byte within them and able to avoid any runtime conversions.
We should do this in more places.

Testing: Just refactor.

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-01-24 13:03:41 +00:00
Sam
6525cd99b6 script: Port indexddb to &mut JSContext (#42123)
Welp, this just happened while I tried to so something else. cc
@arihant2math and @janvarga just so you are aware of these changes.

Testing: Just refactor, but should be covered by WPT tests.
Part of #40600

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-01-24 09:36:10 +00:00
Gae24
b7ccf86cb8 script: remove more unused code (#42081)
This commit remove more unused code from `script_module`,
`inline_module_map` and `dynamic_modules` fields from `GlobalScope` and
the now unused custom interface `DynamicModuleOwner`.

Testing: No functional change, a successful build is enough.

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-01-22 15:12:09 +00:00
Josh Matthews
cadcc605e0 script: Replace uses of RootedVec<JSVal> with Rooted<Vec<JSVal>>. (#41921)
This replaces uses of our custom RootedVec type that were storing JS GC
values with stack rooting that is better integrated with the engine.
This ensures that storing nursery-allocated objects in these vectors is
handled correctly during GC, unlike our RootedVec implementation which
trips an assertion in debug mozjs builds.

Testing: No observable difference in non-mozjs builds.
Fixes: part of #40141

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2026-01-22 03:28:19 +00:00
eri
151074e9a1 devtools: Handle pause in the debugger (#42007)
Add an event listener for `pause` to `debugger.js` and the necessary
glue to access it from the `devtools` crate. This returns important
information to know where we are paused, such as the source location and
frame state.

Fix frame and object actor encoding into messages. Use information from
`debugger.js` to correctly fill the fields.

Add a new `frames` list to the thread actor and handle the `frames`
message.

Fix `getEnvironment` reply in the frame actor. It is out of form (has a
`type` field but it doesn't require a followup empty message, it already
counts as a reply), so we need to handle it specially.

Note: For now we are focusing on the protocol side of the debugger, and
this patch only shows where the pause would happen. Pausing Servo itself
will happen in a followup.

![Debugger showing the line where execution would be
paused](https://github.com/user-attachments/assets/c007f205-0ccd-47f1-ad0b-81b7415e8211)

Testing: `mach test-devtools` and manual testing. No errors (apart from
#42006).
Part of: #36027

---------

Signed-off-by: eri <eri@igalia.com>
Co-authored-by: atbrakhi <atbrakhi@igalia.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
2026-01-19 19:27:52 +00:00
webbeef
f13b8e6ed5 chore: suppress warnings when building without the testbinding feature (#42003)
When building without the `testbinding` feature of `libservo`, we end up
with these compilation warnings (and one error):

```
warning: unused import: `native_from_handlevalue`
   --> components/script_bindings/import.rs:108:9
    |
108 |         native_from_handlevalue, native_from_object_static,
    |         ^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default

warning: unused imports: `DomSlice` and `Dom`
   --> components/script_bindings/import.rs:131:34
    |
131 |     pub(crate) use crate::root::{Dom, DomSlice, MaybeUnreflectedDom, Root};
    |                                  ^^^  ^^^^^^^^

warning: unused import: `crate::root::DomRoot`
 --> /home/webbeef/servo/target/debug/build/script_bindings-9c5650a8d750af8f/out/DomTypes.rs:3:5
  |
3 | use crate::root::DomRoot;
  |     ^^^^^^^^^^^^^^^^^^^^

warning: unused import: `Maplike`
   --> components/script_bindings/import.rs:124:34
    |
124 |     pub(crate) use crate::like::{Maplike, Setlike};
    |                                  ^^^^^^^

warning: `script_bindings` (lib) generated 4 warnings (run `cargo fix --lib -p script_bindings` to apply 3 suggestions)
error[E0412]: cannot find type `IdentityHub` in this scope
  --> components/script/dom/debuggerglobalscope.rs:76:63
   |
76 |         #[cfg(feature = "webgpu")] gpu_id_hub: std::sync::Arc<IdentityHub>,
   |                                                               ^^^^^^^^^^^ not found in this scope
   |
help: consider importing this struct
   |
 5 + use crate::dom::identityhub::IdentityHub;
   |

warning: method `worklet_id` is never used
   --> components/script/dom/worklet.rs:121:19
    |
 95 | impl Worklet {
    | ------------ method in this implementation
...
121 |     pub(crate) fn worklet_id(&self) -> WorkletId {
    |                   ^^^^^^^^^^
    |
    = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default
```

Testing: No test needed, this won't change the default builds.

Signed-off-by: webbeef <me@webbeef.org>
2026-01-19 07:44:15 +00:00
Domenico Rizzo
162c697248 [26488] - Moves drop logic to inner struct for GPUBindGroupLayout (#41984)
Moves the drop logic for `GPUBindGroupLayout` to an inner struct
`DroppableGPUBindGroupLayout`.

Testing: No tests added
Fixes: Partially #26488

Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
2026-01-18 17:20:14 +00:00
Domenico Rizzo
0417968ee9 [26488] - Refactors GPUBindGroup drop implementation (#41977)
Moves the drop implementation for `GPUBindGroup` to a separate
`DroppableGPUBindGroup` struct.

Testing: No tests added
Fixes: partially #26488

Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
2026-01-17 17:53:56 +00:00
Sam
89cfe15b3e script: use &mut CurrentRealm in cross_origin_has_own (#41955)
Testing: Just refactor, but covered by existing WPT tests.
Part of #40600

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-01-16 11:05:26 +00:00
Domenico Rizzo
380884523a script: Move adapter dropping to a dedicated struct (#41911)
Moves the adapter dropping logic from the `GPUAdapter` struct to a new
`DroppableGPUAdapter` struct.

Testing: No tests added.
Fixes: Partially #26488

Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
2026-01-15 07:13:52 +00:00
Sam
2def1fbdce script: &mut JSContext in cross_origin_own_property_keys and append_cross_origin_allowlisted_prop_keys (#41879)
Testing: Just refactor, but should be covered by WPT tests.
Fixes: #40600

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-01-13 15:49:09 +00:00
Sam
5b11f7619e script: add &mut JSContext to codegened toJSON (#41878)
Testing: Just refactor, but should be covered by WPT tests
Part of #40600

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-01-13 14:48:57 +00:00
Sam
5173ea12cd script: More &mut JSContext in codegen (#41808)
Reviewable per commit. First commit adds `&mut JSContext` to
`call_default_constructor`. Second commit adds `&mut JSContext` to
Interface, which in unfortunately required many changes (a lot of
passing `&mut JSContext` down).

Testing: Just a refactor, but should be covered by WPT
Part of #40600

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-01-09 14:50:54 +00:00
Sam
b1245dce4c script: Use &mut JSContext in html_constructor (#41782)
Testing: Just refactor, but should be covered by WPT.
Part of #40600

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-01-08 21:09:48 +00:00
Domenico Rizzo
4d7e4a3b86 26488 - Moves CookieStore drop logic to a separate struct (#41783)
Refactors the `CookieStore` to use a separate `DroppableCookieStore`
struct for handling the drop logic.

Testing: No tests added
Fixes: Partially #26488

Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
2026-01-08 21:06:17 +00:00
Domenico Rizzo
2bcad737fa 26488 - Moves WebGLRenderingContext cleanup to a dedicated struct (#41717)
Refactors the WebGLRenderingContext to manage resource cleanup via a
dedicated `DroppableWebGLRenderingContext` struct.

Testing: This task is only a refactor, no tests added
Fixes: partially #26488

Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
2026-01-07 04:24:17 +00:00
Wayne Van Son
5b9263690d Refactor allow to expect (#41586)
Replace `allow` with `expect` lints for `unused`, `unsafe_code`,
`dead_code`, and `non_upper_case_globals`.

Testing: So far just check it compiled on `x86_64-linux` on NixOS. Need
to use the module `system.fontconfig.enable = true;` I think in my NixOS
config.
Part of: #40383 

Searching `allow\(.*\)` for `.rs` files shows the following. for
(total_results:total_files) went from `707:386` to `675:368`, a
reduction of `32:18`.

How many files is too many files per PR? I feel like the 20-30 I have is
too big.

---------

Signed-off-by: Wayne Van Son <waynevanson@gmail.com>
2026-01-01 13:40:20 +00:00
Kingsley Yung
96ddb0bbf0 script: Implement WebCrypto encapsulation and decapsulation with ML-KEM (#41617)
Complete the ML-KEM support in WebCrypto API, with the implementation of
the "encapsulate" and "decapsulate" operations of ML-KEM, as well as
four new methods `encapsulateKey`, `encapsulateBits`, `decapsulateKey`
and `decapsulateBits` of `SubtleCrypto`.

Specification:

https://wicg.github.io/webcrypto-modern-algos/#ml-kem-operations-encapsulate

https://wicg.github.io/webcrypto-modern-algos/#ml-kem-operations-decapsulate

https://wicg.github.io/webcrypto-modern-algos/#SubtleCrypto-method-encapsulateKey

https://wicg.github.io/webcrypto-modern-algos/#SubtleCrypto-method-encapsulateBits

https://wicg.github.io/webcrypto-modern-algos/#SubtleCrypto-method-decapsulateKey

https://wicg.github.io/webcrypto-modern-algos/#SubtleCrypto-method-decapsulateBits

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

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2026-01-01 13:30:04 +00:00
Sam
d1ba789482 script: Obtain &mut JSContext at the start of the script and pass it down to msg handlers (#41564)
At the start of the script we create first (and only[^1]) safe
`JSContext`, from where we should pass it down to every code that needs
the cx. This PR brings it all the way down to message handlers. There is
clear separation between functions that use new model `&mut JSContext`
and the ones that use the old model (usually they take can_gc).

[^1]: Another place of construction are SM hooks (that pass us down raw
JSContext), but to reach that point we already needed to call another
function that takes `&mut JSContext`, so one can look at this case as
reentering/reborrowing (we derive new shorter `&mut JSContext` from the
old one).

Testing: This is just refactor, but should covered by WPT tests.
Part of #40600

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-12-30 18:19:41 +00:00
Sam
6e0e50505e script: Use more new JSContext/CurrentRealm in crossorigin codegen (#41537)
reviewable per commit

Testing: Should be covered by WPT tests.
try run: https://github.com/sagudev/servo/actions/runs/20540365373
Part of #40600

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-12-27 15:59:32 +00:00
Sam
600accba82 script: Support new context for promise and add some more helpers to ease migration (#41520)
This PR adds support for using new JSContext/CurrentRealm to promise and
adds some more helpers that will ease migration to new context model.
Second commit has another demo.

Testing: Covered by WPT
Part of #40600

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-12-27 13:11:37 +00:00
Gregory Terzian
9cd480f7ee indexeddb: implement databases concept(detete and databases method) (#41322)
Moves the concept of databases closer to the 3.0 spec, by implementing
the delete functionality, and the method returning current databases to
script.

Testing: WPT tests with new passes
Fixes: The "Implement databases deletion and `databases`" item of
https://github.com/servo/servo/issues/40983

---------

Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
2025-12-23 14:09:48 +00:00
Steven Novaryo
b68d277c55 script: Add stub VisualViewport Interface (#41372)
Add placeholder implementation of DOM `VisualViewport` according to the
spec https://drafts.csswg.org/cssom-view/#visualviewport. This is the
first step of implementing the interface and syncing it with the
`PinchZoom` struct that we had in the `Embedder`.

Since this interface's is not accurate and couldn't fulfill it's
purpose, it would be gated behind a preference
`dom_visual_viewport_enabled` and would be open after the interface had
been integrated with `PinchZoom`, viewport resizing, and viewport
scroll.

Testing: Existing WPT Test.
Part of: #41341

---------

Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>
2025-12-23 09:56:13 +00:00
Martin Robinson
75c6dc845f stylo: Enable vendor-prefixed properties (#41350)
This changes updates to the latest version of stylo which includes
vendor-prefixed properties such as `-moz-transform` and
`-webkit-transform`. This allows more web content to render properly.

Note: Unitless perspective is not supported as part of this yet, but
will be once https://phabricator.services.mozilla.com/D274128 is part
of our downstream version of Stylo.

Testing: There are tests for this change.
Fixes: #17635.
Fixes: #14941.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-12-17 19:08:43 +00:00
Josh Matthews
d86d2a90aa script: Use rooted typed arrays in generated code and buffer source APIs (#41228)
There are two flavours of the mozjs `TypedArray<T>` wrapper for typed
array objects: one stores a `Box<Heap<*mut JSObject>>`, while the other
just has a bare `*mut JSObject`. The second one must only be stored
inside the `CustomAutoRoot` rooting values, but we were using it in many
other places like WebIDL dictionaries without rooting it safely. These
changes make our typed array APIs always use
`RootedTraceableBox<TypedArray<T>>` with the `Box<Heap<*mut JSObject>>`
flavour, which ensures that the JS object stored inside the typed array
wrapper is always visible to the SpiderMonkey GC.

Testing: Adds a new test that crashes without these changes.
Fixes: #41206

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-12-12 14:33:45 +00:00
Josh Matthews
d7234379dd script_bindings: Remove Drop impl exception for WebGLProgram. (#41124)
The handwritten Drop implementation was removed in #37622, so we can now
remove the exception for it.

Testing: Compile-time generated code can't be meaningfully tested.
Fixes: part of #26488

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-12-08 05:23:47 +00:00
Domenico Rizzo
34160f994c script: Move WebGLProgram Drop implementation to a member type (#37622)
Testing: No new tests introduced
Fixes: Partially #26488

Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
2025-12-07 22:18:46 +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
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
Josh Matthews
f2d13a98d9 script: Improve spec-compliance of Performance resource timing entries (#40811)
The current implementation doesn't match the specification and is broken
in a way that makes nytimes.com endlessly attempt to enqueue resource
timing entries, making the page completely unresposive to user input.
This PR makes some surgical changes that fix the NYTimes behaviour and
add some comments to make it easier to further improve the
implementation in the future.

Testing: Various WPT that used to timeout now fail instead.
Fixes: #40808

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-11-22 08:59:07 +00:00
Sam
c27f8c565a Use safe JSContext/AutoRealm/CurrentRealm in codegen (#40716)
We replace many places that use `SafeJSContext` with `JSContext` and I
also rewrote `is_platform_object_same_origin` to use new `JSContext`.
Unfortunately using wrappers2 in them causes crashes (in handle code),
so I reverted that part in last commit and will fix handles in mozjs
later.

Testing: Refactor, but it is covered by WPT tests
Part of #40600

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-11-19 05:55:55 +00:00
Tim van der Lippe
8e0c2d5750 Implement WindowOrWorkerGlobalScope::reportError (#40654)
This web API is alternative API to `throw e`, which is why we can reuse
a lot of the existing machinery.

The one testcase that isn't passing yet is because it reports an empty
`TypeError`. The current logic in `ErrorInfo` only retrieves the message
data, but doesn't include the type of the exception. For that, we need
to use `(*report)._base.errorNumber` and map that back to the original
type codes. However, deferring that to a follow-up as that requires some
more work in mozjs.

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-11-16 09:30:16 +00:00
Sam
fa12f7a5e5 script: Add cx_no_gc/cx/realm codegen option and demostrate them (#40582)
Companion to https://github.com/servo/mozjs/pull/650

We added 3 new options to bindings.conf, each more powerful then the
previous one, so one should use the least powerful as possible to keep
things flexible:
1 `cx_no_gc` prepends argument `&JSContext`, which allows creating NoGC
tokens and using functions that do not trigger GC.
2. `cx` prepends argument `&mut JSContext`, which allows everything that
previous one allows, but it also allows calling GC triggering functions.
3. `realm` prepends argument `&mut CurrentRealm`, which can be deref_mut
to `&mut JSContext` (so it can do everything that previous can), but it
also ensures that there is current entered realm, which can be used for
creation of InRealm.

next steps: #40600 

reviewable per commit

Testing: It's just refactoring
try run: https://github.com/sagudev/servo/actions/runs/19287700927

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-11-16 04:53:54 +00:00
Taym Haddadi
4658fc333a Add AbortSignal garbage collection (#40508)
Add AbortSignal garbage collection

Testing: all AbortSignal should pass.

Fixes: #40481

---------

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2025-11-13 10:58:55 +00:00
Andrei Volykhin
59526928af html: Remove canGC argument from <media> internal seek method (#40587)
The `seek` method isn't explicitly exposed in the API, but is called
from various places (`currentTime`, `fastSeek`, by the `media metadata`
event) and doesn't itself create new DOM objects, so the `canGC`
argument can be omitted.

It was previously required because calling the `Seekable` method creates
a new `TimeRanges` object, but it will now be replaced by the internal
`seekable` method to avoid interaction with the JavaScript engine (and
potential garbage collector).

The `earlyest possible position` method has been changed to match the
specification and use `seekable` instead of `played`. See
https://html.spec.whatwg.org/multipage/#earliest-possible-position

Testing: No expected changes in tests

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-12 18:44:15 +00:00
Rocketjumper
9c05abe5f3 Fixed codegen to prevent double declaration of -webkit- prefixed CSS properties (#40549)
Removed the following on `script_bindings/codegen/run.py`:

```
# https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-webkit-cased-attribute
    if property_name.startswith("-webkit-"):
        yield "".join(camel_case(property_name, True))
```
Credits to @jdm !


Fixes: issue #40545

---------

Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
2025-11-11 03:24:06 +00:00
Taym Haddadi
28dd9f9749 Implement read looping using a read request following the spec (#39510)
Implement read looping using a read request following the spec.

Testing:  current wpt test should pass.
Fixes: #39482

---------

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2025-11-09 22:05:12 +00:00
Luke Warlow
e3c4655463 Partially implement dialog.showModal() (#40405)
Partially implement dialog.showModal()

Follow-ups will be needed to further implement proper dialog
functionality but this makes a good start.

Testing: Existing WPTs cover this.

---------

Signed-off-by: Luke Warlow <lwarlow@igalia.com>
2025-11-05 15:03:13 +00:00