Skip to content

script: use &mut JSContext in MessagePort::PostMessage#42880

Merged
Gae24 merged 1 commit intoservo:mainfrom
onsah:issue-42347/message-port-post-message
Feb 26, 2026
Merged

script: use &mut JSContext in MessagePort::PostMessage#42880
Gae24 merged 1 commit intoservo:mainfrom
onsah:issue-42347/message-port-post-message

Conversation

@onsah
Copy link
Copy Markdown
Contributor

@onsah onsah commented Feb 26, 2026

Replace crate::script_runtime::JSContext with js::context::JSContext in MessagePort::PostMessage

Testing: Builds and runs fine
Fixes: part of #42347

Signed-off-by: Onur Sahin <sahinonur2000@hotmail.com>
self.post_message_impl(cx, message, guard)
#[expect(unsafe_code)]
let guard = unsafe { CustomAutoRooterGuard::new(cx.raw_cx(), &mut rooted) };
self.post_message_impl(cx.into(), message, guard)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to push the change to MessagePort::post_message_impl, but that function is also used in MessagePort::pack_and_post_message, which seems to affect a lot of places. I am not sure if those changes are in scope.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah MessagePort::pack_and_post_message is used in stream code too, which requires more code changes. If you want to look into it, you should start propagating JSContext from here:

stream.finish_in_flight_close_with_error(cx.into(), &global, v, CanGc::from_cx(cx));

stream.finish_in_flight_write_with_error(cx.into(), &global, v, CanGc::from_cx(cx));

@onsah onsah marked this pull request as ready for review February 26, 2026 14:57
@onsah onsah requested a review from gterzian as a code owner February 26, 2026 14:57
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Feb 26, 2026
@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Feb 26, 2026
@Gae24 Gae24 added this pull request to the merge queue Feb 26, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Feb 26, 2026
Merged via the queue into servo:main with commit 2a0b460 Feb 26, 2026
34 checks passed
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Feb 26, 2026
shubhamg13 pushed a commit to shubhamg13/servo that referenced this pull request Mar 2, 2026
Replace crate::script_runtime::JSContext with js::context::JSContext in
`MessagePort::PostMessage`

Testing: Builds and runs fine
Fixes: part of servo#42347

Signed-off-by: Onur Sahin <sahinonur2000@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants