Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Fix cross-realm construction bugs #2786

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions
  • Loading branch information
jedel1043 committed Apr 10, 2023
commit 3bbc6128834c2b427d6dba4796712b82580ed375
4 changes: 2 additions & 2 deletions boa_cli/src/debug/realm.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use boa_engine::{object::ObjectInitializer, Context, JsObject, JsResult, JsValue, NativeFunction};

/// Creates a new ECMAScript Realm and returns the global object of the realm.
fn new_realm(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult<JsValue> {
fn create(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult<JsValue> {
let context = &mut Context::default();

Ok(context.global_object().into())
}

pub(super) fn create_object(context: &mut Context<'_>) -> JsObject {
ObjectInitializer::new(context)
.function(NativeFunction::from_fn_ptr(new_realm), "newRealm", 0)
.function(NativeFunction::from_fn_ptr(create), "create", 0)
.build()
}
14 changes: 14 additions & 0 deletions docs/boa_object.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,17 @@ Optimizer {
2
>>
```

## Module `$boa.realm`

This modules contains realm utilities to test cross-realm behaviour.

### `$boa.realm.create`

Creates a new realm with a new set of builtins and returns its global object.

```javascript
let global = $boa.realm.create();

Object != global.Object // true
```