summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Object-asEnvironment-01.js
blob: 39bfe4dabf2bfb4821f77fb55c0eec2089434fb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Tests D.O.asEnvironment() returning the global lexical scope.

var g = newGlobal({newCompartment: true});
var dbg = new Debugger;
var gw = dbg.addDebuggee(g);

g.evaluate(`
  var x = 42;
  let y = "foo"
`);

var globalLexical = gw.asEnvironment();
assertEq(globalLexical.names().length, 1);
assertEq(globalLexical.getVariable("y"), "foo");
assertEq(globalLexical.parent.getVariable("x"), 42);