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 | 5 // Flags: --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 | 10 |
11 var expected_values = | 11 var expected_values = |
12 [ReferenceError, undefined, 0, 0, 0, 0, 1, ReferenceError, ReferenceError]; | 12 [ReferenceError, ReferenceError, 0, 0, 0, 0, 1, |
| 13 ReferenceError, ReferenceError]; |
13 | 14 |
14 function listener(event, exec_state, event_data, data) { | 15 function listener(event, exec_state, event_data, data) { |
15 try { | 16 try { |
16 if (event == Debug.DebugEvent.Break) { | 17 if (event == Debug.DebugEvent.Break) { |
17 assertTrue(exec_state.frameCount() != 0, "FAIL: Empty stack trace"); | 18 assertTrue(exec_state.frameCount() != 0, "FAIL: Empty stack trace"); |
18 // Count number of expected breakpoints in this source file. | 19 // Count number of expected breakpoints in this source file. |
19 if (!break_count) { | 20 if (!break_count) { |
20 var source_text = exec_state.frame(0).func().script().source(); | 21 var source_text = exec_state.frame(0).func().script().source(); |
21 expected_breaks = source_text.match(/\/\/\s*Break\s+\d+\./g).length; | 22 expected_breaks = source_text.match(/\/\/\s*Break\s+\d+\./g).length; |
22 print("Expected breaks: " + expected_breaks); | 23 print("Expected breaks: " + expected_breaks); |
23 } | 24 } |
24 var frameMirror = exec_state.frame(0); | 25 var frameMirror = exec_state.frame(0); |
25 | 26 |
26 var v = null;; | 27 var v = null;; |
27 try { | 28 try { |
28 v = frameMirror.evaluate('i').value(); | 29 v = frameMirror.evaluate('i').value(); |
29 } catch(e) { | 30 } catch(e) { |
30 v = e; | 31 v = e; |
31 } | 32 } |
32 frameMirror.allScopes(); | 33 frameMirror.allScopes(); |
33 var source = frameMirror.sourceLineText(); | 34 var source = frameMirror.sourceLineText(); |
34 print("paused at: " + source); | 35 print("paused at: " + source); |
35 assertTrue(source.indexOf("// Break " + break_count + ".") > 0, | 36 assertTrue(source.indexOf("// Break " + break_count + ".") > 0, |
36 "Unexpected pause at: " + source + "\n" + | 37 "Unexpected pause at: " + source + "\n" + |
37 "Expected: // Break " + break_count + "."); | 38 "Expected: // Break " + break_count + "."); |
38 if (expected_values[break_count] === ReferenceError) { | 39 if (expected_values[break_count] === ReferenceError) { |
39 assertTrue(v instanceof ReferenceError); | 40 assertTrue(v instanceof ReferenceError); |
40 } else { | 41 } else { |
41 assertSame(expected_values[break_count], v); | 42 assertSame(expected_values[break_count], v); |
42 | |
43 } | 43 } |
44 ++break_count; | 44 ++break_count; |
45 | 45 |
46 if (break_count !== expected_breaks) { | 46 if (break_count !== expected_breaks) { |
47 exec_state.prepareStep(Debug.StepAction.StepIn); | 47 exec_state.prepareStep(Debug.StepAction.StepIn); |
48 print("Next step prepared"); | 48 print("Next step prepared"); |
49 } | 49 } |
50 } | 50 } |
51 } catch(e) { | 51 } catch(e) { |
52 exception = e; | 52 exception = e; |
(...skipping 14 matching lines...) Expand all Loading... |
67 i++) { // Break 5. | 67 i++) { // Break 5. |
68 let key = i; // Break 3. | 68 let key = i; // Break 3. |
69 sum += key; // Break 4. | 69 sum += key; // Break 4. |
70 } | 70 } |
71 }()); // Break 7. | 71 }()); // Break 7. |
72 | 72 |
73 assertNull(exception); // Break 8. | 73 assertNull(exception); // Break 8. |
74 assertEquals(expected_breaks, break_count); | 74 assertEquals(expected_breaks, break_count); |
75 | 75 |
76 Debug.setListener(null); | 76 Debug.setListener(null); |
OLD | NEW |