OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --expose-debug-as debug |
| 6 |
| 7 function f() { |
| 8 var a = 1; |
| 9 var b = 2; |
| 10 return a + b; |
| 11 } |
| 12 |
| 13 var exception = null; |
| 14 var break_count = 0; |
| 15 var throw_count = 0; |
| 16 |
| 17 function listener(event, exec_state, event_data, data) { |
| 18 try { |
| 19 if (event == Debug.DebugEvent.Break) { |
| 20 break_count++; |
| 21 // Disable all breakpoints from within the debug event callback. |
| 22 Debug.debuggerFlags().breakPointsActive.setValue(false); |
| 23 } else if (event = Debug.DebugEvent.Exception) { |
| 24 throw_count++; |
| 25 // Enable all breakpoints from within the debug event callback. |
| 26 Debug.debuggerFlags().breakPointsActive.setValue(true); |
| 27 } |
| 28 } catch (e) { |
| 29 exception = e; |
| 30 } |
| 31 } |
| 32 |
| 33 Debug = debug.Debug; |
| 34 |
| 35 Debug.setListener(listener); |
| 36 Debug.setBreakOnException(); |
| 37 Debug.setBreakPoint(f, 2); |
| 38 |
| 39 f(); |
| 40 f(); |
| 41 |
| 42 assertEquals(1, break_count); |
| 43 assertEquals(0, throw_count); |
| 44 |
| 45 // Trigger exception event. |
| 46 try { throw 1; } catch (e) {} |
| 47 |
| 48 f(); |
| 49 f(); |
| 50 |
| 51 Debug.setListener(null); |
| 52 Debug.clearBreakOnException(); |
| 53 Debug.debuggerFlags().breakPointsActive.setValue(true); |
| 54 |
| 55 assertEquals(2, break_count); |
| 56 assertEquals(1, throw_count); |
| 57 assertNull(exception); |
OLD | NEW |