js/src/jit-test/tests/debug/Environment-identity-01.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 // The value of frame.environment is the same Environment object at different
     2 // times within a single visit to a scope.
     4 var g = newGlobal();
     5 var dbg = Debugger(g);
     6 g.eval("function h() { debugger; }");
     7 var hits, env;
     8 dbg.onDebuggerStatement = function (hframe) {
     9     var frame = hframe.older;
    10     var e = frame.environment;
    12     // frame.environment is at least cached from one moment to the next.
    13     assertEq(e, frame.environment);
    15     // frame.environment is cached from statement to statement within a call frame.
    16     if (env === undefined)
    17         env = e;
    18     else
    19         assertEq(e, env);
    21     hits++;
    22 };
    24 hits = 0;
    25 env = undefined;
    26 g.eval("function f() { (function () { var i = 0; h(); var j = 2; h(); })(); }");
    27 g.f();
    28 assertEq(hits, 2);
    30 hits = 0;
    31 env = undefined;
    32 g.eval("function f2() { { let i = 0; h(); let j = 2; h(); } }");
    33 g.f2();
    34 assertEq(hits, 2);
    36 hits = 0;
    37 env = undefined;
    38 g.eval("function f3() { { let i; for (i = 0; i < 2; i++) h(); } }");
    39 g.f3();
    40 assertEq(hits, 2);

mercurial