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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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