summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Environment-scopeKind-01.js
blob: 6f44cc51e26270bd01ed225aa559fda7181bd459 (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
// Environment.prototype.scopeKind produces expected values.

load(libdir + 'eqArrayHelper.js');

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

function getScopeKinds(text) {
  const kinds = [];
  dbg.onDebuggerStatement = frame => {
    let env = frame.environment;
    while (env) {
      kinds.push(env.scopeKind);
      env = env.parent;
    }
  };
  g.eval(text);
  return kinds;
}

assertEqArray(getScopeKinds("function f(x) { debugger; }; f()"),
              ["function", null, null]);
assertEqArray(getScopeKinds("function f(x) { let y = 0; debugger; }; f()"),
              ["function lexical", "function", null, null]);
assertEqArray(getScopeKinds("function f(x) { let y = 0; with(x) { debugger; } } f({})"),
              [null, "function lexical", "function", null, null]);