| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Flags: --expose-debug-as debug | |
| 6 | 5 |
| 7 Debug = debug.Debug | 6 Debug = debug.Debug |
| 8 var exception = null; | 7 var exception = null; |
| 9 var break_count = 0; | 8 var break_count = 0; |
| 9 const expected_breaks = 8; |
| 10 | 10 |
| 11 function listener(event, exec_state, event_data, data) { | 11 function listener(event, exec_state, event_data, data) { |
| 12 try { | 12 try { |
| 13 if (event == Debug.DebugEvent.Break) { | 13 if (event == Debug.DebugEvent.Break) { |
| 14 assertTrue(exec_state.frameCount() != 0, "FAIL: Empty stack trace"); | 14 assertTrue(exec_state.frameCount() != 0, "FAIL: Empty stack trace"); |
| 15 // Count number of expected breakpoints in this source file. | |
| 16 if (!break_count) { | |
| 17 var source_text = exec_state.frame(0).func().script().source(); | |
| 18 expected_breaks = source_text.match(/\/\/\s*Break\s+\d+\./g).length; | |
| 19 print("Expected breaks: " + expected_breaks); | |
| 20 } | |
| 21 var frameMirror = exec_state.frame(0); | 15 var frameMirror = exec_state.frame(0); |
| 22 | 16 |
| 23 frameMirror.allScopes(); | 17 frameMirror.allScopes(); |
| 24 var source = frameMirror.sourceLineText(); | 18 var source = frameMirror.sourceLineText(); |
| 25 print("paused at: " + source); | 19 print("paused at: " + source); |
| 26 assertTrue(source.indexOf("// Break " + break_count + ".") > 0, | 20 assertTrue(source.indexOf("// Break " + break_count + ".") > 0, |
| 27 "Unexpected pause at: " + source + "\n" + | 21 "Unexpected pause at: " + source + "\n" + |
| 28 "Expected: // Break " + break_count + "."); | 22 "Expected: // Break " + break_count + "."); |
| 29 ++break_count; | 23 ++break_count; |
| 30 | 24 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 50 i++; // Break 2. | 44 i++; // Break 2. |
| 51 i++; // Break 3. | 45 i++; // Break 3. |
| 52 debugger; // Break 4. | 46 debugger; // Break 4. |
| 53 return i; // Break 5. | 47 return i; // Break 5. |
| 54 }()); // Break 6. | 48 }()); // Break 6. |
| 55 | 49 |
| 56 assertNull(exception); // Break 7. | 50 assertNull(exception); // Break 7. |
| 57 assertEquals(expected_breaks, break_count); | 51 assertEquals(expected_breaks, break_count); |
| 58 | 52 |
| 59 Debug.setListener(null); | 53 Debug.setListener(null); |
| OLD | NEW |