|
| 1 | +'use strict'; |
| 2 | +const common = require('../common'); |
| 3 | + |
| 4 | +// Test that --inspect-brk pauses at the first line of an ESM entry point. |
| 5 | + |
| 6 | +common.skipIfInspectorDisabled(); |
| 7 | + |
| 8 | +const assert = require('assert'); |
| 9 | +const fixtures = require('../common/fixtures'); |
| 10 | +const { NodeInstance } = require('../common/inspector-helper.js'); |
| 11 | + |
| 12 | +async function testBreakpointOnStart(session) { |
| 13 | + const commands = [ |
| 14 | + { 'method': 'Runtime.enable' }, |
| 15 | + { 'method': 'Debugger.enable' }, |
| 16 | + { 'method': 'Debugger.setPauseOnExceptions', |
| 17 | + 'params': { 'state': 'none' } }, |
| 18 | + { 'method': 'Debugger.setAsyncCallStackDepth', |
| 19 | + 'params': { 'maxDepth': 0 } }, |
| 20 | + { 'method': 'Profiler.enable' }, |
| 21 | + { 'method': 'Profiler.setSamplingInterval', |
| 22 | + 'params': { 'interval': 100 } }, |
| 23 | + { 'method': 'Debugger.setBlackboxPatterns', |
| 24 | + 'params': { 'patterns': [] } }, |
| 25 | + { 'method': 'Runtime.runIfWaitingForDebugger' }, |
| 26 | + ]; |
| 27 | + |
| 28 | + await session.send({ method: 'NodeRuntime.enable' }); |
| 29 | + await session.waitForNotification('NodeRuntime.waitingForDebugger'); |
| 30 | + await session.send(commands); |
| 31 | + await session.send({ method: 'NodeRuntime.disable' }); |
| 32 | + await session.waitForBreakOnLine(0, session.scriptURL()); |
| 33 | +} |
| 34 | + |
| 35 | +async function runTests() { |
| 36 | + const child = new NodeInstance(['--inspect-brk=0'], '', fixtures.path('es-modules', 'loop.mjs')); |
| 37 | + const session = await child.connectInspectorSession(); |
| 38 | + |
| 39 | + await testBreakpointOnStart(session); |
| 40 | + await session.runToCompletion(); |
| 41 | + |
| 42 | + assert.strictEqual((await child.expectShutdown()).exitCode, 55); |
| 43 | +} |
| 44 | + |
| 45 | +runTests().then(common.mustCall()); |
0 commit comments