blob: 633bac84a14f13a793ced7c695539aa85a8a1939 [file] [log] [blame]
Andrew Topef837fa2017-10-04 22:44:25 -07001// Copyright 2017 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.
4
5Debug = debug.Debug
6var exception = null;
7var log = [];
8
9function listener(event, exec_state, event_data, data) {
10 try {
11 if (event == Debug.DebugEvent.Break) {
12 var line = exec_state.frame(0).sourceLineText();
13 log.push(line);
14 if (!/STOP/.test(line)) {
15 exec_state.prepareStep(Debug.StepAction.StepIn);
16 }
17 }
18 } catch (e) {
19 exception = e;
20 }
21};
22
23Debug.setListener(listener);
24
25Promise.resolve().then(
26function() {
27 print(1);
28}
29).then(
30function() {
31 return 2;
32}
33).then(
34function() {
35 throw new Error();
36}
37).catch(
38function() {
39 print(3);
40} // STOP
41);
42
43setTimeout(function() {
44 Debug.setListener(null);
45 assertNull(exception);
46 var expectation =
Andrew Top63c7ad42019-11-25 16:10:13 -080047 ["debugger;",""," print(1);","}"," return 2;"," return 2;",
Andrew Topef837fa2017-10-04 22:44:25 -070048 " throw new Error();"," print(3);","} // STOP"];
49 assertEquals(log, expectation);
50});
51
52debugger;