2016-12-11 14:36:58 -08:00
|
|
|
'use strict';
|
2021-04-08 23:55:45 -07:00
|
|
|
const common = require('../common');
|
2016-12-11 14:36:58 -08:00
|
|
|
|
2021-04-08 23:55:45 -07:00
|
|
|
common.skipIfInspectorDisabled();
|
2016-12-11 14:36:58 -08:00
|
|
|
|
2021-04-08 23:55:45 -07:00
|
|
|
const fixtures = require('../common/fixtures');
|
2021-05-03 21:58:42 -07:00
|
|
|
const startCLI = require('../common/debugger');
|
2021-04-08 23:55:45 -07:00
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
// Debugger agent direct access.
|
|
|
|
{
|
|
|
|
const cli = startCLI([fixtures.path('inspector-cli/three-lines.js')]);
|
|
|
|
const scriptPattern = /^\* (\d+): \S+inspector-cli(?:\/|\\)three-lines\.js/m;
|
2016-12-11 14:36:58 -08:00
|
|
|
|
|
|
|
function onFatal(error) {
|
|
|
|
cli.quit();
|
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
|
2017-04-04 09:47:43 -07:00
|
|
|
return cli.waitForInitialBreak()
|
2016-12-11 14:36:58 -08:00
|
|
|
.then(() => cli.waitForPrompt())
|
|
|
|
.then(() => cli.command('scripts'))
|
|
|
|
.then(() => {
|
|
|
|
const [, scriptId] = cli.output.match(scriptPattern);
|
|
|
|
return cli.command(
|
|
|
|
`Debugger.getScriptSource({ scriptId: '${scriptId}' })`
|
|
|
|
);
|
|
|
|
})
|
|
|
|
.then(() => {
|
2021-04-08 23:55:45 -07:00
|
|
|
assert.match(
|
2016-12-11 14:36:58 -08:00
|
|
|
cli.output,
|
2019-06-03 10:05:10 +02:00
|
|
|
/scriptSource:[ \n]*'(?:\(function \(|let x = 1)/);
|
2021-04-08 23:55:45 -07:00
|
|
|
assert.match(
|
2017-04-04 09:47:43 -07:00
|
|
|
cli.output,
|
|
|
|
/let x = 1;/);
|
2016-12-11 14:36:58 -08:00
|
|
|
})
|
|
|
|
.then(() => cli.quit())
|
|
|
|
.then(null, onFatal);
|
2021-04-08 23:55:45 -07:00
|
|
|
}
|