evaluate_envChainObject.js (969B)
1 load(libdir + "asserts.js"); 2 3 // Test with envChainObject in current global. 4 { 5 let global = newGlobal(); 6 let envChainObject = { a: "test1" }; 7 assertEq(evaluate("a", { global, envChainObject }), "test1"); 8 } 9 10 // Test with envChainObject in target global. 11 { 12 let global = newGlobal(); 13 var envChainObject = global.evaluate('({a: "test2"})'); 14 assertEq(envChainObject.a, "test2"); 15 assertEq(evaluate("a", { global, envChainObject }), "test2"); 16 } 17 18 // Unqualified variables objects are not allowed. 19 20 if (!isProxy(evalcx(""))) { 21 // if --more-compartments option is not give, evalcx returns sandbox, 22 // which is unqualified variables object. 23 assertThrowsInstanceOf(() => { 24 evaluate("10", { envChainObject: evalcx("") }); 25 }, Error); 26 } 27 28 // evalReturningScope returns NonSyntacticVariablesObject, which is unqualified 29 // variables object. 30 assertThrowsInstanceOf(() => { 31 evaluate("10", { envChainObject: evalReturningScope("1") }); 32 }, Error);