2016-12-12 06:36:58 +08:00
|
|
|
'use strict';
|
|
|
|
const { test } = require('tap');
|
|
|
|
|
|
|
|
const startCLI = require('./start-cli');
|
|
|
|
|
|
|
|
test('Debugger agent direct access', (t) => {
|
2017-04-05 00:47:43 +08:00
|
|
|
const cli = startCLI(['examples/three-lines.js']);
|
|
|
|
const scriptPattern = /^\* (\d+): examples(?:\/|\\)three-lines.js/;
|
2016-12-12 06:36:58 +08:00
|
|
|
|
|
|
|
function onFatal(error) {
|
|
|
|
cli.quit();
|
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
|
2017-04-05 00:47:43 +08:00
|
|
|
return cli.waitForInitialBreak()
|
2016-12-12 06: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(() => {
|
|
|
|
t.match(
|
|
|
|
cli.output,
|
2017-04-05 00:47:43 +08:00
|
|
|
/scriptSource: '\(function \(/);
|
|
|
|
t.match(
|
|
|
|
cli.output,
|
|
|
|
/let x = 1;/);
|
2016-12-12 06:36:58 +08:00
|
|
|
})
|
|
|
|
.then(() => cli.quit())
|
|
|
|
.then(null, onFatal);
|
|
|
|
});
|