js/src/jit-test/tests/debug/Environment-setVariable-10.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.

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

mercurial