• 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');
8const assert = require('assert');
9
10// Debugger agent direct access.
11{
12  const cli = startCLI([fixtures.path('debugger/three-lines.js')]);
13  const scriptPattern = /^\* (\d+): \S+debugger(?:\/|\\)three-lines\.js/m;
14
15  function onFatal(error) {
16    cli.quit();
17    throw error;
18  }
19
20  return cli.waitForInitialBreak()
21    .then(() => cli.waitForPrompt())
22    .then(() => cli.command('scripts'))
23    .then(() => {
24      const [, scriptId] = cli.output.match(scriptPattern);
25      return cli.command(
26        `Debugger.getScriptSource({ scriptId: '${scriptId}' })`
27      );
28    })
29    .then(() => {
30      assert.match(
31        cli.output,
32        /scriptSource:[ \n]*'(?:\(function \(|let x = 1)/);
33      assert.match(
34        cli.output,
35        /let x = 1;/);
36    })
37    .then(() => cli.quit())
38    .then(null, onFatal);
39}
40