Browse Source

Add `Context::create_realm`. (#3369)

Provides a function for creating Realms with the default global bindings.
pull/3393/head
Alistair 1 year ago committed by GitHub
parent
commit
b6ff65885e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      boa_engine/src/context/mod.rs

11
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<Realm> {
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 [`RootShape`].
#[inline]
#[must_use]

Loading…
Cancel
Save