• 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');
10
11const cli = startCLI(['--port=0', fixtures.path('debugger/alive.js')]);
12
13async function waitInitialBreak() {
14  try {
15    await cli.waitForInitialBreak();
16    await cli.waitForPrompt();
17    await cli.command('exec [typeof heartbeat, typeof process.exit]');
18    assert.match(cli.output, /\[ 'function', 'function' \]/, 'works w/o paren');
19
20    await cli.command('p [typeof heartbeat, typeof process.exit]');
21    assert.match(
22      cli.output,
23      /\[ 'function', 'function' \]/,
24      'works w/o paren, short'
25    );
26
27    await cli.command('repl');
28    assert.match(
29      cli.output,
30      /Press Ctrl\+C to leave debug repl\n+> /,
31      'shows hint for how to leave repl'
32    );
33    assert.doesNotMatch(cli.output, /debug>/, 'changes the repl style');
34
35    await cli.command('[typeof heartbeat, typeof process.exit]');
36    await cli.waitFor(/function/);
37    await cli.waitForPrompt();
38    assert.match(
39      cli.output,
40      /\[ 'function', 'function' \]/,
41      'can evaluate in the repl'
42    );
43    assert.match(cli.output, /> $/);
44
45    await cli.ctrlC();
46    await cli.waitFor(/debug> $/);
47    await cli.command('exec("[typeof heartbeat, typeof process.exit]")');
48    assert.match(cli.output, /\[ 'function', 'function' \]/, 'works w/ paren');
49    await cli.command('p("[typeof heartbeat, typeof process.exit]")');
50    assert.match(
51      cli.output,
52      /\[ 'function', 'function' \]/,
53      'works w/ paren, short'
54    );
55
56    await cli.command('cont');
57    await cli.command('exec [typeof heartbeat, typeof process.exit]');
58    assert.match(
59      cli.output,
60      /\[ 'undefined', 'function' \]/,
61      'non-paused exec can see global but not module-scope values'
62    );
63  } finally {
64    await cli.quit();
65  }
66}
67
68waitInitialBreak();
69