|
| 1 | +'use strict'; |
| 2 | +const common = require('../common'); |
| 3 | +common.skipIfInspectorDisabled(); |
| 4 | +const assert = require('assert'); |
| 5 | +const helper = require('./inspector-helper.js'); |
| 6 | + |
| 7 | +function setupExpectBreakOnLine(line, url, session, scopeIdCallback) { |
| 8 | + return function(message) { |
| 9 | + if ('Debugger.paused' === message['method']) { |
| 10 | + const callFrame = message['params']['callFrames'][0]; |
| 11 | + const location = callFrame['location']; |
| 12 | + assert.strictEqual(url, session.scriptUrlForId(location['scriptId'])); |
| 13 | + assert.strictEqual(line, location['lineNumber']); |
| 14 | + scopeIdCallback && |
| 15 | + scopeIdCallback(callFrame['scopeChain'][0]['object']['objectId']); |
| 16 | + return true; |
| 17 | + } |
| 18 | + }; |
| 19 | +} |
| 20 | + |
| 21 | +function testBreakpointOnStart(session) { |
| 22 | + const commands = [ |
| 23 | + { 'method': 'Runtime.enable' }, |
| 24 | + { 'method': 'Debugger.enable' }, |
| 25 | + { 'method': 'Debugger.setPauseOnExceptions', |
| 26 | + 'params': {'state': 'none'} }, |
| 27 | + { 'method': 'Debugger.setAsyncCallStackDepth', |
| 28 | + 'params': {'maxDepth': 0} }, |
| 29 | + { 'method': 'Profiler.enable' }, |
| 30 | + { 'method': 'Profiler.setSamplingInterval', |
| 31 | + 'params': {'interval': 100} }, |
| 32 | + { 'method': 'Debugger.setBlackboxPatterns', |
| 33 | + 'params': {'patterns': []} }, |
| 34 | + { 'method': 'Runtime.runIfWaitingForDebugger' } |
| 35 | + ]; |
| 36 | + |
| 37 | + session |
| 38 | + .sendInspectorCommands(commands) |
| 39 | + .expectMessages(setupExpectBreakOnLine(0, session.mainScriptPath, session)); |
| 40 | +} |
| 41 | + |
| 42 | +function testWaitsForFrontendDisconnect(session, harness) { |
| 43 | + console.log('[test]', 'Verify node waits for the frontend to disconnect'); |
| 44 | + session.sendInspectorCommands({ 'method': 'Debugger.resume'}) |
| 45 | + .expectStderrOutput('Waiting for the debugger to disconnect...') |
| 46 | + .disconnect(true); |
| 47 | +} |
| 48 | + |
| 49 | +function runTests(harness) { |
| 50 | + harness |
| 51 | + .runFrontendSession([ |
| 52 | + testBreakpointOnStart, |
| 53 | + testWaitsForFrontendDisconnect |
| 54 | + ]).expectShutDown(55); |
| 55 | +} |
| 56 | + |
| 57 | +helper.startNodeForInspectorTest(runTests, ['--inspect', '--debug-brk']); |
0 commit comments