summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Environment-module-02.js
blob: d88dbc6223889af8258db374e49a45919f792294 (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
// Debug environments for module environments should be able to access closed
// over variables after the module script has executed.

var g = newGlobal({newCompartment: true});
var dbg = Debugger(g);

const m = g.parseModule(`
  var x = 42;
  export function foo() { return x; }
  foo();
`);
moduleLink(m);

let fooFunction;
dbg.onEnterFrame = function (frame) {
  fooFunction = frame.callee;
};

moduleEvaluate(m);
assertEq(fooFunction instanceof Debugger.Object, true);

dbg.onEnterFrame = function (frame) {
  const env = frame.environment.parent;
  assertEq(env.names().join(','), "foo,x");
  assertEq(env.getVariable('x'), 42);
  env.setVariable('x', 3);
  assertEq(env.getVariable('x'), 3);
};

fooFunction.call();