Commit Graph

987 Commits

Author SHA1 Message Date
Martin Robinson
824f551f03 Rename IOCompositor to Paint (#41176)
For a long time, the "Compositor" hasn't done any compositing. This is
handled by WebRender. In addition the "Compositor" does many other
tasks. This change renames `IOCompositor` to `Paint`.

`Paint` is Servo's paint subsystem and contains multiple `Painter`s.
This change does not rename the crate; that will be done in a
followup change.

Testing: This just renames types and updates comments, so no new tests
are necessary.

---------

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-12-10 15:09:49 +00:00
Martin Robinson
87eeae7047 script: Remove reference to closed bug #18998 (#41162)
This bug was closed a while ago, so we should also remove in in code
reference to it.

Testing: This just removes an out-of-date comment so no tests necessary.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-12-09 17:46:06 +00:00
Narfinger
6f62269c8c Devtools: Switch to GenericChannel and GenericCallback (#41051)
Switch the devtools part to GenericCallback and GenericSender.
To keep the diff small the names where not changes as a Sender almost
fills the same requirement as a callback.

Testing: As this is mostly type changes, the compilation is the test but
also devtools seem to work fine with these changes. ./mach try run is
here: https://github.com/Narfinger/servo/actions/runs/19931697694

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-12-08 11:03:45 +00:00
Gae24
ae62ab7fa7 script: Expose a single interface to run js code on globalscope (#41078)
Small cleanup, avoid repeating some code, since in these cases we use
the defaults provided by `GlobalScope`

Testing: Covered by existing tests, no behaviour change.

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2025-12-05 15:27:52 +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
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
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
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
Mukilan Thiyagarajan
90595e3570 compositing: Support per-Painter operations and message handling (#40788)
Currently, only the first `Painter` is used for all operations in the
`Compositor`. This change modifies the compositor API and message
handling to allow routing the operations to the correct `Painter` via a
provided `PainterId` or `WebViewId`.

This change is to enable support for per-`WebView`s `RenderingContext`s.

Testing: This change shouldn't change behavior, so existing WPT tests
should cover it.

---------

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-11-21 13:15:55 +00:00
eri
c6f4c79814 devtools: Support reloading tab (#40760)
Allows to use the reload button from the top bar of `about:debugging`.

<img width="971" height="43" alt="Top bar of about:debugging showing the
tab, title, buttons for back, forward and reload and url bar"
src="https://github.com/user-attachments/assets/5496fcf1-5ee3-41cc-8fdb-53aad020ea96"
/>

Testing: Manual testing.

Signed-off-by: eri <eri@igalia.com>
2025-11-20 12:19:20 +00:00
Tim van der Lippe
e1b9c02de3 webdriver: implement protocol handler automation mode (#40733)
The tests now start running rather than erroring, but they aren't
working yet as we don't currently use protocol handlers yet. That's for
follow-up PRs, as that requires more plumbing.

Part of #40615

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-11-19 11:53:17 +00:00
Martin Robinson
0a1061d8d7 script: Use ScriptEventLoopSender for Runtime event loop callbacks (#40590)
Instead of using a task source for SpiderMonkey runtime callbacks, use a
`ScriptEventLoopSender`. Task sources are associated with a particular
Pipeline, but the runtime callback is run indepenently of any particular
Pipeline and could theoretically happen when no Pipeline exists at all.
This reduces the dependency of the `ScriptThread` on the existence of
the first Pipeline.

Testing: This should not change observable behavior, so is covered by
existing tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-12 18:16:59 +00:00
Martin Robinson
ab0f818583 script: Consolidate more logic into ScriptThread::spawn_pipeline (#40586)
Have more of the code follow the same path calling
`ScriptThread::spawn_pipeline`. Somewhat tricky was that the `origin` of
the new Pipeline was being determined in several different places, but
all in a consistent way for different types of page loads. This change
makes it is so that the origin is always determined in the same place.

This change is preparation for splitting out the creation of a new
`ScriptThread` and the spawning of its first pipeline.

Testing: This should not change observable behavior, so is covered by
existing tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-12 15:37:25 +00:00
Martin Robinson
65deada7ef script: Return only a JoinHandle from ScriptThread constructor (#40571)
The `JoinHandle` was added as a newer return value from this
constructor. Both return values accomplish more or less the same thing.
The difference is that the `Sender` return value is triggered right
before the thread ends while the `JoinHandle` is triggered after thread
completion. One was used in multiprocess mode and one in single process
mode. In any case, the `JoinHandle` works fine for both cases.

Testing: Multiprocess isn't tested currently, but I confirmed that the
ScripThread shut down properly in multiprocess mode with this change.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-12 05:40:28 +00:00
Martin Robinson
bfde51c0db script: Have FetchResponseListener::process_response_eof consume the listener (#40556)
The goal of this change is to prevent having to copy so much data out of
listeners when a fetch completes, which will be particularly important
for off-the-main thread parsing of CSS (see #22478). This change has
pros and cons:

Pros:
- This makes the design of the `FetchResponseListener` a great deal
simpler.
They no longer individually store a dummy `ResourceFetchTiming` that is
   only replaced right before `process_response_eof`.
 - The creation of the `Arc<Mutex<FetchResponseListener>>` in the
   `NetworkListener` is abstracted away from clients and now they just
   pass the `FetchResponseListener` to the fetch methods in the global.

Cons:
 - Now each `FetchResponseListener` must explicitly call `submit_timing`
   instead of having the `NetworkListener` do it. This is arguably a bit
   easier to follow in the code.
 - Since the internal data of the `NetworkListener` is now an
   `Arc<Mutex<Option<FetchResponseListener>>>`, when the fetching code
   needs to share state with the `NetworkListener` it either needs to
   share an `Option` or some sort of internal state. In one case I've
   stored the `Option` and in another case, I've stored a new inner
   shared value.

Testing: This should not change observable behavior and is thus covered
by existing tests.
Fixes: #22550

---------

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-11 22:30:40 +00:00
Martin Robinson
b334c9470b constellation: Reuse InitialScriptState and InitialPipelineState in UnprivilegedPipelineContent (#40529)
`UnprivilegedPipelineContent` contains all of the data necessary to
create a new `ScriptThread` with an initial `Pipeline` in a new
process. This change reuses the `InitialScriptState` and
`InitialPipelineState` structs inside `UnprivilegedPipelineContent` and
renames it to `NewScriptEventLoopProcessInfo` to clarify what it does.

In addition, `InitialScriptState` also repeated much of the data of
`NewPipelineInfo`, which is now deduplicated and passed separately to
the `ScriptThreadFactory`.

The overall goal here is to make `ScriptThread` and `Pipeline` creation
separate. A `ScriptThread` contains many `Pipeline`s which come and go,
so it should not depend on a single creation `Pipeline`. This is the
first step toward doing that.

Some inputs to `ScriptThreadFactory` differ based on whether the new
`ScriptThread` is created in a new process or not. This change makes it
so that these input are passed as extra arguments.

Finally these changes have revealed a couple members of data structures
that aren't used. These have been removed.

Testing: This is just a refactor and shouldn't change behavior so is
covered by existing tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-10 11:41:59 +00:00
Sam
b73b908dbd script: Start preparation to use safer JSContext (#40465)
This PR is companion to https://github.com/servo/mozjs/pull/638,
currently it only make stuff compile. In follwups we will start
passing/using safer JSContext down everywhere.

Testing: Not needed as it's just refactorings.
try run:
https://github.com/sagudev/servo/actions/runs/19196312972/job/54879090390

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-11-09 05:17:26 +00:00
Josh Matthews
cc1552e8a7 Suppress debug representations of network response bodies (#38789)
Adds a wrapper type for vectors that can contain large response bodies
to prevent flooding debug logs with the contents of those bodies.

Testing: Can't test debug log output.
Fixes: #37769

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-11-08 19:49:17 +00:00
Martin Robinson
0c0945c308 script: Handle more ScriptThread messages synchronously (#40490)
Make the handling of more messages to the `ScriptThread` happen
synchronously with the rest of the message handling. Previously these
had to be handled first, but the resiliency of the `ScriptThread` has
increased such that they can be done inline now. This simplifies message
handling.

Testing: This should not change observable behavior and is thus covered
by existing tests. In fact, no tests fail with this change which is
the reason we can do it.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-08 12:46:43 +00:00
Martin Robinson
dfc9819b38 script: Rename ScriptThreadMessage::AttachLayout to ScriptThreadMessage::SpawnPipeline (#40491)
The thing that this message does is to spawn a pipeline in a
`ScriptThread`. I believe that the `AttachLayout` name is a relic of a
different time. The corresponding procedure in the `Constellation` is
already called `Pipeline::spawn`.

Testing: This is just a rename, so existing tests should cover this
change.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-08 11:16:58 +00:00
Mukilan Thiyagarajan
e3f6c06fe4 compositor: Allow GenerateFrame to take Vec<WebViewId> (#40482)
This change simply allows `GenerateFrame` to carry a list of
`WebViewId`s and modifies `update_the_rendering` to collect `WebViewId`s
and pass them in the `GenerateFrame` message. The list of `WebViewId`s
is currently not used and that will be handled in a follow-up patch.

Testing: Covered by existing tests.

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-11-07 11:19:30 +00:00
webbeef
17db529cb9 Reduce boilerplate in Constellation and ScriptThread (#34960)
The constellation has many cases of early returns in match expressions
that can be rewritten using `if let Some(...) = xyz else { return abc;
}`. Two macros are introduced to help with repetitive code blocks that
can't be extracted as functions.

<!-- 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


<!-- 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: webbeef <me@webbeef.org>
2025-11-07 08:48:29 +00:00
Narfinger
f48b6d054f Script: Do not double copy for javascript source (#40464)
Previously, `evaluate_js_on_global_with_result` took a &str and most
cases
of it being called are owned strings. As it itself converts it to a
DOMString which owns the string it double copied it.

We now use Cow<'_, str> as input making both sides happy.

Testing: Does not change functionality.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-11-06 19:43:52 +00:00
Martin Robinson
8f6edca4dd net: Simplify FetchResponseListener and move it to script (#40461)
`FetchReponseListener` has traditionally lived in `net` even though it
is only used in `script` currently. Because of the two way dependency,
it has also use a lot of templating to implement something pretty basic
(call methods on a trait object).

This change moves the trait to `script` and removes several levels of
templating, making the code quite a bit shorter and easier to
understand.

This change is preparation for fixing #22550 and implementing
off-the-main-thread CSS parsing.

Testing: This should not change any behavior so is covered by existing
tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-06 14:44:01 +00:00
Martin Robinson
bdcae320fd net: Use callbacks instead of IPC channels in the ImageCache API (#40453)
Previously, the `ImageCache` would inform consumers of changes to image
availability by messaging an IPC channel. This isn't great, because it
requires serialization and deserialization. Nowadays, `ImageCache`s are
always owned by the same `Global` that uses them. This change replaces
the IPC channel with callback that implements `Send`.

For the case of normal HTML document images, the results are still sent
over the pre-existing Crossbeam channel that was connected via an IPC
route. A followup change might eliminate that channel entirely.

Testing: This should not change observable behavior so is covered by
existing tests.
Fixes: #24338.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2025-11-06 12:52:40 +00:00
WaterWhisperer
241bff962d Change some #[allow]s to #[expect]s (#40458)
Removes some unneeded lints.

Testing: Refactor
Part of: #40383

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2025-11-06 12:31:48 +00:00
Martin Robinson
8e00166585 script: Also set the Theme on incomplete loads (#40449)
When updating the theme, ensure that it is also set on incomplete loads.
This is particularly necessary to make it so that a non-Light theme is
used when it is set before the page loads.

Testing: This adds a new WebView API test.
Fixes: #40437.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-06 10:43:54 +00:00
Martin Robinson
fd54ce9059 script: Eagerly update the Device in Layout when it changes (#40432)
Instead of waiting for a reflow to update the `Device` in layout, update
it eagerly. This ensures that media queries can be answered correctly in
script before the next reflow. Also, it ensure that a new reflow is
triggered and reflects the change to the theme or viewport.

In addition, an unused viewport-related message from the Constellation
is removed. This would have needed to be updated by change, but since
it's unused I've just removed it.

This depends on https://github.com/servo/stylo/pull/260.

Testing: This fixes a WebView API test and improves

`/html/semantics/embedded-content/the-img-element/environment-changes/viewport-change.html`.

Fixes: #40395.
Fixes: #40129.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-05 21:17:23 +00:00
Taym Haddadi
6ec242580c Add CanGc argument to SafeFromJSValConvertible::safe_from_jsval (#40404)
Add CanGc argument to SafeFromJSValConvertible::safe_from_jsval
Fixes: #40392

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2025-11-04 20:43:59 +00:00
Martin Robinson
eed97f458b net: Associate every ImageCache with a WebView (#40376)
Every `ImageCache` should be assigned a `Pipeline` and a `WebView`, so
that it knows what WebRender instance to create image keys in. This
change accomplishes that by splitting the `ImageCache` trait into
`ImageCache` and `ImageCacheFactory`. There should only be one
`ImageCacheFactory` per process.

Testing: This should not change observable behavior and is thus covered
by
existing tests.

Fixes: This is part of #40261.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-04 08:26:05 +00:00
Gae24
44a0570ae5 script: remove microtask queue from globalscope (#40371)
Remove the microtask queue from `GlobalScope`. The queue is moved inside
worker global scopes, while for window globals the script thread's queue
is accessed.

Testing: Covered by existing tests
Fixes: #20908

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2025-11-03 12:51:35 +00:00
Josh Matthews
ba0aaa760c script: Trigger rendering update for skipped resize observations. (#40353)
When resize observations are skipped, they get delayed until the next
turn of the event loop. In headless tests, we're not guaranteed that
this next turn occurs in time, unless some other event happens to run.
This leads to intermittent results unless we ensure that the event loop
will run again.

Testing: Newly passing test.
Fixes: #33599

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-11-02 14:22:21 +00:00
Simon Wülker
13a66f7560 devtools: Support getting XPath selector for node actor (#39892)
You can copy the XPath selector from the inspector by right-clicking on
a node and selecting `Copy->XPath`.

Testing: I tried adding a test but the effort didn't seem worth it. The
devtools tests are currently very specifically tailored towards
source-list tests.

Part of https://github.com/servo/servo/issues/39862
Part of #34527

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-10-25 04:38:49 +00:00
shuppy
3fd9ebb849 script: Make file picker selection flow asynchronous (#39893)
Previously the `<input type=file>` would wait synchronously for file
selection
results from the embedder. This change moves that synchronous wait to
the
`FileManager` worker thread. The main benefit is that script is not
blocked waiting
for the embedder. The synchronous wait on the worker thread is not a
large issue
because it is run from a thread pool, though a later change could also
remove
that synchronous wait.

In addition, the API surface for file selection changes a bit as there
is now a `dismiss`
method which differentiates between selecting no file and not making a
choice at
all.

Testing: Covered by exiting WPT, WebDriver conformance, and unit tests.

---------

Signed-off-by: delan azabani <dazabani@igalia.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-10-20 07:33:11 +00:00
Martin Robinson
148ce3e9c7 constellation: Always include the WebViewId in Pipeline specific messages (#39974)
It would be useful for  the Constellation is ever going to store data
per-WebView for the purposes of making cleanup and resource management
easier. If that's ever going to happen the `WebView` needs to be passed
with all messages that need it. This change makes it so that messages to
the Constellation that require a Pipeline also carry a WebViewId. This
eliminates one way in which message handling might go wrong.

This avoids making the Constelaltion look up the `WebViewId` for many
messages
that it receives.

Testing: This should not change observable behavior, so should be
covered by existing tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-10-18 14:23:24 +00:00
Martin Robinson
a9b9c899ed script: Delay screenshots until the first rendering update after fonts.ready (#39963)
This fixes a regression (likely from #39583) that made the result of
many font loading
tests intermittent. The issues here is that the count of fonts loading
is decremented synchronously in the `FontContext`, but the notification
to the `ScriptThread` happens asynchronously. In between the time the
decrement happens and the `ScriptThread` is notified, a rendering update
could happen which could mark a screenshot as ready to take too soon.

The solution here is to wait until the `fonts.ready` promise is
resolved, which is guaranteed to fire after all fonts have loaded. In
addition, a rendering update is queued after this happens. This means
that the screenshot will wait until that final rendering update to be
ready.

This should remove the flakiness of font load tests.

Testing: This should fix many flaky tests.
Fixes: #39953.
Fixes: #39951.
Fixes #38956.
Fixes #39408.
Fixes #39429.
Fixes #39592.
Fixes #39636.
Fixes #39650.
Fixes #39666.
Fixes #39667.
Fixes #39706.
Fixes #39750.
Fixes #39801.
Fixes #39853.
Fixes #39881.
Fixes #39950.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-10-17 17:48:19 +00:00
Gregory Terzian
631a2b1268 constellation: add source browsing context info in forwarded post message (#39833)
For cross-document messaging, when the constellation forwards the
message, it can add the source browsing context and ancestry info to the
message. This saves a round-trip back to the constellation from script
later, and also allows for messages to be delivered when the source
pipeline is closed by the time of delivery(but not by the time of
forwarding by the constellation).

Testing: Updated various tests in
`/html/semantics/embedded-content/the-iframe-element/` WPT: from
TIMEOUT(because message was not delivered) or intermittent CRASH(because
the source pipeline would be closed by the time of attempted delivery.)
to FAIL.
Fixes: https://github.com/servo/servo/issues/39748

---------

Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
2025-10-17 11:20:53 +00:00
spuradage
113472e171 chore: remove repetitive word in comment (#39948)
remove repetitive word in comment

Signed-off-by: spuradage <spuradage@outlook.com>
2025-10-17 08:48:23 +00:00
Euclid Ye
8971f69143 webdriver: Deserialize WebWindow and report error correctly for script execution (#39885)
We were relying on `fn WebdriverWindow` to report `NoSuchWindow` during
script execution, regardless of the fact that it is never `Fallible`. I
was really hoping to refactor this to return `Fallible` to reduce one
RTT of IPC, but there is no easy way to convert between DOM exception
56b806b129/components/script_bindings/error.rs (L15)
and JavaScriptEvaluationError
56b806b129/components/shared/embedder/lib.rs (L1092).

We also migrate `element.rs` to `script_argument_extraction.rs` to
reflect the true purpose of the file.

Testing: 10 new subtests passing.

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-10-16 03:26:27 +00:00
shuppy
0d57fcb3e6 libservo: Merge file selection dialog into EmbedderControls (#39859)
in #39709, we introduced a single “form control” or “embedder control”
delegate that requests the embedder’s input for &lt;select> and
&lt;input type="color"> elements.

this patch partially merges &lt;input type="file"> elements into that
new system, and renames “form controls” to “embedder controls” for
consistency.

internally we continue to use a separate code path where the embedder
directly communicates with the file manager thread. subsequent work will
make the messages asynchronous via the constellation and script thread,
like other embedder controls.

Testing: this is currently tricky to write an automated test for; we
expect to write a WebDriver test for this once we make the communication
asynchronous

---------

Signed-off-by: delan azabani <dazabani@igalia.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-10-15 06:12:19 +00:00
Euclid Ye
4665363c58 webdriver: Incoporate script execution arm into the rest match block (#39854)
Previously, we had a separate match block for script execution. The
motivation was to avoid runtime error due to persistent RefCell
immutable borrow, caused by mozjs mutation.

This PR merge blocks into one. This avoids wildcard match, helping us
identify arms that were never matched, which normally causes error.

Testing: Manually tested. This is one of two ways to avoid panic.

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-10-14 12:43:14 +00:00
Martin Robinson
b9b2111f34 libservo: Notify the embedder when an input event can't be sent to a Pipeline (#39810)
The `WebViewDelegate::notify_input_event_handled` method is called for
the
embedder when an input event's processing has finished within Servo.
This allows the embedder to chain the event up to parent widgets or do
some kind of post-processing such as the implementation of overridable
keybindings.

This change makes it so that this method is called even when an input
event cannot successfully be sent to a pipeline. This could happen when
an event is handled during navigation or perhaps during shutdown. In any
case, Servo should *always* tell the embedder when the event is done
processing so that they don't get eaten by the Servo widget.

Testing: This is very difficult to test as it only happens in very
specific
time-sensitive sitautions.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-10-12 09:26:38 +00:00
Martin Robinson
35d4b1e937 script: Combine WebDriverJSError with JavaScriptEvaluationError and add the stack (#39647)
This change merges the WebDriver only `WebDriverJSError` with the API
`JavaScriptEvaluationError` and also allows passing `ErrorInfo`
information through to the API layer when possible. In addition, the
stack is added to `ErrorInfo` (but only in situations when evaluating
JavaScript code for WebDriver or via the API for performance reasons).

These changes allow much more useful error output when script execution
fails via WebDriver. Now the error message and source file line numbers
are printed by the test executor.

Testing: These changes should be reflected in the testing output.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-10-10 11:34:42 +00:00
Martin Robinson
89dfb3ee49 libservo: Make FormControl responses completely asynchronous (#39709)
Before responses to `FormControl` requests were handled synchronous in
script (ie they would block the page). This change makes it so that they
are handled asynchronously, with their responses filtering back through
the Constellation. This should fix many WPT tests when run with
WebDriver.

Testing: There are some WebDriver-based test for this, but they do
not quite pass yet. More investigation is required, but this is
necessary to get them to pass.
Fixes: #39652
Fixes: #37013

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Delan Azabani <dazabani@igalia.com>
2025-10-08 09:06:17 +00:00
Martin Robinson
fbbdce2e59 libservo: Remove MouseButtonAction::Click from the API (#39705)
The embedder should never be responsible for triggering click events, so
this change removes that possibility from the API. In addition,
triggering of click events is simplified by moving the logic to the
`DocumentEventHandler`. This has the benefit of making behavior
consistent between in-process and out-of-process `<iframe>`s. Now click
events are never triggered when the button up and down cross frame
boundaries.

Testing: This should be covered by existing tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-10-07 13:08:20 +00:00
Martin Robinson
c98eb40044 script: Allow loading of <iframe srcdoc> with a sandbox attribute (#39686)
Before, `about: srcdoc` was only handled when loading `<iframe>`
contents in the same `ScriptThread` as the parent. This is not always
the case though with sandboxed `<iframe>`s. This change makes it so that
both code paths properly handle `about: srcdoc`.

Testing: This causes around 12 new WPT passes.
Fixes: #36529.
Fixes: #27791.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-10-07 06:40:52 +00:00
Martin Robinson
e9151ec744 script: Use CSP sandboxing flags for <iframe> and pass them to child Documents (#39610)
This change makes it so that `<iframe>` sanboxing is equivalent to the
one used for Content Security Policy, which is how the specification is
written. In addition, these sandboxing flags are passed through to
`<iframe>` `Document`s via `LoadData` and stored as
`Document::creation_sandboxing_flag_set`. The flags are used to
calculate the final `Document::active_sandboxing_flag_set` when loading
a `Document`.

This change makes it so that `<iframe>`s actually behave in a sandboxed
way, the same way that `Document`s with CSP configurations do. For
instance, now scripts and popups are blocked by default in `<iframe>`s
with the
`sandbox` attribute.

Testing: This causes many WPT tests to start to pass or to move from
ERROR to TIMEOUT or failing later. Some tests start to fail:
-
`/html/semantics/embedded-content/the-canvas-element/canvas-descendants-focusability-005.html`:
This test uses a combination of `<iframe allow>` and Canvas fallback
content, which we do not support.
-
`/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_navigate_other_frame_popup.sub.html`:
This test is now failing because the iframe is sanboxed but in the
ScriptThread now due to `allow-same-origin`. More implementation is
needed to add support for the "one permitted sandbox navigator concept."

Fixes: This is part of #31973.

---------

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-10-06 17:23:03 +00:00
Ashwin Naren
65588cd5df script: Stubs for geolocation interfaces (#39584)
Needed for #39526; stubs out all the necessary interface from
https://www.w3.org/TR/geolocation/.

Testing: WPT

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-10-02 04:17:36 +00:00
Martin Robinson
6ffc0cd482 libservo: Add a WebView::take_screenshot() API and use it for reftests (#39583)
This change adds a new API to the `WebView` for capturing screenshots.
This makes it possible to:

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

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

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

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

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-09-29 17:13:34 +00:00