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 promiseResolve() { |
| 35 return Promise.resolve().then(foo1); |
| 36 } |
| 37 |
| 38 function promiseReject() { |
| 39 return Promise.reject().catch(foo1); |
| 40 } |
| 41 |
| 42 function promiseAll() { |
| 43 return Promise.all([ Promise.resolve() ]).then(foo1); |
| 44 } |
| 45 |
| 46 function promiseRace() { |
| 47 return Promise.race([ Promise.resolve() ]).then(foo1); |
| 48 } |
| 49 |
| 50 //# sourceURL=test.js`, |
| 51 8, 4); |
| 52 |
| 53 InspectorTest.setupScriptMap(); |
| 54 Protocol.Debugger.onPaused(message => { |
| 55 InspectorTest.logCallFrames(message.params.callFrames); |
| 56 var asyncStackTrace = message.params.asyncStackTrace; |
| 57 while (asyncStackTrace) { |
| 58 InspectorTest.log(`-- ${asyncStackTrace.description} --`); |
| 59 InspectorTest.logCallFrames(asyncStackTrace.callFrames); |
| 60 if (asyncStackTrace.creationFrame) { |
| 61 InspectorTest.log('--- created in ---'); |
| 62 InspectorTest.logCallFrames([asyncStackTrace.creationFrame]); |
| 63 } |
| 64 asyncStackTrace = asyncStackTrace.parent; |
| 65 } |
| 66 InspectorTest.log(''); |
| 67 Protocol.Debugger.resume(); |
| 68 }); |
| 69 |
| 70 Protocol.Debugger.enable(); |
| 71 Protocol.Debugger.setAsyncCallStackDepth({maxDepth: 128}); |
| 72 |
| 73 InspectorTest.runTestSuite([ |
| 74 function testPromise(next) { |
| 75 Protocol.Runtime |
| 76 .evaluate( |
| 77 {expression: 'promise()//# sourceURL=expr.js', awaitPromise: true}) |
| 78 .then(next); |
| 79 }, |
| 80 |
| 81 function testPromiseThen(next) { |
| 82 Protocol.Runtime |
| 83 .evaluate({ |
| 84 expression: 'promiseThen()//# sourceURL=expr.js', |
| 85 awaitPromise: true |
| 86 }) |
| 87 .then(next); |
| 88 }, |
| 89 |
| 90 function testPromiseResolve(next) { |
| 91 Protocol.Runtime |
| 92 .evaluate({ |
| 93 expression: 'promiseResolve()//# sourceURL=expr.js', |
| 94 awaitPromise: true |
| 95 }) |
| 96 .then(next); |
| 97 }, |
| 98 |
| 99 function testPromiseReject(next) { |
| 100 Protocol.Runtime |
| 101 .evaluate({ |
| 102 expression: 'promiseReject()//# sourceURL=expr.js', |
| 103 awaitPromise: true |
| 104 }) |
| 105 .then(next); |
| 106 }, |
| 107 |
| 108 function testPromiseAll(next) { |
| 109 Protocol.Runtime |
| 110 .evaluate({ |
| 111 expression: 'promiseAll()//# sourceURL=expr.js', |
| 112 awaitPromise: true |
| 113 }) |
| 114 .then(next); |
| 115 }, |
| 116 |
| 117 function testPromiseRace(next) { |
| 118 Protocol.Runtime |
| 119 .evaluate({ |
| 120 expression: 'promiseRace()//# sourceURL=expr.js', |
| 121 awaitPromise: true |
| 122 }) |
| 123 .then(next); |
| 124 } |
| 125 ]); |
OLD | NEW |