diff options
Diffstat (limited to 'components/script/compartments.rs')
-rw-r--r-- | components/script/compartments.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/components/script/compartments.rs b/components/script/compartments.rs index 3c57e753eb7..cb8c973e70e 100644 --- a/components/script/compartments.rs +++ b/components/script/compartments.rs @@ -2,6 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use crate::dom::bindings::reflector::DomObject; use crate::dom::globalscope::GlobalScope; use js::jsapi::{GetCurrentRealmOrNull, JSAutoRealm, JSContext}; @@ -39,3 +40,10 @@ impl<'a> InCompartment<'a> { InCompartment::Entered(token) } } + +pub fn enter_realm(object: &impl DomObject) -> JSAutoRealm { + JSAutoRealm::new( + object.global().get_cx(), + object.reflector().get_jsobject().get(), + ) +} |