summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/environments/evaluate_envChainObject.js
blob: d6edb1f43ce11d119d7774f43cfdcf553d52c1f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
load(libdir + "asserts.js");

// Test with envChainObject in current global.
{
    let global = newGlobal();
    let envChainObject = { a: "test1" };
    assertEq(evaluate("a", { global, envChainObject }), "test1");
}

// Test with envChainObject in target global.
{
    let global = newGlobal();
    var envChainObject = global.evaluate('({a: "test2"})');
    assertEq(envChainObject.a, "test2");
    assertEq(evaluate("a", { global, envChainObject }), "test2");
}

// Unqualified variables objects are not allowed.

if (!isProxy(evalcx(""))) {
  // if --more-compartments option is not give, evalcx returns sandbox,
  // which is unqualified variables object.
  assertThrowsInstanceOf(() => {
    evaluate("10", { envChainObject: evalcx("") });
  }, Error);
}

// evalReturningScope returns NonSyntacticVariablesObject, which is unqualified
// variables object.
assertThrowsInstanceOf(() => {
  evaluate("10", { envChainObject: evalReturningScope("1") });
}, Error);