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