aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/body.rs8
-rw-r--r--components/script/dom/bindings/refcounted.rs6
-rw-r--r--components/script/dom/bluetooth.rs51
-rw-r--r--components/script/dom/bluetoothdevice.rs9
-rw-r--r--components/script/dom/bluetoothpermissionresult.rs9
-rw-r--r--components/script/dom/bluetoothremotegattcharacteristic.rs32
-rw-r--r--components/script/dom/bluetoothremotegattdescriptor.rs20
-rw-r--r--components/script/dom/bluetoothremotegattserver.rs13
-rw-r--r--components/script/dom/bluetoothremotegattservice.rs4
-rw-r--r--components/script/dom/document.rs2
-rw-r--r--components/script/dom/element.rs8
-rw-r--r--components/script/dom/permissions.rs4
-rw-r--r--components/script/dom/promise.rs4
-rw-r--r--components/script/dom/serviceworkercontainer.rs13
-rw-r--r--components/script/dom/testbinding.rs2
-rw-r--r--components/script/dom/vr.rs2
-rw-r--r--components/script/dom/worklet.rs2
-rw-r--r--components/script/fetch.rs6
-rw-r--r--components/script/serviceworkerjob.rs9
19 files changed, 110 insertions, 94 deletions
diff --git a/components/script/body.rs b/components/script/body.rs
index 7f55b1bbac9..83fe5b11932 100644
--- a/components/script/body.rs
+++ b/components/script/body.rs
@@ -44,8 +44,9 @@ pub fn consume_body<T: BodyOperations + DomObject>(object: &T, body_type: BodyTy
// Step 1
if object.get_body_used() || object.is_locked() {
- promise.reject_error(promise.global().get_cx(), Error::Type(
- "The response's stream is disturbed or locked".to_string()));
+ promise.reject_error(Error::Type(
+ "The response's stream is disturbed or locked".to_string(),
+ ));
return promise;
}
@@ -75,7 +76,6 @@ pub fn consume_body_with_promise<T: BodyOperations + DomObject>(object: &T,
body_type,
object.get_mime_type());
- let cx = promise.global().get_cx();
match pkg_data_results {
Ok(results) => {
match results {
@@ -85,7 +85,7 @@ pub fn consume_body_with_promise<T: BodyOperations + DomObject>(object: &T,
FetchedData::FormData(f) => promise.resolve_native(&f),
};
},
- Err(err) => promise.reject_error(cx, err),
+ Err(err) => promise.reject_error(err),
}
}
diff --git a/components/script/dom/bindings/refcounted.rs b/components/script/dom/bindings/refcounted.rs
index 2e2c41dc8a5..0a00148d661 100644
--- a/components/script/dom/bindings/refcounted.rs
+++ b/components/script/dom/bindings/refcounted.rs
@@ -29,7 +29,6 @@ use dom::bindings::js::Root;
use dom::bindings::reflector::{DomObject, Reflector};
use dom::bindings::trace::trace_reflector;
use dom::promise::Promise;
-use js::jsapi::JSAutoCompartment;
use js::jsapi::JSTracer;
use libc;
use std::cell::RefCell;
@@ -126,10 +125,7 @@ impl TrustedPromise {
let this = self;
task!(reject_promise: move || {
debug!("Rejecting promise.");
- let this = this.root();
- let cx = this.global().get_cx();
- let _ac = JSAutoCompartment::new(cx, this.reflector().get_jsobject().get());
- this.reject_error(cx, error);
+ this.root().reject_error(error);
})
}
diff --git a/components/script/dom/bluetooth.rs b/components/script/dom/bluetooth.rs
index f7abfaf2c02..5ea1e06f215 100644
--- a/components/script/dom/bluetooth.rs
+++ b/components/script/dom/bluetooth.rs
@@ -110,7 +110,7 @@ impl<T: AsyncBluetoothListener + DomObject> BluetoothContext<T> {
Ok(response) => self.receiver.root().handle_response(response, promise_cx, &promise),
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice
// Step 3 - 4.
- Err(error) => promise.reject_error(promise_cx, Error::from(error)),
+ Err(error) => promise.reject_error(Error::from(error)),
}
}
}
@@ -158,7 +158,7 @@ impl Bluetooth {
if let &Some(ref filters) = filters {
// Step 2.1.
if filters.is_empty() {
- p.reject_error(p.global().get_cx(), Type(FILTER_EMPTY_ERROR.to_owned()));
+ p.reject_error(Type(FILTER_EMPTY_ERROR.to_owned()));
return;
}
@@ -171,7 +171,7 @@ impl Bluetooth {
// Step 2.4.2.
Ok(f) => uuid_filters.push(f),
Err(e) => {
- p.reject_error(p.global().get_cx(), e);
+ p.reject_error(e);
return;
},
}
@@ -186,7 +186,7 @@ impl Bluetooth {
let uuid = match BluetoothUUID::service(opt_service.clone()) {
Ok(u) => u.to_string(),
Err(e) => {
- p.reject_error(p.global().get_cx(), e);
+ p.reject_error(e);
return;
},
};
@@ -205,7 +205,7 @@ impl Bluetooth {
// Step 4 - 5.
if let PermissionState::Denied = get_descriptor_permission_state(PermissionName::Bluetooth, None) {
- return p.reject_error(p.global().get_cx(), Error::NotFound);
+ return p.reject_error(Error::NotFound);
}
// Note: Step 3, 6 - 8 are implemented in
@@ -266,20 +266,19 @@ pub fn get_gatt_children<T, F> (
where T: AsyncBluetoothListener + DomObject + 'static,
F: FnOnce(StringOrUnsignedLong) -> Fallible<UUID> {
let p = Promise::new(&attribute.global());
- let p_cx = p.global().get_cx();
let result_uuid = if let Some(u) = uuid {
// Step 1.
let canonicalized = match uuid_canonicalizer(u) {
Ok(canonicalized_uuid) => canonicalized_uuid.to_string(),
Err(e) => {
- p.reject_error(p_cx, e);
+ p.reject_error(e);
return p;
}
};
// Step 2.
if uuid_is_blocklisted(canonicalized.as_ref(), Blocklist::All) {
- p.reject_error(p_cx, Security);
+ p.reject_error(Security);
return p;
}
Some(canonicalized)
@@ -289,7 +288,7 @@ pub fn get_gatt_children<T, F> (
// Step 3 - 4.
if !connected {
- p.reject_error(p_cx, Network);
+ p.reject_error(Network);
return p;
}
@@ -479,7 +478,7 @@ impl BluetoothMethods for Bluetooth {
// Step 1.
if (option.filters.is_some() && option.acceptAllDevices) ||
(option.filters.is_none() && !option.acceptAllDevices) {
- p.reject_error(p.global().get_cx(), Error::Type(OPTIONS_ERROR.to_owned()));
+ p.reject_error(Error::Type(OPTIONS_ERROR.to_owned()));
return p;
}
@@ -507,7 +506,11 @@ impl BluetoothMethods for Bluetooth {
}
impl AsyncBluetoothListener for Bluetooth {
- fn handle_response(&self, response: BluetoothResponse, promise_cx: *mut JSContext, promise: &Rc<Promise>) {
+ fn handle_response(
+ &self, response: BluetoothResponse,
+ _promise_cx: *mut JSContext,
+ promise: &Rc<Promise>,
+ ) {
match response {
// https://webbluetoothcg.github.io/web-bluetooth/#request-bluetooth-devices
// Step 11, 13 - 14.
@@ -537,7 +540,7 @@ impl AsyncBluetoothListener for Bluetooth {
BluetoothResponse::GetAvailability(is_available) => {
promise.resolve_native(&is_available);
}
- _ => promise.reject_error(promise_cx, Error::Type("Something went wrong...".to_owned())),
+ _ => promise.reject_error(Error::Type("Something went wrong...".to_owned())),
}
}
}
@@ -562,9 +565,12 @@ impl PermissionAlgorithm for Bluetooth {
}
// https://webbluetoothcg.github.io/web-bluetooth/#query-the-bluetooth-permission
- fn permission_query(cx: *mut JSContext, promise: &Rc<Promise>,
- descriptor: &BluetoothPermissionDescriptor,
- status: &BluetoothPermissionResult) {
+ fn permission_query(
+ _cx: *mut JSContext,
+ promise: &Rc<Promise>,
+ descriptor: &BluetoothPermissionDescriptor,
+ status: &BluetoothPermissionResult,
+ ) {
// Step 1: We are not using the `global` variable.
// Step 2.
@@ -604,7 +610,7 @@ impl PermissionAlgorithm for Bluetooth {
for filter in filters {
match canonicalize_filter(&filter) {
Ok(f) => scan_filters.push(f),
- Err(error) => return promise.reject_error(cx, error),
+ Err(error) => return promise.reject_error(error),
}
}
@@ -620,7 +626,7 @@ impl PermissionAlgorithm for Bluetooth {
match receiver.recv().unwrap() {
Ok(true) => (),
Ok(false) => continue,
- Err(error) => return promise.reject_error(cx, Error::from(error)),
+ Err(error) => return promise.reject_error(Error::from(error)),
};
}
@@ -641,12 +647,15 @@ impl PermissionAlgorithm for Bluetooth {
}
// https://webbluetoothcg.github.io/web-bluetooth/#request-the-bluetooth-permission
- fn permission_request(cx: *mut JSContext, promise: &Rc<Promise>,
- descriptor: &BluetoothPermissionDescriptor,
- status: &BluetoothPermissionResult) {
+ fn permission_request(
+ _cx: *mut JSContext,
+ promise: &Rc<Promise>,
+ descriptor: &BluetoothPermissionDescriptor,
+ status: &BluetoothPermissionResult,
+ ) {
// Step 1.
if descriptor.filters.is_some() == descriptor.acceptAllDevices {
- return promise.reject_error(cx, Error::Type(OPTIONS_ERROR.to_owned()));
+ return promise.reject_error(Error::Type(OPTIONS_ERROR.to_owned()));
}
// Step 2.
diff --git a/components/script/dom/bluetoothdevice.rs b/components/script/dom/bluetoothdevice.rs
index 32a2b99314d..074b1da7d17 100644
--- a/components/script/dom/bluetoothdevice.rs
+++ b/components/script/dom/bluetoothdevice.rs
@@ -266,7 +266,12 @@ impl BluetoothDeviceMethods for BluetoothDevice {
}
impl AsyncBluetoothListener for BluetoothDevice {
- fn handle_response(&self, response: BluetoothResponse, promise_cx: *mut JSContext, promise: &Rc<Promise>) {
+ fn handle_response(
+ &self,
+ response: BluetoothResponse,
+ _promise_cx: *mut JSContext,
+ promise: &Rc<Promise>,
+ ) {
match response {
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-unwatchadvertisements
BluetoothResponse::WatchAdvertisements(_result) => {
@@ -275,7 +280,7 @@ impl AsyncBluetoothListener for BluetoothDevice {
// Step 3.2.
promise.resolve_native(&());
},
- _ => promise.reject_error(promise_cx, Error::Type("Something went wrong...".to_owned())),
+ _ => promise.reject_error(Error::Type("Something went wrong...".to_owned())),
}
}
}
diff --git a/components/script/dom/bluetoothpermissionresult.rs b/components/script/dom/bluetoothpermissionresult.rs
index 36b3eb00192..661ebd9a30c 100644
--- a/components/script/dom/bluetoothpermissionresult.rs
+++ b/components/script/dom/bluetoothpermissionresult.rs
@@ -83,7 +83,12 @@ impl BluetoothPermissionResultMethods for BluetoothPermissionResult {
}
impl AsyncBluetoothListener for BluetoothPermissionResult {
- fn handle_response(&self, response: BluetoothResponse, promise_cx: *mut JSContext, promise: &Rc<Promise>) {
+ fn handle_response(
+ &self,
+ response: BluetoothResponse,
+ _promise_cx: *mut JSContext,
+ promise: &Rc<Promise>,
+ ) {
match response {
// https://webbluetoothcg.github.io/web-bluetooth/#request-bluetooth-devices
// Step 3, 11, 13 - 14.
@@ -119,7 +124,7 @@ impl AsyncBluetoothListener for BluetoothPermissionResult {
// Step 8.
promise.resolve_native(self);
},
- _ => promise.reject_error(promise_cx, Error::Type("Something went wrong...".to_owned())),
+ _ => promise.reject_error(Error::Type("Something went wrong...".to_owned())),
}
}
}
diff --git a/components/script/dom/bluetoothremotegattcharacteristic.rs b/components/script/dom/bluetoothremotegattcharacteristic.rs
index b6d92648448..42c0a634190 100644
--- a/components/script/dom/bluetoothremotegattcharacteristic.rs
+++ b/components/script/dom/bluetoothremotegattcharacteristic.rs
@@ -124,17 +124,16 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-readvalue
fn ReadValue(&self) -> Rc<Promise> {
let p = Promise::new(&self.global());
- let p_cx = p.global().get_cx();
// Step 1.
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Reads) {
- p.reject_error(p_cx, Security);
+ p.reject_error(Security);
return p;
}
// Step 2.
if !self.Service().Device().get_gatt().Connected() {
- p.reject_error(p_cx, Network);
+ p.reject_error(Network);
return p;
}
@@ -142,7 +141,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
// Step 5.1.
if !self.Properties().Read() {
- p.reject_error(p_cx, NotSupported);
+ p.reject_error(NotSupported);
return p;
}
@@ -158,23 +157,22 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-writevalue
fn WriteValue(&self, value: Vec<u8>) -> Rc<Promise> {
let p = Promise::new(&self.global());
- let p_cx = p.global().get_cx();
// Step 1.
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Writes) {
- p.reject_error(p_cx, Security);
+ p.reject_error(Security);
return p;
}
// Step 2 - 3.
if value.len() > MAXIMUM_ATTRIBUTE_LENGTH {
- p.reject_error(p_cx, InvalidModification);
+ p.reject_error(InvalidModification);
return p;
}
// Step 4.
if !self.Service().Device().get_gatt().Connected() {
- p.reject_error(p_cx, Network);
+ p.reject_error(Network);
return p;
}
@@ -184,7 +182,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
if !(self.Properties().Write() ||
self.Properties().WriteWithoutResponse() ||
self.Properties().AuthenticatedSignedWrites()) {
- p.reject_error(p_cx, NotSupported);
+ p.reject_error(NotSupported);
return p;
}
@@ -200,24 +198,23 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-startnotifications
fn StartNotifications(&self) -> Rc<Promise> {
let p = Promise::new(&self.global());
- let p_cx = p.global().get_cx();
// Step 1.
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Reads) {
- p.reject_error(p_cx, Security);
+ p.reject_error(Security);
return p;
}
// Step 2.
if !self.Service().Device().get_gatt().Connected() {
- p.reject_error(p_cx, Network);
+ p.reject_error(Network);
return p;
}
// Step 5.
if !(self.Properties().Notify() ||
self.Properties().Indicate()) {
- p.reject_error(p_cx, NotSupported);
+ p.reject_error(NotSupported);
return p;
}
@@ -255,7 +252,12 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
}
impl AsyncBluetoothListener for BluetoothRemoteGATTCharacteristic {
- fn handle_response(&self, response: BluetoothResponse, promise_cx: *mut JSContext, promise: &Rc<Promise>) {
+ fn handle_response(
+ &self,
+ response: BluetoothResponse,
+ _promise_cx: *mut JSContext,
+ promise: &Rc<Promise>,
+ ) {
let device = self.Service().Device();
match response {
// https://webbluetoothcg.github.io/web-bluetooth/#getgattchildren
@@ -308,7 +310,7 @@ impl AsyncBluetoothListener for BluetoothRemoteGATTCharacteristic {
// (StopNotification) Step 5.
promise.resolve_native(self);
},
- _ => promise.reject_error(promise_cx, Error::Type("Something went wrong...".to_owned())),
+ _ => promise.reject_error(Error::Type("Something went wrong...".to_owned())),
}
}
}
diff --git a/components/script/dom/bluetoothremotegattdescriptor.rs b/components/script/dom/bluetoothremotegattdescriptor.rs
index 941683cbe95..1ab100fb522 100644
--- a/components/script/dom/bluetoothremotegattdescriptor.rs
+++ b/components/script/dom/bluetoothremotegattdescriptor.rs
@@ -89,17 +89,16 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-readvalue
fn ReadValue(&self) -> Rc<Promise> {
let p = Promise::new(&self.global());
- let p_cx = p.global().get_cx();
// Step 1.
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Reads) {
- p.reject_error(p_cx, Security);
+ p.reject_error(Security);
return p;
}
// Step 2.
if !self.Characteristic().Service().Device().get_gatt().Connected() {
- p.reject_error(p_cx, Network);
+ p.reject_error(Network);
return p;
}
@@ -116,23 +115,22 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-writevalue
fn WriteValue(&self, value: Vec<u8>) -> Rc<Promise> {
let p = Promise::new(&self.global());
- let p_cx = p.global().get_cx();
// Step 1.
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Writes) {
- p.reject_error(p_cx, Security);
+ p.reject_error(Security);
return p;
}
// Step 2 - 3.
if value.len() > MAXIMUM_ATTRIBUTE_LENGTH {
- p.reject_error(p_cx, InvalidModification);
+ p.reject_error(InvalidModification);
return p;
}
// Step 4.
if !self.Characteristic().Service().Device().get_gatt().Connected() {
- p.reject_error(p_cx, Network);
+ p.reject_error(Network);
return p;
}
@@ -147,7 +145,11 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
}
impl AsyncBluetoothListener for BluetoothRemoteGATTDescriptor {
- fn handle_response(&self, response: BluetoothResponse, promise_cx: *mut JSContext, promise: &Rc<Promise>) {
+ fn handle_response(
+ &self, response: BluetoothResponse,
+ _promise_cx: *mut JSContext,
+ promise: &Rc<Promise>,
+ ) {
match response {
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-readvalue
BluetoothResponse::ReadValue(result) => {
@@ -173,7 +175,7 @@ impl AsyncBluetoothListener for BluetoothRemoteGATTDescriptor {
// TODO: Resolve promise with undefined instead of a value.
promise.resolve_native(&());
},
- _ => promise.reject_error(promise_cx, Error::Type("Something went wrong...".to_owned())),
+ _ => promise.reject_error(Error::Type("Something went wrong...".to_owned())),
}
}
}
diff --git a/components/script/dom/bluetoothremotegattserver.rs b/components/script/dom/bluetoothremotegattserver.rs
index abc597f0989..7e7f8e64e9e 100644
--- a/components/script/dom/bluetoothremotegattserver.rs
+++ b/components/script/dom/bluetoothremotegattserver.rs
@@ -120,16 +120,21 @@ impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer {
}
impl AsyncBluetoothListener for BluetoothRemoteGATTServer {
- fn handle_response(&self, response: BluetoothResponse, promise_cx: *mut JSContext, promise: &Rc<Promise>) {
+ fn handle_response(
+ &self,
+ response: BluetoothResponse,
+ _promise_cx: *mut JSContext,
+ promise: &Rc<Promise>,
+ ) {
match response {
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-connect
BluetoothResponse::GATTServerConnect(connected) => {
// Step 5.2.3
if self.Device().is_represented_device_null() {
if let Err(e) = self.Device().garbage_collect_the_connection() {
- return promise.reject_error(promise_cx, Error::from(e));
+ return promise.reject_error(Error::from(e));
}
- return promise.reject_error(promise_cx, Error::Network);
+ return promise.reject_error(Error::Network);
}
// Step 5.2.4.
@@ -153,7 +158,7 @@ impl AsyncBluetoothListener for BluetoothRemoteGATTServer {
}
promise.resolve_native(&services);
},
- _ => promise.reject_error(promise_cx, Error::Type("Something went wrong...".to_owned())),
+ _ => promise.reject_error(Error::Type("Something went wrong...".to_owned())),
}
}
}
diff --git a/components/script/dom/bluetoothremotegattservice.rs b/components/script/dom/bluetoothremotegattservice.rs
index afbd5f1cbb6..0a8509603c1 100644
--- a/components/script/dom/bluetoothremotegattservice.rs
+++ b/components/script/dom/bluetoothremotegattservice.rs
@@ -128,7 +128,7 @@ impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService {
}
impl AsyncBluetoothListener for BluetoothRemoteGATTService {
- fn handle_response(&self, response: BluetoothResponse, promise_cx: *mut JSContext, promise: &Rc<Promise>) {
+ fn handle_response(&self, response: BluetoothResponse, _promise_cx: *mut JSContext, promise: &Rc<Promise>) {
let device = self.Device();
match response {
// https://webbluetoothcg.github.io/web-bluetooth/#getgattchildren
@@ -158,7 +158,7 @@ impl AsyncBluetoothListener for BluetoothRemoteGATTService {
}
promise.resolve_native(&services);
},
- _ => promise.reject_error(promise_cx, Error::Type("Something went wrong...".to_owned())),
+ _ => promise.reject_error(Error::Type("Something went wrong...".to_owned())),
}
}
}
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index e50ff071f6e..c5940f02b48 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -2671,7 +2671,7 @@ impl Document {
let promise = Promise::new(global.r());
// Step 2
if self.fullscreen_element.get().is_none() {
- promise.reject_error(global.get_cx(), Error::Type(String::from("fullscreen is null")));
+ promise.reject_error(Error::Type(String::from("fullscreen is null")));
return promise
}
// TODO Step 3-6
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index 76990dc9aa6..d7996348109 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -3053,17 +3053,13 @@ impl TaskOnce for ElementPerformFullscreenEnter {
#[allow(unrooted_must_root)]
fn run_once(self) {
let element = self.element.root();
+ let promise = self.promise.root();
let document = document_from_node(element.r());
// Step 7.1
if self.error || !element.fullscreen_element_ready_check() {
- // JSAutoCompartment needs to be manually made.
- // Otherwise, Servo will crash.
- let promise = self.promise.root();
- let promise_cx = promise.global().get_cx();
- let _ac = JSAutoCompartment::new(promise_cx, promise.reflector().get_jsobject().get());
document.upcast::<EventTarget>().fire_event(atom!("fullscreenerror"));
- promise.reject_error(promise.global().get_cx(), Error::Type(String::from("fullscreen is not connected")));
+ promise.reject_error(Error::Type(String::from("fullscreen is not connected")));
return
}
diff --git a/components/script/dom/permissions.rs b/components/script/dom/permissions.rs
index a73b9591d65..99908aa51e9 100644
--- a/components/script/dom/permissions.rs
+++ b/components/script/dom/permissions.rs
@@ -89,7 +89,7 @@ impl Permissions {
let root_desc = match Permissions::create_descriptor(cx, permissionDesc) {
Ok(descriptor) => descriptor,
Err(error) => {
- p.reject_error(cx, error);
+ p.reject_error(error);
return p;
},
};
@@ -103,7 +103,7 @@ impl Permissions {
let bluetooth_desc = match Bluetooth::create_descriptor(cx, permissionDesc) {
Ok(descriptor) => descriptor,
Err(error) => {
- p.reject_error(cx, error);
+ p.reject_error(error);
return p;
},
};
diff --git a/components/script/dom/promise.rs b/components/script/dom/promise.rs
index 9ba110456c8..ef4919beabd 100644
--- a/components/script/dom/promise.rs
+++ b/components/script/dom/promise.rs
@@ -173,7 +173,9 @@ impl Promise {
}
#[allow(unsafe_code)]
- pub fn reject_error(&self, cx: *mut JSContext, error: Error) {
+ pub fn reject_error(&self, error: Error) {
+ let cx = self.global().get_cx();
+ let _ac = JSAutoCompartment::new(cx, self.reflector().get_jsobject().get());
rooted!(in(cx) let mut v = UndefinedValue());
unsafe {
error.to_jsval(cx, &self.global(), v.handle_mut());
diff --git a/components/script/dom/serviceworkercontainer.rs b/components/script/dom/serviceworkercontainer.rs
index 37e89714fe2..ed423c0a849 100644
--- a/components/script/dom/serviceworkercontainer.rs
+++ b/components/script/dom/serviceworkercontainer.rs
@@ -58,14 +58,13 @@ impl ServiceWorkerContainerMethods for ServiceWorkerContainer {
options: &RegistrationOptions) -> Rc<Promise> {
// A: Step 1
let promise = Promise::new(&*self.global());
- let ctx = (&*self.global()).get_cx();
let USVString(ref script_url) = script_url;
let api_base_url = self.global().api_base_url();
// A: Step 3-5
let script_url = match api_base_url.join(script_url) {
Ok(url) => url,
Err(_) => {
- promise.reject_error(ctx, Error::Type("Invalid script URL".to_owned()));
+ promise.reject_error(Error::Type("Invalid script URL".to_owned()));
return promise;
}
};
@@ -73,14 +72,14 @@ impl ServiceWorkerContainerMethods for ServiceWorkerContainer {
match script_url.scheme() {
"https" | "http" => {},
_ => {
- promise.reject_error(ctx, Error::Type("Only secure origins are allowed".to_owned()));
+ promise.reject_error(Error::Type("Only secure origins are allowed".to_owned()));
return promise;
}
}
// B: Step 3
if script_url.path().to_ascii_lowercase().contains("%2f") ||
script_url.path().to_ascii_lowercase().contains("%5c") {
- promise.reject_error(ctx, Error::Type("Script URL contains forbidden characters".to_owned()));
+ promise.reject_error(Error::Type("Script URL contains forbidden characters".to_owned()));
return promise;
}
// B: Step 4-5
@@ -90,7 +89,7 @@ impl ServiceWorkerContainerMethods for ServiceWorkerContainer {
match api_base_url.join(inner_scope) {
Ok(url) => url,
Err(_) => {
- promise.reject_error(ctx, Error::Type("Invalid scope URL".to_owned()));
+ promise.reject_error(Error::Type("Invalid scope URL".to_owned()));
return promise;
}
}
@@ -101,14 +100,14 @@ impl ServiceWorkerContainerMethods for ServiceWorkerContainer {
match scope.scheme() {
"https" | "http" => {},
_ => {
- promise.reject_error(ctx, Error::Type("Only secure origins are allowed".to_owned()));
+ promise.reject_error(Error::Type("Only secure origins are allowed".to_owned()));
return promise;
}
}
// B: Step 7
if scope.path().to_ascii_lowercase().contains("%2f") ||
scope.path().to_ascii_lowercase().contains("%5c") {
- promise.reject_error(ctx, Error::Type("Scope URL contains forbidden characters".to_owned()));
+ promise.reject_error(Error::Type("Scope URL contains forbidden characters".to_owned()));
return promise;
}
diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs
index d6407e31d58..1a56a77a64f 100644
--- a/components/script/dom/testbinding.rs
+++ b/components/script/dom/testbinding.rs
@@ -695,7 +695,7 @@ impl TestBindingMethods for TestBinding {
}
fn PromiseRejectWithTypeError(&self, p: &Promise, s: USVString) {
- p.reject_error(self.global().get_cx(), Error::Type(s.0));
+ p.reject_error(Error::Type(s.0));
}
#[allow(unrooted_must_root)]
diff --git a/components/script/dom/vr.rs b/components/script/dom/vr.rs
index 226979d0888..04c63a2f002 100644
--- a/components/script/dom/vr.rs
+++ b/components/script/dom/vr.rs
@@ -79,7 +79,7 @@ impl VRMethods for VR {
}
} else {
// WebVR spec: The Promise MUST be rejected if WebVR is not enabled/supported.
- promise.reject_error(promise.global().get_cx(), Error::Security);
+ promise.reject_error(Error::Security);
return promise;
}
diff --git a/components/script/dom/worklet.rs b/components/script/dom/worklet.rs
index 4028670b393..6049f7cf0e0 100644
--- a/components/script/dom/worklet.rs
+++ b/components/script/dom/worklet.rs
@@ -123,7 +123,7 @@ impl WorkletMethods for Worklet {
Err(err) => {
// Step 4.
debug!("URL {:?} parse error {:?}.", module_url.0, err);
- promise.reject_error(self.window.get_cx(), Error::Syntax);
+ promise.reject_error(Error::Syntax);
return promise;
}
};
diff --git a/components/script/fetch.rs b/components/script/fetch.rs
index 9fe0932eab4..47be4ced130 100644
--- a/components/script/fetch.rs
+++ b/components/script/fetch.rs
@@ -77,7 +77,7 @@ pub fn Fetch(global: &GlobalScope, input: RequestInfo, init: RootedTraceableBox<
// Step 2
let request = match Request::Constructor(global, input, init) {
Err(e) => {
- promise.reject_error(promise.global().get_cx(), e);
+ promise.reject_error(e);
return promise;
},
Ok(r) => r.get_request(),
@@ -135,9 +135,7 @@ impl FetchResponseListener for FetchContext {
match fetch_metadata {
// Step 4.1
Err(_) => {
- promise.reject_error(
- promise.global().get_cx(),
- Error::Type("Network error occurred".to_string()));
+ promise.reject_error(Error::Type("Network error occurred".to_string()));
self.fetch_promise = Some(TrustedPromise::new(promise));
self.response_object.root().set_type(DOMResponseType::Error);
return;
diff --git a/components/script/serviceworkerjob.rs b/components/script/serviceworkerjob.rs
index bb5b9e8be91..f9eddbb9af4 100644
--- a/components/script/serviceworkerjob.rs
+++ b/components/script/serviceworkerjob.rs
@@ -13,11 +13,9 @@ use dom::bindings::js::JS;
use dom::bindings::refcounted::{Trusted, TrustedPromise};
use dom::bindings::reflector::DomObject;
use dom::client::Client;
-use dom::globalscope::GlobalScope;
use dom::promise::Promise;
use dom::serviceworkerregistration::ServiceWorkerRegistration;
use dom::urlhelper::UrlHelper;
-use js::jsapi::JSAutoCompartment;
use script_thread::ScriptThread;
use servo_url::ServoUrl;
use std::cmp::PartialEq;
@@ -261,11 +259,10 @@ impl JobQueue {
}
}
-fn settle_job_promise(global: &GlobalScope, promise: &Promise, settle: SettleType) {
- let _ac = JSAutoCompartment::new(global.get_cx(), promise.reflector().get_jsobject().get());
+fn settle_job_promise(promise: &Promise, settle: SettleType) {
match settle {
SettleType::Resolve(reg) => promise.resolve_native(&*reg.root()),
- SettleType::Reject(err) => promise.reject_error(global.get_cx(), err),
+ SettleType::Reject(err) => promise.reject_error(err),
};
}
@@ -277,7 +274,7 @@ fn queue_settle_promise_for_job(job: &Job, settle: SettleType, task_source: &DOM
let _ = task_source.queue(
task!(settle_promise_for_job: move || {
let promise = promise.root();
- settle_job_promise(&promise.global(), &promise, settle)
+ settle_job_promise(&promise, settle)
}),
&*global,
);