michael@0: // frame.environment is different for different activations of a scope. michael@0: michael@0: var g = newGlobal(); michael@0: var dbg = Debugger(g); michael@0: g.eval("function h() { debugger; }"); michael@0: var arr; michael@0: dbg.onDebuggerStatement = function (hframe) { michael@0: var e = hframe.older.environment; michael@0: assertEq(arr.indexOf(e), -1); michael@0: arr.push(e); michael@0: }; michael@0: michael@0: function test(code, expectedHits) { michael@0: arr = []; michael@0: g.eval(code); michael@0: assertEq(arr.length, expectedHits); michael@0: } michael@0: michael@0: // two separate calls to a function michael@0: test("(function () { var f = function (a) { h(); return a; }; f(1); f(2); })();", 2); michael@0: michael@0: // recursive calls to a function michael@0: test("(function f(n) { h(); return n < 2 ? 1 : n * f(n - 1); })(3);", 3); michael@0: michael@0: // separate visits to a block in the same call frame michael@0: test("(function () { for (var i = 0; i < 3; i++) { let j = i * 4; h(); }})();", 3); michael@0: michael@0: // two strict direct eval calls in the same function scope michael@0: test("(function () { 'use strict'; for (var i = 0; i < 3; i++) eval('h();'); })();", 3);