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 InspectorTest.log('Check that continue-to-location works with different strategi
es.'); |
| 6 |
| 7 InspectorTest.addScript(` |
| 8 async function asyncFact(n) { |
| 9 if (n == 0) return 1; |
| 10 let r = n * await asyncFact(n - 1); |
| 11 console.log(r); |
| 12 return r; |
| 13 } |
| 14 |
| 15 function fact(n) { |
| 16 if (n == 0) return 1; |
| 17 let r = n * fact(n - 1); |
| 18 console.log(r); |
| 19 return r; |
| 20 } |
| 21 |
| 22 function topLevel() { |
| 23 eval(` + '`' + ` |
| 24 var a = 1; |
| 25 var b = 2; |
| 26 fact(3); |
| 27 console.log(a + b); |
| 28 ` + '`' + `); |
| 29 } |
| 30 |
| 31 //# sourceURL=test.js`, 7, 26); |
| 32 |
| 33 InspectorTest.setupScriptMap(); |
| 34 InspectorTest.runAsyncTestSuite([ |
| 35 async function testAwaitAny() { |
| 36 Protocol.Debugger.enable(); |
| 37 Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 128 }); |
| 38 Protocol.Debugger.pause(); |
| 39 Protocol.Runtime.evaluate({expression: 'asyncFact(4)//# sourceURL=expr.js'})
; |
| 40 await pausedAndDumpStack(); |
| 41 Protocol.Debugger.stepInto(); |
| 42 let message = await pausedAndDumpStack(); |
| 43 let location = message.params.callFrames[0].location; |
| 44 location.lineNumber = 11; |
| 45 Protocol.Debugger.continueToLocation({location, targetCallFrames: 'any'}); |
| 46 await pausedAndDumpStack(); |
| 47 Protocol.Debugger.disable(); |
| 48 }, |
| 49 |
| 50 async function testAwaitCurrent() { |
| 51 Protocol.Debugger.enable(); |
| 52 Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 128 }); |
| 53 Protocol.Debugger.pause(); |
| 54 Protocol.Runtime.evaluate({expression: 'asyncFact(4)//# sourceURL=expr.js'})
; |
| 55 await pausedAndDumpStack(); |
| 56 Protocol.Debugger.stepInto(); |
| 57 let message = await pausedAndDumpStack(); |
| 58 let location = message.params.callFrames[0].location; |
| 59 location.lineNumber = 11; |
| 60 Protocol.Debugger.continueToLocation({location, targetCallFrames: 'current'}
); |
| 61 await pausedAndDumpStack(); |
| 62 await Protocol.Debugger.resume(); |
| 63 Protocol.Debugger.disable(); |
| 64 }, |
| 65 |
| 66 async function testAny() { |
| 67 Protocol.Debugger.enable(); |
| 68 Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 128 }); |
| 69 Protocol.Debugger.pause(); |
| 70 Protocol.Runtime.evaluate({expression: 'fact(4)//# sourceURL=expr.js'}); |
| 71 await pausedAndDumpStack(); |
| 72 Protocol.Debugger.stepInto(); |
| 73 let message = await pausedAndDumpStack(); |
| 74 let location = message.params.callFrames[0].location; |
| 75 location.lineNumber = 18; |
| 76 Protocol.Debugger.continueToLocation({location, targetCallFrames: 'any'}); |
| 77 await pausedAndDumpStack(); |
| 78 Protocol.Debugger.disable(); |
| 79 }, |
| 80 |
| 81 async function testCurrent() { |
| 82 Protocol.Debugger.enable(); |
| 83 Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 128 }); |
| 84 Protocol.Debugger.pause(); |
| 85 Protocol.Runtime.evaluate({expression: 'fact(4)//# sourceURL=expr.js'}); |
| 86 await pausedAndDumpStack(); |
| 87 Protocol.Debugger.stepInto(); |
| 88 let message = await pausedAndDumpStack(); |
| 89 let location = message.params.callFrames[0].location; |
| 90 location.lineNumber = 18; |
| 91 Protocol.Debugger.continueToLocation({location, targetCallFrames: 'current'}
); |
| 92 await pausedAndDumpStack(); |
| 93 await Protocol.Debugger.resume(); |
| 94 Protocol.Debugger.disable(); |
| 95 }, |
| 96 |
| 97 async function testTopLevelAny() { |
| 98 Protocol.Debugger.enable(); |
| 99 Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 128 }); |
| 100 Protocol.Debugger.pause(); |
| 101 Protocol.Runtime.evaluate({expression: 'topLevel()//# sourceURL=expr.js'}); |
| 102 await pausedAndDumpStack(); |
| 103 Protocol.Debugger.stepInto(); |
| 104 await pausedAndDumpStack(); |
| 105 Protocol.Debugger.stepInto(); |
| 106 let message = await pausedAndDumpStack(); |
| 107 let location = message.params.callFrames[0].location; |
| 108 location.lineNumber = 4; |
| 109 Protocol.Debugger.continueToLocation({location, targetCallFrames: 'any'}); |
| 110 await pausedAndDumpStack(); |
| 111 Protocol.Debugger.disable(); |
| 112 }, |
| 113 |
| 114 async function testTopLevelCurrent() { |
| 115 Protocol.Debugger.enable(); |
| 116 Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 128 }); |
| 117 Protocol.Debugger.pause(); |
| 118 Protocol.Runtime.evaluate({expression: 'topLevel()//# sourceURL=expr.js'}); |
| 119 await pausedAndDumpStack(); |
| 120 Protocol.Debugger.stepInto(); |
| 121 await pausedAndDumpStack(); |
| 122 Protocol.Debugger.stepInto(); |
| 123 let message = await pausedAndDumpStack(); |
| 124 let location = message.params.callFrames[0].location; |
| 125 location.lineNumber = 4; |
| 126 Protocol.Debugger.continueToLocation({location, targetCallFrames: 'current'}
); |
| 127 await pausedAndDumpStack(); |
| 128 await Protocol.Debugger.resume(); |
| 129 Protocol.Debugger.disable(); |
| 130 } |
| 131 ]); |
| 132 |
| 133 async function pausedAndDumpStack() { |
| 134 let message = await Protocol.Debugger.oncePaused(); |
| 135 InspectorTest.logCallFrames(message.params.callFrames); |
| 136 InspectorTest.logAsyncStackTrace(message.params.asyncStackTrace); |
| 137 InspectorTest.log(''); |
| 138 return message; |
| 139 } |
OLD | NEW |