From 8cba07b33852e185b3f71f58002c6c4c2e406a92 Mon Sep 17 00:00:00 2001 From: Brendan Kenny Date: Mon, 1 Aug 2022 18:20:35 -0400 Subject: [PATCH 1/2] core(network-requests): include starting timestamp as debug data --- core/audits/network-requests.js | 8 ++++++++ core/test/audits/network-requests-test.js | 5 +++++ .../reports/sample-flow-result.json | 18 +++++++++++++++--- core/test/results/sample_v2.json | 6 +++++- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/core/audits/network-requests.js b/core/audits/network-requests.js index 7074e4cc87e6..7208d8f401ea 100644 --- a/core/audits/network-requests.js +++ b/core/audits/network-requests.js @@ -110,6 +110,14 @@ class NetworkRequests extends Audit { const tableDetails = Audit.makeTableDetails(headings, results); + // Include starting timestamp to allow syncing requests with navStart/metric timestamps. + const networkStartTimeTs = Number.isFinite(earliestStartTime) ? + earliestStartTime * 1_000_000 : undefined; + tableDetails.debugData = { + type: 'debugdata', + networkStartTimeTs, + }; + return { score: 1, details: tableDetails, diff --git a/core/test/audits/network-requests-test.js b/core/test/audits/network-requests-test.js index 82b4b9d7feec..3f0e6cd8a2cc 100644 --- a/core/test/audits/network-requests-test.js +++ b/core/test/audits/network-requests-test.js @@ -56,6 +56,11 @@ describe('Network requests audit', () => { mimeType: 'application/javascript', resourceType: 'Script', }); + + expect(output.details.debugData).toBe({ + type: 'debugdata', + networkStartTimeTs: 360725781425, + }); }); it('should handle times correctly', async () => { diff --git a/core/test/fixtures/fraggle-rock/reports/sample-flow-result.json b/core/test/fixtures/fraggle-rock/reports/sample-flow-result.json index 9c2d93d17a54..223d5ff764e9 100644 --- a/core/test/fixtures/fraggle-rock/reports/sample-flow-result.json +++ b/core/test/fixtures/fraggle-rock/reports/sample-flow-result.json @@ -1055,7 +1055,11 @@ "resourceType": "Other", "experimentalFromMainFrame": true } - ] + ], + "debugData": { + "type": "debugdata", + "networkStartTimeTs": 49208077236 + } } }, "network-rtt": { @@ -8142,7 +8146,11 @@ "mimeType": "image/jpeg", "resourceType": "Image" } - ] + ], + "debugData": { + "type": "debugdata", + "networkStartTimeTs": 49220053647 + } } }, "network-rtt": { @@ -15273,7 +15281,11 @@ "resourceType": "Script", "experimentalFromMainFrame": true } - ] + ], + "debugData": { + "type": "debugdata", + "networkStartTimeTs": 49241053294 + } } }, "network-rtt": { diff --git a/core/test/results/sample_v2.json b/core/test/results/sample_v2.json index bba714599e60..f5705f41c7bd 100644 --- a/core/test/results/sample_v2.json +++ b/core/test/results/sample_v2.json @@ -1630,7 +1630,11 @@ "resourceType": "Other", "experimentalFromMainFrame": true } - ] + ], + "debugData": { + "type": "debugdata", + "networkStartTimeTs": 8696703416 + } } }, "network-rtt": { From cc8789e3c646262ec663e3982e13fcba3af47a8d Mon Sep 17 00:00:00 2001 From: Brendan Kenny Date: Mon, 1 Aug 2022 19:41:33 -0400 Subject: [PATCH 2/2] object equality --- core/test/audits/network-requests-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/test/audits/network-requests-test.js b/core/test/audits/network-requests-test.js index 3f0e6cd8a2cc..eca96a6e8cc6 100644 --- a/core/test/audits/network-requests-test.js +++ b/core/test/audits/network-requests-test.js @@ -57,7 +57,7 @@ describe('Network requests audit', () => { resourceType: 'Script', }); - expect(output.details.debugData).toBe({ + expect(output.details.debugData).toStrictEqual({ type: 'debugdata', networkStartTimeTs: 360725781425, });