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('Checks Debugger.scheduleStepIntoAsync.'); |
| 6 |
| 7 InspectorTest.addScript(` |
| 8 function testNoScheduledTask() { |
| 9 debugger; |
| 10 return 42; |
| 11 } |
| 12 |
| 13 function testSimple() { |
| 14 debugger; |
| 15 Promise.resolve().then(v => v * 2); |
| 16 } |
| 17 |
| 18 function testNotResolvedPromise() { |
| 19 var resolveCallback; |
| 20 var p = new Promise(resolve => resolveCallback = resolve); |
| 21 debugger; |
| 22 p.then(v => v * 2); |
| 23 resolveCallback(); |
| 24 } |
| 25 |
| 26 function testTwoAsyncTasks() { |
| 27 debugger; |
| 28 Promise.resolve().then(v => v * 2); |
| 29 Promise.resolve().then(v => v * 4); |
| 30 } |
| 31 |
| 32 function testTwoAsyncTasksWithBreak() { |
| 33 debugger; |
| 34 Promise.resolve().then(v => v * 2); |
| 35 debugger; |
| 36 Promise.resolve().then(v => v * 4); |
| 37 } |
| 38 |
| 39 function testPromiseAll() { |
| 40 debugger; |
| 41 Promise.all([ Promise.resolve(), Promise.resolve() ]).then(v => v * 2); |
| 42 } |
| 43 |
| 44 function testBlackboxedCreatePromise() { |
| 45 debugger; |
| 46 createPromise().then(v => v * 2); |
| 47 } |
| 48 //# sourceURL=test.js`); |
| 49 |
| 50 InspectorTest.addScript(` |
| 51 |
| 52 function createPromise() { |
| 53 return Promise.resolve().then(v => v * 3).then(v => v * 4); |
| 54 } |
| 55 |
| 56 //# sourceURL=framework.js`) |
| 57 |
| 58 InspectorTest.setupScriptMap(); |
| 59 |
| 60 Protocol.Debugger.enable(); |
| 61 InspectorTest.runAsyncTestSuite([ |
| 62 async function testScheduleErrors() { |
| 63 Protocol.Runtime.evaluate({ expression: 'testNoScheduledTask()' }); |
| 64 await waitPauseAndDumpLocation(); |
| 65 Protocol.Debugger.scheduleStepIntoAsync().then(InspectorTest.logMessage); |
| 66 Protocol.Debugger.scheduleStepIntoAsync().then(InspectorTest.logMessage); |
| 67 Protocol.Debugger.stepInto(); |
| 68 await waitPauseAndDumpLocation(); |
| 69 await Protocol.Debugger.resume(); |
| 70 }, |
| 71 |
| 72 async function testSimple() { |
| 73 Protocol.Runtime.evaluate({ expression: 'testSimple()' }); |
| 74 await waitPauseAndDumpLocation(); |
| 75 Protocol.Debugger.stepOver(); |
| 76 await waitPauseAndDumpLocation(); |
| 77 Protocol.Debugger.scheduleStepIntoAsync().then(InspectorTest.logMessage); |
| 78 Protocol.Debugger.stepInto(); |
| 79 await waitPauseAndDumpLocation(); |
| 80 await Protocol.Debugger.resume(); |
| 81 }, |
| 82 |
| 83 async function testNotResolvedPromise() { |
| 84 Protocol.Runtime.evaluate({ expression: 'testNotResolvedPromise()' }); |
| 85 await waitPauseAndDumpLocation(); |
| 86 Protocol.Debugger.stepOver(); |
| 87 await waitPauseAndDumpLocation(); |
| 88 Protocol.Debugger.scheduleStepIntoAsync().then(InspectorTest.logMessage); |
| 89 Protocol.Debugger.stepInto(); |
| 90 await waitPauseAndDumpLocation(); |
| 91 await Protocol.Debugger.resume(); |
| 92 }, |
| 93 |
| 94 async function testTwoAsyncTasks() { |
| 95 Protocol.Runtime.evaluate({ expression: 'testTwoAsyncTasks()' }); |
| 96 await waitPauseAndDumpLocation(); |
| 97 Protocol.Debugger.scheduleStepIntoAsync().then(InspectorTest.logMessage); |
| 98 Protocol.Debugger.resume(); |
| 99 await waitPauseAndDumpLocation(); |
| 100 await Protocol.Debugger.resume(); |
| 101 }, |
| 102 |
| 103 async function testTwoTasksAndGoToSecond() { |
| 104 Protocol.Runtime.evaluate({ expression: 'testTwoAsyncTasks()' }); |
| 105 await waitPauseAndDumpLocation(); |
| 106 Protocol.Debugger.stepOver(); |
| 107 await waitPauseAndDumpLocation(); |
| 108 Protocol.Debugger.stepOver(); |
| 109 await waitPauseAndDumpLocation(); |
| 110 Protocol.Debugger.scheduleStepIntoAsync().then(InspectorTest.logMessage); |
| 111 Protocol.Debugger.resume(); |
| 112 await waitPauseAndDumpLocation(); |
| 113 await Protocol.Debugger.resume(); |
| 114 }, |
| 115 |
| 116 async function testTwoAsyncTasksWithBreak() { |
| 117 Protocol.Runtime.evaluate({ expression: 'testTwoAsyncTasksWithBreak()' }); |
| 118 await waitPauseAndDumpLocation(); |
| 119 Protocol.Debugger.stepOver(); |
| 120 await waitPauseAndDumpLocation(); |
| 121 Protocol.Debugger.scheduleStepIntoAsync().then(InspectorTest.logMessage); |
| 122 Protocol.Debugger.resume(); |
| 123 await waitPauseAndDumpLocation(); |
| 124 Protocol.Debugger.scheduleStepIntoAsync().then(InspectorTest.logMessage); |
| 125 Protocol.Debugger.resume(); |
| 126 await waitPauseAndDumpLocation(); |
| 127 await Protocol.Debugger.resume(); |
| 128 }, |
| 129 |
| 130 async function testPromiseAll() { |
| 131 Protocol.Runtime.evaluate({ expression: 'testPromiseAll()' }); |
| 132 await waitPauseAndDumpLocation(); |
| 133 Protocol.Debugger.stepOver(); |
| 134 await waitPauseAndDumpLocation(); |
| 135 Protocol.Debugger.scheduleStepIntoAsync().then(InspectorTest.logMessage); |
| 136 Protocol.Debugger.stepOver(); |
| 137 await waitPauseAndDumpLocation(); |
| 138 await Protocol.Debugger.resume(); |
| 139 }, |
| 140 |
| 141 async function testWithBlackboxedCode() { |
| 142 Protocol.Runtime.evaluate({ expression: 'testBlackboxedCreatePromise()' }); |
| 143 await waitPauseAndDumpLocation(); |
| 144 Protocol.Debugger.stepOver(); |
| 145 await waitPauseAndDumpLocation(); |
| 146 await Protocol.Debugger.setBlackboxPatterns({patterns: ['framework\.js'] }); |
| 147 Protocol.Debugger.scheduleStepIntoAsync().then(InspectorTest.logMessage); |
| 148 Protocol.Debugger.stepOver(); |
| 149 await waitPauseAndDumpLocation(); |
| 150 await Protocol.Debugger.resume(); |
| 151 } |
| 152 ]); |
| 153 |
| 154 async function waitPauseAndDumpLocation() { |
| 155 var message = await Protocol.Debugger.oncePaused(); |
| 156 InspectorTest.log('paused at:'); |
| 157 InspectorTest.logSourceLocation(message.params.callFrames[0].location); |
| 158 return message; |
| 159 } |
OLD | NEW |