step-into-break-on-async-call.js 2.48 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

let {session, contextGroup, Protocol} =
    InspectorTest.start('Test for Debugger.stepInto with breakOnAsyncCall.');

InspectorTest.runAsyncTestSuite([
  async function testSetTimeout() {
    Protocol.Debugger.enable();
    Protocol.Debugger.pause();
12 13
    Protocol.Debugger.setAsyncCallStackDepth({maxDepth: 128});

14 15 16 17 18 19
    let pausedPromise = Protocol.Debugger.oncePaused();
    Protocol.Runtime.evaluate({
      expression: 'setTimeout(() => 42, 0)//# sourceURL=test.js'
    });
    await pausedPromise;
    Protocol.Debugger.stepInto({breakOnAsyncCall: true});
20 21
    let {params: {callFrames, asyncCallStackTraceId}} =
        await Protocol.Debugger.oncePaused();
22
    session.logCallFrames(callFrames);
23 24
    if (asyncCallStackTraceId) {
      InspectorTest.log('asyncCallStackTraceId is set');
25
    }
26 27
    Protocol.Debugger.pauseOnAsyncCall(
        {parentStackTraceId: asyncCallStackTraceId});
28 29
    pausedPromise = Protocol.Debugger.oncePaused();
    Protocol.Debugger.resume();
30
    ({params: {callFrames, asyncCallStackTraceId}} = await pausedPromise);
31
    session.logCallFrames(callFrames);
32 33
    if (!asyncCallStackTraceId) {
      InspectorTest.log('asyncCallStackTraceId is empty');
34 35 36 37 38 39
    }
    await Protocol.Debugger.disable();
  },

  async function testPromiseThen() {
    Protocol.Debugger.enable();
40 41
    Protocol.Debugger.setAsyncCallStackDepth({maxDepth: 128});

42 43 44 45 46 47
    Protocol.Runtime.evaluate({expression: 'var p = Promise.resolve()'});
    Protocol.Debugger.pause();
    let pausedPromise = Protocol.Debugger.oncePaused();
    Protocol.Runtime.evaluate({expression: 'p.then(() => 42)//# sourceURL=test.js'});
    await pausedPromise;
    Protocol.Debugger.stepInto({breakOnAsyncCall: true});
48 49
    let {params: {callFrames, asyncCallStackTraceId}} =
        await Protocol.Debugger.oncePaused();
50
    session.logCallFrames(callFrames);
51 52
    if (asyncCallStackTraceId) {
      InspectorTest.log('asyncCallStackTraceId is set');
53
    }
54 55
    Protocol.Debugger.pauseOnAsyncCall(
        {parentStackTraceId: asyncCallStackTraceId});
56 57
    pausedPromise = Protocol.Debugger.oncePaused();
    Protocol.Debugger.resume();
58
    ({params: {callFrames, asyncCallStackTraceId}} = await pausedPromise);
59
    session.logCallFrames(callFrames);
60 61
    if (!asyncCallStackTraceId) {
      InspectorTest.log('asyncCallStackTraceId is empty');
62 63 64 65
    }
    await Protocol.Debugger.disable();
  }
]);