Browse Source

debugger: Fix some parser issues

Wouldn't handle events if it got backed up.
v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
294bcb33e6
  1. 1
      lib/_debugger.js
  2. 49
      test/simple/test-debugger-client.js

1
lib/_debugger.js

@ -43,6 +43,7 @@ Protocol.prototype._newRes = function(raw) {
this.res = { raw: raw || '', headers: {} };
this.state = 'headers';
this.reqSeq = 1;
this.execute('');
};

49
test/simple/test-debugger-client.js

@ -18,6 +18,55 @@ p.execute("Type: connect\r\n" +
"Content-Length: 0\r\n\r\n");
assert.equal(1, resCount);
// Make sure split messages go in.
var parts = [];
parts.push('Content-Length: 336\r\n');
assert.equal(21, parts[0].length);
parts.push('\r\n');
assert.equal(2, parts[1].length);
var bodyLength = 0;
parts.push('{"seq":12,"type":"event","event":"break","body":' +
'{"invocationText":"#<a Server>');
assert.equal(78, parts[2].length);
bodyLength += parts[2].length;
parts.push('.[anonymous](req=#<an IncomingMessage>, res=#<a ServerResponse>)",' +
'"sourceLine"');
assert.equal(78, parts[3].length);
bodyLength += parts[3].length;
parts.push(':45,"sourceColumn":4,"sourceLineText":" debugger;","script":' +
'{"id":24,"name":"/home/ryan/projects/node/benchmark/http_simple.js",' +
'"lineOffset":0,"columnOffset":0,"lineCount":98}}}');
assert.equal(180, parts[4].length);
bodyLength += parts[4].length;
assert.equal(336, bodyLength);
for (var i = 0; i < parts.length; i++) {
p.execute(parts[i]);
}
assert.equal(2, resCount);
// Make sure that if we get backed up, we still manage to get all the
// messages
var d = 'Content-Length: 466\r\n\r\n' +
'{"seq":10,"type":"event","event":"afterCompile","success":true,' +
'"body":{"script":{"handle":1,"type":"script","name":"dns.js",' +
'"id":34,"lineOffset":0,"columnOffset":0,"lineCount":241,"sourceStart":' +
'"(function (module, exports, require) {var dns = process.binding(\'cares\')' +
';\\nvar ne","sourceLength":6137,"scriptType":2,"compilationType":0,' +
'"context":{"ref":0},"text":"dns.js (lines: 241)"}},"refs":[{"handle":0' +
',"type":"context","text":"#<a ContextMirror>"}],"running":true}' +
'Content-Length: 119\r\n\r\n' +
'{"seq":11,"type":"event","event":"scriptCollected","success":true,' +
'"body":{"script":{"id":26}},"refs":[],"running":true}';
p.execute(d);
assert.equal(4, resCount);
var expectedConnections = 0;
var tests = [];
function addTest (cb) {

Loading…
Cancel
Save