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

@ -25,6 +25,7 @@ use crate::dom::bindings::root::{Dom, DomRoot};
use crate::dom::fakexrdevice::{get_origin, get_views, get_world, FakeXRDevice};
use crate::dom::globalscope::GlobalScope;
use crate::dom::promise::Promise;
use crate::script_runtime::CanGc;
use crate::script_thread::ScriptThread;
use crate::task_source::TaskSource;
@ -67,9 +68,9 @@ impl XRTest {
impl XRTestMethods for XRTest {
/// <https://github.com/immersive-web/webxr-test-api/blob/master/explainer.md>
#[allow(unsafe_code)]
fn SimulateDeviceConnection(&self, init: &FakeXRDeviceInit) -> Rc<Promise> {
fn SimulateDeviceConnection(&self, init: &FakeXRDeviceInit, can_gc: CanGc) -> Rc<Promise> {
let global = self.global();
let p = Promise::new(&global);
let p = Promise::new(&global, can_gc);
let origin = if let Some(ref o) = init.viewerOrigin {
match get_origin(o) {
@ -188,10 +189,10 @@ impl XRTestMethods for XRTest {
}
/// <https://github.com/immersive-web/webxr-test-api/blob/master/explainer.md>
fn DisconnectAllDevices(&self) -> Rc<Promise> {
fn DisconnectAllDevices(&self, can_gc: CanGc) -> Rc<Promise> {
// XXXManishearth implement device disconnection and session ending
let global = self.global();
let p = Promise::new(&global);
let p = Promise::new(&global, can_gc);
let mut devices = self.devices_connected.borrow_mut();
if devices.is_empty() {
p.resolve_native(&());