@@ -11,6 +11,9 @@ const assert = require('node:assert');
1111const { waitUntil } = require ( '../common/inspector-helper' ) ;
1212const { setTimeout } = require ( 'node:timers/promises' ) ;
1313
14+ // The complete payload string received by the network agent
15+ const payloadString = `Hello, world${ '.' . repeat ( 4096 ) } ` ;
16+
1417const session = new inspector . Session ( ) ;
1518session . connect ( ) ;
1619session . post ( 'Network.enable' ) ;
@@ -67,9 +70,20 @@ async function triggerNetworkEvents(requestId, charset) {
6770 } ) ;
6871 await setTimeout ( 1 ) ;
6972
70- Network . loadingFinished ( {
73+ // Test inspector binary conversions with large input
74+ const chunk3 = Buffer . allocUnsafe ( 4096 ) . fill ( '.' ) ;
75+ Network . dataReceived ( {
7176 requestId,
7277 timestamp : 5 ,
78+ dataLength : chunk3 . byteLength ,
79+ encodedDataLength : chunk3 . byteLength ,
80+ data : chunk3 ,
81+ } ) ;
82+ await setTimeout ( 1 ) ;
83+
84+ Network . loadingFinished ( {
85+ requestId,
86+ timestamp : 6 ,
7387 } ) ;
7488}
7589
@@ -116,7 +130,7 @@ test('should stream Network.dataReceived with data chunks', async () => {
116130
117131 const data = Buffer . concat ( chunks ) ;
118132 assert . strictEqual ( data . byteLength , totalDataLength , data ) ;
119- assert . strictEqual ( data . toString ( 'utf8' ) , 'Hello, world' ) ;
133+ assert . strictEqual ( data . toString ( 'utf8' ) , payloadString ) ;
120134} ) ;
121135
122136test ( 'Network.streamResourceContent should send all buffered chunks' , async ( ) => {
@@ -131,7 +145,7 @@ test('Network.streamResourceContent should send all buffered chunks', async () =
131145 const { bufferedData } = await session . post ( 'Network.streamResourceContent' , {
132146 requestId,
133147 } ) ;
134- assert . strictEqual ( Buffer . from ( bufferedData , 'base64' ) . toString ( 'utf8' ) , 'Hello, world' ) ;
148+ assert . strictEqual ( Buffer . from ( bufferedData , 'base64' ) . toString ( 'utf8' ) , payloadString ) ;
135149} ) ;
136150
137151test ( 'Network.streamResourceContent should reject if request id not found' , async ( ) => {
@@ -158,7 +172,7 @@ test('Network.getResponseBody should send all buffered binary data', async () =>
158172 requestId,
159173 } ) ;
160174 assert . strictEqual ( base64Encoded , true ) ;
161- assert . strictEqual ( body , Buffer . from ( 'Hello, world' ) . toString ( 'base64' ) ) ;
175+ assert . strictEqual ( body , Buffer . from ( payloadString ) . toString ( 'base64' ) ) ;
162176} ) ;
163177
164178test ( 'Network.getResponseBody should send all buffered text data' , async ( ) => {
@@ -174,5 +188,5 @@ test('Network.getResponseBody should send all buffered text data', async () => {
174188 requestId,
175189 } ) ;
176190 assert . strictEqual ( base64Encoded , false ) ;
177- assert . strictEqual ( body , 'Hello, world' ) ;
191+ assert . strictEqual ( body , payloadString ) ;
178192} ) ;
0 commit comments