michael@0: // getVariable works on a heavyweight environment after control leaves its scope. michael@0: michael@0: var g = newGlobal(); michael@0: var dbg = Debugger(g); michael@0: var envs = []; michael@0: dbg.onDebuggerStatement = function (frame) { michael@0: envs.push(frame.environment); michael@0: }; michael@0: g.eval("var f;\n" + michael@0: "for (var x = 0; x < 3; x++) {\n" + michael@0: " (function (x) {\n" + michael@0: " for (var y = 0; y < 3; y++) {\n" + michael@0: " (function (z) {\n" + michael@0: " eval(z); // force heavyweight\n" + michael@0: " debugger;\n" + michael@0: " })(x + y);\n" + michael@0: " }\n" + michael@0: " })(x);\n" + michael@0: "}"); michael@0: michael@0: var i = 0; michael@0: for (var x = 0; x < 3; x++) { michael@0: for (var y = 0; y < 3; y++) { michael@0: var e = envs[i++]; michael@0: assertEq(e.getVariable("z"), x + y); michael@0: } michael@0: }