@@ -11,6 +11,9 @@ const assert = require('node:assert');
11
11
const { waitUntil } = require ( '../common/inspector-helper' ) ;
12
12
const { setTimeout } = require ( 'node:timers/promises' ) ;
13
13
14
+ // The complete payload string received by the network agent
15
+ const payloadString = `Hello, world${ '.' . repeat ( 4096 ) } ` ;
16
+
14
17
const session = new inspector . Session ( ) ;
15
18
session . connect ( ) ;
16
19
session . post ( 'Network.enable' ) ;
@@ -67,9 +70,20 @@ async function triggerNetworkEvents(requestId, charset) {
67
70
} ) ;
68
71
await setTimeout ( 1 ) ;
69
72
70
- Network . loadingFinished ( {
73
+ // Test inspector binary conversions with large input
74
+ const chunk3 = Buffer . allocUnsafe ( 4096 ) . fill ( '.' ) ;
75
+ Network . dataReceived ( {
71
76
requestId,
72
77
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 ,
73
87
} ) ;
74
88
}
75
89
@@ -116,7 +130,7 @@ test('should stream Network.dataReceived with data chunks', async () => {
116
130
117
131
const data = Buffer . concat ( chunks ) ;
118
132
assert . strictEqual ( data . byteLength , totalDataLength , data ) ;
119
- assert . strictEqual ( data . toString ( 'utf8' ) , 'Hello, world' ) ;
133
+ assert . strictEqual ( data . toString ( 'utf8' ) , payloadString ) ;
120
134
} ) ;
121
135
122
136
test ( 'Network.streamResourceContent should send all buffered chunks' , async ( ) => {
@@ -131,7 +145,7 @@ test('Network.streamResourceContent should send all buffered chunks', async () =
131
145
const { bufferedData } = await session . post ( 'Network.streamResourceContent' , {
132
146
requestId,
133
147
} ) ;
134
- assert . strictEqual ( Buffer . from ( bufferedData , 'base64' ) . toString ( 'utf8' ) , 'Hello, world' ) ;
148
+ assert . strictEqual ( Buffer . from ( bufferedData , 'base64' ) . toString ( 'utf8' ) , payloadString ) ;
135
149
} ) ;
136
150
137
151
test ( 'Network.streamResourceContent should reject if request id not found' , async ( ) => {
@@ -158,7 +172,7 @@ test('Network.getResponseBody should send all buffered binary data', async () =>
158
172
requestId,
159
173
} ) ;
160
174
assert . strictEqual ( base64Encoded , true ) ;
161
- assert . strictEqual ( body , Buffer . from ( 'Hello, world' ) . toString ( 'base64' ) ) ;
175
+ assert . strictEqual ( body , Buffer . from ( payloadString ) . toString ( 'base64' ) ) ;
162
176
} ) ;
163
177
164
178
test ( 'Network.getResponseBody should send all buffered text data' , async ( ) => {
@@ -174,5 +188,5 @@ test('Network.getResponseBody should send all buffered text data', async () => {
174
188
requestId,
175
189
} ) ;
176
190
assert . strictEqual ( base64Encoded , false ) ;
177
- assert . strictEqual ( body , 'Hello, world' ) ;
191
+ assert . strictEqual ( body , payloadString ) ;
178
192
} ) ;
0 commit comments