mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Make Promise::reject_native sound
This commit is contained in:
parent
5addc2dfa3
commit
15acd1525e
4 changed files with 11 additions and 9 deletions
|
@ -343,7 +343,7 @@ impl CustomElementRegistryMethods for CustomElementRegistry {
|
|||
// Step 1
|
||||
if !is_valid_custom_element_name(&name) {
|
||||
let promise = Promise::new(global_scope);
|
||||
promise.reject_native(global_scope.get_cx(), &DOMException::new(global_scope, DOMErrorName::SyntaxError));
|
||||
promise.reject_native(&DOMException::new(global_scope, DOMErrorName::SyntaxError));
|
||||
return promise
|
||||
}
|
||||
|
||||
|
|
|
@ -162,7 +162,9 @@ impl Promise {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub fn reject_native<T>(&self, cx: *mut JSContext, val: &T) where T: ToJSValConvertible {
|
||||
pub fn reject_native<T>(&self, val: &T) where T: ToJSValConvertible {
|
||||
let cx = self.global().get_cx();
|
||||
let _ac = JSAutoCompartment::new(cx, self.reflector().get_jsobject().get());
|
||||
rooted!(in(cx) let mut v = UndefinedValue());
|
||||
unsafe {
|
||||
val.to_jsval(cx, v.handle_mut());
|
||||
|
|
|
@ -73,7 +73,7 @@ impl VRMethods for VR {
|
|||
}
|
||||
},
|
||||
Err(e) => {
|
||||
promise.reject_native(promise.global().get_cx(), &e);
|
||||
promise.reject_native(&e);
|
||||
return promise;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -284,7 +284,7 @@ impl VRDisplayMethods for VRDisplay {
|
|||
// WebVR spec: If canPresent is false the promise MUST be rejected
|
||||
if !self.display.borrow().capabilities.can_present {
|
||||
let msg = "VRDisplay canPresent is false".to_string();
|
||||
promise.reject_native(promise.global().get_cx(), &msg);
|
||||
promise.reject_native(&msg);
|
||||
return promise;
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,7 @@ impl VRDisplayMethods for VRDisplay {
|
|||
// That functionality is not allowed by this revision of the spec.
|
||||
if layers.len() != 1 {
|
||||
let msg = "The number of layers must be 1".to_string();
|
||||
promise.reject_native(promise.global().get_cx(), &msg);
|
||||
promise.reject_native(&msg);
|
||||
return promise;
|
||||
}
|
||||
|
||||
|
@ -311,7 +311,7 @@ impl VRDisplayMethods for VRDisplay {
|
|||
},
|
||||
Err(msg) => {
|
||||
let msg = msg.to_string();
|
||||
promise.reject_native(promise.global().get_cx(), &msg);
|
||||
promise.reject_native(&msg);
|
||||
return promise;
|
||||
}
|
||||
};
|
||||
|
@ -338,7 +338,7 @@ impl VRDisplayMethods for VRDisplay {
|
|||
promise.resolve_native(&());
|
||||
},
|
||||
Err(e) => {
|
||||
promise.reject_native(promise.global().get_cx(), &e);
|
||||
promise.reject_native(&e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -353,7 +353,7 @@ impl VRDisplayMethods for VRDisplay {
|
|||
// WebVR spec: If the VRDisplay is not presenting the promise MUST be rejected.
|
||||
if !self.presenting.get() {
|
||||
let msg = "VRDisplay is not presenting".to_string();
|
||||
promise.reject_native(promise.global().get_cx(), &msg);
|
||||
promise.reject_native(&msg);
|
||||
return promise;
|
||||
}
|
||||
|
||||
|
@ -369,7 +369,7 @@ impl VRDisplayMethods for VRDisplay {
|
|||
promise.resolve_native(&());
|
||||
},
|
||||
Err(e) => {
|
||||
promise.reject_native(promise.global().get_cx(), &e);
|
||||
promise.reject_native(&e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue