v8/test/inspector/debugger/step-into-break-on-async-call.js
Alexey Kozyatinskiy 653a9e2bd3 [inspector] introduced universal Debugger.pauseOnAsyncCall
If protocol client needs to make step-into async call:
- pause before async call using any Debugger agent capabilities,
- call Debugger.stepInto with breakOnAsyncCall flag,
- wait for Debugger.paused event, this event will contain
  asyncCallStackTrace if async call is scheduled,
- call Debugger.pauseOnAsyncCall on each known target,
- resume execution in current debugger by Debugger.resume.

Bug: chromium:778796
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I40c56278e7b1ceafc3bf81608b8ca6716c2b3168
Reviewed-on: https://chromium-review.googlesource.com/773573
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49594}
2017-11-23 00:20:10 +00:00

62 lines
2.4 KiB
JavaScript

// 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();
let pausedPromise = Protocol.Debugger.oncePaused();
Protocol.Runtime.evaluate({
expression: 'setTimeout(() => 42, 0)//# sourceURL=test.js'
});
await pausedPromise;
Protocol.Debugger.stepInto({breakOnAsyncCall: true});
let {params: {callFrames, asyncCallStackTraceId}} =
await Protocol.Debugger.oncePaused();
session.logCallFrames(callFrames);
if (asyncCallStackTraceId) {
InspectorTest.log('asyncCallStackTraceId is set');
}
Protocol.Debugger.pauseOnAsyncCall(
{parentStackTraceId: asyncCallStackTraceId});
pausedPromise = Protocol.Debugger.oncePaused();
Protocol.Debugger.resume();
({params: {callFrames, asyncCallStackTraceId}} = await pausedPromise);
session.logCallFrames(callFrames);
if (!asyncCallStackTraceId) {
InspectorTest.log('asyncCallStackTraceId is empty');
}
await Protocol.Debugger.disable();
},
async function testPromiseThen() {
Protocol.Debugger.enable();
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});
let {params: {callFrames, asyncCallStackTraceId}} =
await Protocol.Debugger.oncePaused();
session.logCallFrames(callFrames);
if (asyncCallStackTraceId) {
InspectorTest.log('asyncCallStackTraceId is set');
}
Protocol.Debugger.pauseOnAsyncCall(
{parentStackTraceId: asyncCallStackTraceId});
pausedPromise = Protocol.Debugger.oncePaused();
Protocol.Debugger.resume();
({params: {callFrames, asyncCallStackTraceId}} = await pausedPromise);
session.logCallFrames(callFrames);
if (!asyncCallStackTraceId) {
InspectorTest.log('asyncCallStackTraceId is empty');
}
await Protocol.Debugger.disable();
}
]);