aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/testbinding.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-09-22 07:36:38 -0500
committerGitHub <noreply@github.com>2017-09-22 07:36:38 -0500
commit4af0d9acb3f5724cac9f40a46ee03ab364a053bc (patch)
tree9c8a2567dc5d2fb6f0ec66b33a6bd9fc74395371 /components/script/dom/testbinding.rs
parenta8a25dac5226a12916c8fe17155d1dbb3b6cb565 (diff)
parent386973efeb574ebf99cd8a4f75d0b2856be63bf7 (diff)
downloadservo-4af0d9acb3f5724cac9f40a46ee03ab364a053bc.tar.gz
servo-4af0d9acb3f5724cac9f40a46ee03ab364a053bc.zip
Auto merge of #18600 - servo:promises, r=<try>
Improve Promise The elephant 🐘 (not PHP's) still remains in the room: `Rc<Promise>` shouldn't require `#⁠[allow(unrooted_must_root)]`. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18600) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/testbinding.rs')
-rw-r--r--components/script/dom/testbinding.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs
index 7bdb6e9910c..1a56a77a64f 100644
--- a/components/script/dom/testbinding.rs
+++ b/components/script/dom/testbinding.rs
@@ -35,7 +35,7 @@ use dom::promise::Promise;
use dom::promisenativehandler::{PromiseNativeHandler, Callback};
use dom::url::URL;
use dom_struct::dom_struct;
-use js::jsapi::{HandleObject, HandleValue, Heap, JSContext, JSObject, JSAutoCompartment};
+use js::jsapi::{HandleObject, HandleValue, Heap, JSContext, JSObject};
use js::jsapi::{JS_NewPlainObject, JS_NewUint8ClampedArray};
use js::jsval::{JSVal, NullValue};
use script_traits::MsDuration;
@@ -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)]
@@ -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)]
@@ -814,9 +814,6 @@ pub struct TestBindingCallback {
impl TestBindingCallback {
#[allow(unrooted_must_root)]
pub fn invoke(self) {
- let p = self.promise.root();
- let cx = p.global().get_cx();
- let _ac = JSAutoCompartment::new(cx, p.reflector().get_jsobject().get());
- p.resolve_native(cx, &self.value);
+ self.promise.root().resolve_native(&self.value);
}
}