1
1
'use strict' ;
2
2
const common = require ( '../common' ) ;
3
- var assert = require ( 'assert' ) ;
4
- var debug = require ( '_debugger' ) ;
3
+ const assert = require ( 'assert' ) ;
4
+ const debug = require ( '_debugger' ) ;
5
5
6
6
process . env . NODE_DEBUGGER_TIMEOUT = 2000 ;
7
- var debugPort = common . PORT ;
7
+ const debugPort = common . PORT ;
8
8
debug . port = debugPort ;
9
- var spawn = require ( 'child_process' ) . spawn ;
9
+ const spawn = require ( 'child_process' ) . spawn ;
10
10
11
11
setTimeout ( function ( ) {
12
12
if ( nodeProcess ) nodeProcess . kill ( 'SIGTERM' ) ;
13
13
throw new Error ( 'timeout' ) ;
14
14
} , 10000 ) . unref ( ) ;
15
15
16
16
17
- var resCount = 0 ;
18
- var p = new debug . Protocol ( ) ;
17
+ let resCount = 0 ;
18
+ const p = new debug . Protocol ( ) ;
19
19
p . onResponse = function ( res ) {
20
20
resCount ++ ;
21
21
} ;
@@ -29,12 +29,12 @@ assert.strictEqual(resCount, 1);
29
29
30
30
// Make sure split messages go in.
31
31
32
- var parts = [ ] ;
32
+ const parts = [ ] ;
33
33
parts . push ( 'Content-Length: 336\r\n' ) ;
34
34
assert . strictEqual ( parts [ 0 ] . length , 21 ) ;
35
35
parts . push ( '\r\n' ) ;
36
36
assert . strictEqual ( parts [ 1 ] . length , 2 ) ;
37
- var bodyLength = 0 ;
37
+ let bodyLength = 0 ;
38
38
39
39
parts . push ( '{"seq":12,"type":"event","event":"break","body":' +
40
40
'{"invocationText":"#<a Server>' ) ;
@@ -55,32 +55,32 @@ bodyLength += parts[4].length;
55
55
56
56
assert . strictEqual ( bodyLength , 336 ) ;
57
57
58
- for ( var i = 0 ; i < parts . length ; i ++ ) {
58
+ for ( let i = 0 ; i < parts . length ; i ++ ) {
59
59
p . execute ( parts [ i ] ) ;
60
60
}
61
61
assert . strictEqual ( resCount , 2 ) ;
62
62
63
63
64
64
// Make sure that if we get backed up, we still manage to get all the
65
65
// messages
66
- var d = 'Content-Length: 466\r\n\r\n' +
67
- '{"seq":10,"type":"event","event":"afterCompile","success":true,' +
68
- '"body":{"script":{"handle":1,"type":"script","name":"dns.js",' +
69
- '"id":34,"lineOffset":0,"columnOffset":0,"lineCount":241,' +
70
- '"sourceStart":"(function(module, exports, require) {' +
71
- 'var dns = process.binding(\'cares\')' +
72
- ';\\nvar ne","sourceLength":6137,"scriptType":2,"compilationType":0, ' +
73
- ' "context":{"ref":0},"text":"dns.js (lines: 241)"}},"refs":' +
74
- '[{"handle":0' +
75
- ',"type":"context","text":"#<a ContextMirror>"}],"running":true}' +
76
- '\r\n\r\nContent-Length: 119\r\n\r\n' +
77
- '{"seq":11,"type":"event","event":"scriptCollected","success":true, ' +
78
- ' "body":{"script":{"id":26}},"refs":[],"running":true}';
66
+ const d = 'Content-Length: 466\r\n\r\n' +
67
+ '{"seq":10,"type":"event","event":"afterCompile","success":true,' +
68
+ '"body":{"script":{"handle":1,"type":"script","name":"dns.js",' +
69
+ '"id":34,"lineOffset":0,"columnOffset":0,"lineCount":241,' +
70
+ '"sourceStart":"(function(module, exports, require) {' +
71
+ 'var dns = process.binding(\'cares\')' +
72
+ ';\\nvar ne","sourceLength":6137,"scriptType":2,"compilationType"' +
73
+ ':0, "context":{"ref":0},"text":"dns.js (lines: 241)"}},"refs":' +
74
+ '[{"handle":0' +
75
+ ',"type":"context","text":"#<a ContextMirror>"}],"running":true}' +
76
+ '\r\n\r\nContent-Length: 119\r\n\r\n' +
77
+ '{"seq":11,"type":"event","event":"scriptCollected","success":true' +
78
+ ', "body":{"script":{"id":26}},"refs":[],"running":true}';
79
79
p . execute ( d ) ;
80
80
assert . strictEqual ( resCount , 4 ) ;
81
81
82
- var expectedConnections = 0 ;
83
- var tests = [ ] ;
82
+ let expectedConnections = 0 ;
83
+ const tests = [ ] ;
84
84
function addTest ( cb ) {
85
85
expectedConnections ++ ;
86
86
tests . push ( cb ) ;
@@ -102,9 +102,9 @@ addTest(function(client, done) {
102
102
assert . ok ( ! err ) ;
103
103
console . error ( 'got %d scripts' , Object . keys ( client . scripts ) . length ) ;
104
104
105
- var foundMainScript = false ;
106
- for ( var k in client . scripts ) {
107
- var script = client . scripts [ k ] ;
105
+ let foundMainScript = false ;
106
+ for ( const k in client . scripts ) {
107
+ const script = client . scripts [ k ] ;
108
108
if ( script && script . name === 'node.js' ) {
109
109
foundMainScript = true ;
110
110
break ;
@@ -127,19 +127,19 @@ addTest(function(client, done) {
127
127
} ) ;
128
128
129
129
130
- var connectCount = 0 ;
131
- var script = 'setTimeout(function() { console.log("blah"); });' +
132
- 'setInterval(function() {}, 1000000);' ;
130
+ let connectCount = 0 ;
131
+ const script = 'setTimeout(function() { console.log("blah"); });' +
132
+ 'setInterval(function() {}, 1000000);' ;
133
133
134
- var nodeProcess ;
134
+ let nodeProcess ;
135
135
136
136
function doTest ( cb , done ) {
137
- var args = [ '--debug=' + debugPort , '-e' , script ] ;
137
+ const args = [ '--debug=' + debugPort , '-e' , script ] ;
138
138
nodeProcess = spawn ( process . execPath , args ) ;
139
139
140
140
nodeProcess . stdout . once ( 'data' , function ( c ) {
141
141
console . log ( '>>> new node process: %d' , nodeProcess . pid ) ;
142
- var failed = true ;
142
+ let failed = true ;
143
143
try {
144
144
process . _debugProcess ( nodeProcess . pid ) ;
145
145
failed = false ;
@@ -151,9 +151,9 @@ function doTest(cb, done) {
151
151
console . log ( '>>> starting debugger session' ) ;
152
152
} ) ;
153
153
154
- var didTryConnect = false ;
154
+ let didTryConnect = false ;
155
155
nodeProcess . stderr . setEncoding ( 'utf8' ) ;
156
- var b = '' ;
156
+ let b = '' ;
157
157
nodeProcess . stderr . on ( 'data' , function ( data ) {
158
158
console . error ( 'got stderr data %j' , data ) ;
159
159
nodeProcess . stderr . resume ( ) ;
0 commit comments