script: use &mut JSContext inside workers PostMessage api#42342
Merged
Conversation
Signed-off-by: Gae24 <[email protected]>
Contributor
Author
|
There haven’t been many pull requests to convert to |
Member
Yes please! Fell free to ping me on any questions or for requesting reviews. |
Member
|
btw we have meta issue here: #40600 and I have rough porting guide here: https://gist.github.com/sagudev/839382e70631b1eaed5a4d226b830b6e |
sagudev
approved these changes
Feb 4, 2026
7 tasks
MavenRain
added a commit
to MavenRain/servo
that referenced
this pull request
May 9, 2026
… and `post_message_impl`. Continues the propagation of `&mut JSContext` (issue servo#42347) through the MessagePort message-passing chain: `pack_and_post_message`, `pack_and_post_message_handling_error`, `cross_realm_transform_send_error`, and `post_message_impl` now take `&mut JSContext` instead of `SafeJSContext` (or no `cx` parameter at all). Stream callers in `underlyingsourcecontainer`, `writablestreamdefaultcontroller`, `readablestream`, and `writablestream` pass `cx` through. The `structuredclone::write` signature itself is left as a follow-up; this PR keeps the existing `cx.into()` bridge at the call site in `MessagePort::post_message_impl`, matching the pattern from servo#42342. Testing: No new tests; existing tests in CI cover the message-passing paths. Local cargo check could not be run because `mozjs_sys` requires `lld` (part of `./mach bootstrap`), so I am relying on CI for compile verification. Fixes: servo#42347 Signed-off-by: Onyeka Obi <[email protected]>
MavenRain
added a commit
to MavenRain/servo
that referenced
this pull request
May 9, 2026
… and `post_message_impl`. Continues the propagation of `&mut JSContext` (issue servo#42347) through the MessagePort message-passing chain: `pack_and_post_message`, `pack_and_post_message_handling_error`, `cross_realm_transform_send_error`, and `post_message_impl` now take `&mut JSContext` instead of `SafeJSContext` (or no `cx` parameter at all). Stream callers in `underlyingsourcecontainer`, `writablestreamdefaultcontroller`, `readablestream`, and `writablestream` pass `cx` through. The `structuredclone::write` signature itself is left as a follow-up; this PR keeps the existing `cx.into()` bridge at the call site in `MessagePort::post_message_impl`, matching the pattern from servo#42342. Testing: No new tests; existing tests in CI cover the message-passing paths. Local cargo check could not be run because `mozjs_sys` requires `lld` (part of `./mach bootstrap`), so I am relying on CI for compile verification. Fixes: servo#42347 Signed-off-by: Onyeka Obi <[email protected]>
MavenRain
added a commit
to MavenRain/servo
that referenced
this pull request
May 9, 2026
… and `post_message_impl`. Continues the propagation of `&mut JSContext` (issue servo#42347) through the MessagePort message-passing chain: `pack_and_post_message`, `pack_and_post_message_handling_error`, `cross_realm_transform_send_error`, and `post_message_impl` now take `&mut JSContext` instead of `SafeJSContext` (or no `cx` parameter at all). Stream callers in `underlyingsourcecontainer`, `writablestreamdefaultcontroller`, `readablestream`, and `writablestream` pass `cx` through. The `structuredclone::write` signature itself is left as a follow-up; this PR keeps the existing `cx.into()` bridge at the call site in `MessagePort::post_message_impl`, matching the pattern from servo#42342. Testing: No new tests; existing tests in CI cover the message-passing paths. Local cargo check could not be run because `mozjs_sys` requires `lld` (part of `./mach bootstrap`), so I am relying on CI for compile verification. Fixes: servo#42347 Signed-off-by: Onyeka Obi <[email protected]>
MavenRain
added a commit
to MavenRain/servo
that referenced
this pull request
May 11, 2026
… and `post_message_impl`. Continues the propagation of `&mut JSContext` (issue servo#42347) through the MessagePort message-passing chain: `pack_and_post_message`, `pack_and_post_message_handling_error`, `cross_realm_transform_send_error`, and `post_message_impl` now take `&mut JSContext` instead of `SafeJSContext` (or no `cx` parameter at all). Stream callers in `underlyingsourcecontainer`, `writablestreamdefaultcontroller`, `readablestream`, and `writablestream` pass `cx` through. The `structuredclone::write` signature itself is left as a follow-up; this PR keeps the existing `cx.into()` bridge at the call site in `MessagePort::post_message_impl`, matching the pattern from servo#42342. Testing: No new tests; existing tests in CI cover the message-passing paths. Local cargo check could not be run because `mozjs_sys` requires `lld` (part of `./mach bootstrap`), so I am relying on CI for compile verification. Fixes: servo#42347 Signed-off-by: Onyeka Obi <[email protected]>
MavenRain
added a commit
to MavenRain/servo
that referenced
this pull request
May 11, 2026
… and `post_message_impl`. Continues the propagation of `&mut JSContext` (issue servo#42347) through the MessagePort message-passing chain: `pack_and_post_message`, `pack_and_post_message_handling_error`, `cross_realm_transform_send_error`, and `post_message_impl` now take `&mut JSContext` instead of `SafeJSContext` (or no `cx` parameter at all). Stream callers in `underlyingsourcecontainer`, `writablestreamdefaultcontroller`, `readablestream`, and `writablestream` pass `cx` through. The `structuredclone::write` signature itself is left as a follow-up; this PR keeps the existing `cx.into()` bridge at the call site in `MessagePort::post_message_impl`, matching the pattern from servo#42342. Testing: No new tests; existing tests in CI cover the message-passing paths. Local cargo check could not be run because `mozjs_sys` requires `lld` (part of `./mach bootstrap`), so I am relying on CI for compile verification. Fixes: servo#42347 Signed-off-by: Onyeka Obi <[email protected]>
webbeef
pushed a commit
to webbeef/servo
that referenced
this pull request
May 11, 2026
…and `post_message_impl`. (servo#44806) Continues the propagation of `&mut JSContext` (issue servo#42347) through the MessagePort message-passing chain: `pack_and_post_message`, `pack_and_post_message_handling_error`, `cross_realm_transform_send_error`, and `post_message_impl` now take `&mut JSContext` instead of `SafeJSContext` (or no `cx` parameter at all). Stream callers in `underlyingsourcecontainer`, `writablestreamdefaultcontroller`, `readablestream`, and `writablestream` pass `cx` through. The `structuredclone::write` signature itself is left as a follow-up; this PR keeps the existing `cx.into()` bridge at the call site in `MessagePort::post_message_impl`, matching the pattern from servo#42342. Testing: No new tests; existing tests in CI cover the message-passing paths. Local cargo check could not be run because `mozjs_sys` requires `lld` (part of `./mach bootstrap`), so I am relying on CI for compile verification. Fixes: servo#42347 Signed-off-by: Onyeka Obi <[email protected]>
MavenRain
added a commit
to MavenRain/servo
that referenced
this pull request
May 15, 2026
Migrate `structuredclone::write` from `SafeJSContext` to `&mut JSContext` (issue servo#42347), the last remaining checkbox in the MessagePort/structured-clone propagation chain started by servo#42342. Changes in `bindings/structuredclone.rs`: - Signature: `cx: SafeJSContext` becomes `cx: &mut JSContext`. - Body: `safe_to_jsval(cx, ...)` becomes `safe_to_jsval(cx.into(), ...)`; the `JS_WriteStructuredClone` import moves to `js::rust::wrappers2` so the call site passes `cx` directly; `*cx` becomes `cx.raw_cx()` at the `JS_IsExceptionPending` call site. - The `SafeJSContext` import is retained because the `read_callback` and `read_transfer_callback` paths still construct one via `SafeJSContext::from_ptr`. Caller cleanup across 13 files: drops the now-redundant `cx.into()` bridge at all 15 call sites; `cx` is passed by reborrow directly. All callers already had `cx: &mut JSContext` (or `&mut CurrentRealm` which auto-derefs) from earlier sub-PRs. Fixes servo#42347 Signed-off-by: Onyeka Obi <[email protected]>
MavenRain
added a commit
to MavenRain/servo
that referenced
this pull request
May 15, 2026
Migrate `structuredclone::write` from `SafeJSContext` to `&mut JSContext` (issue servo#42347), the last remaining checkbox in the MessagePort/structured-clone propagation chain started by servo#42342. Changes in `bindings/structuredclone.rs`: - Signature: `cx: SafeJSContext` becomes `cx: &mut JSContext`. - Body: `safe_to_jsval(cx, ...)` becomes `safe_to_jsval(cx.into(), ...)`; the `JS_WriteStructuredClone` import moves to `js::rust::wrappers2` so the call site passes `cx` directly; `*cx` becomes `cx.raw_cx()` at the `JS_IsExceptionPending` call site. - The `SafeJSContext` import is retained because the `read_callback` and `read_transfer_callback` paths still construct one via `SafeJSContext::from_ptr`. Caller cleanup across 13 files: drops the now-redundant `cx.into()` bridge at all 15 call sites; `cx` is passed by reborrow directly. All callers already had `cx: &mut JSContext` (or `&mut CurrentRealm` which auto-derefs) from earlier sub-PRs. Fixes servo#42347 Signed-off-by: Onyeka Obi <[email protected]> Signed-off-by: Onyeka Obi <[email protected]>
MavenRain
added a commit
to MavenRain/servo
that referenced
this pull request
May 15, 2026
Migrate `structuredclone::write` from `SafeJSContext` to `&mut JSContext` (issue servo#42347), the last remaining checkbox in the MessagePort/structured-clone propagation chain started by servo#42342. Changes in `bindings/structuredclone.rs`: - Signature: `cx: SafeJSContext` becomes `cx: &mut JSContext`. - Body: `safe_to_jsval(cx, ...)` becomes `safe_to_jsval(cx.into(), ...)`; the `JS_WriteStructuredClone` import moves to `js::rust::wrappers2` so the call site passes `cx` directly; `*cx` becomes `cx.raw_cx()` at the `JS_IsExceptionPending` call site. - The `SafeJSContext` import is retained because the `read_callback` and `read_transfer_callback` paths still construct one via `SafeJSContext::from_ptr`. Caller cleanup across 13 files: drops the now-redundant `cx.into()` bridge at all 15 call sites; `cx` is passed by reborrow directly. All callers already had `cx: &mut JSContext` (or `&mut CurrentRealm` which auto-derefs) from earlier sub-PRs. Fixes servo#42347 Signed-off-by: Onyeka Obi <[email protected]> Signed-off-by: Onyeka Obi <[email protected]>
pull Bot
pushed a commit
to Patreos998/servo
that referenced
this pull request
May 15, 2026
Migrate `structuredclone::write` from `SafeJSContext` to `&mut JSContext` (issue servo#42347), the last remaining checkbox in the MessagePort / structured-clone propagation chain started by servo#42342. Changes in `components/script/dom/bindings/structuredclone.rs`: - Signature: `cx: SafeJSContext` becomes `cx: &mut JSContext`. - Body: `safe_to_jsval(cx, ...)` becomes `safe_to_jsval(cx.into(), ...)`; `*cx` becomes `cx.raw_cx()` at the two `JS_WriteStructuredClone` and `JS_IsExceptionPending` call sites. - The `SafeJSContext` import is retained because the `read_callback` and `read_transfer_callback` paths still construct one via `SafeJSContext::from_ptr`. Caller cleanup across 13 files: drops the now-redundant `cx.into()` bridge at all 15 call sites; `cx` is passed by reborrow directly. All callers already had `cx: &mut JSContext` (or `&mut CurrentRealm` which auto-derefs) from earlier sub-PRs in the chain. Testing: No new tests required; this is a type-signature refactor (`SafeJSContext` to `&mut JSContext`) with no runtime behavior change. Existing structured-clone tests continue to exercise the same code paths through `JS_WriteStructuredClone` and the `safe_to_jsval` conversion. Fixes: servo#42347 Signed-off-by: Onyeka Obi <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Switch
PostMessageofWorker,DedicatedWorkerGlobalScopeandServiceWokerto use&mut JSContext, propagating it topost_message_impl.Testing: A successful build is enough