• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3
4common.skipIfInspectorDisabled();
5
6const fixtures = require('../common/fixtures');
7const startCLI = require('../common/debugger');
8
9const assert = require('assert');
10const path = require('path');
11
12// clearBreakpoint
13{
14  const scriptFullPath = fixtures.path('debugger', 'break.js');
15  const script = path.relative(process.cwd(), scriptFullPath);
16  const cli = startCLI([script]);
17
18  function onFatal(error) {
19    cli.quit();
20    throw error;
21  }
22
23  return cli.waitForInitialBreak()
24    .then(() => cli.waitForPrompt())
25    .then(() => cli.command('sb("break.js", 3)'))
26    .then(() => cli.command('sb("break.js", 9)'))
27    .then(() => cli.command('breakpoints'))
28    .then(() => {
29      assert.ok(cli.output.includes(`#0 ${script}:3`));
30      assert.ok(cli.output.includes(`#1 ${script}:9`));
31    })
32    .then(() => cli.command('clearBreakpoint("break.js", 4)'))
33    .then(() => {
34      assert.match(cli.output, /Could not find breakpoint/);
35    })
36    .then(() => cli.command('clearBreakpoint("not-such-script.js", 3)'))
37    .then(() => {
38      assert.match(cli.output, /Could not find breakpoint/);
39    })
40    .then(() => cli.command('clearBreakpoint("break.js", 3)'))
41    .then(() => cli.command('breakpoints'))
42    .then(() => {
43      assert.ok(cli.output.includes(`#0 ${script}:9`));
44    })
45    .then(() => cli.stepCommand('cont'))
46    .then(() => {
47      assert.ok(
48        cli.output.includes(`break in ${script}:9`),
49        'hits the 2nd breakpoint because the 1st was cleared');
50    })
51    .then(() => cli.quit())
52    .then(null, onFatal);
53}
54