From 3bb946d8885227ba6c3397350a4d282c32c0b1fe Mon Sep 17 00:00:00 2001 From: Sam Finch Date: Thu, 2 Nov 2023 14:46:39 +0000 Subject: [PATCH] reintroduce missing function --- boa_engine/src/context/mod.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/boa_engine/src/context/mod.rs b/boa_engine/src/context/mod.rs index 9b657322ac9..2a8a3df9c79 100644 --- a/boa_engine/src/context/mod.rs +++ b/boa_engine/src/context/mod.rs @@ -513,6 +513,17 @@ impl<'host> Context<'host> { std::mem::replace(&mut self.realm, realm) } + /// Create a new Realm with the default global bindings. + pub fn create_realm(&mut self) -> JsResult { + let realm = Realm::create(&*self.host_hooks, &self.root_shape); + + let old_realm = self.enter_realm(realm); + + builtins::set_default_global_bindings(self)?; + + Ok(self.enter_realm(old_realm)) + } + /// Get the remaining instruction count #[cfg(freature = "fuzz")] #[inline]