diff --git a/test/debugger/test-debugger-client.js b/test/debugger/test-debugger-client.js
index 04823113ec32c1..743a3c4352e2e1 100644
--- a/test/debugger/test-debugger-client.js
+++ b/test/debugger/test-debugger-client.js
@@ -1,12 +1,12 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var debug = require('_debugger');
+const assert = require('assert');
+const debug = require('_debugger');
process.env.NODE_DEBUGGER_TIMEOUT = 2000;
-var debugPort = common.PORT;
+const debugPort = common.PORT;
debug.port = debugPort;
-var spawn = require('child_process').spawn;
+const spawn = require('child_process').spawn;
setTimeout(function() {
if (nodeProcess) nodeProcess.kill('SIGTERM');
@@ -14,8 +14,8 @@ setTimeout(function() {
}, 10000).unref();
-var resCount = 0;
-var p = new debug.Protocol();
+let resCount = 0;
+const p = new debug.Protocol();
p.onResponse = function(res) {
resCount++;
};
@@ -29,12 +29,12 @@ assert.strictEqual(resCount, 1);
// Make sure split messages go in.
-var parts = [];
+const parts = [];
parts.push('Content-Length: 336\r\n');
assert.strictEqual(parts[0].length, 21);
parts.push('\r\n');
assert.strictEqual(parts[1].length, 2);
-var bodyLength = 0;
+let bodyLength = 0;
parts.push('{"seq":12,"type":"event","event":"break","body":' +
'{"invocationText":"#');
@@ -55,7 +55,7 @@ bodyLength += parts[4].length;
assert.strictEqual(bodyLength, 336);
-for (var i = 0; i < parts.length; i++) {
+for (let i = 0; i < parts.length; i++) {
p.execute(parts[i]);
}
assert.strictEqual(resCount, 2);
@@ -63,24 +63,24 @@ assert.strictEqual(resCount, 2);
// 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":"#"}],"running":true}' +
- '\r\n\r\nContent-Length: 119\r\n\r\n' +
- '{"seq":11,"type":"event","event":"scriptCollected","success":true,' +
- '"body":{"script":{"id":26}},"refs":[],"running":true}';
+const 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":"#"}],"running":true}' +
+ '\r\n\r\nContent-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.strictEqual(resCount, 4);
-var expectedConnections = 0;
-var tests = [];
+let expectedConnections = 0;
+const tests = [];
function addTest(cb) {
expectedConnections++;
tests.push(cb);
@@ -102,9 +102,9 @@ addTest(function(client, done) {
assert.ok(!err);
console.error('got %d scripts', Object.keys(client.scripts).length);
- var foundMainScript = false;
- for (var k in client.scripts) {
- var script = client.scripts[k];
+ let foundMainScript = false;
+ for (const k in client.scripts) {
+ const script = client.scripts[k];
if (script && script.name === 'node.js') {
foundMainScript = true;
break;
@@ -127,19 +127,19 @@ addTest(function(client, done) {
});
-var connectCount = 0;
-var script = 'setTimeout(function() { console.log("blah"); });' +
- 'setInterval(function() {}, 1000000);';
+let connectCount = 0;
+const script = 'setTimeout(function() { console.log("blah"); });' +
+ 'setInterval(function() {}, 1000000);';
-var nodeProcess;
+let nodeProcess;
function doTest(cb, done) {
- var args = ['--debug=' + debugPort, '-e', script];
+ const args = ['--debug=' + debugPort, '-e', script];
nodeProcess = spawn(process.execPath, args);
nodeProcess.stdout.once('data', function(c) {
console.log('>>> new node process: %d', nodeProcess.pid);
- var failed = true;
+ let failed = true;
try {
process._debugProcess(nodeProcess.pid);
failed = false;
@@ -151,9 +151,9 @@ function doTest(cb, done) {
console.log('>>> starting debugger session');
});
- var didTryConnect = false;
+ let didTryConnect = false;
nodeProcess.stderr.setEncoding('utf8');
- var b = '';
+ let b = '';
nodeProcess.stderr.on('data', function(data) {
console.error('got stderr data %j', data);
nodeProcess.stderr.resume();