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: --allow-natives-syntax --expose-debug-as debug | 5 // Flags: --allow-natives-syntax --expose-debug-as debug |
6 | 6 |
7 Debug = debug.Debug | 7 Debug = debug.Debug |
8 var exception = null; | 8 var exception = null; |
9 var break_count = 0; | 9 var break_count = 0; |
10 var expected_breaks = -1; | 10 const expected_breaks = 9; |
11 | 11 |
12 function listener(event, exec_state, event_data, data) { | 12 function listener(event, exec_state, event_data, data) { |
13 try { | 13 try { |
14 if (event == Debug.DebugEvent.Break) { | 14 if (event == Debug.DebugEvent.Break) { |
15 assertTrue(exec_state.frameCount() != 0, "FAIL: Empty stack trace"); | 15 assertTrue(exec_state.frameCount() != 0, "FAIL: Empty stack trace"); |
16 if (!break_count) { | |
17 // Count number of expected breakpoints in this source file. | |
18 var source_text = exec_state.frame(0).func().script().source(); | |
19 expected_breaks = source_text.match(/\/\/\s*Break\s+\d+\./g).length; | |
20 print("Expected breaks: " + expected_breaks); | |
21 } | |
22 var source = exec_state.frame(0).sourceLineText(); | 16 var source = exec_state.frame(0).sourceLineText(); |
23 print("paused at: " + source); | 17 print("paused at: " + source); |
24 assertTrue(source.indexOf("// Break " + break_count + ".") > 0, | 18 assertTrue(source.indexOf("// Break " + break_count + ".") > 0, |
25 "Unexpected pause at: " + source + "\n" + | 19 "Unexpected pause at: " + source + "\n" + |
26 "Expected: // Break " + break_count + "."); | 20 "Expected: // Break " + break_count + "."); |
27 if (source.indexOf("StepOver.") !== -1) { | 21 if (source.indexOf("StepOver.") !== -1) { |
28 exec_state.prepareStep(Debug.StepAction.StepNext); | 22 exec_state.prepareStep(Debug.StepAction.StepNext); |
29 } else { | 23 } else { |
30 exec_state.prepareStep(Debug.StepAction.StepIn); | 24 exec_state.prepareStep(Debug.StepAction.StepIn); |
31 } | 25 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 Promise.resolve().then(function() { | 66 Promise.resolve().then(function() { |
73 if (expected_breaks !== break_count) { | 67 if (expected_breaks !== break_count) { |
74 %AbortJS("FAIL: expected <" + expected_breaks + "> breaks instead of <" + | 68 %AbortJS("FAIL: expected <" + expected_breaks + "> breaks instead of <" + |
75 break_count + ">"); | 69 break_count + ">"); |
76 } | 70 } |
77 if (exception !== null) { | 71 if (exception !== null) { |
78 %AbortJS("FAIL: exception: " + exception); | 72 %AbortJS("FAIL: exception: " + exception); |
79 } | 73 } |
80 }); | 74 }); |
81 } | 75 } |
OLD | NEW |