debugger isRunning state changes
Check isRunning state on 'break' and exception 'events'. Update isRunning state on 'connect' event with help of 'gc' command.
This commit is contained in:
Родитель
88cd8989d8
Коммит
4a8b957435
|
@ -47,7 +47,7 @@ DebuggerClient.prototype.connect = function() {
|
|||
this._conn = DebugConnection.attachDebugger(this._port);
|
||||
|
||||
this._conn.
|
||||
on('connect', this.emit.bind(this, 'connect')).
|
||||
on('connect', this._onConnectionOpen.bind(this)).
|
||||
on('error', this.emit.bind(this, 'error')).
|
||||
on('close', this._onConnectionClose.bind(this));
|
||||
|
||||
|
@ -65,6 +65,14 @@ DebuggerClient.prototype._registerDebuggerEventHandlers = function(eventNames) {
|
|||
}
|
||||
};
|
||||
|
||||
DebuggerClient.prototype._onConnectionOpen = function() {
|
||||
//We need to update isRunning state before we continue with debugging.
|
||||
//Send the dummy requestso that we can read the state from the response.
|
||||
this.request('version', {}, function(error, result) {
|
||||
this.emit('connect');
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} reason
|
||||
*/
|
||||
|
|
|
@ -45,6 +45,9 @@ exports.attachDebugger = function(port) {
|
|||
}
|
||||
else if (obj.type === 'event') {
|
||||
debugProtocol('event: ' + msg.body);
|
||||
if (['break', 'exception'].indexOf(obj.event) > -1) {
|
||||
debugr.isRunning = false;
|
||||
}
|
||||
debugr.emit(obj.event, obj);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -7,7 +7,7 @@ describe('DebuggerClient', function() {
|
|||
after(launcher.stopAllDebuggers);
|
||||
|
||||
describe('evaluteGlobal', function() {
|
||||
var client;
|
||||
var client, child;
|
||||
before(setupConnectedDebuggerClient);
|
||||
|
||||
it('returns full value of a long string', function(done) {
|
||||
|
@ -29,10 +29,45 @@ describe('DebuggerClient', function() {
|
|||
'LiveEdit.js',
|
||||
function(childProcess, debuggerClient) {
|
||||
client = debuggerClient;
|
||||
child = childProcess;
|
||||
done();
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
describe('isRunning', function() {
|
||||
var debuggerClient, childProcess;
|
||||
|
||||
before(setupDebuggerClient);
|
||||
|
||||
it('is updated on connect in --debug-brk mode', function(done) {
|
||||
expect(debuggerClient.isRunning, 'isRunning').to.be.false;
|
||||
done();
|
||||
});
|
||||
|
||||
it('is updated on break', function(done) {
|
||||
debuggerClient.on('break', function() {
|
||||
expect(debuggerClient.isRunning, 'isRunning').to.be.false;
|
||||
done();
|
||||
});
|
||||
|
||||
debuggerClient.request('continue', undefined, function() {
|
||||
childProcess.stdin.write('pause\n');
|
||||
});
|
||||
});
|
||||
|
||||
function setupDebuggerClient(done) {
|
||||
launcher.stopAllDebuggers();
|
||||
launcher.startDebugger(
|
||||
'LiveEdit.js',
|
||||
true,
|
||||
function(child, client) {
|
||||
debuggerClient = client;
|
||||
childProcess = child;
|
||||
done();
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,16 +3,23 @@ var spawn = require('child_process').spawn,
|
|||
DebuggerClient = require('../../lib/DebuggerClient').DebuggerClient,
|
||||
stopDebuggerCallbacks = [];
|
||||
|
||||
function startDebugger(scriptPath, done) {
|
||||
function startDebugger(scriptPath, breakOnStart, done) {
|
||||
if (done === undefined) {
|
||||
done = breakOnStart;
|
||||
breakOnStart = false;
|
||||
}
|
||||
|
||||
var testDir = path.dirname(__filename),
|
||||
debugPort = 61000,
|
||||
debugOption,
|
||||
child,
|
||||
debuggerClient,
|
||||
ignoreErrors = false;
|
||||
|
||||
debugOption = '--debug' + (breakOnStart ? '-brk=' : '=');
|
||||
if (scriptPath.indexOf(path.sep) == -1)
|
||||
scriptPath = path.join(testDir, '..', 'fixtures', scriptPath);
|
||||
child = spawn('node', ['--debug=' + debugPort, scriptPath]);
|
||||
child = spawn('node', [debugOption + debugPort, scriptPath]);
|
||||
|
||||
child.stderr.on('data', function(data) { process.stderr.write(data); });
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче