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
3 // found in the LICENSE file.
5 // Flags: --expose-debug-as debug
11 function listener(event, exec_state, event_data, data) {
13 if (event == Debug.DebugEvent.Break) {
14 assertTrue(exec_state.frameCount() != 0, "FAIL: Empty stack trace");
15 // Count number of expected breakpoints in this source file.
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);
21 var frameMirror = exec_state.frame(0);
23 frameMirror.allScopes();
24 var source = frameMirror.sourceLineText();
25 print("paused at: " + source);
26 assertTrue(source.indexOf("// Break " + break_count + ".") > 0,
27 "Unexpected pause at: " + source + "\n" +
28 "Expected: // Break " + break_count + ".");
31 if (break_count !== expected_breaks) {
32 exec_state.prepareStep(Debug.StepAction.StepIn, 1);
33 print("Next step prepared");
42 Debug.setListener(listener);
49 var i = 0; // Break 1.
55 assertNull(exception); // Break 6.
56 assertEquals(expected_breaks, break_count);
58 Debug.setListener(null);