@@ -80,8 +80,8 @@ function tearDown(child, err) {
8080 }
8181}
8282
83- function checkHttpResponse ( port , path , callback ) {
84- http . get ( { port, path} , function ( res ) {
83+ function checkHttpResponse ( host , port , path , callback , errorcb ) {
84+ const req = http . get ( { host , port, path} , function ( res ) {
8585 let response = '' ;
8686 res . setEncoding ( 'utf8' ) ;
8787 res
@@ -98,6 +98,8 @@ function checkHttpResponse(port, path, callback) {
9898 callback ( err , json ) ;
9999 } ) ;
100100 } ) ;
101+ if ( errorcb )
102+ req . on ( 'error' , errorcb ) ;
101103}
102104
103105function makeBufferingDataCallback ( dataCallback ) {
@@ -295,7 +297,7 @@ TestSession.prototype.disconnect = function(childDone) {
295297
296298TestSession . prototype . testHttpResponse = function ( path , check ) {
297299 return this . enqueue ( ( callback ) =>
298- checkHttpResponse ( this . harness_ . port , path , ( err , response ) => {
300+ checkHttpResponse ( null , this . harness_ . port , path , ( err , response ) => {
299301 check . call ( this , err , response ) ;
300302 callback ( ) ;
301303 } ) ) ;
@@ -361,12 +363,17 @@ Harness.prototype.enqueue_ = function(task) {
361363 return this ;
362364} ;
363365
364- Harness . prototype . testHttpResponse = function ( path , check ) {
366+ Harness . prototype . testHttpResponse = function ( host , path , check , errorcb ) {
365367 return this . enqueue_ ( ( doneCallback ) => {
366- checkHttpResponse ( this . port , path , ( err , response ) => {
367- check . call ( this , err , response ) ;
368- doneCallback ( ) ;
369- } ) ;
368+ function wrap ( callback ) {
369+ if ( callback ) {
370+ return function ( ) {
371+ callback ( ...arguments ) ;
372+ doneCallback ( ) ;
373+ } ;
374+ }
375+ }
376+ checkHttpResponse ( host , this . port , path , wrap ( check ) , wrap ( errorcb ) ) ;
370377 } ) ;
371378} ;
372379
@@ -404,7 +411,7 @@ Harness.prototype.wsHandshake = function(devtoolsUrl, tests, readyCallback) {
404411
405412Harness . prototype . runFrontendSession = function ( tests ) {
406413 return this . enqueue_ ( ( callback ) => {
407- checkHttpResponse ( this . port , '/json/list' , ( err , response ) => {
414+ checkHttpResponse ( null , this . port , '/json/list' , ( err , response ) => {
408415 assert . ifError ( err ) ;
409416 this . wsHandshake ( response [ 0 ] [ 'webSocketDebuggerUrl' ] , tests , callback ) ;
410417 } ) ;
0 commit comments