summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Environment-getVariable-15.js
blob: f0495cda17b9441a6a56895b15400fbd5ffa4de4 (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
31
// Don't hand out internal function objects via Debugger.Environment.prototype.getVariable.

// When the real scope chain object holding the binding for 'f' in 'function f()
// { ... }' is optimized out because it's never used, we whip up fake scope
// chain objects for Debugger to use, if it looks. However, the value of the
// variable f will be an internal function object, not a live function object,
// since the latter was not recorded. Internal function objects should not be
// exposed via Debugger.

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

dbg.onDebuggerStatement = function (frame) {
  var g_call_env = frame.older.environment;     // g's locals
  var g_decl_env = g_call_env.parent;           // 'function g' binding
  var f_call_env = g_decl_env.parent;           // f's locals
  var f_decl_env = f_call_env.parent;           // 'function f' binding
  assertEq(f_decl_env.getVariable('f').optimizedOut, true);
}

g.evaluate(`

           function h() { debugger; }
           (function f() {
             return function g() {
               h();
               return 1;
             }
           })()();

           `);