MCPcopy Index your code
hub / github.com/nodejs/node / triggerNetworkEvents

Function triggerNetworkEvents

test/parallel/test-inspector-network-data-received.js:21–88  ·  view source on GitHub ↗
(requestId, charset)

Source from the content-addressed store, hash-verified

19session.post('Network.enable');
20
21async function triggerNetworkEvents(requestId, charset) {
22 const url = 'https://example.com';
23 Network.requestWillBeSent({
24 requestId,
25 timestamp: 1,
26 wallTime: 1,
27 request: {
28 url,
29 method: 'GET',
30 headers: {
31 mKey: 'mValue',
32 },
33 },
34 });
35 await setTimeout(1);
36
37 Network.responseReceived({
38 requestId,
39 timestamp: 2,
40 type: 'Fetch',
41 response: {
42 url,
43 status: 200,
44 statusText: 'OK',
45 headers: {
46 mKey: 'mValue',
47 },
48 charset,
49 },
50 });
51 await setTimeout(1);
52
53 const chunk1 = Buffer.from('Hello, ');
54 Network.dataReceived({
55 requestId,
56 timestamp: 3,
57 dataLength: chunk1.byteLength,
58 encodedDataLength: chunk1.byteLength,
59 data: chunk1,
60 });
61 await setTimeout(1);
62
63 const chunk2 = Buffer.from('world');
64 Network.dataReceived({
65 requestId,
66 timestamp: 4,
67 dataLength: chunk2.byteLength,
68 encodedDataLength: chunk2.byteLength,
69 data: chunk2,
70 });
71 await setTimeout(1);
72
73 // Test inspector binary conversions with large input
74 const chunk3 = Buffer.allocUnsafe(4096).fill('.');
75 Network.dataReceived({
76 requestId,
77 timestamp: 5,
78 dataLength: chunk3.byteLength,

Calls 3

fillMethod · 0.80
setTimeoutFunction · 0.50
fromMethod · 0.45

Tested by

no test coverage detected