Rename a couple of Promise methods

This commit is contained in:
Anthony Ramine 2017-09-21 15:35:04 +02:00
parent 581f0bf09a
commit 658dc8a501
3 changed files with 13 additions and 9 deletions

View file

@ -788,7 +788,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
if !JS_WrapValue(cx, valueToResolve.handle_mut()) {
$*{exceptionCode}
}
match Promise::Resolve(&promiseGlobal, cx, valueToResolve.handle()) {
match Promise::new_resolved(&promiseGlobal, cx, valueToResolve.handle()) {
Ok(value) => value,
Err(error) => {
throw_dom_exception(cx, &promiseGlobal, error);

View file

@ -114,9 +114,11 @@ impl Promise {
}
#[allow(unrooted_must_root, unsafe_code)]
pub fn Resolve(global: &GlobalScope,
cx: *mut JSContext,
value: HandleValue) -> Fallible<Rc<Promise>> {
pub fn new_resolved(
global: &GlobalScope,
cx: *mut JSContext,
value: HandleValue,
) -> Fallible<Rc<Promise>> {
let _ac = JSAutoCompartment::new(cx, global.reflector().get_jsobject().get());
rooted!(in(cx) let p = unsafe { CallOriginalPromiseResolve(cx, value) });
assert!(!p.handle().is_null());
@ -126,9 +128,11 @@ impl Promise {
}
#[allow(unrooted_must_root, unsafe_code)]
pub fn Reject(global: &GlobalScope,
cx: *mut JSContext,
value: HandleValue) -> Fallible<Rc<Promise>> {
pub fn new_rejected(
global: &GlobalScope,
cx: *mut JSContext,
value: HandleValue,
) -> Fallible<Rc<Promise>> {
let _ac = JSAutoCompartment::new(cx, global.reflector().get_jsobject().get());
rooted!(in(cx) let p = unsafe { CallOriginalPromiseReject(cx, value) });
assert!(!p.handle().is_null());

View file

@ -675,13 +675,13 @@ impl TestBindingMethods for TestBinding {
#[allow(unrooted_must_root)]
#[allow(unsafe_code)]
unsafe fn ReturnResolvedPromise(&self, cx: *mut JSContext, v: HandleValue) -> Fallible<Rc<Promise>> {
Promise::Resolve(&self.global(), cx, v)
Promise::new_resolved(&self.global(), cx, v)
}
#[allow(unrooted_must_root)]
#[allow(unsafe_code)]
unsafe fn ReturnRejectedPromise(&self, cx: *mut JSContext, v: HandleValue) -> Fallible<Rc<Promise>> {
Promise::Reject(&self.global(), cx, v)
Promise::new_rejected(&self.global(), cx, v)
}
#[allow(unsafe_code)]