2017-04-28 21:07:01 +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
|
|
|
|
2017-05-11 19:21:24 +00:00
|
|
|
// TODO(kozyatinskiy): fix or remove it later.
|
2017-05-19 00:35:45 +00:00
|
|
|
let {session, contextGroup, Protocol} = InspectorTest.start('Tests how async promise chains behave when reaching the limit of stacks');
|
|
|
|
|
2017-04-28 21:07:01 +00:00
|
|
|
(async function test(){
|
|
|
|
InspectorTest.log('Checks correctness of promise chains when limit hit');
|
|
|
|
await Protocol.Runtime.enable();
|
|
|
|
await Protocol.Debugger.enable();
|
|
|
|
Protocol.Debugger.setAsyncCallStackDepth({maxDepth: 128});
|
|
|
|
|
|
|
|
await setMaxAsyncTaskStacks(3);
|
|
|
|
runWithAsyncChainPromise(3, 'console.trace()');
|
|
|
|
InspectorTest.logMessage(await Protocol.Runtime.onceConsoleAPICalled());
|
|
|
|
|
|
|
|
await setMaxAsyncTaskStacks(4);
|
|
|
|
runWithAsyncChainPromise(3, 'console.trace()');
|
|
|
|
InspectorTest.logMessage(await Protocol.Runtime.onceConsoleAPICalled());
|
|
|
|
|
|
|
|
await setMaxAsyncTaskStacks(5);
|
|
|
|
runWithAsyncChainPromise(3, 'console.trace()');
|
|
|
|
InspectorTest.logMessage(await Protocol.Runtime.onceConsoleAPICalled());
|
|
|
|
|
|
|
|
await setMaxAsyncTaskStacks(6);
|
|
|
|
runWithAsyncChainPromise(3, 'console.trace()');
|
|
|
|
InspectorTest.logMessage(await Protocol.Runtime.onceConsoleAPICalled());
|
|
|
|
|
|
|
|
await setMaxAsyncTaskStacks(7);
|
|
|
|
runWithAsyncChainPromise(3, 'console.trace()');
|
|
|
|
InspectorTest.logMessage(await Protocol.Runtime.onceConsoleAPICalled());
|
|
|
|
|
|
|
|
await setMaxAsyncTaskStacks(8);
|
|
|
|
runWithAsyncChainPromise(3, 'console.trace()');
|
|
|
|
InspectorTest.logMessage(await Protocol.Runtime.onceConsoleAPICalled());
|
|
|
|
|
|
|
|
InspectorTest.completeTest();
|
|
|
|
})();
|
|
|
|
|
|
|
|
function runWithAsyncChainPromise(len, source) {
|
|
|
|
InspectorTest.log(`Run expression '${source}' with async chain len: ${len}`);
|
2017-11-21 15:42:43 +00:00
|
|
|
let asyncCall = `(function asyncCall(num) {
|
|
|
|
if (num === 0) {
|
|
|
|
${source};
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Promise.resolve().then(() => asyncCall(num - 1));
|
|
|
|
})(${len})`;
|
|
|
|
Protocol.Runtime.evaluate({expression: asyncCall});
|
2017-04-28 21:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function setMaxAsyncTaskStacks(max) {
|
|
|
|
let expression = `inspector.setMaxAsyncTaskStacks(${max})`;
|
|
|
|
InspectorTest.log(expression);
|
|
|
|
await Protocol.Runtime.evaluate({expression});
|
|
|
|
}
|