mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Ensure ConsumeBodyPromiseHandler values are always rooted (#34194)
* script: Root the use of ComsumeBodyPromiseHandler. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Update mozjs and run crown on mozjs_sys. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
5f927a2c28
commit
20d67bdc44
3 changed files with 10 additions and 8 deletions
|
@ -30,7 +30,7 @@ linker = "lld-link.exe"
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
MACOSX_DEPLOYMENT_TARGET = "13.0"
|
MACOSX_DEPLOYMENT_TARGET = "13.0"
|
||||||
RUSTC_BOOTSTRAP = "crown,script,style_tests,mozjs"
|
RUSTC_BOOTSTRAP = "crown,script,style_tests,mozjs,mozjs_sys"
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
rustdocflags = ["--document-private-items"]
|
rustdocflags = ["--document-private-items"]
|
||||||
|
|
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -4447,7 +4447,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mozjs"
|
name = "mozjs"
|
||||||
version = "0.14.1"
|
version = "0.14.1"
|
||||||
source = "git+https://github.com/servo/mozjs#ce24cb7ef19f0d649ecaa90b6e006c7c213ef991"
|
source = "git+https://github.com/servo/mozjs#1765a7c7eaf1e4a02fdfff6866c8f427c659dc91"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bindgen",
|
"bindgen",
|
||||||
"cc",
|
"cc",
|
||||||
|
@ -4459,8 +4459,8 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mozjs_sys"
|
name = "mozjs_sys"
|
||||||
version = "0.128.6-0"
|
version = "0.128.6-1"
|
||||||
source = "git+https://github.com/servo/mozjs#ce24cb7ef19f0d649ecaa90b6e006c7c213ef991"
|
source = "git+https://github.com/servo/mozjs#1765a7c7eaf1e4a02fdfff6866c8f427c659dc91"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bindgen",
|
"bindgen",
|
||||||
"cc",
|
"cc",
|
||||||
|
|
|
@ -611,6 +611,8 @@ impl Callback for ConsumeBodyPromiseRejectionHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl js::gc::Rootable for ConsumeBodyPromiseHandler {}
|
||||||
|
|
||||||
#[derive(Clone, JSTraceable, MallocSizeOf)]
|
#[derive(Clone, JSTraceable, MallocSizeOf)]
|
||||||
#[crown::unrooted_must_root_lint::must_root]
|
#[crown::unrooted_must_root_lint::must_root]
|
||||||
/// The promise handler used to consume the body,
|
/// The promise handler used to consume the body,
|
||||||
|
@ -747,7 +749,6 @@ pub fn consume_body<T: BodyMixin + DomObject>(
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://fetch.spec.whatwg.org/#concept-body-consume-body
|
// https://fetch.spec.whatwg.org/#concept-body-consume-body
|
||||||
#[allow(crown::unrooted_must_root)]
|
|
||||||
fn consume_body_with_promise<T: BodyMixin + DomObject>(
|
fn consume_body_with_promise<T: BodyMixin + DomObject>(
|
||||||
object: &T,
|
object: &T,
|
||||||
body_type: BodyType,
|
body_type: BodyType,
|
||||||
|
@ -777,14 +778,15 @@ fn consume_body_with_promise<T: BodyMixin + DomObject>(
|
||||||
// https://fetch.spec.whatwg.org/#concept-read-all-bytes-from-readablestream
|
// https://fetch.spec.whatwg.org/#concept-read-all-bytes-from-readablestream
|
||||||
let read_promise = stream.read_a_chunk(can_gc);
|
let read_promise = stream.read_a_chunk(can_gc);
|
||||||
|
|
||||||
let promise_handler = Box::new(ConsumeBodyPromiseHandler {
|
let cx = GlobalScope::get_cx();
|
||||||
|
rooted!(in(*cx) let mut promise_handler = Some(ConsumeBodyPromiseHandler {
|
||||||
result_promise: promise.clone(),
|
result_promise: promise.clone(),
|
||||||
stream: Some(Dom::from_ref(&stream)),
|
stream: Some(Dom::from_ref(&stream)),
|
||||||
body_type: DomRefCell::new(Some(body_type)),
|
body_type: DomRefCell::new(Some(body_type)),
|
||||||
mime_type: DomRefCell::new(Some(object.get_mime_type(can_gc))),
|
mime_type: DomRefCell::new(Some(object.get_mime_type(can_gc))),
|
||||||
// Step 2.
|
// Step 2.
|
||||||
bytes: DomRefCell::new(Some(vec![])),
|
bytes: DomRefCell::new(Some(vec![])),
|
||||||
});
|
}));
|
||||||
|
|
||||||
let rejection_handler = Box::new(ConsumeBodyPromiseRejectionHandler {
|
let rejection_handler = Box::new(ConsumeBodyPromiseRejectionHandler {
|
||||||
result_promise: promise,
|
result_promise: promise,
|
||||||
|
@ -792,7 +794,7 @@ fn consume_body_with_promise<T: BodyMixin + DomObject>(
|
||||||
|
|
||||||
let handler = PromiseNativeHandler::new(
|
let handler = PromiseNativeHandler::new(
|
||||||
&object.global(),
|
&object.global(),
|
||||||
Some(promise_handler),
|
promise_handler.take().map(|h| Box::new(h) as Box<_>),
|
||||||
Some(rejection_handler),
|
Some(rejection_handler),
|
||||||
);
|
);
|
||||||
// We are already in a realm and a script.
|
// We are already in a realm and a script.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue