Andrew Top | ef837fa | 2017-10-04 22:44:25 -0700 | [diff] [blame] | 1 | // 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 | |
| 5 | Debug = debug.Debug |
| 6 | var exception = null; |
| 7 | var log = []; |
| 8 | |
| 9 | function 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 | |
| 23 | Debug.setListener(listener); |
| 24 | |
| 25 | Promise.resolve().then( |
| 26 | function() { |
| 27 | print(1); |
| 28 | } |
| 29 | ).then( |
| 30 | function() { |
| 31 | return 2; |
| 32 | } |
| 33 | ).then( |
| 34 | function() { |
| 35 | throw new Error(); |
| 36 | } |
| 37 | ).catch( |
| 38 | function() { |
| 39 | print(3); |
| 40 | } // STOP |
| 41 | ); |
| 42 | |
| 43 | setTimeout(function() { |
| 44 | Debug.setListener(null); |
| 45 | assertNull(exception); |
| 46 | var expectation = |
Andrew Top | 63c7ad4 | 2019-11-25 16:10:13 -0800 | [diff] [blame] | 47 | ["debugger;",""," print(1);","}"," return 2;"," return 2;", |
Andrew Top | ef837fa | 2017-10-04 22:44:25 -0700 | [diff] [blame] | 48 | " throw new Error();"," print(3);","} // STOP"]; |
| 49 | assertEquals(log, expectation); |
| 50 | }); |
| 51 | |
| 52 | debugger; |