js/src/jit-test/tests/debug/Debugger-debuggees-03.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 // Debugger hooks fire based on debuggees.
michael@0 2
michael@0 3 var g1 = newGlobal();
michael@0 4 g1.eval("var g2 = newGlobal('same-compartment')");
michael@0 5 var g2 = g1.g2;
michael@0 6 g1.eval("function f() { debugger; g2.g(); }");
michael@0 7 g2.eval("function g() { debugger; }");
michael@0 8
michael@0 9 var log;
michael@0 10 var dbg = new Debugger;
michael@0 11 dbg.onDebuggerStatement = function (frame) { log += frame.callee.name; };
michael@0 12
michael@0 13 // No debuggees: onDebuggerStatement is not called.
michael@0 14 log = '';
michael@0 15 g1.f();
michael@0 16 assertEq(log, '');
michael@0 17
michael@0 18 // Add a debuggee and check that the handler is called.
michael@0 19 var g1w = dbg.addDebuggee(g1);
michael@0 20 log = '';
michael@0 21 g1.f();
michael@0 22 assertEq(log, 'f');
michael@0 23
michael@0 24 // Two debuggees, two onDebuggerStatement calls.
michael@0 25 dbg.addDebuggee(g2);
michael@0 26 log = '';
michael@0 27 g1.f();
michael@0 28 assertEq(log, 'fg');
michael@0 29
michael@0 30 // After a debuggee is removed, it no longer calls hooks.
michael@0 31 assertEq(dbg.removeDebuggee(g1w), undefined);
michael@0 32 log = '';
michael@0 33 g1.f();
michael@0 34 assertEq(log, 'g');

mercurial