js/src/jit-test/tests/debug/Environment-setVariable-10.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 // setVariable works on non-innermost environments.
     3 // (The debuggee code here is a bit convoluted to defeat optimizations that
     4 // could make obj.b a null closure or obj.i a flat closure--that is, a function
     5 // that gets a frozen copy of i instead of a reference to the runtime
     6 // environment that contains it. setVariable does not currently detect this
     7 // flat closure case.)
     9 var g = newGlobal();
    10 g.eval("function d() { debugger; }\n" +
    11        "var i = 'FAIL';\n" +
    12        "function a() {\n" +
    13        "    var obj = {b: function (i) { d(obj); return i; },\n" +
    14        "               i: function () { return i; }};\n" +
    15        "    var i = 'FAIL2';\n" +
    16        "    return obj;\n" +
    17        "}\n");
    19 var dbg = Debugger(g);
    20 dbg.onDebuggerStatement = function (frame) {
    21     var x = 0;
    22     for (var env = frame.older.environment; env; env = env.parent) {
    23         if (env.getVariable("i") !== undefined)
    24             env.setVariable("i", x++);
    25     }
    26 };
    28 var obj = g.a();
    29 var r = obj.b('FAIL3');
    30 assertEq(r, 0);
    31 assertEq(obj.i(), 1);
    32 assertEq(g.i, 2);

mercurial