Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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); |