OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 print('Checks created frame for async call chain'); |
| 6 |
| 7 InspectorTest.addScript( |
| 8 ` |
| 9 function foo1() { |
| 10 debugger; |
| 11 } |
| 12 |
| 13 function foo2() { |
| 14 debugger; |
| 15 } |
| 16 |
| 17 function promise() { |
| 18 var resolve; |
| 19 var p1 = new Promise(r => resolve = r); |
| 20 var p2 = p1.then(foo1); |
| 21 resolve(); |
| 22 return p2; |
| 23 } |
| 24 |
| 25 function promiseThen() { |
| 26 var resolve; |
| 27 var p1 = new Promise(r => resolve = r); |
| 28 var p2 = p1.then(foo1); |
| 29 var p3 = p2.then(foo2); |
| 30 resolve(); |
| 31 return p3; |
| 32 } |
| 33 |
| 34 function promiseThenThen() { |
| 35 var resolve; |
| 36 var p1 = new Promise(r => resolve = r); |
| 37 var p2 = p1.then(foo1).then(foo2); |
| 38 var p3 = p1.then(foo1); |
| 39 resolve(); |
| 40 return p2; |
| 41 } |
| 42 |
| 43 function promiseResolve() { |
| 44 return Promise.resolve().then(foo1); |
| 45 } |
| 46 |
| 47 function promiseReject() { |
| 48 return Promise.reject().catch(foo1); |
| 49 } |
| 50 |
| 51 function promiseAll() { |
| 52 return Promise.all([ Promise.resolve() ]).then(foo1); |
| 53 } |
| 54 |
| 55 function promiseRace() { |
| 56 return Promise.race([ Promise.resolve() ]).then(foo1); |
| 57 } |
| 58 |
| 59 function thenableJob1() { |
| 60 return Promise.resolve().then(() => Promise.resolve().then(() => 42)).then(foo
1); |
| 61 } |
| 62 |
| 63 function thenableJob2() { |
| 64 return Promise.resolve().then(() => Promise.resolve()).then(foo1); |
| 65 } |
| 66 |
| 67 //# sourceURL=test.js`, |
| 68 8, 4); |
| 69 |
| 70 InspectorTest.setupScriptMap(); |
| 71 Protocol.Debugger.onPaused(message => { |
| 72 InspectorTest.logCallFrames(message.params.callFrames); |
| 73 var asyncStackTrace = message.params.asyncStackTrace; |
| 74 while (asyncStackTrace) { |
| 75 if (asyncStackTrace.promiseCreationFrame) { |
| 76 var frame = asyncStackTrace.promiseCreationFrame; |
| 77 InspectorTest.log(`-- ${asyncStackTrace.description} (${frame.url |
| 78 }:${frame.lineNumber}:${frame.columnNumber})--`); |
| 79 } else { |
| 80 InspectorTest.log(`-- ${asyncStackTrace.description} --`); |
| 81 } |
| 82 InspectorTest.logCallFrames(asyncStackTrace.callFrames); |
| 83 asyncStackTrace = asyncStackTrace.parent; |
| 84 } |
| 85 InspectorTest.log(''); |
| 86 Protocol.Debugger.resume(); |
| 87 }); |
| 88 |
| 89 Protocol.Debugger.enable(); |
| 90 Protocol.Debugger.setAsyncCallStackDepth({maxDepth: 128}); |
| 91 |
| 92 InspectorTest.runTestSuite([ |
| 93 function testPromise(next) { |
| 94 Protocol.Runtime |
| 95 .evaluate( |
| 96 {expression: 'promise()//# sourceURL=expr.js', awaitPromise: true}) |
| 97 .then(next); |
| 98 }, |
| 99 |
| 100 function testPromiseThen(next) { |
| 101 Protocol.Runtime |
| 102 .evaluate({ |
| 103 expression: 'promiseThen()//# sourceURL=expr.js', |
| 104 awaitPromise: true |
| 105 }) |
| 106 .then(next); |
| 107 }, |
| 108 |
| 109 function testPromiseThenThen(next) { |
| 110 Protocol.Runtime |
| 111 .evaluate({ |
| 112 expression: 'promiseThenThen()//# sourceURL=expr.js', |
| 113 awaitPromise: true |
| 114 }) |
| 115 .then(next); |
| 116 }, |
| 117 |
| 118 function testPromiseResolve(next) { |
| 119 Protocol.Runtime |
| 120 .evaluate({ |
| 121 expression: 'promiseResolve()//# sourceURL=expr.js', |
| 122 awaitPromise: true |
| 123 }) |
| 124 .then(next); |
| 125 }, |
| 126 |
| 127 function testPromiseReject(next) { |
| 128 Protocol.Runtime |
| 129 .evaluate({ |
| 130 expression: 'promiseReject()//# sourceURL=expr.js', |
| 131 awaitPromise: true |
| 132 }) |
| 133 .then(next); |
| 134 }, |
| 135 |
| 136 function testPromiseAll(next) { |
| 137 Protocol.Runtime |
| 138 .evaluate({ |
| 139 expression: 'promiseAll()//# sourceURL=expr.js', |
| 140 awaitPromise: true |
| 141 }) |
| 142 .then(next); |
| 143 }, |
| 144 |
| 145 function testPromiseRace(next) { |
| 146 Protocol.Runtime |
| 147 .evaluate({ |
| 148 expression: 'promiseRace()//# sourceURL=expr.js', |
| 149 awaitPromise: true |
| 150 }) |
| 151 .then(next); |
| 152 }, |
| 153 |
| 154 function testThenableJob1(next) { |
| 155 Protocol.Runtime |
| 156 .evaluate({ |
| 157 expression: 'thenableJob1()//# sourceURL=expr.js', |
| 158 awaitPromise: true |
| 159 }) |
| 160 .then(next); |
| 161 }, |
| 162 |
| 163 function testThenableJob2(next) { |
| 164 Protocol.Runtime |
| 165 .evaluate({ |
| 166 expression: 'thenableJob2()//# sourceURL=expr.js', |
| 167 awaitPromise: true |
| 168 }) |
| 169 .then(next); |
| 170 } |
| 171 ]); |
OLD | NEW |