Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(756)

Unified Diff: test/inspector/debugger/step-into-async.js

Issue 2655253004: [inspector] introduced stepIntoAsync for chained callbacks (Closed)
Patch Set: fixed async/await and added tests Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | test/inspector/debugger/step-into-async-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/inspector/debugger/step-into-async.js
diff --git a/test/inspector/debugger/step-into-async.js b/test/inspector/debugger/step-into-async.js
new file mode 100644
index 0000000000000000000000000000000000000000..fc8274c82a010cdac883568080612541e486ca85
--- /dev/null
+++ b/test/inspector/debugger/step-into-async.js
@@ -0,0 +1,164 @@
+// 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.
+
+print('Checks stepIntoAsync for Promise.then');
+
+InspectorTest.addScript(`
+function foo() {
+}
+
+function boo() {
+}
+
+function basic(next) {
+ var p = new Promise(r => resolve = r);
+ debugger;
+ p.then(foo).then(next);
+ resolve();
+ foo();
+}
+
+function promiseResolve(next) {
+ debugger;
+ Promise.resolve().then(foo).then(next);
+}
+
+function promiseReject(next) {
+ debugger;
+ Promise.reject().catch(foo).then(next);
+}
+
+function promiseAll(next) {
+ debugger;
+ Promise.all([ Promise.resolve() ]).then(foo).then(next);
+}
+
+function promiseRace(next) {
+ debugger;
+ Promise.race([ Promise.resolve() ]).then(foo).then(next);
+}
+
+function twoChainedCallbacks(next) {
+ debugger;
+ Promise.resolve().then(boo).then(foo).then(next);
+}
+
+function newPromise(next) {
+ var resolve;
+ debugger;
+ new Promise(r => resolve = r).then(boo).then(next);
+ resolve();
+}
+
+function returnedPromise(next) {
+ function promise() {
+ return Promise.resolve();
+ }
+ debugger;
+ promise().then(boo).then(next);
+}
+
+function asyncAwait(next) {
+ async function foo2() {
+ await Promise.resolve();
+ }
+
+ async function foo1() {
+ await foo2();
+ next();
+ }
+ debugger;
+ foo1();
+}
+
+function runTest(test) {
+ return new Promise(function runTest(resolve) { test(resolve); });
+}
+//# sourceURL=test.js`, 7, 26);
+
+InspectorTest.setupScriptMap();
+var actions = [];
+Protocol.Debugger.onPaused(message => {
+ var frames = message.params.callFrames.filter(frame => frame.functionName !== 'runTest');
+ InspectorTest.logCallFrames(frames);
+ delete message.params.callFrames;
+ if (message.params.data) InspectorTest.logMessage(message);
+ InspectorTest.log('');
+ var action = actions.shift() || 'resume';
+ InspectorTest.log('Executing: ' + action);
+ Protocol.Debugger[action]().then(message => {
+ if (!message.error) return;
+ InspectorTest.logMessage(message);
+ Protocol.Debugger.resume();
+ });
+});
+
+Protocol.Debugger.enable();
+InspectorTest.runTestSuite([
+ function testBasic(next) {
+ actions = [ 'stepInto', 'stepInto', 'stepIntoAsync' ];
+ Protocol.Runtime.evaluate({ expression: 'runTest(basic)', awaitPromise: true })
+ .then(next);
+ },
+
+ function testPromiseResolve(next) {
+ actions = [ 'stepInto', 'stepInto', 'stepIntoAsync' ];
+ Protocol.Runtime.evaluate({ expression: 'runTest(promiseResolve)', awaitPromise: true })
+ .then(next);
+ },
+
+ function testPromiseReject(next) {
+ actions = [ 'stepInto', 'stepInto', 'stepIntoAsync' ];
+ Protocol.Runtime.evaluate({ expression: 'runTest(promiseReject)', awaitPromise: true })
+ .then(next);
+ },
+
+ function testPromiseAll(next) {
+ actions = [ 'stepInto', 'stepInto', 'stepIntoAsync' ];
+ Protocol.Runtime.evaluate({ expression: 'runTest(promiseAll)', awaitPromise: true })
+ .then(next);
+ },
+
+ function testPromiseRace(next) {
+ actions = [ 'stepInto', 'stepInto', 'stepIntoAsync' ];
+ Protocol.Runtime.evaluate({ expression: 'runTest(promiseRace)', awaitPromise: true })
+ .then(next);
+ },
+
+ function testTwoChainedCallbacks(next) {
+ actions = [ 'stepInto', 'stepInto', 'stepInto', 'stepIntoAsync' ];
+ Protocol.Runtime.evaluate({ expression: 'runTest(twoChainedCallbacks)', awaitPromise: true })
+ .then(next);
+ },
+
+ function testNewPromise(next) {
+ actions = [ 'stepInto', 'stepInto', 'stepOut', 'stepInto', 'stepIntoAsync' ];
+ Protocol.Runtime.evaluate({ expression: 'runTest(newPromise)', awaitPromise: true })
+ .then(next);
+ },
+
+ function testReturnedPromise(next) {
+ actions = [ 'stepInto', 'stepInto', 'stepOut', 'stepInto', 'stepIntoAsync' ];
+ Protocol.Runtime.evaluate({ expression: 'runTest(returnedPromise)', awaitPromise: true })
+ .then(next);
+ },
+
+ function testAsyncAwait(next) {
+ actions = [ 'stepInto', 'stepInto', 'stepInto', 'stepInto', 'stepInto', 'stepInto', 'stepInto' ];
+ Protocol.Runtime.evaluate({ expression: 'runTest(asyncAwait)', awaitPromise: true })
+ .then(next);
+ },
+
+ function testResumeWorkAfterBreak(next) {
+ actions = [ 'stepInto', 'stepInto' ];
+ Protocol.Runtime.evaluate({ expression: 'runTest(basic)', awaitPromise: true })
+ .then(next);
+ },
+
+ function testStepIntoAsyncWithoutScheduled(next) {
+ actions = [ 'stepIntoAsync' ];
+ Protocol.Runtime.evaluate({ expression: 'runTest(basic)', awaitPromise: true })
+ .then(next);
+ }
+]);
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | test/inspector/debugger/step-into-async-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698