aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/promise.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2017-09-21 16:00:48 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2017-09-21 16:00:48 +0200
commit5addc2dfa36a48a657c36ecbda0331bfaa8ebf11 (patch)
treedb35ab2ddce4a406097d59f697ccc01ab0a555f7 /components/script/dom/promise.rs
parent658dc8a5013973ceff3c91291d5536043b2e8e58 (diff)
downloadservo-5addc2dfa36a48a657c36ecbda0331bfaa8ebf11.tar.gz
servo-5addc2dfa36a48a657c36ecbda0331bfaa8ebf11.zip
Make Promise::resolve_native actually sound
We shouldn't have to pass a raw JSContext pointer, and to enter the promise's context's compartment by hand.
Diffstat (limited to 'components/script/dom/promise.rs')
-rw-r--r--components/script/dom/promise.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/components/script/dom/promise.rs b/components/script/dom/promise.rs
index f850ef10172..a0ad29753ba 100644
--- a/components/script/dom/promise.rs
+++ b/components/script/dom/promise.rs
@@ -142,7 +142,9 @@ impl Promise {
}
#[allow(unsafe_code)]
- pub fn resolve_native<T>(&self, cx: *mut JSContext, val: &T) where T: ToJSValConvertible {
+ pub fn resolve_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());