Commit Graph

1042 Commits

Author SHA1 Message Date
eri
f53a259216 devtools: Handle getEnvironment message (#43167)
Initial work to support scopes in the debugger. They don't show at the
moment since we are not processing variables yet. Depends on #43166.

Testing: Ran `mach test-devtools` and manual testing.
Part of: #36027

Signed-off-by: eri <eri@igalia.com>
Co-authored-by: atbrakhi <atbrakhi@igalia.com>
2026-03-12 13:13:03 +00:00
Euclid Ye
0153f2ff0a embedder_traits: Upgrade InputEventHandled to InputEventsHandled to batch IPC response (#43169)
We send back input events handling results in batch. This reduces IPC,
and make the following **TODO** possible in a follow-up.

Testing: I hope existing tests results won't change.
Part of
https://github.com/servo/servo/issues/43136#issuecomment-4031915873
**TODO**: We have not done 
> collect ids and send back a reply for each of them once the coalesced
event has been handled.

yet.

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2026-03-11 10:14:25 +00:00
Gae24
bc1cd2ceeb script: bump mozjs to use SpiderMonkey 140.8 and set more compile options (#43020)
Set `mutedErrors_`, `noScriptRval`, `isRunOnce` compile options.

Testing: A test now passes
Part of #38378

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2026-03-10 17:02:19 +00:00
Brent Schroeter
4c69d856f6 tools: Support tab navigation via navigateTo, goBack, and goForward (#43026)
Add support for navigation requests ("navigateTo", "goBack", and
"goForward") over the Remote Debugging Protocol. These may be sent by a
UI client in response to user input (for example the address bar in the
Firefox inspector), or they can be used to automate navigation during
unit tests.

This currently only supports navigation within the URL domain at which
servoshell is initially launched, due to a bug in servo's
`BrowsingContextActor` implementation. (Unit tests covering a fix for
that issue will depend on this change.)

Testing: The behavior of all 3 new message types is covered by a new
test case—`test_navigation`—in the devtools unit test suite.
Fixes: #38668

---------

Signed-off-by: Brent Schroeter <contact@brentsch.com>
Co-authored-by: eri <eri@igalia.com>
2026-03-06 09:13:39 +00:00
atbrakhi
9a915ece22 devtools: Pass ListFrames back to devtools (#43039)
Pass `ListFrames` back to devtools

Testing: existing test passes
Fixes: part of #36027

Signed-off-by: atbrakhi <atbrakhi@igalia.com>
Co-authored-by: eri <eri@igalia.com>
2026-03-06 08:47:15 +00:00
atbrakhi
1b7ec96fb6 devtools: implement listing all frames (#43015)
This change implements listing all frames from youngest to oldest. This
is in order to send correct frame message from thread actor

This is needed for our upcoming work!

Testing: Current tests are passing + manual test
Fixes: #36027

Signed-off-by: atbrakhi <atbrakhi@igalia.com>
Co-authored-by: eri <eri@igalia.com>
2026-03-05 14:58:30 +00:00
Martin Robinson
b47b39f974 script: Distinguish between sequential (keyboard) and click focusability (#43019)
This changes makes it so that keyboard and click focusability are two
separate concepts in `script`. Some elements may be focusable only by
the keyboard and some only by the click events.

In addition, the `SEQUENTIALLY_FOCUSABLE` `Node` flag is removed in
favor of a
more specification-aligned approach of checking lazily if an element is
a focusable area. This allows moving the focus fixup steps to their
correct place, asynchronously during "update the rendering" and
synchronously during `unbind_from_tree`.

Testing: This causes some WPT tests to start passing and some to start
failing:
- Two subtests tests in
`tests/wpt/meta/css/css-conditional/container-queries/` because
we do not implement support for container queries. These are legitimate
failures
   and they are compensated by a good subtest pass in the same file.
- A few subtests in `/html/interaction/focus/tabindex-focus-flag.html`
because now
we do not allow focusing non-rendering elements. The failures are HTML
elements with
`<svg>` which we do not rendering and `<summary>` elements of
`<details>` which
   need special handling we do not implement yet.
- `html/semantics/forms/the-fieldset-element/disabled-003.html`: Some of
these tests
start to fail, but they are not spec compliant and browser properly
implementing
   the asynchronous focus fixup rule also fail them. 

Fixes: #31870.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2026-03-05 08:58:59 +00:00
Josh Matthews
f206571869 layout: Prevent DomRefCell::borrow from being used in layout code (#42976)
DomRefCell::borrow inside of layout code is risky because it leads to
memory races if the code is ever called from layout worker threads. This
can be caught via TSAN, but we can also catch it deterministically in CI
by using our existing thread state debug assertions correctly.

Testing: Existing WPT test coverage is sufficient.
Fixes: #42962

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2026-03-04 06:44:39 +00:00
atbrakhi
630e4b75da devtools: Implement frame scoped evaluation (#42936)
When paused at a breakpoint, hovering over local variables now shows
their value. Previously `eval` used `executeInGlobal()` which could not
access local scope, so hovering showed `ReferenceError` instead of the
actual value.


https://github.com/user-attachments/assets/05247b82-4e4d-422d-a428-63e46b55d55f

Testing: Added a new test
Fixes: Part #36027

Signed-off-by: atbrakhi <atbrakhi@igalia.com>
2026-03-03 14:22:25 +00:00
eri
88f2469270 devtools: Implement initial support for Step in, Step out and Step over (#42907)
We are adding initial support for stepping in the debugger. Step over
mostly works, but Step in and Step out have some quirks that we are
working on.

![2026-02-27
12-32-05](https://github.com/user-attachments/assets/0b73b32c-efa3-444c-80a4-f863a64b6fdc)

Testing: DevTools tests and manual checks.
Part of: #36027

Signed-off-by: eri <eri@igalia.com>
Co-authored-by: atbrakhi <atbrakhi@igalia.com>
2026-03-02 18:35:02 +00:00
webbeef
1ad41dc15f script: Add a ServoInternals.garbageCollectAllContexts() (#42798)
This is useful in about:memory to measure memory usage after running the
GC.

The calling page sends a callback to the constellation that in turn wait
for all script threads to run the GC and report back.

Testing: Manual testing in `about:memory`

Before running GC:

<img width="2048" height="1480" alt="Screenshot from 2026-02-23
18-50-46"
src="https://github.com/user-attachments/assets/fd8399c1-fbc7-4f4c-886d-f29629ef8369"
/>

After running GC:

<img width="2048" height="1480" alt="Screenshot from 2026-02-23
18-51-00"
src="https://github.com/user-attachments/assets/82c793f7-8229-4de4-9cb5-47c94383b410"
/>

Signed-off-by: webbeef <me@webbeef.org>
2026-02-28 08:38:32 +00:00
Gae24
49b13627b5 script: Propagate &mut JSContext inside evaluate_js_on_global (#42846)
Since `evaluate_js_on_global` called `enter_realm` and there were
already some callee that did it, I've actually passed `&mut
CurrentRealm`.
Also converted `Window::WebdriverException` to pass `&mut JSContext`
inside `javascript_error_info_from_error_info`.

Testing: A successful build is enough
Part of #40600

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-02-27 11:49:44 +00:00
Steven Novaryo
d70ab4e1c0 script: Merge ScrollEvent with SetScrollStates messages (#42834)
Remove embedder defined `ScrollEvent` and merge the payload of it to the
`SetScrollStates` message which tell the `ScriptThread` to update the
scroll state.

In the past, `ScrollEvent` is defined as a embedder's `InputEvent` and
being used only to forward the external scroll node id for a node that
is considered scrolled. This make us sends an additional message to
constellation and additionally, `ScrollEvent` went through lengthy
pipelines as it was deemed as an embedder input event, albeit being a
synthetic input fired by `WebviewRenderer`.

Subsequently, we could introduce a flag to detect whether the scrolling
is still ongoing or not (like whether it is still flinging) for
`scrollend` event.

Testing: No WPT changes

---------

Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2026-02-26 07:36:55 +00:00
Oriol Brufau
d5c82150e0 layout: Add testing API for counting restyled and rebuilt fragments (#42817)
Now `ServoTestUtils.forceLayout()` will provide the number of fragments
that have been restyled and rebuilt. This will be useful to test that
incremental layout works well.

Testing: Adds a test using this new API

---------

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Luke Warlow <lwarlow@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2026-02-25 21:25:32 +00:00
Simon Wülker
ea8375beaf script: Remember which nodes the devtools know about (#42785)
Currently, `script` and `devtools` use a node's unique id to identify it
across requests. The unique ID is part of a node's rare data field and
is really only meant for debugging. Instantiating it on a node causes
it's memory usage to go up significantly. Now, when the devtools ask for
information about a specific `Node` then they send the unique ID to
`script`, and the script thread then walks the whole DOM tree searching
for that specific ID. This happens here:

6d0b651218/components/script/devtools.rs (L142-L153)

So, in the worst case, all of the nodes in the tree now have a unique
ID. That's not great!

Also, when `script` notifies `devtools` about changes to a DOM node then
`devtools` expects a `NodeActor` to exist for that Node. The actor might
not exist if the inspector doesn't know about that node yet - that
happens when the user hasn't expanded their parent yet.
That is an oversight from https://github.com/servo/servo/pull/42601 and
causes problems now(https://github.com/servo/servo/issues/42784) because
for the longest time, `devtools` was mostly the one sending requests. Of
course, we could make `devtools` simply ignore updates for nodes that it
doesn't know about, but ideally we shouldn't send these updates in the
first place.

This change implements a lookup map on the `ScriptThread` that contains
all nodes that have been sent to the devtools inspector. The map allows
us to efficiently resolve a unique ID to a `Node` in O(1), without
creating unique IDs for the whole tree. It also allows us to only send
DOM updates for nodes that the inspector cares about.

For now, entries from the cache are not evicted unless the relevant
pipeline is closed. That reflects reality, because the inspector also
keeps using them forever.
In the future we will tell the inspector when nodes are removed from the
tree - then it can't interact with them anymore, and we can remove them
from the script-side map.

This is change is not all that complicated but it involves moving a lot
of code around, so feel free to ask for clarification when something is
unclear!





Testing: This change adds a test
Fixes part of https://github.com/servo/servo/issues/42784

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2026-02-25 12:35:52 +00:00
Sam
6c334f2811 script: Replace RAII of CallSetup and AutoEntryScript with a function wrapper (#42715)
As mentioned in #40600 we will need this to properly handle &mut
JSContext (we cannot pass it to drop) and I think this wrappers are
preferred ways of doing this in rust as it is safe to forget (not call
drop) which is unsound in this case (due to realm stack at least).

Revieable per commits.

Testing: Just a refactor, but should be covered by WPT

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-02-25 09:13:18 +00:00
Sam
3e2f14c455 script: Pass down &mut JSContext in servoparser and event loop. (#42635)
I only wanted to get `&mut JSContext` in microtask chunk and checkpoint,
but this in turn needed `&mut JSContext` in servoparser, which then
caused need for even more changes in script.

I tried to limit the size by putting some `temp_cx` in:
- drops of `LoadBlocker`, `GenericAutoEntryScript`
- methods of `VirtualMethods`
- methods of `FetchResponseListener`

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

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-02-25 07:14:23 +00:00
eri
92259af702 devtools: Unify pause handling for breakpoints and interrupt (#42599)
The pause debugger screen should be shown for both pausing manually
(interrupt) and hitting a breakpoint.

Reuse the logic for pausing breakpoints to pause the debugger when the
user manually clicks the pause button.

Rename the pause event to interrupt to match the language of the
DevTools client and to avoid confusion with paused frames, which can
happen on interrupt or on a breakpoint.


https://github.com/user-attachments/assets/ceb0007d-0e57-44d6-a159-55980ff8b517

Testing: New DevTools test and manual testing.
Part of: #36027

cc @atbrakhi

---------

Signed-off-by: eri <eri@igalia.com>
Co-authored-by: atbrakhi <atbrakhi@igalia.com>
2026-02-23 09:29:59 +00:00
Sam
43bdd3818d script: Pass &mut JSContext to more dom methods (#42751)
split from https://github.com/servo/servo/pull/42635, some dom methods
are also called from other function, which require passing down cx from
many more places :(

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

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-02-22 13:22:33 +00:00
Sam
9f1e5d084e script: Pass &mut JSContext in FetchResponseListener::process_response_eof (#42729)
`process_response_eof` is the only method that needs cx at least right
now. This PR removes one temp_cx and introduces one, removing that one
will is hard (needs VirtualMethods and a lot of work)

Testing: Just refactor
Part of #40600

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-02-20 16:03:21 +00:00
shuppy
c07682f222 libservo: Allow the embedder to activate accessibility (#42336)
this patch adds a Servo::set_accessibility_active() method that
embedders can use to tell Servo to start building and sending
accessibility trees to the platform, as long as the pref is enabled
(#42333). doing so sets a global flag in the constellation, which is
then propagated to the layout of all existing and future pipelines.

Testing: none yet, no functional change
Fixes: part of #4344

---------

Signed-off-by: delan azabani <dazabani@igalia.com>
Signed-off-by: Alice Boxhall <alice@igalia.com>
Co-authored-by: Alice Boxhall <alice@igalia.com>
2026-02-20 05:56:15 +00:00
atbrakhi
3c8c46d32f devtools: implement pause and resume in debugger (#42580)
When a breakpoint is hit, the script thread now pauses execution and
notifies devtools clients with a "paused" event. The script
thread enters a loop that processes devtools messages until
a Resume command is received.

This change does not implement manual pause

Testing: Added new test
Fixes: part of https://github.com/servo/servo/issues/36027




https://github.com/user-attachments/assets/c619db20-4579-4f77-aa60-0e43e6e7e575

Signed-off-by: atbrakhi <atbrakhi@igalia.com>
2026-02-18 10:08:46 +00:00
Martin Robinson
6842da5f5b script: Use the Weak<ScriptThread> reference for tracing instead of thread-local storage (#42657)
This changes makes it so that tracing accesses the `ScriptThread` via a
weak reference set on the `Runtime` rather than thread local storage.
The idea is to use TLS less and less as time goes on. This is done by
creating a new data structure that holds all the data that is necessary
for SpiderMonkey callbacks in the `ScriptThread`.

Testing: This should not change behavior in a way that is observable
via testing.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-02-16 14:45:55 +00:00
Gae24
c13d8a2eff script: Start using &mut JSContext in devtools and webdriver code (#42640)
This is a first step to compile scripts using `&mut JSContext`.

Testing: Refactor, covered by existing WPT tests.
Part of #40600

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-02-16 08:32:08 +00:00
Josh Matthews
ab85eafc7e Revert "script: Introduce end of loading phases" (#42562)
Reverts servo/servo#42446 . Too many new intermittent timeouts caused by
missing document load events.

Fixes: #42555
Fixes: #42556
Fixes: #42560
Fixes: #42557
Fixes: #42561 
Fixes: #42559 
Fixes: #42554
2026-02-12 04:10:30 +00:00
Tim van der Lippe
94f418c6e6 script: Introduce end of loading phases (#42446)
Since the steps for
https://html.spec.whatwg.org/multipage/parsing.html#the-end are
scattered throughout various pieces, it has been difficult to figure out
when to run what.

To remedy that, introduce the concept of phases. These phases are
checked in every method that needs to
"Spin the event loop" to know whether

1. It is the appropriate time to continue with #the-end
2. It has fully achieved its goal

For example, when processing deferred scripts, we need to do this after
a deferred script has finished loading. But we also need to do it at the
start of parsing, since we might not have any deferred scripts at all.

Therefore, each previous step sets the appropriate phase and calls the
corresponding next step. Each step then verifies its conditions and
continues if required.

Part of #41972

---------

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
2026-02-11 21:45:14 +00:00
Simon Wülker
929e275fcd devtools: Show attached event listeners in inspector tab (#42355)
This change makes the devtools inspector show any event listeners that
are attached to a node. The primary motivation is making the devtools
more useful for debugging real-world websites.

<img width="536" height="268" alt="image"
src="https://github.com/user-attachments/assets/5ba13e41-14b4-4202-b994-eadff5d1c6b5"
/>

You can also click on the event listener to show some more info, though
most of that (everything except the event type and the event phase) is
currently just placeholder text:

<img width="1360" height="456" alt="image"
src="https://github.com/user-attachments/assets/ec025847-43fc-489c-8b26-46afb6dada64"
/>


Testing: This change adds a new test

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2026-02-11 13:31:25 +00:00
atbrakhi
d6097d1967 devtools: Implement debugger Eval event (#42306)
Replace the `EvaluateJS` function to use `debugger.js` `Eval` event and
the proper context. This takes the global context and calls
[executeInGlobal](https://firefox-source-docs.mozilla.org/js/Debugger/Debugger.Object.html#executeinglobal-code-options).

In future we also add the version that takes a frame and calls
[eval](https://firefox-source-docs.mozilla.org/js/Debugger/Debugger.Frame.html#eval-code-options).

Testing: No new tests added yet, Old tests are not impacted by this
change.
Fixes: Part of https://github.com/servo/servo/issues/36027

---------

Signed-off-by: atbrakhi <atbrakhi@igalia.com>
Co-authored-by: eri <eri@igalia.com>
2026-02-09 12:58:51 +00:00
Mukilan Thiyagarajan
79ed814ec1 libservo: Expand the UserContentManager API. (#42288)
The patch adds the following functionality to the per-WebView
`UserContentManager` API.
- Removing a `UserScript` at that was previously added.
- Adding a new `UserStyleSheet` representing a user-origin style sheet.
allow removing user script
- Removing a previously added `UserStyleSheet`.

There might be scope for some improvements in the API:
- `UserScript` and `UserStyleSheet` have different ways of representing
the source location - a `PathBuf` and `Url` respectively. This is due to
how those values are used by the underlying evaluation APIs in script
and stylo. More investigation is needed here and could be addressed in
future patches.

Testing: New unit tests are added for the user stylesheet APIs. Existing
tests have been updated to test the removal of user scripts.
2026-02-05 13:26:54 +00:00
Osoro Bironga
8d4f2db3c9 script: Start a performance timeline entry for iframe documents (#42270)
Added resource timing that was missing for an iframe document.

Testing: Added
Fixes: https://github.com/servo/servo/issues/41666

---------

Signed-off-by: Osoro Bironga <fanosoro@gmail.com>
2026-02-03 16:07:10 +00:00
Narfinger
db052c4990 script: Change some HashSets to FxHashSet (#42257)
This changes 3 occurences of HashSet to FxHashSet for speed
improvements:
- dom/notifications::pending_request_ids: Pending Request ids are
Uuid::new_v4, hence, not user assignable.
- script_thread: painters_generating_frames: These are pipeline ids and,
hence, ideal for FxHash.
- script_thread:: docs_with_no_blocking_loads: These are Dom<Document>
and their hash is the ptr address, so ideal for FxHash.

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

Testing: These do not change functionality.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2026-01-30 17:02:58 +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
Tim van der Lippe
c0b55a2c34 script: Add about_base_url (#42104)
We populate the required field for all relevant entrypoints
and set it to `document.base_url` when the url is `about:blank`
or `about:srcdoc`. In all other cases, it uses
`document.about_base_url`.

Testing: WPT
Fixes #41836

---------

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-01-27 18:09:01 +00:00
atbrakhi
e28a0f6d6c devtools: implement clearBreakpoint (#42154)
Add an event listener for `clearBreakpoint` to `debugger.js` and the
necessary glue to access it from the `devtools` crate.

Testing: `./mach test-devtools` and manual testing.
Fixes: Part of: https://github.com/servo/servo/issues/36027

---------

Signed-off-by: atbrakhi <atbrakhi@igalia.com>
Co-authored-by: eri <eri@igalia.com>
2026-01-27 15:46:54 +00:00
Martin Robinson
9c9d9c863f Rename compositing and compositing_traits to paint and paint_api (#42066)
This change finishes the big rename associated with the old
`compositing` crates. Long ago, these crates managed a compositor, like
you might find in a traditional web engine. These days, compositing is
done in WebRender so the name has stopped making much sense. Various
structs inside the crates have already been renamed and this is the
final big change necessary for the rename

Testing: This is just a rename so existing tests should cover it.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-01-24 09:17:35 +00:00
Narfinger
71cc3b2382 WebGPU: Use GenericChannel (#42032)
Switching WebGPU component to use GenericChannel.

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

Testing: Compilation is the test.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2026-01-21 05:59:18 +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
Josh Matthews
a97a345d6e script: Check same-origin-domain when evaluating javscript: URLs. (#41969)
These changes introduce a new OriginSnapshot type, which is an immutable
version of MutableOrigin (ie. an origin that includes an optional domain
modifier). This is now propagated as part of LoadData's origin, allowing
us to perform the same-origin-domain check for javascript: URLs as
needed.

Testing: Newly-passing tests.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2026-01-18 02:32:51 +00:00
shuppy
c2530a49ee Plumb accessibility tree updates from layout to embedder (#41924)
this patch adds some new methods and messages that allow layout to send
the embedder [accessibility tree
updates](https://docs.rs/accesskit/0.22.0/accesskit/struct.TreeUpdate.html):

- layout —[ ScriptThreadMessage::AccessibilityTreeUpdate ]→ script
- script —[ EmbedderMsg::AccessibilityTreeUpdate ]→ libservo
- libservo —[ WebViewDelegate::notify_accessibility_tree_update() ]→
servoshell
- servoshell —[ PlatformWindow::notify_accessibility_tree_update() ]→
servoshell
- servoshell —[ Gui::notify_accessibility_tree_update() ]→ servoshell

Testing: none yet, no functional change
Fixes: part of #4344

---------

Signed-off-by: delan azabani <dazabani@igalia.com>
Co-authored-by: Luke Warlow <lwarlow@igalia.com>
Co-authored-by: Alice Boxhall <alice@igalia.com>
2026-01-16 12:32:08 +00:00
eri
9d35414386 devtools: Handle the setBreakpoint message. (#41925)
Listen for `setBreakpoint` on `debugger.js` and add the relevant WebIDLs
and Servo counterparts to trigger this event and notify SpiderMonkey.

Implement `find_source` for `SourceManager` and `find_offset` for
`SourceActor`.

Testing: Manual testing and `./mach test-devtools` (note, the latter
seems to have some failing tests, we are investigating this, but this
patch doesn't add any new failure).
Fixes: Part of #36027

---------

Signed-off-by: eri <eri@igalia.com>
Co-authored-by: atbrakhi <atbrakhi@igalia.com>
2026-01-16 10:17:55 +00:00
Laurent Belmonte
0dc28296e0 script: Some failed requests should record resource timing entries (#41804)
Some failed requests should record resource timing entries

Testing: ./mach test-wpt
tests/wpt/tests/resource-timing/entries-for-network-errors.sub.https.html
Fixes: https://github.com/servo/servo/issues/41667

---------

Signed-off-by: bellau <laurent.belmonte@gmail.com>
2026-01-14 13:20:12 +00:00
Euclid Ye
014fb968a8 webdriver: Consolidates synchronous and asynchrounous script execution (#41830)
Follow-up to #41823.
Now that we always execute JS with callback, we can safely remove the
obsolete sync script handler.

- Rename `ExecuteAsyncScript` to `ExecuteScriptWithCallback`
- Remove `ExecuteScript` related logic.
- Rewrite async callback wrapper to simplify things.

Testing: I expect no change in behaviour. See if WPT tests agree with
it.

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2026-01-11 09:19:09 +00:00
WaterWhisperer
2a759ed6de Replace allow(crown::unrooted_must_root) with expect(crown::unrooted_must_root) (#41815)
Testing: `./mach build -d --use-crown` with no warnings
Fixes: #41761

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2026-01-10 08:05:49 +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
89067e5450 script: Pass &mut JSContext to tasks (#41756)
This change is reviewable per commits:
In first commit we added `&mut JSContext` to `run_box` (it is very hard
to bring `&mut JSContext` to `remove_script_and_layout_blocker`).
In second commit we pass `&mut JSContext` to `run_once`.
In third commit we added support for accepting `&mut JSContext` in
closures of `task!` macro and lastly we demo new macro invocations (to
ensure they actually compile)

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 07:49:27 +00:00
Sam
38306eaf7b script: Init and pass down &mut JSContext in script-related threads (#41692)
1. removed `ScriptThread::get_safe_cx` in favor of `Runtime::cx` (this
intentionally shadows
[RustRuntime::cx](https://doc.servo.org/mozjs/rust/struct.Runtime.html#method.cx),
which is not really safe with all other stuff that happen in servo).
2. passed down cx from `ScriptThread::new` to accommodate those changes
(we also need to pass cx for some other stuff).
3. we create JSContext in workers/worklets, so we can pass all the way
down to
6ccc47f4c9/components/script/dom/workers/workerglobalscope.rs (L1013)
(so we can get &mut JSContext in tasks).

So with this PR, we prepared all entry points of JSContext (or other
should actually be reentering via SM callback or passed down from the
root one in the thread).

Testing: No changes just safety, but it should be covered by WPT
Part of #40600

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-01-06 18:27:10 +00:00
Tim van der Lippe
d44c38998c net: Keep track of size of keep-alive records (#41457)
These keep-alive records live on the `CoreResourceManager` since the vec
of records must be modified by the fetch thread. The script thread
sometimes
requires this information as well, which is why it can send a message to
obtain the total size.

The keep-alive records must be tracked per global. That's why all code
needs
to specify the `pipeline_id`. Requests optionally have this field, which
is why
the code expects it to be present. The relevant information is added to
the
navigator request to ensure it can compute it.

Fixes #41230

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-01-05 18:22:58 +00:00
Narfinger
94eafd4ef9 script: Store a Weak handle to ScriptThread in both ScriptThread and Window (#40645)
We construct `ScriptThread` in an `Rc` which itself has the given `Weak`
for it. It then can give it to `Window` and other elements in the
future. We currently only use this for the microtask checkpoint function
in `Window`. This is the first step toward eliminating the usage of
thread local storage to access the `ScriptThread`.

Testing: This should not change behavior so is covered by existing
tests.
Fixes: Part of addressing:
https://github.com/servo/servo/issues/37969#issuecomment-3520463442

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2026-01-05 13:20:19 +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
ffa4864f49 script: Remove redundant realm entering (#41565)
`spawn_pipeline` does not need realm entered and
`handle_fullscreen_exit` does realm entering on it's own:
133c9b4266/components/script/script_thread.rs (L2503)

try run: https://github.com/sagudev/servo/actions/runs/20567048851

Signed-off-by: Sam <16504129+sagudev@users.noreply.github.com>
2025-12-29 12:11:09 +00:00