script: make Error::to_jsval safe (#35411)

Signed-off-by: Stephen Muss <stephenmuss@gmail.com>
This commit is contained in:
Stephen Muss 2025-02-11 10:47:31 +11:00 committed by GitHub
parent 8486e585f5
commit cb588bab6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 41 additions and 64 deletions

View file

@ -450,7 +450,6 @@ impl ReadableStreamDefaultController {
}
/// <https://streams.spec.whatwg.org/#readable-stream-default-controller-call-pull-if-needed>
#[allow(unsafe_code)]
fn call_pull_if_needed(&self, can_gc: CanGc) {
if !self.should_call_pull() {
return;
@ -500,11 +499,9 @@ impl ReadableStreamDefaultController {
let cx = GlobalScope::get_cx();
rooted!(in(*cx) let mut rval = UndefinedValue());
// TODO: check if `self.global()` is the right globalscope.
unsafe {
error
.clone()
.to_jsval(*cx, &self.global(), rval.handle_mut())
};
error
.clone()
.to_jsval(cx, &self.global(), rval.handle_mut());
let promise = Promise::new(&global, can_gc);
promise.reject_native(&rval.handle());
promise
@ -513,7 +510,6 @@ impl ReadableStreamDefaultController {
}
/// <https://streams.spec.whatwg.org/#rs-default-controller-private-cancel>
#[allow(unsafe_code)]
pub(crate) fn perform_cancel_steps(
&self,
reason: SafeHandleValue,
@ -540,11 +536,9 @@ impl ReadableStreamDefaultController {
let cx = GlobalScope::get_cx();
rooted!(in(*cx) let mut rval = UndefinedValue());
// TODO: check if `self.global()` is the right globalscope.
unsafe {
error
.clone()
.to_jsval(*cx, &self.global(), rval.handle_mut())
};
error
.clone()
.to_jsval(cx, &self.global(), rval.handle_mut());
let promise = Promise::new(&global, can_gc);
promise.reject_native(&rval.handle());
promise