1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/debug/Debugger-multi-02.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,32 @@ 1.4 +// Test adding hooks during dispatch. The behavior is deterministic and "nice", 1.5 +// but mainly what we are checking here is that we do not crash due to 1.6 +// modifying a data structure while we're iterating over it. 1.7 + 1.8 +var g = newGlobal(); 1.9 +var n = 0; 1.10 +var hits; 1.11 + 1.12 +function addDebugger() { 1.13 + var dbg = new Debugger(g); 1.14 + dbg.onDebuggerStatement = function (stack) { 1.15 + hits++; 1.16 + addDebugger(); 1.17 + }; 1.18 +} 1.19 + 1.20 +addDebugger(); // now there is one enabled Debugger 1.21 +hits = 0; 1.22 +g.eval("debugger;"); // after this there are two 1.23 +assertEq(hits, 1); 1.24 + 1.25 +hits = 0; 1.26 +g.eval("debugger;"); // after this there are four 1.27 +assertEq(hits, 2); 1.28 + 1.29 +hits = 0; 1.30 +g.eval("debugger;"); // after this there are eight 1.31 +assertEq(hits, 4); 1.32 + 1.33 +hits = 0; 1.34 +g.eval("debugger;"); 1.35 +assertEq(hits, 8);