Skip to content

Commit

Permalink
core(test): add modern chrome trace for paint metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed May 14, 2024
1 parent e5038e4 commit 12096d5
Show file tree
Hide file tree
Showing 18 changed files with 26,624 additions and 79 deletions.
76 changes: 38 additions & 38 deletions core/test/audits/__snapshots__/metrics-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -116,58 +116,58 @@ Object {

exports[`Performance: metrics evaluates valid input (with lcp) correctly 1`] = `
Object {
"cumulativeLayoutShift": 0,
"cumulativeLayoutShiftMainFrame": 0,
"firstContentfulPaint": 2294,
"cumulativeLayoutShift": 0.23332411101386594,
"cumulativeLayoutShiftMainFrame": 0.23332411101386594,
"firstContentfulPaint": 1059,
"firstContentfulPaintAllFrames": undefined,
"firstContentfulPaintAllFramesTs": undefined,
"firstContentfulPaintTs": undefined,
"firstMeaningfulPaint": 2764,
"firstMeaningfulPaint": 1059,
"firstMeaningfulPaintTs": undefined,
"interactive": 4607,
"interactive": 3149,
"interactiveTs": undefined,
"largestContentfulPaint": 2764,
"largestContentfulPaint": 1524,
"largestContentfulPaintAllFrames": undefined,
"largestContentfulPaintAllFramesTs": undefined,
"largestContentfulPaintTs": undefined,
"lcpLoadEnd": undefined,
"lcpLoadStart": undefined,
"maxPotentialFID": 1336,
"observedCumulativeLayoutShift": 0,
"observedCumulativeLayoutShiftMainFrame": 0,
"observedDomContentLoaded": 1513,
"observedDomContentLoadedTs": 713038536140,
"observedFirstContentfulPaint": 1122,
"observedFirstContentfulPaintAllFrames": 1122,
"observedFirstContentfulPaintAllFramesTs": 713038144775,
"observedFirstContentfulPaintTs": 713038144775,
"observedFirstMeaningfulPaint": 1122,
"observedFirstMeaningfulPaintTs": 713038144775,
"observedFirstPaint": 1122,
"observedFirstPaintTs": 713038144775,
"observedFirstVisualChange": 1105,
"observedFirstVisualChangeTs": 713038128064,
"observedLargestContentfulPaint": 1122,
"observedLargestContentfulPaintAllFrames": 1122,
"observedLargestContentfulPaintAllFramesTs": 713038144775,
"observedLargestContentfulPaintTs": 713038144775,
"observedLastVisualChange": 1722,
"observedLastVisualChangeTs": 713038745064,
"observedLoad": 2159,
"observedLoadTs": 713039182071,
"maxPotentialFID": 163,
"observedCumulativeLayoutShift": 0.23332411101386594,
"observedCumulativeLayoutShiftMainFrame": 0.23332411101386594,
"observedDomContentLoaded": 331,
"observedDomContentLoadedTs": 343577515428,
"observedFirstContentfulPaint": 292,
"observedFirstContentfulPaintAllFrames": 292,
"observedFirstContentfulPaintAllFramesTs": 343577475882,
"observedFirstContentfulPaintTs": 343577475882,
"observedFirstMeaningfulPaint": 292,
"observedFirstMeaningfulPaintTs": 343577475882,
"observedFirstPaint": 292,
"observedFirstPaintTs": 343577475882,
"observedFirstVisualChange": 207,
"observedFirstVisualChangeTs": 343577391048,
"observedLargestContentfulPaint": 292,
"observedLargestContentfulPaintAllFrames": 292,
"observedLargestContentfulPaintAllFramesTs": 343577475882,
"observedLargestContentfulPaintTs": 343577475882,
"observedLastVisualChange": 391,
"observedLastVisualChangeTs": 343577575048,
"observedLoad": 436,
"observedLoadTs": 343577620312,
"observedNavigationStart": 0,
"observedNavigationStartTs": 713037023064,
"observedSpeedIndex": 1393,
"observedSpeedIndexTs": 713038416494,
"observedNavigationStartTs": 343577184048,
"observedSpeedIndex": 261,
"observedSpeedIndexTs": 343577445114,
"observedTimeOrigin": 0,
"observedTimeOriginTs": 713037023064,
"observedTraceEnd": 7416,
"observedTraceEndTs": 713044439102,
"speedIndex": 3172,
"observedTimeOriginTs": 343577184048,
"observedTraceEnd": 3479,
"observedTraceEndTs": 343580662857,
"speedIndex": 1059,
"speedIndexTs": undefined,
"timeToFirstByte": 611,
"timeToFirstByte": 638,
"timeToFirstByteTs": undefined,
"totalBlockingTime": 1205,
"totalBlockingTime": 84,
}
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {networkRecordsToDevtoolsLog} from '../../network-records-to-devtools-log
import {createTestTrace, rootFrame} from '../../create-test-trace.js';
import {defaultSettings} from '../../../config/constants.js';

const trace = readJson('../../fixtures/traces/lcp-m78.json', import.meta);
const devtoolsLog = readJson('../../fixtures/traces/lcp-m78.devtools.log.json', import.meta);
const trace = readJson('../../fixtures/artifacts/paul/trace.json', import.meta);
const devtoolsLog = readJson('../../fixtures/artifacts/paul/devtoolslog.json', import.meta);

describe('Byte efficiency base audit', () => {
let simulator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
readJson,
} from '../../test-utils.js';

const trace = readJson('../../fixtures/traces/lcp-m78.json', import.meta);
const devtoolsLog = readJson('../../fixtures/traces/lcp-m78.devtools.log.json', import.meta);
const trace = readJson('../../fixtures/artifacts/paul/trace.json', import.meta);
const devtoolsLog = readJson('../../fixtures/artifacts/paul/devtoolslog.json', import.meta);

describe('DuplicatedJavascript computed artifact', () => {
it('works (simple)', async () => {
Expand Down
4 changes: 2 additions & 2 deletions core/test/audits/metrics-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {defaultSettings} from '../../config/constants.js';

const pwaTrace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta);
const pwaDevtoolsLog = readJson('../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta);
const lcpTrace = readJson('../fixtures/traces/lcp-m78.json', import.meta);
const lcpDevtoolsLog = readJson('../fixtures/traces/lcp-m78.devtools.log.json', import.meta);
const lcpTrace = readJson('../fixtures/artifacts/paul/trace.json', import.meta);
const lcpDevtoolsLog = readJson('../fixtures/artifacts/paul/devtoolslog.json', import.meta);
const lcpImageTrace = readJson('../fixtures/traces/amp-m86.trace.json', import.meta);
const lcpImageDevtoolsLog = readJson('../fixtures/traces/amp-m86.devtoolslog.json', import.meta);
const lcpAllFramesTrace = readJson('../fixtures/traces/frame-metrics-m89.json', import.meta);
Expand Down
4 changes: 2 additions & 2 deletions core/test/audits/network-requests-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('Network requests audit', () => {

it('should report if records are from the main frame', async () => {
const records = [
{url: 'https://example.com/'},
{url: 'https://example.com/', frameId: 'main'},
{url: 'https://iframed.local/', frameId: '71D866EC199B90A2E0B2D9CF88DCBC4E'},
];

Expand All @@ -123,7 +123,7 @@ describe('Network requests audit', () => {

it('should not include main frame information outside of navigations', async () => {
const records = [
{url: 'https://example.com/'},
{url: 'https://example.com/', frameId: 'main'},
{url: 'https://iframed.local/', frameId: '71D866EC199B90A2E0B2D9CF88DCBC4E'},
];

Expand Down
4 changes: 2 additions & 2 deletions core/test/audits/predictive-perf-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import PredictivePerf from '../../audits/predictive-perf.js';
import {getURLArtifactFromDevtoolsLog, readJson} from '../test-utils.js';

const acceptableTrace = readJson('../fixtures/traces/lcp-m78.json', import.meta);
const acceptableDevToolsLog = readJson('../fixtures/traces/lcp-m78.devtools.log.json', import.meta);
const acceptableTrace = readJson('../fixtures/artifacts/paul/trace.json', import.meta);
const acceptableDevToolsLog = readJson('../fixtures/artifacts/paul/devtoolslog.json', import.meta);

describe('Performance: predictive performance audit', () => {
it('should compute the predicted values', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {readJson} from '../../test-utils.js';

const traceAllFrames = readJson('../../fixtures/traces/frame-metrics-m89.json', import.meta);
const devtoolsLogAllFrames = readJson('../../fixtures/traces/frame-metrics-m89.devtools.log.json', import.meta);
const traceMainFrame = readJson('../../fixtures/traces/lcp-m78.json', import.meta);
const devtoolsLogMainFrame = readJson('../../fixtures/traces/lcp-m78.devtools.log.json', import.meta);
const traceMainFrame = readJson('../../fixtures/artifacts/paul/trace.json', import.meta);
const devtoolsLogMainFrame = readJson('../../fixtures/artifacts/paul/devtoolslog.json', import.meta);
const invalidTrace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta);
const invalidDevtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta);

Expand Down Expand Up @@ -54,9 +54,11 @@ describe('Metrics: LCP from all frames', () => {
{gatherContext, trace: traceMainFrame, devtoolsLog: devtoolsLogMainFrame, settings},
context
);
await expect(result).toEqual({
timestamp: 713038144775,
timing: 1121.711,
});
await expect(result).toMatchInlineSnapshot(`
Object {
"timestamp": 343577475882,
"timing": 291.834,
}
`);
});
});
20 changes: 11 additions & 9 deletions core/test/computed/metrics/largest-contentful-paint-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/

import assert from 'assert/strict';

import {LargestContentfulPaint} from '../../../computed/metrics/largest-contentful-paint.js';
import {getURLArtifactFromDevtoolsLog, readJson} from '../../test-utils.js';

const trace = readJson('../../fixtures/traces/lcp-m78.json', import.meta);
const devtoolsLog = readJson('../../fixtures/traces/lcp-m78.devtools.log.json', import.meta);
const trace = readJson('../../fixtures/artifacts/paul/trace.json', import.meta);
const devtoolsLog = readJson('../../fixtures/artifacts/paul/devtoolslog.json', import.meta);
const invalidTrace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta);
const invalidDevtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta);

Expand All @@ -30,9 +28,9 @@ describe('Metrics: LCP', () => {
pessimistic: Math.round(result.pessimisticEstimate.timeInMs)}).
toMatchInlineSnapshot(`
Object {
"optimistic": 2294,
"pessimistic": 3233,
"timing": 2764,
"optimistic": 1445,
"pessimistic": 1603,
"timing": 1524,
}
`);
});
Expand All @@ -44,8 +42,12 @@ Object {
const result = await LargestContentfulPaint.request({trace, devtoolsLog, gatherContext,
settings, URL}, context);

assert.equal(Math.round(result.timing), 1122);
assert.equal(result.timestamp, 713038144775);
await expect(result).toMatchInlineSnapshot(`
Object {
"timestamp": 343577475882,
"timing": 291.834,
}
`);
});

['provided', 'simulate'].forEach(throttlingMethod => {
Expand Down
4 changes: 2 additions & 2 deletions core/test/computed/tbt-impact-tasks-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {createTestTrace, rootFrame} from '../create-test-trace.js';
import {networkRecordsToDevtoolsLog} from '../network-records-to-devtools-log.js';
import {MainThreadTasks} from '../../computed/main-thread-tasks.js';

const trace = readJson('../fixtures/traces/lcp-m78.json', import.meta);
const devtoolsLog = readJson('../fixtures/traces/lcp-m78.devtools.log.json', import.meta);
const trace = readJson('../fixtures/artifacts/paul/trace.json', import.meta);
const devtoolsLog = readJson('../fixtures/artifacts/paul/devtoolslog.json', import.meta);

describe('TBTImpactTasks', () => {
const mainDocumentUrl = 'https://example.com';
Expand Down
Loading

0 comments on commit 12096d5

Please sign in to comment.