@@ -5,6 +5,7 @@ const common = require('../common');
55common . skipIfInspectorDisabled ( ) ;
66
77const assert = require ( 'node:assert' ) ;
8+ const { addresses } = require ( '../common/internet' ) ;
89const fixtures = require ( '../common/fixtures' ) ;
910const http = require ( 'node:http' ) ;
1011const https = require ( 'node:https' ) ;
@@ -144,11 +145,50 @@ const testHttpsGet = () => new Promise((resolve, reject) => {
144145 } , common . mustCall ( ) ) ;
145146} ) ;
146147
148+ const testHttpError = ( ) => new Promise ( ( resolve , reject ) => {
149+ session . on ( 'Network.requestWillBeSent' , common . mustCall ( ) ) ;
150+ session . on ( 'Network.loadingFailed' , common . mustCall ( ( { params } ) => {
151+ assert . ok ( params . requestId . startsWith ( 'node-network-event-' ) ) ;
152+ assert . strictEqual ( typeof params . timestamp , 'number' ) ;
153+ assert . strictEqual ( params . type , 'Other' ) ;
154+ assert . strictEqual ( typeof params . errorText , 'string' ) ;
155+ resolve ( ) ;
156+ } ) ) ;
157+ session . on ( 'Network.responseReceived' , common . mustNotCall ( ) ) ;
158+ session . on ( 'Network.loadingFinished' , common . mustNotCall ( ) ) ;
159+
160+ http . get ( {
161+ host : addresses . INVALID_HOST ,
162+ } , common . mustNotCall ( ) ) . on ( 'error' , common . mustCall ( ) ) ;
163+ } ) ;
164+
165+
166+ const testHttpsError = ( ) => new Promise ( ( resolve , reject ) => {
167+ session . on ( 'Network.requestWillBeSent' , common . mustCall ( ) ) ;
168+ session . on ( 'Network.loadingFailed' , common . mustCall ( ( { params } ) => {
169+ assert . ok ( params . requestId . startsWith ( 'node-network-event-' ) ) ;
170+ assert . strictEqual ( typeof params . timestamp , 'number' ) ;
171+ assert . strictEqual ( params . type , 'Other' ) ;
172+ assert . strictEqual ( typeof params . errorText , 'string' ) ;
173+ resolve ( ) ;
174+ } ) ) ;
175+ session . on ( 'Network.responseReceived' , common . mustNotCall ( ) ) ;
176+ session . on ( 'Network.loadingFinished' , common . mustNotCall ( ) ) ;
177+
178+ https . get ( {
179+ host : addresses . INVALID_HOST ,
180+ } , common . mustNotCall ( ) ) . on ( 'error' , common . mustCall ( ) ) ;
181+ } ) ;
182+
147183const testNetworkInspection = async ( ) => {
148184 await testHttpGet ( ) ;
149185 session . removeAllListeners ( ) ;
150186 await testHttpsGet ( ) ;
151187 session . removeAllListeners ( ) ;
188+ await testHttpError ( ) ;
189+ session . removeAllListeners ( ) ;
190+ await testHttpsError ( ) ;
191+ session . removeAllListeners ( ) ;
152192} ;
153193
154194httpServer . listen ( 0 , ( ) => {
0 commit comments