Debian Codegraph @

js/src/jit-test/tests/basic/non-syntactic-with-unscopables.js

raw
1 // Tests evaluate's supportUnscopables option.
2 function test(supportUnscopables) {
3 var env = {x: 1, y: 2};
4 Object.defineProperty(env, Symbol.unscopables, {get: function() {
5 assertEq(supportUnscopables, true);
6 return {x: false, y: true};
7 }});
8
9 evaluate(`this.gotX = x; try { this.gotY = y; } catch {}`,
10 {envChainObject: env, supportUnscopables});
11 assertEq(env.gotX, 1);
12 assertEq(env.gotY, supportUnscopables ? undefined : 2);
13 }
14 test(false);
15 test(true);