Chromium Code Reviews| Index: test/inspector/debugger/async-instrumentation.js |
| diff --git a/test/inspector/debugger/async-instrumentation.js b/test/inspector/debugger/async-instrumentation.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..05e814e119abeec790daebe6d81ed3372614c31d |
| --- /dev/null |
| +++ b/test/inspector/debugger/async-instrumentation.js |
| @@ -0,0 +1,67 @@ |
| +// 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 async instrumentation enabled in the middle.'); |
| + |
| +InspectorTest.addScript(` |
| +function foo() { |
| + // asyncTaskStarted |
| + debugger; |
| + // asyncTaskFinished |
| + debugger; |
| +} |
| + |
| +function test() { |
| + var resolve1; |
| + var p1 = new Promise(resolve => resolve1 = resolve); |
| + var p2 = p1.then(foo); |
| + debugger; |
| + resolve1(); // asyncTaskScheduled |
| + debugger; |
| + return p2; |
| +} |
| + |
| +//# sourceURL=test.js`, 7, 26); |
| + |
| +InspectorTest.setupScriptMap(); |
| +Protocol.Debugger.onPaused(message => { |
| + if (enableOnPause-- === 0) |
|
dgozman
2017/01/09 22:59:30
Declare this variable somewhere please.
kozy
2017/01/10 00:11:38
Done.
|
| + Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 128 }); |
| + 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(); |
| +InspectorTest.runTestSuite([ |
| + function beforeAsyncTaskScheduled(next) { |
| + enableOnPause = 0; |
| + Protocol.Runtime.evaluate({ expression: 'test()//# sourceURL=expr1.js', |
| + awaitPromise: true }) |
| + .then(() => Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 0 })) |
| + .then(next); |
| + }, |
| + |
| + function afterAsyncTaskScheduled(next) { |
| + enableOnPause = 2; |
| + Protocol.Runtime.evaluate({ expression: 'test()//# sourceURL=expr1.js', |
| + awaitPromise: true }) |
| + .then(() => Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 0 })) |
| + .then(next); |
| + }, |
| + |
| + function afterAsyncTaskStarted(next) { |
| + enableOnPause = 3; |
| + Protocol.Runtime.evaluate({ expression: 'test()//# sourceURL=expr1.js', |
| + awaitPromise: true }) |
| + .then(() => Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 0 })) |
| + .then(next); |
| + } |
| +]); |