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 --allow-natives-syntax --noalways-opt | 5 // Flags: --expose-debug-as debug --allow-natives-syntax --noalways-opt |
6 // Tests stepping into through Promises. | 6 // Tests stepping into through Promises. |
7 | 7 |
8 Debug = debug.Debug | 8 Debug = debug.Debug |
9 var exception = null; | 9 var exception = null; |
10 var break_count = 0; | 10 var break_count = 0; |
11 var expected_breaks = -1; | 11 const expected_breaks = 9; |
12 | 12 |
13 function listener(event, exec_state, event_data, data) { | 13 function listener(event, exec_state, event_data, data) { |
14 try { | 14 try { |
15 if (event == Debug.DebugEvent.Break) { | 15 if (event == Debug.DebugEvent.Break) { |
16 assertTrue(exec_state.frameCount() != 0, "FAIL: Empty stack trace"); | 16 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(); | 17 var source = exec_state.frame(0).sourceLineText(); |
24 print("paused at: " + source); | 18 print("paused at: " + source); |
25 assertTrue(source.indexOf("// Break " + break_count + ".") > 0, | 19 assertTrue(source.indexOf("// Break " + break_count + ".") > 0, |
26 "Unexpected pause at: " + source + "\n" + | 20 "Unexpected pause at: " + source + "\n" + |
27 "Expected: // Break " + break_count + "."); | 21 "Expected: // Break " + break_count + "."); |
28 ++break_count; | 22 ++break_count; |
29 if (break_count !== expected_breaks) { | 23 if (break_count !== expected_breaks) { |
30 exec_state.prepareStep(Debug.StepAction.StepIn); | 24 exec_state.prepareStep(Debug.StepAction.StepIn); |
31 } | 25 } |
32 } | 26 } |
(...skipping 23 matching lines...) Expand all Loading... |
56 function callback(x) { | 50 function callback(x) { |
57 return x; // Break 2. // Break 4. // Break 6. | 51 return x; // Break 2. // Break 4. // Break 6. |
58 } // Break 3. // Break 5. // Break 7. | 52 } // Break 3. // Break 5. // Break 7. |
59 | 53 |
60 function finalize() { | 54 function finalize() { |
61 assertNull(exception); // Break 8. | 55 assertNull(exception); // Break 8. |
62 assertEquals(expected_breaks, break_count); | 56 assertEquals(expected_breaks, break_count); |
63 | 57 |
64 Debug.setListener(null); | 58 Debug.setListener(null); |
65 } | 59 } |
OLD | NEW |