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 function setTimeouts() { |
| 68 var resolve; |
| 69 var p = new Promise(r => resolve = r); |
| 70 setTimeout(() => |
| 71 setTimeout(() => |
| 72 setTimeout(() => { foo1(); resolve(); }, 0), 0), 0); |
| 73 return p; |
| 74 } |
| 75 |
| 76 //# sourceURL=test.js`, |
| 77 8, 4); |
| 78 |
| 79 InspectorTest.setupScriptMap(); |
| 80 Protocol.Debugger.onPaused(message => { |
| 81 InspectorTest.logCallFrames(message.params.callFrames); |
| 82 InspectorTest.logAsyncStackTrace(message.params.asyncStackTrace); |
| 83 InspectorTest.log(''); |
| 84 Protocol.Debugger.resume(); |
| 85 }); |
| 86 |
| 87 Protocol.Debugger.enable(); |
| 88 Protocol.Debugger.setAsyncCallStackDepth({maxDepth: 128}); |
| 89 |
| 90 InspectorTest.runTestSuite([ |
| 91 function testPromise(next) { |
| 92 Protocol.Runtime |
| 93 .evaluate( |
| 94 {expression: 'promise()//# sourceURL=expr.js', awaitPromise: true}) |
| 95 .then(next); |
| 96 }, |
| 97 |
| 98 function testPromiseThen(next) { |
| 99 Protocol.Runtime |
| 100 .evaluate({ |
| 101 expression: 'promiseThen()//# sourceURL=expr.js', |
| 102 awaitPromise: true |
| 103 }) |
| 104 .then(next); |
| 105 }, |
| 106 |
| 107 function testPromiseThenThen(next) { |
| 108 Protocol.Runtime |
| 109 .evaluate({ |
| 110 expression: 'promiseThenThen()//# sourceURL=expr.js', |
| 111 awaitPromise: true |
| 112 }) |
| 113 .then(next); |
| 114 }, |
| 115 |
| 116 function testPromiseResolve(next) { |
| 117 Protocol.Runtime |
| 118 .evaluate({ |
| 119 expression: 'promiseResolve()//# sourceURL=expr.js', |
| 120 awaitPromise: true |
| 121 }) |
| 122 .then(next); |
| 123 }, |
| 124 |
| 125 function testPromiseReject(next) { |
| 126 Protocol.Runtime |
| 127 .evaluate({ |
| 128 expression: 'promiseReject()//# sourceURL=expr.js', |
| 129 awaitPromise: true |
| 130 }) |
| 131 .then(next); |
| 132 }, |
| 133 |
| 134 function testPromiseAll(next) { |
| 135 Protocol.Runtime |
| 136 .evaluate({ |
| 137 expression: 'promiseAll()//# sourceURL=expr.js', |
| 138 awaitPromise: true |
| 139 }) |
| 140 .then(next); |
| 141 }, |
| 142 |
| 143 function testPromiseRace(next) { |
| 144 Protocol.Runtime |
| 145 .evaluate({ |
| 146 expression: 'promiseRace()//# sourceURL=expr.js', |
| 147 awaitPromise: true |
| 148 }) |
| 149 .then(next); |
| 150 }, |
| 151 |
| 152 function testThenableJob1(next) { |
| 153 Protocol.Runtime |
| 154 .evaluate({ |
| 155 expression: 'thenableJob1()//# sourceURL=expr.js', |
| 156 awaitPromise: true |
| 157 }) |
| 158 .then(next); |
| 159 }, |
| 160 |
| 161 function testThenableJob2(next) { |
| 162 Protocol.Runtime |
| 163 .evaluate({ |
| 164 expression: 'thenableJob2()//# sourceURL=expr.js', |
| 165 awaitPromise: true |
| 166 }) |
| 167 .then(next); |
| 168 }, |
| 169 |
| 170 function testSetTimeouts(next) { |
| 171 Protocol.Runtime |
| 172 .evaluate({ |
| 173 expression: 'setTimeouts()//# sourceURL=expr.js', |
| 174 awaitPromise: true |
| 175 }) |
| 176 .then(next); |
| 177 } |
| 178 ]); |
OLD | NEW |