754736d26c
... which were done after the promise has been resolved. Goal of this CL - change promise instrumentation to support better callbacks, chained after promise resolution and prepare instrumentation for adding new asyncTaskCreated instrumentation. Instrumentation changes: - asyncTaskScheduled(recurring) when promise is fulfilled or rejected, - asyncTaskCancelled when promise is collected (since [1] we can be sure that promise will survive scheduled microtasks). Minor changes: - async task type in inspector <-> debugger API transferred by enum instead of string, - Debug manages async task ids based on promise objects. More details: https://docs.google.com/document/d/1u19N45f1gSF7M39mGsycJEK3IPyJgIXCBnWyiPeuJFE [1] https://codereview.chromium.org/2581503003/ BUG=chromium:632829,v8:5738 R=dgozman@chromium.org,yangguo@chromium.org,gsathya@chromium.org Review-Url: https://codereview.chromium.org/2578923002 Cr-Commit-Position: refs/heads/master@{#42178}
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
// Copyright 2016 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.
|
|
|
|
print('Checks that async stacks works for async/await');
|
|
|
|
InspectorTest.addScript(`
|
|
async function foo1() {
|
|
debugger;
|
|
return Promise.resolve();
|
|
}
|
|
|
|
async function foo2() {
|
|
await Promise.resolve();
|
|
debugger;
|
|
await Promise.resolve();
|
|
debugger;
|
|
await foo1();
|
|
await Promise.all([ Promise.resolve() ]).then(foo1);
|
|
debugger;
|
|
}
|
|
|
|
async function test() {
|
|
await foo2();
|
|
}
|
|
//# sourceURL=test.js`, 7, 26);
|
|
|
|
InspectorTest.setupScriptMap();
|
|
Protocol.Debugger.onPaused(message => {
|
|
InspectorTest.logCallFrames(message.params.callFrames);
|
|
var asyncStackTrace = message.params.asyncStackTrace;
|
|
while (asyncStackTrace) {
|
|
InspectorTest.log(`-- ${asyncStackTrace.description} --`);
|
|
InspectorTest.logCallFrames(asyncStackTrace.callFrames);
|
|
asyncStackTrace = asyncStackTrace.parent;
|
|
}
|
|
InspectorTest.log('');
|
|
Protocol.Debugger.resume();
|
|
});
|
|
|
|
Protocol.Debugger.enable();
|
|
Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 128 });
|
|
Protocol.Runtime.evaluate({ expression: 'test()//# sourceURL=expr.js',
|
|
awaitPromise: true })
|
|
.then(InspectorTest.logMessage)
|
|
.then(InspectorTest.completeTest);
|