• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3const fixtures = require('../common/fixtures');
4
5common.skipIfInspectorDisabled();
6
7const assert = require('assert');
8const { NodeInstance } = require('../common/inspector-helper.js');
9const { pathToFileURL } = require('url');
10
11const script = fixtures.path('throws_error.js');
12
13async function testBreakpointOnStart(session) {
14  console.log('[test]',
15              'Verifying debugger stops on start (--inspect-brk option)');
16  const commands = [
17    { 'method': 'Runtime.enable' },
18    { 'method': 'Debugger.enable' },
19    { 'method': 'Debugger.setPauseOnExceptions',
20      'params': { 'state': 'none' } },
21    { 'method': 'Debugger.setAsyncCallStackDepth',
22      'params': { 'maxDepth': 0 } },
23    { 'method': 'Profiler.enable' },
24    { 'method': 'Profiler.setSamplingInterval',
25      'params': { 'interval': 100 } },
26    { 'method': 'Debugger.setBlackboxPatterns',
27      'params': { 'patterns': [] } },
28    { 'method': 'Runtime.runIfWaitingForDebugger' },
29  ];
30
31  await session.send(commands);
32  await session.waitForBreakOnLine(21, pathToFileURL(script).toString());
33}
34
35
36async function runTest() {
37  const child = new NodeInstance(undefined, undefined, script);
38  const session = await child.connectInspectorSession();
39  await testBreakpointOnStart(session);
40  await session.runToCompletion();
41  assert.strictEqual((await child.expectShutdown()).exitCode, 1);
42}
43
44runTest().then(common.mustCall());
45