aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/promise.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2016-09-10 16:50:52 -0400
committerJosh Matthews <josh@joshmatthews.net>2016-09-22 16:16:59 -0400
commit498ccd41e8cec4f180f286db8d5c1d9e398203d4 (patch)
tree4fcac2fecc14c1864023883f8335264a12dfa859 /components/script/dom/promise.rs
parent27d44c8d1042e5705853b272fc340c76c4d02785 (diff)
downloadservo-498ccd41e8cec4f180f286db8d5c1d9e398203d4.tar.gz
servo-498ccd41e8cec4f180f286db8d5c1d9e398203d4.zip
Support an equivalent of Trusted<T> for Rc<Promise> objects named TrustedPromise.
Diffstat (limited to 'components/script/dom/promise.rs')
-rw-r--r--components/script/dom/promise.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/components/script/dom/promise.rs b/components/script/dom/promise.rs
index f167d95bfd2..295a73f43a1 100644
--- a/components/script/dom/promise.rs
+++ b/components/script/dom/promise.rs
@@ -80,6 +80,14 @@ impl Promise {
}
#[allow(unsafe_code, unrooted_must_root)]
+ pub fn duplicate(&self) -> Rc<Promise> {
+ let cx = self.global().r().get_cx();
+ unsafe {
+ Promise::new_with_js_promise(self.reflector().get_jsobject(), cx)
+ }
+ }
+
+ #[allow(unsafe_code, unrooted_must_root)]
unsafe fn new_with_js_promise(obj: HandleObject, cx: *mut JSContext) -> Rc<Promise> {
assert!(IsPromiseObject(obj));
let mut promise = Promise {