Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: update remaining old traces for Lantern #16039

Merged
merged 3 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/audits/third-party-facades.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class ThirdPartyFacades extends Audit {
itemCount: results.length,
}),
details: Audit.makeTableDetails(headings, results),
metricSavings: {TBT: tbtImpact},
metricSavings: {TBT: Math.round(tbtImpact)},
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/audits/third-party-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class ThirdPartySummary extends Audit {
}),
details,
metricSavings: {
TBT: overallSummary.tbtImpact,
TBT: Math.round(overallSummary.tbtImpact),
},
};
}
Expand Down
8,242 changes: 8,242 additions & 0 deletions core/test/audits/__snapshots__/third-party-summary-test.js.snap

Large diffs are not rendered by default.

60 changes: 30 additions & 30 deletions core/test/audits/mainthread-work-breakdown-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ import {networkRecordsToDevtoolsLog} from '../network-records-to-devtools-log.js
import {defaultSettings} from '../../config/constants.js';
import {createTestTrace} from '../create-test-trace.js';

const acceptableTrace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta);
const acceptableDevtoolsLog = readJson('../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta);
const acceptableTrace = readJson('../fixtures/artifacts/cnn/defaultPass.trace.json.gz', import.meta);
const acceptableDevtoolsLog = readJson('../fixtures/artifacts/cnn/defaultPass.devtoolslog.json.gz', import.meta);
const siteWithRedirectTrace = readJson('../fixtures/artifacts/redirect/trace.json', import.meta);
const siteWithRedirectDevtoolsLog = readJson('../fixtures/artifacts/redirect/devtoolslog.json', import.meta);
const loadTraceOld = readJson('../fixtures/traces/load.json', import.meta);
const loadTrace = readJson('../fixtures/artifacts/animation/trace.json', import.meta);
const loadDevtoolsLog = readJson('../fixtures/artifacts/animation/devtoolslog.json', import.meta);
const loadTrace = readJson('../fixtures/artifacts/animation/trace.json.gz', import.meta);
const loadDevtoolsLog = readJson('../fixtures/artifacts/animation/devtoolslog.json.gz', import.meta);

const options = PageExecutionTimings.defaultOptions;

const acceptableTraceExpectations = {
parseHTML: 14,
styleLayout: 308,
paintCompositeRender: 87,
scriptEvaluation: 215,
scriptParseCompile: 25,
garbageCollection: 48,
other: 663,
garbageCollection: 64,
other: 875,
paintCompositeRender: 27,
parseHTML: 84,
scriptEvaluation: 3703,
scriptParseCompile: 210,
styleLayout: 90,
};

describe('Performance: page execution timings audit', () => {
Expand Down Expand Up @@ -64,18 +64,13 @@ describe('Performance: page execution timings audit', () => {

const output = await PageExecutionTimings.audit(artifacts, context);
assert.deepStrictEqual(keyOutput(output), acceptableTraceExpectations);
assert.equal(Math.round(output.numericValue), 1360);
assert.equal(Math.round(output.numericValue), 5052);
assert.equal(output.details.items.length, 7);
assert.equal(output.score, 0.98);
expect(output.metricSavings.TBT).toBeCloseTo(48.3, 0.1);
assert.equal(output.score, 0.33);
expect(output.metricSavings.TBT).toBeCloseTo(400, 0.1);
});

it('should compute the correct values when simulated', async () => {
// TODO(15841): update trace
if (process.env.INTERNAL_LANTERN_USE_TRACE !== undefined) {
return;
}

const artifacts = {
traces: {defaultPass: acceptableTrace},
devtoolsLogs: {defaultPass: acceptableDevtoolsLog},
Expand All @@ -94,10 +89,15 @@ describe('Performance: page execution timings audit', () => {
assert.ok(Math.abs(actual - expected) <= 2, `expected ${expected} got ${actual}`);
}

assert.equal(Math.round(output.numericValue), 4081);
assert.equal(Math.round(output.numericValue), 15157);
assert.equal(output.details.items.length, 7);
assert.equal(output.score, 0.48);
expect(output.metricSavings.TBT).toBeCloseTo(478, 0.1);
assert.equal(output.score, 0);
// TODO(15841): investigate difference
if (process.env.INTERNAL_LANTERN_USE_TRACE !== undefined) {
expect(output.metricSavings.TBT).toBeCloseTo(1714.5, 0.1);
} else {
expect(output.metricSavings.TBT).toBeCloseTo(1710.5, 0.1);
}
});

it('should compute the correct values for the redirect trace', async () => {
Expand Down Expand Up @@ -173,17 +173,17 @@ Object {
const output = await PageExecutionTimings.audit(artifacts, context);
expect(keyOutput(output)).toMatchInlineSnapshot(`
Object {
"other": 319,
"paintCompositeRender": 152,
"parseHTML": 2,
"scriptEvaluation": 14,
"scriptParseCompile": 2,
"styleLayout": 470,
"other": 405,
"paintCompositeRender": 254,
"parseHTML": 3,
"scriptEvaluation": 29,
"scriptParseCompile": 1,
"styleLayout": 707,
}
`);
expect(Math.round(output.numericValue)).toMatchInlineSnapshot(`958`);
expect(Math.round(output.numericValue)).toMatchInlineSnapshot(`1399`);
assert.equal(output.details.items.length, 6);
assert.equal(output.score, 1);
assert.equal(output.score, 0.97);
});

it('should get no data when no events are present', () => {
Expand Down
104 changes: 40 additions & 64 deletions core/test/audits/third-party-facades-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import {createTestTrace} from '../create-test-trace.js';
import {getURLArtifactFromDevtoolsLog, readJson} from '../test-utils.js';
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 videoEmbedsTrace = readJson('../fixtures/artifacts/video-embed/trace.json', import.meta);
const videoEmbedsDevtolsLog = readJson('../fixtures/artifacts/video-embed/devtoolslog.json', import.meta);
const blockingWidgetTrace = readJson('../fixtures/artifacts/intercom-widget/trace.json', import.meta);
const blockingWidgetDevtoolsLog = readJson('../fixtures/artifacts/intercom-widget/devtoolslog.json', import.meta);
const noThirdPartyTrace = readJson('../fixtures/traces/no-tracingstarted-m74.json', import.meta);
const pwaTrace = readJson('../fixtures/artifacts/progressive-app/trace.json', import.meta);
const pwaDevtoolsLog = readJson('../fixtures/artifacts/progressive-app/devtoolslog.json', import.meta);
const videoEmbedsTrace = readJson('../fixtures/artifacts/video-embed/trace.json.gz', import.meta);
const videoEmbedsDevtolsLog = readJson('../fixtures/artifacts/video-embed/devtoolslog.json.gz', import.meta);
const blockingWidgetTrace = readJson('../fixtures/artifacts/intercom-widget/trace.json.gz', import.meta);
const blockingWidgetDevtoolsLog = readJson('../fixtures/artifacts/intercom-widget/devtoolslog.json.gz', import.meta);
const noThirdPartyTrace = readJson('../fixtures/artifacts/animation/trace.json.gz', import.meta);
const noThirdPartyDevtoolsLog = readJson('../fixtures/artifacts/animation/devtoolslog.json.gz', import.meta);

function intercomProductUrl(id) {
return `https://widget.intercom.io/widget/${id}`;
Expand Down Expand Up @@ -245,11 +246,6 @@ describe('Third party facades audit', () => {
});

it('only reports resources which have facade alternatives', async () => {
// TODO(15841): traces needs updating.
if (process.env.INTERNAL_LANTERN_USE_TRACE !== undefined) {
return;
}

const artifacts = {
// This devtools log has third party requests but none have facades
devtoolsLogs: {defaultPass: pwaDevtoolsLog},
Expand All @@ -269,23 +265,13 @@ describe('Third party facades audit', () => {
});

it('not applicable when no third party resources are present', async () => {
// TODO(15841): traces needs updating.
if (process.env.INTERNAL_LANTERN_USE_TRACE !== undefined) {
return;
}

const networkRecords = [
{transferSize: 2000, url: 'https://example.com', priority: 'High'},
];
const artifacts = {
devtoolsLogs: {
defaultPass: networkRecordsToDevtoolsLog(networkRecords),
},
devtoolsLogs: {defaultPass: noThirdPartyDevtoolsLog},
traces: {defaultPass: noThirdPartyTrace},
URL: {
requestedUrl: 'https://example.com',
mainDocumentUrl: 'https://example.com',
finalDisplayedUrl: 'https://example.com',
requestedUrl: 'http://localhost:65178/animation.html',
mainDocumentUrl: 'http://localhost:65178/animation.html',
finalDisplayedUrl: 'http://localhost:65178/animation.html',
},
GatherContext: {gatherMode: 'navigation'},
};
Expand All @@ -301,11 +287,6 @@ describe('Third party facades audit', () => {
});

it('handles real trace', async () => {
// TODO(15841): traces needs updating.
if (process.env.INTERNAL_LANTERN_USE_TRACE !== undefined) {
return;
}

const artifacts = {
devtoolsLogs: {defaultPass: videoEmbedsDevtolsLog},
traces: {defaultPass: videoEmbedsTrace},
Expand Down Expand Up @@ -339,42 +320,42 @@ Array [
"blockingTime": 0,
"mainThreadTime": 0,
"tbtImpact": 0,
"transferSize": 459603,
"url": "https://www.youtube.com/s/player/e0d83c30/player_ias.vflset/en_US/base.js",
"transferSize": 824806,
"url": "https://www.youtube.com/s/player/4b63a6a1/player_ias.vflset/en_US/base.js",
},
Object {
"blockingTime": 0,
"mainThreadTime": 0,
"tbtImpact": 0,
"transferSize": 66273,
"url": "https://i.ytimg.com/vi/tgbNymZ7vqY/maxresdefault.jpg",
"transferSize": 129402,
"url": "https://i.ytimg.com/vi/t_rzYnXEQlE/maxresdefault.jpg",
},
Object {
"blockingTime": 0,
"mainThreadTime": 0,
"tbtImpact": 0,
"transferSize": 50213,
"url": "https://www.youtube.com/s/player/e0d83c30/www-embed-player.vflset/www-embed-player.js",
"transferSize": 98747,
"url": "https://www.youtube.com/s/player/4b63a6a1/www-embed-player.vflset/www-embed-player.js",
},
Object {
"blockingTime": 0,
"mainThreadTime": 0,
"tbtImpact": 0,
"transferSize": 46813,
"url": "https://www.youtube.com/s/player/e0d83c30/www-player.css",
"transferSize": 48296,
"url": "https://www.youtube.com/s/player/4b63a6a1/www-player.css",
},
Object {
"blockingTime": 0,
"mainThreadTime": 0,
"mainThreadTime": 0.384,
"tbtImpact": 0,
"transferSize": 11477,
"url": "https://www.youtube.com/s/player/e0d83c30/player_ias.vflset/en_US/embed.js",
"transferSize": 40447,
"url": "https://www.youtube.com/embed/t_rzYnXEQlE",
},
Object {
"blockingTime": 0,
"mainThreadTime": 0,
"tbtImpact": 0,
"transferSize": 16971,
"transferSize": 22879,
"url": Object {
"formattedDefault": "Other resources",
"i18nId": "core/lib/i18n/i18n.js | otherResourcesLabel",
Expand All @@ -384,7 +365,7 @@ Array [
],
"type": "subitems",
},
"transferSize": 651350,
"transferSize": 1164577,
},
Object {
"blockingTime": 0,
Expand All @@ -402,42 +383,42 @@ Array [
"blockingTime": 0,
"mainThreadTime": 0,
"tbtImpact": 0,
"transferSize": 145772,
"url": "https://f.vimeocdn.com/p/3.22.3/js/player.js",
"transferSize": 143719,
"url": "https://f.vimeocdn.com/p/4.33.11/js/player.module.js",
},
Object {
"blockingTime": 0,
"mainThreadTime": 0,
"tbtImpact": 0,
"transferSize": 17633,
"url": "https://f.vimeocdn.com/p/3.22.3/css/player.css",
"transferSize": 104244,
"url": "https://f.vimeocdn.com/p/4.33.11/js/vendor.module.js",
},
Object {
"blockingTime": 0,
"mainThreadTime": 0,
"tbtImpact": 0,
"transferSize": 9313,
"url": "https://i.vimeocdn.com/video/784397921.webp?mw=1200&mh=675&q=70",
"transferSize": 22326,
"url": "https://f.vimeocdn.com/p/4.33.11/css/player.css",
},
Object {
"blockingTime": 0,
"mainThreadTime": 0,
"mainThreadTime": 0.128,
"tbtImpact": 0,
"transferSize": 8300,
"url": "https://player.vimeo.com/video/336812660",
"transferSize": 20465,
"url": "https://player.vimeo.com/video/517294790?h=da863dae0d",
},
Object {
"blockingTime": 0,
"mainThreadTime": 0,
"tbtImpact": 0,
"transferSize": 1474,
"url": "https://f.vimeocdn.com/js_opt/modules/utils/vuid.min.js",
"transferSize": 6329,
"url": "https://i.vimeocdn.com/video/1071113919-b94500e76071b48f12f379fb6fc9573b52eac89eac80438679f34564bb66cd6e-d?mw=1280&mh=720&q=70",
},
Object {
"blockingTime": 0,
"mainThreadTime": 0,
"tbtImpact": 0,
"transferSize": 2003,
"transferSize": 4903,
"url": Object {
"formattedDefault": "Other resources",
"i18nId": "core/lib/i18n/i18n.js | otherResourcesLabel",
Expand All @@ -447,18 +428,13 @@ Array [
],
"type": "subitems",
},
"transferSize": 184495,
"transferSize": 301986,
},
]
`);
});

it('handles real trace that blocks the main thread', async () => {
// TODO(15841): traces needs updating.
if (process.env.INTERNAL_LANTERN_USE_TRACE !== undefined) {
return;
}

const artifacts = {
devtoolsLogs: {defaultPass: blockingWidgetDevtoolsLog},
traces: {defaultPass: blockingWidgetTrace},
Expand All @@ -470,9 +446,9 @@ Array [
const results = await ThirdPartyFacades.audit(artifacts, {computedCache: new Map(), settings});

expect(results.score).toBe(0);
expect(results.metricSavings).toEqual({TBT: 224});
expect(results.metricSavings).toEqual({TBT: 145});
expect(results.displayValue).toBeDisplayString('1 facade alternative available');
expect(results.details.items[0].blockingTime).toEqual(234.984); // TBT impact is not equal to the blocking time
expect(results.details.items[0].blockingTime).toEqual(134.076); // TBT impact is not equal to the blocking time
expect(results.details.items[0].product)
.toBeDisplayString('Intercom Widget (Customer Success)');
});
Expand Down
Loading
Loading