| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 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 // Tests stepping into through Array.prototype.forEach callbacks. | 5 // Tests stepping into through Array.prototype.forEach callbacks. |
| 7 | 6 |
| 8 Debug = debug.Debug | 7 Debug = debug.Debug |
| 9 var exception = null; | 8 var exception = null; |
| 10 var break_count = 0; | 9 var break_count = 0; |
| 11 var expected_breaks = -1; | 10 var expected_breaks = 11; |
| 12 | 11 |
| 13 function listener(event, exec_state, event_data, data) { | 12 function listener(event, exec_state, event_data, data) { |
| 14 try { | 13 try { |
| 15 if (event == Debug.DebugEvent.Break) { | 14 if (event == Debug.DebugEvent.Break) { |
| 16 assertTrue(exec_state.frameCount() != 0, "FAIL: Empty stack trace"); | 15 assertTrue(exec_state.frameCount() != 0, "FAIL: Empty stack trace"); |
| 17 if (!break_count) { | |
| 18 // Count number of expected breakpoints in this source file. | |
| 19 var source_text = exec_state.frame(0).func().script().source(); | |
| 20 expected_breaks = source_text.match(/\/\/\s*Break\s+\d+\./g).length; | |
| 21 print("Expected breaks: " + expected_breaks); | |
| 22 } | |
| 23 var source = exec_state.frame(0).sourceLineText(); | 16 var source = exec_state.frame(0).sourceLineText(); |
| 24 print("paused at: " + source); | 17 print("paused at: " + source); |
| 25 assertTrue(source.indexOf("// Break " + break_count + ".") > 0, | 18 assertTrue(source.indexOf("// Break " + break_count + ".") > 0, |
| 26 "Unexpected pause at: " + source + "\n" + | 19 "Unexpected pause at: " + source + "\n" + |
| 27 "Expected: // Break " + break_count + "."); | 20 "Expected: // Break " + break_count + "."); |
| 28 ++break_count; | 21 ++break_count; |
| 29 if (break_count !== expected_breaks) { | 22 if (break_count !== expected_breaks) { |
| 30 exec_state.prepareStep(Debug.StepAction.StepIn); | 23 exec_state.prepareStep(Debug.StepAction.StepIn); |
| 31 } | 24 } |
| 32 } | 25 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 44 [3,4].forEach(bound_callback); // Break 6. | 37 [3,4].forEach(bound_callback); // Break 6. |
| 45 | 38 |
| 46 function callback(x) { | 39 function callback(x) { |
| 47 return x; // Break 2. // Break 4. // Break 7. // Break 9. | 40 return x; // Break 2. // Break 4. // Break 7. // Break 9. |
| 48 } // Break 3. // Break 5. // Break 8. // Break 10. | 41 } // Break 3. // Break 5. // Break 8. // Break 10. |
| 49 | 42 |
| 50 assertNull(exception); // Break 11. | 43 assertNull(exception); // Break 11. |
| 51 assertEquals(expected_breaks, break_count); | 44 assertEquals(expected_breaks, break_count); |
| 52 | 45 |
| 53 Debug.setListener(null); | 46 Debug.setListener(null); |
| OLD | NEW |