2017-04-18 15:53:08 +00:00
|
|
|
// 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.
|
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
let {session, contextGroup, Protocol} = InspectorTest.start('Checks that we report not more then maxDepth call chains.');
|
2017-04-18 15:53:08 +00:00
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
contextGroup.addScript(`
|
2019-02-20 00:08:38 +00:00
|
|
|
function asyncChain(breakAtEnd) {
|
|
|
|
function asyncOpNested() {
|
|
|
|
setTimeout(asyncOpNested1, 0);
|
2017-04-18 15:53:08 +00:00
|
|
|
}
|
2019-02-20 00:08:38 +00:00
|
|
|
function asyncOpNested1() {
|
|
|
|
setTimeout(asyncOpNested2, 0);
|
|
|
|
}
|
|
|
|
function asyncOpNested2() {
|
|
|
|
setTimeout(asyncOpNested3, 0);
|
|
|
|
}
|
|
|
|
function asyncOpNested3() {
|
|
|
|
setTimeout(asyncOpNested4, 0);
|
|
|
|
}
|
|
|
|
function asyncOpNested4() {
|
|
|
|
if (breakAtEnd) {
|
|
|
|
debugger;
|
|
|
|
} else {
|
|
|
|
console.trace(42);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
asyncOpNested();
|
2017-04-18 15:53:08 +00:00
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
|
|
|
Protocol.Debugger.enable();
|
|
|
|
InspectorTest.runAsyncTestSuite([
|
|
|
|
async function testPaused() {
|
2019-02-20 00:08:38 +00:00
|
|
|
const breakAtEnd = true;
|
|
|
|
startTest({ limit: 8, breakAtEnd });
|
2017-04-18 15:53:08 +00:00
|
|
|
dumpCaptured((await Protocol.Debugger.oncePaused()).params.asyncStackTrace);
|
|
|
|
await Protocol.Debugger.resume();
|
|
|
|
|
2019-02-20 00:08:38 +00:00
|
|
|
startTest({ limit: 4, breakAtEnd });
|
2017-04-18 15:53:08 +00:00
|
|
|
dumpCaptured((await Protocol.Debugger.oncePaused()).params.asyncStackTrace);
|
|
|
|
await Protocol.Debugger.resume();
|
|
|
|
|
2019-02-20 00:08:38 +00:00
|
|
|
startTest({ limit: 3, breakAtEnd });
|
2017-04-18 15:53:08 +00:00
|
|
|
dumpCaptured((await Protocol.Debugger.oncePaused()).params.asyncStackTrace);
|
|
|
|
await Protocol.Debugger.resume();
|
|
|
|
|
2019-02-20 00:08:38 +00:00
|
|
|
startTest({ limit: 0, breakAtEnd });
|
2017-04-18 15:53:08 +00:00
|
|
|
dumpCaptured((await Protocol.Debugger.oncePaused()).params.asyncStackTrace);
|
|
|
|
await Protocol.Debugger.resume();
|
|
|
|
},
|
|
|
|
|
|
|
|
async function testConsoleTrace() {
|
|
|
|
await Protocol.Runtime.enable();
|
2019-02-20 00:08:38 +00:00
|
|
|
const breakAtEnd = false;
|
|
|
|
startTest({ limit: 8, breakAtEnd});
|
2017-04-18 15:53:08 +00:00
|
|
|
let msg = await Protocol.Runtime.onceConsoleAPICalled();
|
|
|
|
dumpCaptured(msg.params.stackTrace.parent);
|
|
|
|
|
2019-02-20 00:08:38 +00:00
|
|
|
startTest({ limit: 4, breakAtEnd});
|
2017-04-18 15:53:08 +00:00
|
|
|
msg = await Protocol.Runtime.onceConsoleAPICalled();
|
|
|
|
dumpCaptured(msg.params.stackTrace.parent);
|
|
|
|
|
2019-02-20 00:08:38 +00:00
|
|
|
startTest({ limit: 3, breakAtEnd});
|
2017-04-18 15:53:08 +00:00
|
|
|
msg = await Protocol.Runtime.onceConsoleAPICalled();
|
|
|
|
dumpCaptured(msg.params.stackTrace.parent);
|
|
|
|
|
2019-02-20 00:08:38 +00:00
|
|
|
startTest({ limit: 0, breakAtEnd});
|
2017-04-18 15:53:08 +00:00
|
|
|
msg = await Protocol.Runtime.onceConsoleAPICalled();
|
|
|
|
dumpCaptured(msg.params.stackTrace.parent);
|
|
|
|
|
|
|
|
await Protocol.Runtime.disable();
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
|
|
|
|
function startTest(params) {
|
2019-02-20 00:08:38 +00:00
|
|
|
InspectorTest.log('Actual call chain length: 4');
|
|
|
|
InspectorTest.log(`setAsyncCallStackDepth(maxDepth): ${params.limit}`);
|
2017-04-18 15:53:08 +00:00
|
|
|
|
|
|
|
Protocol.Debugger.setAsyncCallStackDepth({maxDepth: params.limit});
|
|
|
|
Protocol.Runtime.evaluate({expression:
|
2019-02-20 00:08:38 +00:00
|
|
|
`asyncChain(${params.breakAtEnd})`});
|
2017-04-18 15:53:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function dumpCaptured(stack) {
|
|
|
|
let count = 0;
|
|
|
|
while (stack) {
|
|
|
|
++count;
|
|
|
|
stack = stack.parent;
|
|
|
|
}
|
|
|
|
InspectorTest.log('reported: ' + count + '\n');
|
|
|
|
}
|