Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // frame.environment is different for different activations of a scope. |
michael@0 | 2 | |
michael@0 | 3 | var g = newGlobal(); |
michael@0 | 4 | var dbg = Debugger(g); |
michael@0 | 5 | g.eval("function h() { debugger; }"); |
michael@0 | 6 | var arr; |
michael@0 | 7 | dbg.onDebuggerStatement = function (hframe) { |
michael@0 | 8 | var e = hframe.older.environment; |
michael@0 | 9 | assertEq(arr.indexOf(e), -1); |
michael@0 | 10 | arr.push(e); |
michael@0 | 11 | }; |
michael@0 | 12 | |
michael@0 | 13 | function test(code, expectedHits) { |
michael@0 | 14 | arr = []; |
michael@0 | 15 | g.eval(code); |
michael@0 | 16 | assertEq(arr.length, expectedHits); |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | // two separate calls to a function |
michael@0 | 20 | test("(function () { var f = function (a) { h(); return a; }; f(1); f(2); })();", 2); |
michael@0 | 21 | |
michael@0 | 22 | // recursive calls to a function |
michael@0 | 23 | test("(function f(n) { h(); return n < 2 ? 1 : n * f(n - 1); })(3);", 3); |
michael@0 | 24 | |
michael@0 | 25 | // separate visits to a block in the same call frame |
michael@0 | 26 | test("(function () { for (var i = 0; i < 3; i++) { let j = i * 4; h(); }})();", 3); |
michael@0 | 27 | |
michael@0 | 28 | // two strict direct eval calls in the same function scope |
michael@0 | 29 | test("(function () { 'use strict'; for (var i = 0; i < 3; i++) eval('h();'); })();", 3); |