Mark promise creation methods with CanGc (#33928)

* Add CanGc annotations to promise constructor.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Propagate CanGc arguments for Promise::new_in_current_realm.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Fix out-of-order entries.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Propagate CanGc from Promise::new.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Suppress clippy warning.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Formatting.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2024-10-22 05:35:20 -04:00 committed by GitHub
parent edc304854f
commit 575e885529
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
50 changed files with 422 additions and 221 deletions

View file

@ -264,7 +264,7 @@ impl TransmitBodyConnectHandler {
let realm = enter_realm(&*global);
let comp = InRealm::Entered(&realm);
promise.append_native_handler(&handler, comp);
promise.append_native_handler(&handler, comp, CanGc::note());
}),
&self.canceller,
);
@ -708,7 +708,7 @@ impl Callback for ConsumeBodyPromiseHandler {
let realm = enter_realm(&*global);
let comp = InRealm::Entered(&realm);
read_promise.append_native_handler(&handler, comp);
read_promise.append_native_handler(&handler, comp, CanGc::note());
}
}
}
@ -721,7 +721,7 @@ pub fn consume_body<T: BodyMixin + DomObject>(
can_gc: CanGc,
) -> Rc<Promise> {
let in_realm_proof = AlreadyInRealm::assert();
let promise = Promise::new_in_current_realm(InRealm::Already(&in_realm_proof));
let promise = Promise::new_in_current_realm(InRealm::Already(&in_realm_proof), can_gc);
// Step 1
if object.is_disturbed() || object.is_locked() {
@ -792,7 +792,7 @@ fn consume_body_with_promise<T: BodyMixin + DomObject>(
Some(rejection_handler),
);
// We are already in a realm and a script.
read_promise.append_native_handler(&handler, comp);
read_promise.append_native_handler(&handler, comp, can_gc);
}
// https://fetch.spec.whatwg.org/#concept-body-package-data