• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const { test } = require('tap');
3
4const startCLI = require('./start-cli');
5
6test('Debugger agent direct access', (t) => {
7  const cli = startCLI(['examples/three-lines.js']);
8  const scriptPattern = /^\* (\d+): examples(?:\/|\\)three-lines.js/;
9
10  function onFatal(error) {
11    cli.quit();
12    throw error;
13  }
14
15  return cli.waitForInitialBreak()
16    .then(() => cli.waitForPrompt())
17    .then(() => cli.command('scripts'))
18    .then(() => {
19      const [, scriptId] = cli.output.match(scriptPattern);
20      return cli.command(
21        `Debugger.getScriptSource({ scriptId: '${scriptId}' })`
22      );
23    })
24    .then(() => {
25      t.match(
26        cli.output,
27        /scriptSource:[ \n]*'(?:\(function \(|let x = 1)/);
28      t.match(
29        cli.output,
30        /let x = 1;/);
31    })
32    .then(() => cli.quit())
33    .then(null, onFatal);
34});
35