js/src/jit-test/tests/debug/Debugger-multi-02.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 // Test adding hooks during dispatch. The behavior is deterministic and "nice",
michael@0 2 // but mainly what we are checking here is that we do not crash due to
michael@0 3 // modifying a data structure while we're iterating over it.
michael@0 4
michael@0 5 var g = newGlobal();
michael@0 6 var n = 0;
michael@0 7 var hits;
michael@0 8
michael@0 9 function addDebugger() {
michael@0 10 var dbg = new Debugger(g);
michael@0 11 dbg.onDebuggerStatement = function (stack) {
michael@0 12 hits++;
michael@0 13 addDebugger();
michael@0 14 };
michael@0 15 }
michael@0 16
michael@0 17 addDebugger(); // now there is one enabled Debugger
michael@0 18 hits = 0;
michael@0 19 g.eval("debugger;"); // after this there are two
michael@0 20 assertEq(hits, 1);
michael@0 21
michael@0 22 hits = 0;
michael@0 23 g.eval("debugger;"); // after this there are four
michael@0 24 assertEq(hits, 2);
michael@0 25
michael@0 26 hits = 0;
michael@0 27 g.eval("debugger;"); // after this there are eight
michael@0 28 assertEq(hits, 4);
michael@0 29
michael@0 30 hits = 0;
michael@0 31 g.eval("debugger;");
michael@0 32 assertEq(hits, 8);

mercurial