(session, post)
| 127 | } |
| 128 | |
| 129 | async function testBasicWorkerDebug(session, post) { |
| 130 | // 1. Do 'enable' with waitForDebuggerOnStart = true |
| 131 | // 2. Run worker. It should break on start. |
| 132 | // 3. Enable Runtime (to get console message) and Debugger. Resume. |
| 133 | // 4. Breaks on the 'debugger' statement. Resume. |
| 134 | // 5. Console message received, worker runs to a completion. |
| 135 | // 6. contextCreated/contextDestroyed had been properly dispatched |
| 136 | console.log('Test basic debug scenario'); |
| 137 | await post('NodeWorker.enable', { waitForDebuggerOnStart: true }); |
| 138 | const attached = waitForWorkerAttach(session); |
| 139 | const worker = runWorker(1); |
| 140 | const { sessionId, waitingForDebugger } = await attached; |
| 141 | assert.strictEqual(waitingForDebugger, true); |
| 142 | const detached = waitForWorkerDetach(session, sessionId); |
| 143 | const workerSession = new WorkerSession(session, sessionId); |
| 144 | const contextEventPromises = Promise.all([ |
| 145 | waitForEvent(workerSession, 'Runtime.executionContextCreated'), |
| 146 | waitForEvent(workerSession, 'Runtime.executionContextDestroyed'), |
| 147 | ]); |
| 148 | const consolePromise = waitForEvent(workerSession, 'Runtime.consoleAPICalled') |
| 149 | .then((notification) => notification.params.args[0].value); |
| 150 | await workerSession.post('Debugger.enable'); |
| 151 | await workerSession.post('Runtime.enable'); |
| 152 | await workerSession.waitForBreakAfterCommand( |
| 153 | 'Runtime.runIfWaitingForDebugger', __filename, 1); |
| 154 | await workerSession.waitForBreakAfterCommand( |
| 155 | 'Debugger.resume', __filename, 25); // V8 line number is zero-based |
| 156 | const msg = await consolePromise; |
| 157 | assert.strictEqual(msg, workerMessage); |
| 158 | workerSession.post('Debugger.resume'); |
| 159 | await Promise.all([worker, detached, contextEventPromises]); |
| 160 | } |
| 161 | |
| 162 | async function testNoWaitOnStart(session, post) { |
| 163 | console.log('Test disabled waitForDebuggerOnStart'); |
no test coverage detected
searching dependent graphs…