-
-
Notifications
You must be signed in to change notification settings - Fork 601
Expand file tree
/
Copy pathtests.rs
More file actions
21 lines (19 loc) · 778 Bytes
/
tests.rs
File metadata and controls
21 lines (19 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use crate::{run_test_actions, TestAction};
#[test]
fn constructor() {
run_test_actions([
TestAction::assert("new ShadowRealm() instanceof ShadowRealm"),
TestAction::assert("typeof ShadowRealm.prototype.evaluate === 'function'"),
TestAction::assert("typeof ShadowRealm.prototype.importValue === 'function'"),
]);
}
#[test]
fn evaluate_isolation() {
run_test_actions([
TestAction::run("const realm = new ShadowRealm();"),
TestAction::run("realm.evaluate('globalThis.x = 42;');"),
TestAction::assert("globalThis.x === undefined"),
TestAction::assert("realm.evaluate('globalThis.x') === 42"),
TestAction::assert("realm.evaluate('globalThis.x = 100;'); realm.evaluate('globalThis.x') === 100"),
]);
}