Commit Graph

69 Commits

Author SHA1 Message Date
Shubham Gupta
d1e3e8080c script: Correctly apply resource timing buffer limit (#44228)
Strictly follow the
[specs](https://w3c.github.io/resource-timing/#performance-can-add-resource-timing-entry)

Also fires the performance resource timing earlier to
match WPT expectations.

Testing: More WPT tests Passed.

---------

Signed-off-by: Shubham Gupta <shubham.gupta@chromium.org>
2026-04-21 11:17:11 +00:00
Gae24
85eda69130 script: Complete script_module &mut JSContext migration (#44368)
Switch the remaining `SafeJSContext` usages to `&mut JSContext` inside
script_module.rs

Testing: It compiles.
Part of #40600

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-04-20 09:12:28 +00:00
Gae24
2b21c528ea script: Clean up prepare the script element related code and remove ModuleOwner (#44179)
Drop the `ModuleOwner` logic in favour of closures passed down by the
script fetching initiator.
When processing inline module scripts a task in now queued on the
networking task source. Since `Rc<ModuleTree>` is not `Send`, a `result`
field is now introduced to `HTMLScriptElement`, which is initialized
before queueing the task.

This slightly improves `inline-async-inserted-execorder.html`, which now
fails at the fourth assertion instead of stopping at the second one (the
inline module script with no dependencies still resolves after the one
that has a parse error).

Testing: Covered by existing tests.

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-04-18 15:58:33 +00:00
Josh Matthews
62f9971a87 script: Log failed script fetch URL. (#44319)
Testing: Can't test for debug logs.
Should assist with diagnosing #26272.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2026-04-17 17:35:05 +00:00
Simon Wülker
64f4f080dd script: Unbind <script> elements properly from the tree (#44127)
Necessary for https://github.com/servo/servo/pull/44120

Testing: After https://github.com/servo/servo/pull/44120 we would crash
on WPT without this change. Given that this is a pretty obscure bug with
next to no chance of regressing, I think its okay to wait for that PR
for test coverage?

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2026-04-11 20:22:18 +00:00
Abbas Olanrewaju Sarafa
66d232e1e7 Remove introduction_type_override field from HTMLScriptElement (#44003)
Removed ```introduction_type_override``` field from
```HTMLScriptElement``` & passed the new variable to
```fetch_inline_module_script```

Testing: No testing required, compiles successfully.
Fixes: #43980

Signed-off-by: Sabb <sarafaabbas@gmail.com>
2026-04-07 18:36:21 +00:00
elomscansio
a7bc4a6fa9 script: implement render-blocking option for script fetch and load events (#43741)
Implement render-blocking option for script fetch and load events

## Testing: 
### Test summary on main branch
```bash
  ▶ OK [expected CRASH] /html/semantics/scripting-1/the-script-element/moving-between-documents/move-back-createHTMLDocument-success-external-module.html

Ran 470 tests finished in 217.9 seconds.
  • 453 ran as expected.
  • 4 tests crashed unexpectedly
  • 1 tests timed out unexpectedly
  • 11 tests unexpectedly okay
  • 2 tests had unexpected subtest results

/home/elomscansio/.local/share/uv/python/cpython-3.11.15-linux-x86_64-gnu/lib/python3.11/multiprocessing/resource_tracker.py:254: UserWarning: resource_tracker: There appear to be 3 leaked semaphore objects to clean up at shutdown
  warnings.warn('resource_tracker: There appear to be %d '

```

### Test summary for this commits
```bash

Ran 470 tests finished in 488.0 seconds.
  • 397 ran as expected.
  • 15 tests crashed unexpectedly
  • 27 tests timed out unexpectedly
  • 11 tests unexpectedly okay
  • 28 tests had unexpected subtest results

```
Fixes: #43697
Fixes: #43354

---------

Signed-off-by: Emmanuel Paul Elom <elomemmanuel007@gmail.com>
Signed-off-by: elomscansio <163124154+elomscansio@users.noreply.github.com>
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
Co-authored-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-04-06 08:08:43 +00:00
Tim van der Lippe
a1c8896eda script: Pass &mut JSContext to reflect_node_with_proto (#43952)
A lot (and I mean, really a lot) depends on these constructors.
Therefore, this is the one spaghetti ball that I could extract and
convert all `can_gc` to `cx`. There are some new introductions of
`temp_cx` in the callbacks of the servo parser, but we already had some
in other callbacks.

Part of #40600

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-04-05 18:07:30 +00:00
Tim van der Lippe
f340042c1d script: Pass &mut JSContext to FetchResponseListener::process_response_chunk (#43657)
Fixes #42841

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-26 18:05:24 +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
Philipp Albrecht
2f1b7f0f84 Pass &mut JSContext (#43543)
This is follow-up of #41459.

We replace some of these:

```rust
let mut cx = unsafe { script_bindings::script_runtime::temp_cx() };
```

..by passing a `cx: &mut JSContext` instead.

---

Testing: existing WPT tests  
Fixes: #43453

Signed-off-by: pylbrecht <pylbrecht@mailbox.org>
2026-03-22 20:58:05 +00:00
Kelechi Ebiri
a63a00936f remove referrer field from ScriptFetchOptions (#43532)
Remove `referrer` field from `ScriptFetchOptions` and pass it directly
to `script_fetch_request`.

This keeps ScriptFetchOptions aligned with the HTML 
fixes #42875

---------

Signed-off-by: Kelechi Ebiri <ebiritg@gmail.com>
2026-03-22 16:41:29 +00:00
Tim van der Lippe
8f699b1f17 script: Pass &mut JSContext to submit_timing_data (#43479)
Part of #40600

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-20 15:31:46 +00:00
Tim van der Lippe
3d4cfa4718 net: Remove process_request_eof (#43477)
This is no longer present in the spec. Instead, the
`process_request_body` is the new way. These two
methods were called right after each other and there was only 1
implementation in `htmlvideoelement`. That implementation is now moved
to `process_request_body` and hence we can remove the unnecessary
method.

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-20 10:51:33 +00:00
Gae24
e0fc0174fa script: Propagate &mut JSContext inside global_scope_script_execution.rs (#43473)
Pass `&mut JSContext` to `HTMLScriptElement::execute`, propagate it
inside `global_scope_script_execution.rs` and then switch to wrappers2
bindings.

Testing: A successful build is enough.
Part of #40600

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-20 10:51:33 +00:00
Philipp Albrecht
15a400b42a Add basic support for handling module scripts in workers (#40365)
While we now pass a lot of worker tests, we still fail a bunch:
```
% fd '^worker-.*.html.ini'
tests/wpt/meta/content-security-policy/gen/top.http-rp/script-src-self/worker-import.http.html.ini
tests/wpt/meta/content-security-policy/gen/top.http-rp/script-src-self/worker-import.https.html.ini
tests/wpt/meta/content-security-policy/gen/top.http-rp/worker-src-self/worker-import.http.html.ini
tests/wpt/meta/content-security-policy/gen/top.http-rp/worker-src-self/worker-import.https.html.ini
tests/wpt/meta/content-security-policy/gen/top.meta/script-src-self/worker-import.http.html.ini
tests/wpt/meta/content-security-policy/gen/top.meta/script-src-self/worker-import.https.html.ini
tests/wpt/meta/content-security-policy/gen/top.meta/worker-src-self/worker-import.http.html.ini
tests/wpt/meta/content-security-policy/gen/top.meta/worker-src-self/worker-import.https.html.ini
tests/wpt/meta/content-security-policy/script-src/worker-data-set-timeout.sub.html.ini
tests/wpt/meta/content-security-policy/script-src/worker-importscripts.sub.html.ini
tests/wpt/meta/content-security-policy/script-src/worker-set-timeout.sub.html.ini
tests/wpt/meta/fetch/metadata/generated/worker-dedicated-constructor.sub.html.ini
tests/wpt/meta/fetch/metadata/generated/worker-dedicated-importscripts.https.sub.html.ini
tests/wpt/meta/fetch/metadata/generated/worker-dedicated-importscripts.sub.html.ini
tests/wpt/meta/mixed-content/gen/top.http-rp/opt-in/worker-import-data.https.html.ini
tests/wpt/meta/mixed-content/gen/top.http-rp/opt-in/worker-import.https.html.ini
tests/wpt/meta/referrer-policy/generic/subresource-test/worker-messaging.html.ini
tests/wpt/meta/service-workers/service-worker/worker-client-id.https.html.ini
tests/wpt/meta/service-workers/service-worker/worker-in-sandboxed-iframe-by-csp-fetch-event.https.html.ini
tests/wpt/meta/service-workers/service-worker/worker-interception-redirect.https.html.ini
tests/wpt/meta/service-workers/service-worker/worker-interception.https.html.ini
tests/wpt/meta/upgrade-insecure-requests/gen/worker-classic.http-rp/upgrade/worker-classic.https.html.ini
tests/wpt/meta/upgrade-insecure-requests/gen/worker-classic.http-rp/upgrade/worker-module.https.html.ini
tests/wpt/meta/upgrade-insecure-requests/gen/worker-module.http-rp/upgrade/worker-classic.https.html.ini
tests/wpt/meta/upgrade-insecure-requests/gen/worker-module.http-rp/upgrade/worker-module.https.html.ini
tests/wpt/meta/wasm/webapi/esm-integration/worker-import-source-phase.tentative.html.ini
tests/wpt/meta/wasm/webapi/esm-integration/worker-import.tentative.html.ini
tests/wpt/meta/workers/Worker-creation-happens-in-parallel.https.html.ini
tests/wpt/meta/workers/Worker-postMessage-happens-in-parallel.https.html.ini
tests/wpt/meta/workers/Worker-terminate-forever-during-evaluation.html.ini
tests/wpt/meta/workers/worker-request-animation-frame.html.ini
```

Also, we are passing `Option<PolicyContainer>` down the call stack
through `LoadState`, which is more of a workaround. However, since
maintaining this long-lived branch is becoming a bit painful (merge
conflicts) and I was starting to lose momentum because of that, I would
like get this merged rather sooner than later.

We will address the failing tests and find the right place for
`PolicyContainer` in follow-ups, including the added
`#[allow(clippy::too_many_arguments)]`.


# See also
* https://html.spec.whatwg.org/multipage/#worker-processing-model
*
https://html.spec.whatwg.org/multipage/#fetch-a-module-worker-script-tree

---

Fixes: #23308
Testing: WPT tests

Signed-off-by: pylbrecht <pylbrecht@mailbox.org>
Co-authored-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-20 00:58:16 +00:00
Javier Olaechea
eea60b8eb1 script: Pass &mut JSContext to FetchResponseListener::process_response (#43259)
Add the cx parameter to `fn process_response` in the
`FetchResponseListener` trait and the traits that that interface change
requires. Chose to add it as the first parameter, following the same
order that `FetchResponseListener::process_response_eof` uses.

Testing: Checked that servo builds locally as well as `./mach fmt` and
`./mach test-tidy`. I don't think more tests are needed as we are not
introducing new functionality
Fixes: #42840

---------

Signed-off-by: Javier Olaechea <pirata@gmail.com>
2026-03-19 06:22:00 +00:00
Tim van der Lippe
479a9b6be3 script: Pass &mut JSContext to attribute_mutated (#43383)
It pushes the `temp_cx` 1 level up to `element.rs` where the calling
chain begins. Other than that this was purely a mechanical change where
I used regexes to replace all patterns with the new ones.

Part of #42812

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-18 11:03:54 +00:00
Tim van der Lippe
48f1da9fe6 script: Pass &mut JSContext to TrustedScript::get_trusted_type_compliant_string (#43362)
Part of #40600

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-17 20:26:58 +00:00
Gae24
9a8571efcc script: Add support for modulepreload link elements (#42964)
Add support to modulepreload link elements. Currently we only fetch the
root module, as I think it is needs to be discussed whether we should
always fetch module dependencies, or if it should be limited due to
network constraints.
Inside `bind_to_tree` I ended up calling
`fetch_and_process_modulepreload` inside a delayed task, since it would
cause a crash due to DOM not being in a stable state when firing an
event (queueing the event seems to also do the trick).

Remaining tests failures are due to not supporting CSS modules and
performance entries's `transfer_size` being 0.

Testing: Covered by existing tests

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-17 09:28:05 +00:00
Sharan Poojari
ae08945a54 script: inline dispatch_load_event and dispatch_error_event (#43285)
fixes #43280 
This PR in lines the dispatch_load_event and dispatch_error_event
wrappers directly into their call sites and removes the unused function
definitions

Signed-off-by: SharanRP <z8903830@gmail.com>
2026-03-15 16:38:18 +00:00
Gae24
e8b581aaf0 script: Pass &mut JSContext in more places (#43252)
Continuation of #43220, removes many `temp_cx` calls introduced by that.

Testing: No behaviour change, a successful build is enough.
Fixes: #43241 #43240

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-14 10:03:48 +00:00
Gae24
ef97d7e199 script: Pass &mut JSContext to VirtualMethods::bind_to_tree (#43220)
Testing: No behaviour change, a successful build is enough.
Fixes: #42838 #43239

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-14 07:37:47 +00:00
Tim van der Lippe
b6ba612a54 script: Pass &mut JSContext to TrustedScriptURL::get_trusted_type_compliant_string (#43245)
Also rename the method and consolidate the sink to be consistent with
both `TrustedHTML` and `TrustedScript`

Part of #42638

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-13 13:56:46 +00:00
Gae24
048612fe84 script: Pass &mut JSContext to children_changed and adopting_steps (#43219)
Switch `VirtualMethods::children_changed` and
`VirtualMethods::adopting_steps` to `&mut JSContext`.

Testing: No behaviour change, a successful build is enough.
Part of #40600

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-13 13:40:40 +00:00
Tim van der Lippe
af256bd6e5 script: Check for render-blocking documents before continuing (#43150)
The spec expects us to check for render blocking (among some other
state) before we start procesing a document. Therefore, add those checks
and also check in the
stylesheet loader that we should only do so when we are allowed to do
so.

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-13 09:54:03 +00:00
Simon Wülker
c0ff7c1fc9 Everywhere: Remove instances of clippy::redundant-clone (#43212)
This change fixes all instances where
[`clippy::redundant-clone`](https://rust-lang.github.io/rust-clippy/master/index.html?groups=complexity%2Ccorrectness%2Cnursery%2Csuspicious&levels=allow#redundant_clone)
would trigger. It's allowed by default

I've also changed the lint to warn-by-default for servo.

Testing: Covered by WPT

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2026-03-12 13:28:21 +00:00
Tim van der Lippe
aae5c4cd97 script: Move Trusted Types interfaces to script/dom/trustedtypes (#43181)
Part of #38901 

Testing: it compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-11 16:26:56 +00:00
Gae24
4ef22ed227 script: Pass &mut JSContext to VirtualMethods::cloning_steps and Node::clone (#43130)
Continuation of #43108, two new `temp_cx()` calls were required:
- inside `maybe_clone_an_option_into_selectedcontent` since it's part of
a markup5ever trait
- inside `serialize_and_cache_subtree` replacing a `CanGc::note()` call,
propagating it inside reflow code will require even more effort.

Testing: No behaviour change, a successful build is enough.
Part of #40600

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-10 17:05:34 +00:00
Martin Robinson
401d327b96 script: Clean up attribute access a little bit in Element (#43064)
- Use modern Rust conveniences such as `unwrap_or_default`
 - Unabbreviate `attr`
- Unify the lowercase ASCII name assertion and make it a debug assertion
 - Use `unreachable!` instead of panic
- Expose two attribute getters that follow the behavior of two
specification concepts and what we expect internally in Servo:
- One that takes a namespace, but does not require lowercase attribute
names. ([specification
concept](https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace>))
- One that does not take a namespace, but does require lowercase
attribute names. ([specification
concept](https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name))
Testing: This should not really change behavior so should be covered by
existing tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-03-06 20:02:37 +00:00
Narfinger
b55bc205a7 script: jscontext-ify element aria methods and SetCrossOrigin (#42957)
Use &mut JSContext in element aria* methods and SetCrossOrigin methods.

Testing: Compilation is the test as this is part from
https://github.com/servo/servo/issues/40600

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2026-03-02 17:23:33 +00:00
dyegoaurelio
453166752b Fix CSP nonce validation and violation reporting for external scripts (#40956)
This PR fixes two related issues with Content Security Policy (CSP)
nonce validation for external scripts:

1. Missing nonce validation for external scripts with malformed
attributes
2. Incorrect violation event reporting for blocked external resources


This makes servo closer to passing the `nonce-enforce-blocked` wpt test.

The remaining failures are blocked by required changes in the html
parser.

1. Svg script support (https://github.com/servo/html5ever/issues/118)
```html
<svg xmlns="http://www.w3.org/2000/svg">
<script attribute attribute nonce="abc">
    t.unreached_func("Duplicate attribute in SVG, no execution.")();
</script>
</svg>
```

2. Duplicate attrs check
the html parser needs to provide this flag, as mentioned on the original
commit message
(4821bc0ab0)

```html
<script attribute attribute nonce="abc">
    t.unreached_func("Duplicate attribute, no execution.")();
</script>
<script attribute attribute=<style nonce="abc">
    t.unreached_func("2# Duplicate attribute, no execution.")();
</script>

[...]

<script src="../support/nonce-should-be-blocked.js?5" attribute attribute nonce="abc"></script>
```

I've also created a PR to implement the duplicate attrs flag on
html5ever https://github.com/servo/html5ever/pull/695

Testing: doesn't fixes the aforementioned wpt test yet.
Fixes: part of #36437

---------

Signed-off-by: Dyego Aurélio <dyegoaurelio@gmail.com>
2026-02-27 13:17:33 +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
Gae24
ea7703c39d script: Preserve the order of entries when parsing an import map (#42754)
Unless the feature `preserve_order` is enabled, serde_json will sort the
map's entries in an alphanumerical order.
The specification instead expect the entries to be visited by the order
they are listed, a latter entry should replace a previous one when they
are resolved to the same url.

I've also removed a couple of `CanGc` introduced in #37405, unless I've
missed something there is not code that can trigger a GC.

Testing: A subtest now pass
Part of #37553

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-02-23 21:39:37 +00:00
Philipp Albrecht
adee703046 Move run_a_module_script() to GlobalScope (#41459)
Prerequisite for #40365.

Moving `run_a_module_script()` to `GlobalScope` will allow us to execute
module scripts on `WorkerGlobalScope`.

---

Relates to #23308

Signed-off-by: pylbrecht <pylbrecht@mailbox.org>
2026-02-22 09:14:39 +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
Gae24
8a3738dc43 script: pass down &mut JSContext in post_connection_steps (#42679)
Pass down `&mut JSContext` in `post_connection_steps` 

Testing: No functionality change, a successful build is enough
Part of #40600

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-02-17 13:20:52 +00:00
Gae24
49adfed9a8 script: implement resolve_a_module_integrity_metadata (#42604)
`ImportMap` _integrity_ entry was practically unused, since it is only
needed for [resolving a module integrity
metadata](https://html.spec.whatwg.org/multipage/#resolving-a-module-integrity-metadata).
Now, we correctly initialize `ScriptFetchOptions` when loading a
module's descendants.
I slightly modified `nonimport-integrity.html` test to run
`modulepreload` test cases at the end. Since we haven't an
implementation for it, the test timeout, making the test cases that
comes after them not run.

Testing: More tests start passing
Part of #37553

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-02-14 10:26:49 +00:00
Gae24
3748667775 chore: move ClassicScript related code to a new module (#42363)
As discussed on a [Zulip
thread](https://servo.zulipchat.com/#narrow/channel/263398-general/topic/Code.20organization/with/571886607),
move `ClassicScript` code to a new module.

Testing: A successful build is enough

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-02-05 12:32:38 +00:00
Gae24
047cb39fa9 script: Drop ModuleTree network_error and simplify pending fetches logic (#42127)
Since we use `NetworkError` just for logging reasons, we don't really
need to pass it around; instead lets follow spec more closely and pass a
`None` on network failures.
Make more explicit if a `modulemap` entry is currently fetching or
ready.

Testing: No functional change, covered by existing tests

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-01-26 05:43:12 +00:00
Krzysztof Biedroń
17e3061ecd script: Modify ModuleObject::handle() to return a handle with a lifetime (#42071)
Changed the return type of `ModuleObject::handle()` to the original type
of its contained handle by removing `.into()` call, as requested in the
linked issue.

Additional changes are due to temporary borrows now sharing lifetime
with returned handle reference.

Testing: No new tests needed, as the code is functionally the same after
the changes. Verified with running `./mach test-build` and `./mach
test-unit` successfully.
Fixes: https://github.com/servo/servo/issues/42051

Signed-off-by: Krzysztof Biedroń <arkendil@gmail.com>
2026-01-25 00:13:32 +00:00
Josh Matthews
7925a26a99 script: Use OnceCell instead of RefCell for some module fields. (#42119)
This better reflects the intention of the code, which is that these
fields are set at most one time.

Testing: No behaviour change expected, so existing tests suffice.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2026-01-24 06:53:33 +00:00
Gae24
b7ccf86cb8 script: remove more unused code (#42081)
This commit remove more unused code from `script_module`,
`inline_module_map` and `dynamic_modules` fields from `GlobalScope` and
the now unused custom interface `DynamicModuleOwner`.

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

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-01-22 15:12:09 +00:00
Gae24
a953ba954a script: revamp module script loading to follow current spec (#41779)
Rewrite module script fetching logic to follow current spec.

Testing: Covered by existing wpt tests
Fixes: #31397

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-01-22 11:40:53 +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
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
Tim van der Lippe
e2d62531f5 script: Consolidate global initialization for fetch requests (#41663)
Rather than having each callside specifying the relevant
information from the GlobalScope, do this via a trait instead.
This would have saved us quite a bit of test debugging
since we would often forget to set relevant information
from the global context for a request.

Now, in the future when we need additional information from
the globalscope for a request, we only need to update this
method to make that happen.

Previously it would also sometimes use `document`, but
calling the relevant information on either `document` or
`globalscope` doesn't matter, since the `globalscope`
defers to the value from the `document` anyways.

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-01-07 13:22:03 +00:00
Usman Yahaya Baba
6decaaefa9 Replace NetworkError::Internal with structured enum variants for calls with literal strings (#36599)
Replace NetworkError::Internal with structured enum variants
- Adds
UnsupportedScheme,CorsViolation,ConnectionFailure,Timeout,RedirectError,InvalidMethod,ResourceError,SecurityBlock,MixedContent,CacheError,InvalidPort,
LocalDirectoryError, variants in NetworkError enum.
- Refactored the usage of NetworkError::Internal(String) to use the
appropriate new variant

Testing: Changes does not require test.
Fixes: https://github.com/servo/servo/issues/36434

---------

Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
Signed-off-by: Usman Yahaya Baba <91813795+uthmaniv@users.noreply.github.com>
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Co-authored-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-01-02 10:28:17 +00:00
Tim van der Lippe
0de7b23a7b script: Initialize all requests with clients (#41584)
In preparation for adding preload support for all requests, we need to
add relevant client information to all these entrypoints. Additionally,
for links we now also set the referrer correctly and initialize
documents. All of which are required to start loading preload
information when processing requests.

Part of #35035

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
2025-12-30 13:10:29 +00:00
Gae24
6f14742707 script: Pass ModuleTree instead of retrieving it in run_a_module_script (#41571)
Inside `notify_owner_to_finish` we already retrieve the `ModuleTree`
tied to the corresponding `ModuleIdentity`, but we ended up retrieving
it a second time inside of `run_a_module_script` instead of simply
passing it.

Testing: Covered by existing tests, a simple cleanup.

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2025-12-29 23:49:04 +00:00