js/src/jit-test/tests/debug/Environment-getVariable-12.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 var g = newGlobal();
michael@0 2 var dbg = new Debugger;
michael@0 3 var gw = dbg.addDebuggee(g);
michael@0 4
michael@0 5 var hits = 0;
michael@0 6 dbg.onDebuggerStatement = function (frame) {
michael@0 7 hits++;
michael@0 8 assertEq(frame.environment.parent.getVariable('y'), true);
michael@0 9 };
michael@0 10
michael@0 11 g.eval("var g;" +
michael@0 12 "function f(x) {" +
michael@0 13 " let (y = x) {" +
michael@0 14 " if (x)" +
michael@0 15 " g = function() { eval('debugger') };" +
michael@0 16 " else" +
michael@0 17 " g();" +
michael@0 18 " }" +
michael@0 19 "}" +
michael@0 20 "f(true);" +
michael@0 21 "f(false);");
michael@0 22 assertEq(hits, 1);
michael@0 23
michael@0 24 var hits = 0;
michael@0 25 dbg.onDebuggerStatement = function (frame) {
michael@0 26 hits++;
michael@0 27 assertEq(frame.environment.parent.getVariable('y'), 1);
michael@0 28 assertEq(frame.environment.parent.names().indexOf('z'), -1);
michael@0 29 };
michael@0 30
michael@0 31 g.eval("var g;" +
michael@0 32 "let (y = 1) {" +
michael@0 33 " g = function () { debugger; };" +
michael@0 34 " let (z = 2) {" +
michael@0 35 " g();" +
michael@0 36 " }"+
michael@0 37 "}");
michael@0 38 assertEq(hits, 1);
michael@0 39
michael@0 40 var hits = 0;
michael@0 41 dbg.onDebuggerStatement = function (frame) {
michael@0 42 hits++;
michael@0 43 var e = frame.older.environment.parent;
michael@0 44 assertEq(e.getVariable('z'), true);
michael@0 45 e = e.parent;
michael@0 46 assertEq(e.getVariable('y'), true);
michael@0 47 };
michael@0 48
michael@0 49 g.eval("var g;" +
michael@0 50 "function h() { debugger };" +
michael@0 51 "for (var x of [true, false]) {" +
michael@0 52 " let (y = x) {" +
michael@0 53 " let (z = x) {" +
michael@0 54 " if (x)" +
michael@0 55 " g = function () { print(z); h() };" +
michael@0 56 " else" +
michael@0 57 " g();" +
michael@0 58 " }" +
michael@0 59 " }" +
michael@0 60 "}");
michael@0 61 assertEq(hits, 1);

mercurial