js/src/jit-test/tests/debug/breakpoint-multi-04.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 // After clearing one breakpoint, another breakpoint from a different Debugger object at the same instruction still works.
michael@0 2
michael@0 3 function test(which) {
michael@0 4 var g = newGlobal();
michael@0 5 g.eval("var line0 = Error().lineNumber;\n" +
michael@0 6 "function f() {\n" + // line0 + 1
michael@0 7 " return " + which + ";\n" + // line0 + 2
michael@0 8 "}\n");
michael@0 9
michael@0 10 var log;
michael@0 11 var scripts = [];
michael@0 12 var handlers = [];
michael@0 13 function addDebugger(g, i) {
michael@0 14 var dbg = Debugger(g);
michael@0 15 dbg.onDebuggerStatement = function (frame) {
michael@0 16 var s = frame.eval("f").return.script;
michael@0 17 scripts[i] = s;
michael@0 18 var offs = s.getLineOffsets(g.line0 + 2);
michael@0 19 var handler = {hit: function (frame) { log += '' + i; } };
michael@0 20 s.setBreakpoint(0, handler);
michael@0 21 handlers[i] = handler;
michael@0 22 };
michael@0 23 }
michael@0 24
michael@0 25 var expected = '';
michael@0 26 for (var i = 0; i < 3; i++) {
michael@0 27 addDebugger(g, i);
michael@0 28 if (i !== which)
michael@0 29 expected += '' + i;
michael@0 30 }
michael@0 31 g.eval('debugger;');
michael@0 32
michael@0 33 for (var i = 0; i < 3; i++)
michael@0 34 assertEq(scripts[i].getBreakpoints()[0], handlers[i]);
michael@0 35
michael@0 36 log = '';
michael@0 37 g.f();
michael@0 38 assertEq(log, '012');
michael@0 39
michael@0 40 scripts[which].clearAllBreakpoints();
michael@0 41
michael@0 42 log = '';
michael@0 43 g.f();
michael@0 44 assertEq(log, expected);
michael@0 45 }
michael@0 46
michael@0 47 for (var j = 0; j < 3; j++)
michael@0 48 test(j);

mercurial