1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/debug/Environment-identity-02.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,29 @@ 1.4 +// frame.environment is different for different activations of a scope. 1.5 + 1.6 +var g = newGlobal(); 1.7 +var dbg = Debugger(g); 1.8 +g.eval("function h() { debugger; }"); 1.9 +var arr; 1.10 +dbg.onDebuggerStatement = function (hframe) { 1.11 + var e = hframe.older.environment; 1.12 + assertEq(arr.indexOf(e), -1); 1.13 + arr.push(e); 1.14 +}; 1.15 + 1.16 +function test(code, expectedHits) { 1.17 + arr = []; 1.18 + g.eval(code); 1.19 + assertEq(arr.length, expectedHits); 1.20 +} 1.21 + 1.22 +// two separate calls to a function 1.23 +test("(function () { var f = function (a) { h(); return a; }; f(1); f(2); })();", 2); 1.24 + 1.25 +// recursive calls to a function 1.26 +test("(function f(n) { h(); return n < 2 ? 1 : n * f(n - 1); })(3);", 3); 1.27 + 1.28 +// separate visits to a block in the same call frame 1.29 +test("(function () { for (var i = 0; i < 3; i++) { let j = i * 4; h(); }})();", 3); 1.30 + 1.31 +// two strict direct eval calls in the same function scope 1.32 +test("(function () { 'use strict'; for (var i = 0; i < 3; i++) eval('h();'); })();", 3);