From 1b6949d4cf951600efa6db6747b65e2db42a96cd Mon Sep 17 00:00:00 2001 From: Aron Zwaan Date: Wed, 24 Apr 2019 18:53:50 +0200 Subject: Add proof parameter to Promise::new_in_current_compartment --- components/script/dom/testbinding.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'components/script/dom/testbinding.rs') diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index f5d64a478de..a1515340199 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -4,6 +4,7 @@ // check-tidy: no specs after this line +use crate::compartments::{AlreadyInCompartment, InCompartment}; use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::codegen::Bindings::EventListenerBinding::EventListener; use crate::dom::bindings::codegen::Bindings::FunctionBinding::Function; @@ -1009,7 +1010,6 @@ impl TestBindingMethods for TestBinding { ); } - #[allow(unsafe_code)] fn PromiseNativeHandler( &self, resolve: Option>, @@ -1021,7 +1021,11 @@ impl TestBindingMethods for TestBinding { resolve.map(SimpleHandler::new), reject.map(SimpleHandler::new), ); - let p = unsafe { Promise::new_in_current_compartment(&global) }; + let in_compartment_proof = AlreadyInCompartment::assert(&global); + let p = Promise::new_in_current_compartment( + &global, + &InCompartment::Already(&in_compartment_proof), + ); p.append_native_handler(&handler); return p; @@ -1044,9 +1048,12 @@ impl TestBindingMethods for TestBinding { } } - #[allow(unsafe_code)] fn PromiseAttribute(&self) -> Rc { - unsafe { Promise::new_in_current_compartment(&self.global()) } + let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); + Promise::new_in_current_compartment( + &self.global(), + &InCompartment::Already(&in_compartment_proof), + ) } fn AcceptPromise(&self, _promise: &Promise) {} -- cgit v1.2.3 From e2e6e2ac9428b9448edb06f7f11b201ce68e7191 Mon Sep 17 00:00:00 2001 From: Aron Zwaan Date: Wed, 24 Apr 2019 22:33:16 +0200 Subject: Pass InCompartment by value --- components/script/dom/testbinding.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'components/script/dom/testbinding.rs') diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index a1515340199..99e294e75e9 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -1024,7 +1024,7 @@ impl TestBindingMethods for TestBinding { let in_compartment_proof = AlreadyInCompartment::assert(&global); let p = Promise::new_in_current_compartment( &global, - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); p.append_native_handler(&handler); return p; @@ -1052,7 +1052,7 @@ impl TestBindingMethods for TestBinding { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ) } -- cgit v1.2.3