v8/test/inspector/debugger/step-into-break-on-async-call.js
Alexey Kozyatinskiy 8205786a4b [inspector] decouple debugger delegate and async stacks delegate
Currently we enable instrumentation if debugger is active. With this
approach we can not:
- capture async stack when debugger is disabled,
- avoid async instrumentation overhead when debugger is enabled and
  async stacks are disabled.

R=dgozman@chromium.org,yangguo@chromium.org

Bug: none
Cq-Include-Trybots: luci.chromium.try:linux_chromium_headless_rel;luci.chromium.try:linux_chromium_rel_ng;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I19400c4c4e12b6c9b5a980fb6bd3293bac6e6a64
Reviewed-on: https://chromium-review.googlesource.com/1081494
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53530}
2018-06-05 17:39:22 +00:00

66 lines
2.5 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();
Protocol.Debugger.setAsyncCallStackDepth({maxDepth: 128});
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.Debugger.setAsyncCallStackDepth({maxDepth: 128});
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();
}
]);