Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions components/script/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ pub(crate) fn consume_body<T: BodyMixin + DomObject>(

// If object is unusable, then return a promise rejected with a TypeError.
if object.is_unusable() {
promise.reject_error_with_cx(
promise.reject_error(
cx,
Error::Type(c"The body's stream is disturbed or locked".to_owned()),
);
Expand Down Expand Up @@ -764,7 +764,7 @@ pub(crate) fn consume_body<T: BodyMixin + DomObject>(
let reader = match stream.acquire_default_reader(cx) {
Ok(r) => r,
Err(e) => {
promise.reject_error_with_cx(cx, e);
promise.reject_error(cx, e);
return promise;
},
};
Expand Down Expand Up @@ -824,7 +824,7 @@ fn resolve_result_promise(
FetchedData::JSException(e) => promise.reject_native(cx, &e.handle()),
};
},
Err(err) => promise.reject_error_with_cx(cx, err),
Err(err) => promise.reject_error(cx, err),
}
}

Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/audio/audiocontext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl AudioContextMethods<crate::DomTypeHolder> for AudioContext {

// Step 2.
if self.context.control_thread_state() == ProcessingState::Closed {
promise.reject_error_with_cx(cx, Error::InvalidState(None));
promise.reject_error(cx, Error::InvalidState(None));
return promise;
}

Expand Down Expand Up @@ -187,7 +187,7 @@ impl AudioContextMethods<crate::DomTypeHolder> for AudioContext {
.dom_manipulation_task_source()
.queue(task!(suspend_error: move |cx| {
let promise = trusted_promise.root();
promise.reject_error_with_cx(cx, Error::Type(c"Something went wrong".to_owned()));
promise.reject_error(cx, Error::Type(c"Something went wrong".to_owned()));
}));
},
};
Expand All @@ -203,7 +203,7 @@ impl AudioContextMethods<crate::DomTypeHolder> for AudioContext {

// Step 2.
if self.context.control_thread_state() == ProcessingState::Closed {
promise.reject_error_with_cx(cx, Error::InvalidState(None));
promise.reject_error(cx, Error::InvalidState(None));
return promise;
}

Expand Down Expand Up @@ -243,7 +243,7 @@ impl AudioContextMethods<crate::DomTypeHolder> for AudioContext {
.dom_manipulation_task_source()
.queue(task!(suspend_error: move |cx| {
let promise = trusted_promise.root();
promise.reject_error_with_cx(cx, Error::Type(c"Something went wrong".to_owned()));
promise.reject_error(cx, Error::Type(c"Something went wrong".to_owned()));
}));
},
};
Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/audio/baseaudiocontext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl BaseAudioContext {
for promise in &*promises {
match result {
Ok(ref value) => promise.resolve_native_with_cx(cx, value),
Err(ref error) => promise.reject_error_with_cx(cx, error.clone()),
Err(ref error) => promise.reject_error(cx, error.clone()),
}
}
}
Expand Down Expand Up @@ -293,7 +293,7 @@ impl BaseAudioContextMethods<crate::DomTypeHolder> for BaseAudioContext {

// Step 2.
if self.audio_context_impl.lock().unwrap().state() == ProcessingState::Closed {
promise.reject_error_with_cx(cx, Error::InvalidState(None));
promise.reject_error(cx, Error::InvalidState(None));
return promise;
}

Expand Down Expand Up @@ -558,7 +558,7 @@ impl BaseAudioContextMethods<crate::DomTypeHolder> for BaseAudioContext {
let _ = callback.Call__(cx, &exception, ExceptionHandling::Report);
}
let error = cformat!("Audio decode error {:?}", error);
resolver.promise.reject_error_with_cx(cx, Error::Type(error));
resolver.promise.reject_error(cx, Error::Type(error));
}));
})
.build();
Expand All @@ -568,7 +568,7 @@ impl BaseAudioContextMethods<crate::DomTypeHolder> for BaseAudioContext {
.decode_audio_data(audio_data, callbacks);
} else {
// Step 3.
promise.reject_error_with_cx(cx, Error::DataClone(None));
promise.reject_error(cx, Error::DataClone(None));
return promise;
}

Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/audio/offlineaudiocontext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl OfflineAudioContextMethods<crate::DomTypeHolder> for OfflineAudioContext {
fn StartRendering(&self, cx: &mut CurrentRealm) -> Rc<Promise> {
let promise = Promise::new_in_realm(cx);
if self.rendering_started.get() {
promise.reject_error_with_cx(cx, Error::InvalidState(None));
promise.reject_error(cx, Error::InvalidState(None));
return promise;
}
self.rendering_started.set(true);
Expand Down Expand Up @@ -216,7 +216,7 @@ impl OfflineAudioContextMethods<crate::DomTypeHolder> for OfflineAudioContext {
.resume()
.is_none()
{
promise.reject_error_with_cx(
promise.reject_error(
cx,
Error::Type(c"Could not start offline rendering".to_owned()),
);
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/bindings/refcounted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl TrustedPromise {
let this = self;
task!(reject_promise: move |cx| {
debug!("Rejecting promise.");
this.root().reject_error_with_cx(cx, error);
this.root().reject_error(cx, error);
})
}

Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ impl BlobMethods<crate::DomTypeHolder> for Blob {
promise.resolve_native_with_cx(cx, &text);
},
Err(e) => {
promise.reject_error_with_cx(cx, e);
promise.reject_error(cx, e);
},
}),
);
Expand All @@ -346,7 +346,7 @@ impl BlobMethods<crate::DomTypeHolder> for Blob {
let reader = match stream.and_then(|s| s.acquire_default_reader(cx)) {
Ok(reader) => reader,
Err(error) => {
promise.reject_error_with_cx(cx, error);
promise.reject_error(cx, error);
return promise;
},
};
Expand Down Expand Up @@ -389,7 +389,7 @@ impl BlobMethods<crate::DomTypeHolder> for Blob {
let reader = match stream.and_then(|s| s.acquire_default_reader(cx)) {
Ok(r) => r,
Err(e) => {
p.reject_error_with_cx(cx, e);
p.reject_error(cx, e);
return p;
},
};
Expand Down
28 changes: 13 additions & 15 deletions components/script/dom/bluetooth/bluetooth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ where
Ok(response) => self.receiver.root().handle_response(cx, response, &promise),
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice
// Step 3 - 4.
Err(error) => promise.reject_error_with_cx(cx, error.convert()),
Err(error) => promise.reject_error(cx, error.convert()),
}
}
}
Expand Down Expand Up @@ -178,7 +178,7 @@ impl Bluetooth {
if let Some(filters) = filters {
// Step 2.1.
if filters.is_empty() {
p.reject_error_with_cx(cx, Type(FILTER_EMPTY_ERROR.to_owned()));
p.reject_error(cx, Type(FILTER_EMPTY_ERROR.to_owned()));
return;
}

Expand All @@ -191,7 +191,7 @@ impl Bluetooth {
// Step 2.4.2.
Ok(f) => uuid_filters.push(f),
Err(e) => {
p.reject_error_with_cx(cx, e);
p.reject_error(cx, e);
return;
},
}
Expand All @@ -205,7 +205,7 @@ impl Bluetooth {
let uuid = match BluetoothUUID::service(opt_service.clone()) {
Ok(u) => String::from(u),
Err(e) => {
p.reject_error_with_cx(cx, e);
p.reject_error(cx, e);
return;
},
};
Expand All @@ -228,7 +228,7 @@ impl Bluetooth {
if let PermissionState::Denied =
descriptor_permission_state(PermissionName::Bluetooth, None)
{
return p.reject_error_with_cx(cx, Error::NotFound(None));
return p.reject_error(cx, Error::NotFound(None));
}

// Note: Step 3, 6 - 8 are implemented in
Expand Down Expand Up @@ -301,13 +301,13 @@ where
let canonicalized = match uuid_canonicalizer(u) {
Ok(canonicalized_uuid) => String::from(canonicalized_uuid),
Err(e) => {
p.reject_error_with_cx(cx, e);
p.reject_error(cx, e);
return p;
},
};
// Step 2.
if uuid_is_blocklisted(canonicalized.as_ref(), Blocklist::All) {
p.reject_error_with_cx(cx, Security(None));
p.reject_error(cx, Security(None));
return p;
}
Some(canonicalized)
Expand All @@ -317,7 +317,7 @@ where

// Step 3 - 4.
if !connected {
p.reject_error_with_cx(cx, Network(None));
p.reject_error(cx, Network(None));
return p;
}

Expand Down Expand Up @@ -539,7 +539,7 @@ impl BluetoothMethods<crate::DomTypeHolder> for Bluetooth {
if (option.filters.is_some() && option.acceptAllDevices) ||
(option.filters.is_none() && !option.acceptAllDevices)
{
p.reject_error_with_cx(cx, Error::Type(OPTIONS_ERROR.to_owned()));
p.reject_error(cx, Error::Type(OPTIONS_ERROR.to_owned()));
return p;
}

Expand Down Expand Up @@ -610,9 +610,7 @@ impl AsyncBluetoothListener for Bluetooth {
BluetoothResponse::GetAvailability(is_available) => {
promise.resolve_native_with_cx(cx, &is_available);
},
_ => {
promise.reject_error_with_cx(cx, Error::Type(c"Something went wrong...".to_owned()))
},
_ => promise.reject_error(cx, Error::Type(c"Something went wrong...".to_owned())),
}
}
}
Expand Down Expand Up @@ -685,7 +683,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_with_cx(cx, error),
Err(error) => return promise.reject_error(cx, error),
}
}

Expand All @@ -706,7 +704,7 @@ impl PermissionAlgorithm for Bluetooth {
match receiver.recv().unwrap() {
Ok(true) => (),
Ok(false) => continue,
Err(error) => return promise.reject_error_with_cx(cx, error.convert()),
Err(error) => return promise.reject_error(cx, error.convert()),
};
}

Expand Down Expand Up @@ -735,7 +733,7 @@ impl PermissionAlgorithm for Bluetooth {
) {
// Step 1.
if descriptor.filters.is_some() == descriptor.acceptAllDevices {
return promise.reject_error_with_cx(cx, Error::Type(OPTIONS_ERROR.to_owned()));
return promise.reject_error(cx, Error::Type(OPTIONS_ERROR.to_owned()));
}

// Step 2.
Expand Down
4 changes: 1 addition & 3 deletions components/script/dom/bluetooth/bluetoothdevice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,7 @@ impl AsyncBluetoothListener for BluetoothDevice {
// Step 3.2.
promise.resolve_native_with_cx(cx, &());
},
_ => {
promise.reject_error_with_cx(cx, Error::Type(c"Something went wrong...".to_owned()))
},
_ => promise.reject_error(cx, Error::Type(c"Something went wrong...".to_owned())),
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,7 @@ impl AsyncBluetoothListener for BluetoothPermissionResult {
// Step 8.
promise.resolve_native_with_cx(cx, self);
},
_ => {
promise.reject_error_with_cx(cx, Error::Type(c"Something went wrong...".to_owned()))
},
_ => promise.reject_error(cx, Error::Type(c"Something went wrong...".to_owned())),
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,21 +161,21 @@ impl BluetoothRemoteGATTCharacteristicMethods<crate::DomTypeHolder>

// Step 1.
if uuid_is_blocklisted(&self.uuid.str(), Blocklist::Reads) {
p.reject_error_with_cx(cx, Security(None));
p.reject_error(cx, Security(None));
return p;
}

// Step 2.
if !self.Service().Device().get_gatt(cx).Connected() {
p.reject_error_with_cx(cx, Network(None));
p.reject_error(cx, Network(None));
return p;
}

// TODO: Step 5: Implement the `connection-checking-wrapper` algorithm for BluetoothRemoteGATTServer.

// Step 5.1.
if !self.Properties().Read() {
p.reject_error_with_cx(cx, NotSupported(None));
p.reject_error(cx, NotSupported(None));
return p;
}

Expand All @@ -198,7 +198,7 @@ impl BluetoothRemoteGATTCharacteristicMethods<crate::DomTypeHolder>

// Step 1.
if uuid_is_blocklisted(&self.uuid.str(), Blocklist::Writes) {
p.reject_error_with_cx(cx, Security(None));
p.reject_error(cx, Security(None));
return p;
}

Expand All @@ -209,13 +209,13 @@ impl BluetoothRemoteGATTCharacteristicMethods<crate::DomTypeHolder>
};

if vec.len() > MAXIMUM_ATTRIBUTE_LENGTH {
p.reject_error_with_cx(cx, InvalidModification(None));
p.reject_error(cx, InvalidModification(None));
return p;
}

// Step 4.
if !self.Service().Device().get_gatt(cx).Connected() {
p.reject_error_with_cx(cx, Network(None));
p.reject_error(cx, Network(None));
return p;
}

Expand All @@ -226,7 +226,7 @@ impl BluetoothRemoteGATTCharacteristicMethods<crate::DomTypeHolder>
self.Properties().WriteWithoutResponse() ||
self.Properties().AuthenticatedSignedWrites())
{
p.reject_error_with_cx(cx, NotSupported(None));
p.reject_error(cx, NotSupported(None));
return p;
}

Expand All @@ -249,19 +249,19 @@ impl BluetoothRemoteGATTCharacteristicMethods<crate::DomTypeHolder>

// Step 1.
if uuid_is_blocklisted(&self.uuid.str(), Blocklist::Reads) {
p.reject_error_with_cx(cx, Security(None));
p.reject_error(cx, Security(None));
return p;
}

// Step 2.
if !self.Service().Device().get_gatt(cx).Connected() {
p.reject_error_with_cx(cx, Network(None));
p.reject_error(cx, Network(None));
return p;
}

// Step 5.
if !(self.Properties().Notify() || self.Properties().Indicate()) {
p.reject_error_with_cx(cx, NotSupported(None));
p.reject_error(cx, NotSupported(None));
return p;
}

Expand Down Expand Up @@ -368,9 +368,7 @@ impl AsyncBluetoothListener for BluetoothRemoteGATTCharacteristic {
// (StopNotification) Step 5.
promise.resolve_native_with_cx(cx, self);
},
_ => {
promise.reject_error_with_cx(cx, Error::Type(c"Something went wrong...".to_owned()))
},
_ => promise.reject_error(cx, Error::Type(c"Something went wrong...".to_owned())),
}
}
}
Loading