Chromium Code Reviews| 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 | |
|
aandrey
2014/11/18 14:07:27
mind adding assertEquals(1, break_count); here?
| |
| 42 // Trigger exception event. | |
| 43 try { throw 1; } catch (e) {} | |
| 44 | |
| 45 f(); | |
| 46 f(); | |
| 47 | |
| 48 Debug.setListener(null); | |
| 49 Debug.clearBreakOnException(); | |
| 50 Debug.debuggerFlags().breakPointsActive.setValue(true); | |
| 51 | |
| 52 assertEquals(2, break_count); | |
| 53 assertEquals(1, throw_count); | |
| 54 assertNull(exception); | |
| OLD | NEW |