diff --git a/components/script/body.rs b/components/script/body.rs index 41886e0aee0..ade32161549 100644 --- a/components/script/body.rs +++ b/components/script/body.rs @@ -42,7 +42,7 @@ pub enum FetchedData { // https://fetch.spec.whatwg.org/#concept-body-consume-body #[allow(unrooted_must_root)] pub fn consume_body(object: &T, body_type: BodyType) -> Rc { - let promise = Promise::new(object.global().r()); + let promise = Promise::new(&object.global_scope()); // Step 1 if object.get_body_used() || object.is_locked() { diff --git a/components/script/dom/bluetooth.rs b/components/script/dom/bluetooth.rs index db32bcd4edf..02bccb80f91 100644 --- a/components/script/dom/bluetooth.rs +++ b/components/script/dom/bluetooth.rs @@ -276,7 +276,7 @@ fn canonicalize_filter(filter: &BluetoothRequestDeviceFilter) -> Fallible(global_ref: GlobalRef, bluetooth_result: Fallible) -> Rc { - let p = Promise::new(global_ref); + let p = Promise::new(global_ref.as_global_scope()); match bluetooth_result { Ok(v) => p.resolve_native(p.global().r().get_cx(), &v), Err(e) => p.reject_error(p.global().r().get_cx(), e), diff --git a/components/script/dom/promise.rs b/components/script/dom/promise.rs index 5fd1ef6f85e..867be7809d3 100644 --- a/components/script/dom/promise.rs +++ b/components/script/dom/promise.rs @@ -18,6 +18,7 @@ use dom::bindings::error::{Error, Fallible}; use dom::bindings::global::GlobalRef; use dom::bindings::js::MutHeapJSVal; use dom::bindings::reflector::{Reflectable, MutReflectable, Reflector}; +use dom::globalscope::GlobalScope; use dom::promisenativehandler::PromiseNativeHandler; use js::conversions::ToJSValConvertible; use js::jsapi::{CallOriginalPromiseResolve, CallOriginalPromiseReject, CallOriginalPromiseThen}; @@ -70,7 +71,7 @@ impl Drop for Promise { impl Promise { #[allow(unsafe_code)] - pub fn new(global: GlobalRef) -> Rc { + pub fn new(global: &GlobalScope) -> Rc { let cx = global.get_cx(); rooted!(in(cx) let mut obj = ptr::null_mut()); unsafe { diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index 0ebeac1ccb1..fdb20fc5114 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -691,11 +691,11 @@ impl TestBindingMethods for TestBinding { fn PromiseNativeHandler(&self, resolve: Option>, reject: Option>) -> Rc { - let global = self.global(); - let handler = PromiseNativeHandler::new(global.r().as_global_scope(), + let global = self.global_scope(); + let handler = PromiseNativeHandler::new(&global, resolve.map(SimpleHandler::new), reject.map(SimpleHandler::new)); - let p = Promise::new(global.r()); + let p = Promise::new(&global); p.append_native_handler(&handler); return p; @@ -720,7 +720,7 @@ impl TestBindingMethods for TestBinding { #[allow(unrooted_must_root)] fn PromiseAttribute(&self) -> Rc { - Promise::new(self.global().r()) + Promise::new(&self.global_scope()) } fn AcceptPromise(&self, _promise: &Promise) { diff --git a/components/script/fetch.rs b/components/script/fetch.rs index 75d6e3b0848..bc04a5ecd92 100644 --- a/components/script/fetch.rs +++ b/components/script/fetch.rs @@ -70,8 +70,9 @@ pub fn Fetch(global: GlobalRef, input: RequestOrUSVString, init: &RequestInit) - let core_resource_thread = global.core_resource_thread(); // Step 1 - let promise = Promise::new(global); - let response = Response::new(global.as_global_scope()); + let global_scope = global.as_global_scope(); + let promise = Promise::new(global_scope); + let response = Response::new(global_scope); // Step 2 let request = match Request::Constructor(global, input, init) {