Commit Graph

156 Commits

Author SHA1 Message Date
Tim van der Lippe
c8029ea092 script: Rename CanGc::note() to CanGc::deprecated_note() (#44081)
Per the suggestion in

https://servo.zulipchat.com/#narrow/channel/263398-general/topic/PSA.3A.20avoid.20new.20usages.20of.20CanGc.20whenever.20possible/near/583995807
to mark this method as deprecated and make clear it shouldn't be used
anymore, as alternatives exist.

Part of #40600

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-04-10 06:07:52 +00:00
Martin Robinson
718c8913af script/constellation: Rename and consolidate cross-Document focus messaging (#44020)
There are two times that Servo needs to ask other `Document`s to either
focus or blur.

- During processing of the "focusing steps". When a new element gains
  focus this may cause focus to be lost or gained in parent `<iframe>`s.
- When calling `focus()` on a DOM Window from another origin.

In both of these cases we need to request that a `Document` gain or lose
focus via the Constellation, but in the second case we may have a
`BrowsingContextId` of the `<iframe>` gaining focus and a
`FocusSequence`. This change splits those cases into two kinds of
messages.

Finally, run the entire focusing steps when calling `window.focus()`
instead of going to the constellation immediately. This will be
important in a followup changes where messaging order is made more
consistent.

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

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-04-09 08:59:47 +00:00
Josh Matthews
c1bddb3801 script: Use snapshot of navigation target when navigating. (#43807)
This set of changes introduces a type matching the spec's "target
snapshot params" and uses it as part of determining the origin of new
documents. This has a side benefit of making our sandbox flag
determination more accurate, which leads to a bunch of sandboxing tests
passing as well as some new failures due to spec confusion about
origins.

Testing: Many new passing tests.
Part of the long road to #43149

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2026-04-01 04:45:12 +00:00
Tim van der Lippe
6656061fc3 script: Implement frame-ancestors CSP check (#43630)
Requires communication between the script thread and the constellation
to be able to retrieve the origin of a cross-origin document. However,
in the fast-path where the document resides in the same script-thread,
we use the `frame_element` instead.

If no CSP list is active, then we skip all this logic, to have a minimal
impact on document navigation.

Part of #4577
Fixes #36468

---------

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
2026-03-28 08:54:17 +00:00
Tim van der Lippe
f7876c3db8 script: Pass &mut JSContext to navigate (#43713)
Also move the related `navigate_to_fragment` method next to it.

Part of #40600

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-27 17:11:22 +00:00
Babalola Taiwo J
ed8b28b642 script: Merge Window::load_url with ScriptThread::navigate (#43668)
Both `Window::load_url` and `ScriptThread::navigate` implement parts of
the same navigate algorithm from the HTML spec
(https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate).
`ScriptThread::navigate` had only one caller: `Window::load_url`.

This merges both methods into a single `navigate` function in
`navigation.rs`, which is the appropriate home for navigation logic. All
previous callers of `Window::load_url` now call `navigation::navigate`
directly.

Testing: This is a pure refactor with no behaviour changes, so no new
tests are needed. Existing tests cover the navigation paths affected.
Fixes: #43494

---------

Signed-off-by: thebabalola <t.babalolajoseph@gmail.com>
2026-03-27 08:38:43 +00:00
Euclid Ye
2f5e3fdb5c cargo: Rename workspace-local library starting with c to servo_* (#43622)
- canvas 
- constellation_traits
- canvas_traits
- constellation

Testing: This should not change any behaviour.

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2026-03-25 06:04:57 +00:00
Euclid Ye
cae0752676 cargo: Rename workspace-local library starting with b to servo_* (#43552)
Follow up of #43526. This addresses Nico's comment:
https://github.com/servo/servo/pull/43526#issuecomment-4104953308

- `bluetooth_traits` -> `servo_bluetooth_traits`
- `base` -> `servo_base`
- `bluetooth` -> `servo_bluetooth`
- `background_hang_monitor` -> `servo_background_hang_monitor`

Testing: This should not change any behaviour.

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2026-03-23 08:26:49 +00:00
Josh Matthews
c166fec94a script: Do not record associated memory for Promises, and release associated memory for WindowProxy. (#43487)
This fixes two assertions observed in Servo using debug mozjs builds:
* `Assertion failure: !IsInsideNursery(obj)` for every promise object
reflected into Rust code
* `Missing calls to JS::RemoveAssociatedMemory` when shutting down the
browser

Testing: Verified locally that WPT tests can run to completion in debug
mozjs builds, but we don't run those on CI.
Fixes: #43486

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2026-03-20 17:08:32 +00:00
Narfinger
81c3bde86c script: Move easy IpcChannel usage to GenericChannel usage (#43309)
This moves some easy elements in Script from IpcChannel and related
methods to GenericChannel and related methods and some callbacks.

Testing: This will be covered by WPT if the channels behave differently.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2026-03-20 07:24:25 +00:00
Tim van der Lippe
3c852261b9 script: Pass &mut JSContext in CSP code (#43184)
Part of #40600

Testing: it compiles

---------

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
2026-03-14 21:42:02 +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
Narfinger
c6a5eb584a script: Do not unnecessary clone CSP list in Document::get_csp_list (#42716)
We previously clonsed the CSP list unnecessarily which consisted of
roughly 2.7%. 1.2% spend in Document::get_csp_list.
We can easily avoid it with Ref and cloning it deliberately when needed.

Testing: This is functionally identical to the previous code as it is a
change from clone to a Ref<>.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2026-02-23 11:49:58 +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
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
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
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
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
aquaThirsty
d9ef15ea3a script/dom: Remove unused creator-related methods from WindowProxy. (#41860)
Methods were unused and removed from the HTML spec.

Testing: Verified with ./mach build and ./mach test-unit. Without errors
or warnings.
Fixes: #41835

Signed-off-by: TimurBora <timurborisov5561@gmail.com>
2026-01-12 20:43:55 +00:00
Mukilan Thiyagarajan
2ccd9f54ad libservo: Let UserContentManager be per WebView and add basic support for mutations. (#41352)
This change moves the `UserContentManager` abstraction from the
`ServoBuilder` to `WebViewBuilder` so that embedders can inject content
for each `WebView` independently. It also adds basic support for runtime
mutations to the `UserContentManager` API. Only adding new scripts is
currently supported, but future changes will add support for both other
mutations such as removal of scripts and addition & removal of
stylesheets. Future changes could also optimize the way mutations are
propagated to `ScriptThread`s by sending just the "delta" rather than
the whole `UserContents` structure for each mutation.

The `UserContentManager` now becomes just a convenient handle for the
embedders to invoke the mutation API while the actual management of the
manager's content is handled by the Constellation. The mutations are
relayed to the constellation via messages. The change also separates the
serialized version containg the user contents into a new `UserContent`
structure so that the API cannot be misused.

Testing: New unit tests have been added for the different scenarios
involving UserContentManager.

---------

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2025-12-23 06:15:01 +00:00
Anonmiraj
b207be05d9 change some allows to expects (#41040)
Changed some allow to expects and removed the unfulfilled expectations.

Testing: Refactor
Part of: #40383

Signed-off-by: anonmiraj <nabilmalek48@gmail.com>
2025-12-05 07:23:32 +00:00
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
d-kraus
0a0a20a9c6 Replace some #[allow] with #[expect] (#40865)
Replaces some #[allow] with #[expect]. In case where the lint
expectation was unfulfilled, I removed it.


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

Signed-off-by: Dennis Kraus <kraus@posteo.de>
2025-11-24 22:41:45 +00:00
Ashwin Naren
e0eb23ce18 script: Finish converting all error message enum variants to Option<String> (#40750)
I used find and replace to finish the job. All this PR does is replace
all `Error::<error_name>` occurrences with `Error::<error_name>(None)`.

Testing: Refactor
Fixes: #39053

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-11-20 06:20:47 +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
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
Martin Robinson
65b4e183a4 script: Wrap unsafe code in windowproxy.rs in unsafe {} (#40493)
This is another step on the way toward enabling the default set
of rustc compiler warnings for `script`. This also renames two
functions according to Rust snake case guidelines.

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

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-08 07:26:37 +00:00
WaterWhisperer
158bf97e30 script/dom/: Change some #[allow]s to #[expect]s (#40454)
Removes some unneeded lints, especially `#[allow(unsafe_code)]`.

Testing: Refactor
Part of: #40383

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2025-11-06 11:06:03 +00:00
Simon Wülker
c4ae451612 Turn all commented links before functions into doccomments (#40331)
Servo has a lot of comments like this:
```rust
// https://example-spec.com/#do-the-thing
fn do_the_thing() {}
```
and I keep turning these into doc comments whenever I'm working close to
one of them. Doing so allows me to hover over a function call in an IDE
and open its specification without having to jump to the function
definition first. This change fixes all of these comments at once.

This was done using `find components -name '*.rs' -exec perl -i -0777
-pe 's|^([ \t]*)// (https?://.*)\n\1(fn )|\1/// <$2>\n\1$3|mg' {} +`.

Note that these comments should be doc comments even within trait `impl`
blocks, because rustdoc will use them as fallback documentation when the
method definition on the trait does not have documentation.

Testing: Comments only, no testing required
Preparation for https://github.com/servo/servo/pull/39552

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-11-01 05:32:45 +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
Gregory Terzian
1af34ca483 script: prevent panic when opening an auxiliary using a window with a closed browsing context(iframe) (#39922)
When one unbinds an iframe from the tree, its browsing context is
destroyed, however if script keeps a reference to the window, it can
still try to open an auxiliary, resulting in a crash because the
constellation has already removed the browsing context. This adds a
non-intermittent test for the problem, and addresses it in a seemingly
ad-hoc way by checking whether the browsing context has already been
discarded, and if so doing an early return, as part of the window open
steps.

Testing: Added a crash test in the mozilla wpt folder.
Fixes: https://github.com/servo/servo/issues/39716

---------

Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
2025-10-17 12:05:08 +00:00
Narfinger
423800eec4 Script: Lazily transform the DOMString into Rust String instead of immediately. (#39509)
This implements LazyDOMString (from now on DOMString) as outlined in
https://github.com/servo/servo/issues/39479.
Constructing from a *mut JSString we keep the in a
RootedTraceableBox<Heap<*mut JSString>> and transform
the string into a rust string if necessary via the `make_rust_string`
method.
Methods used in script are implemented on this string. Currently we
transform the string at all times.
But in the future more efficient implementations are possible.

We implement the safety critical sections in a separate module
DOMStringInner which allows simple constructors, `make_rust_string` and
the `bytes` method.
This method returns the new type `EncodedBytes` which contains the
reference to the underlying string in either format.

Testing: WPT tests still seem to work, so this should test this
functionality.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-10-09 18:18:03 +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
Tim van der Lippe
6a0f9d1bcb Define conditional_malloc_size_of for all Rc (#39660)
This updates all Rc that were ignored for malloc_size_of to use
conditional_malloc_size_of, unless the type in the Rc itself doesn't
support malloc_size.

Regular expressions used to search for all occurrences:

```
ignore_malloc_size_of = "Rc.*"
ignore_malloc_size_of = "Arc.*"
```

There are a couple left since they have nested Rc, which I don't know
how to fix.

To be able to define these, several new implementations were added to
`malloc_size_of/lib.rs` as well as
`HashMapTracedValues`.

Testing: if it compiles, it's safe

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-10-05 15:12:16 +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
Narfinger
389f0d4cc2 Split WindowProxies in script to own struct and allow to get an Rc to it. (#39274)
Split the window_proxies in script thread into its own struct with
appropiate methods. ScriptThread allows to get an Rc to it.
HtmlIFrameElement, Window and WindowProxy now get the Rc on construction
from ScriptThread.


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

---------

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

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

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

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-09-28 08:00:20 +00:00
Narfinger
1e471b9b41 Script: Change the rest of script to not rely on Deref<str> for DOMString (#39481)
This is part of the future work of implementing LazyDOMString as
outlined in issue #39479.

We use str() method or direct implementations on DOMString for these
methods. We also change some types.
This is independent of https://github.com/servo/servo/pull/39480

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

Testing: This is essentially just renaming a method and a type and
should not change functionality.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-09-25 12:27:42 +00:00
Martin Robinson
ffdb7d3663 script: Chain up keyboard scrolling to parent <iframe>s (#39469)
When an `<iframe>` cannot scroll because the size of the frame is
greater than or
equal to the size of page contents, chain up the keyboard scroll
operation to the parent frame.

Testing: A new Servo-only WPT tests is added, though needs to be
manually
run with `--product servodriver`.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Delan Azabani <dazabani@igalia.com>
2025-09-25 11:16:41 +00:00
Ashwin Naren
97c8c83cbb script: Add message to SyntaxError (#39056)
Adding an optional message to be attached to a SyntaxError. Unblocks
#39050.

The enum definition of Syntax is now `Syntax(Option<String>)`. Future
PRs should probably add more appropriate messages to some of the
`Syntax(None)`s.

Testing: Just a refactor
Fixes: Partially #39053

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-09-02 05:51:36 +00:00
Jonathan Schwender
a24e13184f storage: Port Reply senders to GenericSender (#38999)
Port the reply / back channels of StorageThreadMsg to GenericChannel.

Testing: No functional changes
Part of #38912

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2025-08-28 17:51:00 +00:00
Jonathan Schwender
32aba08be7 Port StorageThreadMsg to GenericChannel (#38932)
This change includes the following additions to GenericChannel:
- Add a GenericSend trait which is meant to replace the `IpcSend` trait
over time, as channels are migrated. For the time being this means, that
we often need to use `GenericSend::send()` to disambiguate from the
`IpcSend::send` function, until all usages of `IpcSend` have been
replaced.
- Add an OpaqueSender impl for GenericSender
- Add a profiled version of GenericChannel. The profiling is 1:1 the
same as for the existing profiled IPC channel, namely that only the
blocked time during `recv` is measured.


Testing: No functional changes, covered by existing tests
Part of #38912

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2025-08-27 01:58:43 +00:00
Jonathan Schwender
b9dc228e51 script: Clean-up IpcSend .sender().send() pattern (#38919)
The IpcSend trait defines a `send()` method, so doing .sender().send()
seems like it just adds a useless clone of the sender, when we could
just `send()` directly.
This only cleans up the direct usages of this pattern, there are more
instances, where a helper method is defined, which returns the
IpcSender, and the only usages also just directly call send.

Testing: No functional changes

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2025-08-25 19:16:12 +00:00
Jan Varga
934b3341d7 storage: Isolate sessionStorage per top-level browsing context and copy sessionStorage when creating a new auxiliary browsing context (#37803)
This pull request introduces changes to the storage subsystem to:
- Isolate sessionStorage per top-level browsing context (WebViewId), in
  addition to origin.
- Copy sessionStorage when creating a new auxiliary browsing context
without
  noopener, as required by the corresponding spec
 
These changes bring Servo closer to spec compliance, matching expected
browser
behavior.

Testing: This work affects observable behavior. As a result, some
previously
failing WPT tests now pass. No new tests are added, since the behavior
is
already covered by existing web-platform-tests.

Fixes: #21291

---------

Signed-off-by: Jan Varga <jan.varga@gmail.com>
2025-07-04 09:15:12 +00:00
Euclid Ye
a3c792e5aa servoshell: Do not focus and raise new auxiliary WebDriver-created WebViews (#37284)
For Desktop port of `request_open_auxiliary_webview`, stay on the
original WebView if the request originates WebDriver.

This is to make sure `webdriver_server::handle_new_window` does not
focus the new window, according to spec. See
c7eba2dbba/tests/wpt/tests/webdriver/tests/classic/new_window/new_window.py (L31-L37)

**To clarify**: this won't change the behaviour when user interacts, but
only affects WebDriver [New
Window](https://w3c.github.io/webdriver/#new-window).

Testing: `./mach test-wpt -r --log-raw "D:/servo log/all.txt"
./tests/wpt/tests/webdriver/tests/classic --product servodriver` based
on 96b0973037

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-06-09 11:07:09 +00:00
Martin Robinson
d3e57a513c constellation: Pass system theme to new Pipelines (#37132)
Previously, when the theme was set it was only set on currently active
`Window`s. This change makes setting the `Theme` stateful. Now the
`Constellation` tracks what theme is applied to a `WebView` and properly
passes that value to new `Pipeline`s when they are constructed. In
addition, the value is passed to layout when that is constructed as
well.

Testing: this change adds a unit test.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-05-26 12:05:38 +00:00
Fuguo
0c0ee04b8e Improve inter-document focus handling (#36649)
*Describe the changes that this pull request makes here. This will be
the commit message.*
rewritten the PR #28571
Implement
[Window#focus](https://html.spec.whatwg.org/multipage/#dom-window-focus),
[Window#blur](https://html.spec.whatwg.org/multipage/#dom-window-blur)
Testing: WPT
Fixes: #8981 #9421

---------

Signed-off-by: kongbai1996 <1782765876@qq.com>
Co-authored-by: yvt <i@yvt.jp>
2025-04-30 04:37:53 +00:00
Martin Robinson
6031a12fd1 Move ScriptToConstellationMsg to constellation_traits (#36364)
This is the last big change necessary to create the
`constellation_traits` crate. This moves the data structure for messages
that originate from the `ScriptThread` and are sent to the
`Contellation` to `constellation_traits`, effectively splitting
`script_traits` in half. Before, `script_traits` was responsible for
exposing the API of both the `ScriptThread` and the `Constellation` to
the rest of Servo.

- Data structures that are used by `ScriptToConstellationMsg` are moved
  to `constellation_traits`. The dependency graph looks a bit like this:
  `script_layout_interface` depends on `script_traits` depends on
  `constellation_traits` depends on `embedder_traits`.
- Data structures that are used in the embedding layer
  (`UntrustedNodeAddress`, `CompositorHitTestResult`, `TouchEventResult`
  and `AnimationState`) are moved to embedder_traits, to avoid a
  dependency cycle between `webrender_traits` and
  `constellation_traits`.
- Types dealing with MessagePorts and serialization are moved to
  `constellation_traits::message_port`.

Testing: This is covered by existing tests as it just moves types
around.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-04-05 22:13:29 +00:00