js/src/jit-test/tests/debug/Environment-identity-02.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // frame.environment is different for different activations of a scope.
     3 var g = newGlobal();
     4 var dbg = Debugger(g);
     5 g.eval("function h() { debugger; }");
     6 var arr;
     7 dbg.onDebuggerStatement = function (hframe) {
     8     var e = hframe.older.environment;
     9     assertEq(arr.indexOf(e), -1);
    10     arr.push(e);
    11 };
    13 function test(code, expectedHits) {
    14     arr = [];
    15     g.eval(code);
    16     assertEq(arr.length, expectedHits);
    17 }
    19 // two separate calls to a function
    20 test("(function () { var f = function (a) { h(); return a; }; f(1); f(2); })();", 2);
    22 // recursive calls to a function
    23 test("(function f(n) { h(); return n < 2 ? 1 : n * f(n - 1); })(3);", 3);
    25 // separate visits to a block in the same call frame
    26 test("(function () { for (var i = 0; i < 3; i++) { let j = i * 4; h(); }})();", 3);
    28 // two strict direct eval calls in the same function scope
    29 test("(function () { 'use strict'; for (var i = 0; i < 3; i++) eval('h();'); })();", 3);

mercurial