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

core(largest-contentful-paint): remove m79 check #14082

Merged
merged 4 commits into from
Jun 13, 2022
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
22 changes: 1 addition & 21 deletions lighthouse-core/audits/metrics/largest-contentful-paint.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
const Audit = require('../audit.js');
const i18n = require('../../lib/i18n/i18n.js');
const ComputedLcp = require('../../computed/metrics/largest-contentful-paint.js');
const LHError = require('../../lib/lh-error.js');

const UIStrings = {
/** Description of the Largest Contentful Paint (LCP) metric, which marks the time at which the largest text or image is painted by the browser. This is displayed within a tooltip when the user hovers on the metric name to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */
Expand Down Expand Up @@ -77,28 +76,9 @@ class LargestContentfulPaint extends Audit {
const metricComputationData = {trace, devtoolsLog, gatherContext,
settings: context.settings, URL: artifacts.URL};

let metricResult;
try {
metricResult = await ComputedLcp.request(metricComputationData, context);
} catch (err) {
const match = artifacts.HostUserAgent.match(/Chrome\/(\d+)/);
if (!match) throw err;
const milestone = Number(match[1]);

// m79 is the minimum version which supports LCP
// https://chromium.googlesource.com/chromium/src/+/master/docs/speed/metrics_changelog/lcp.md
if (milestone < 79 && err.code === 'NO_LCP') {
throw new LHError(
LHError.errors.UNSUPPORTED_OLD_CHROME,
{featureName: 'Largest Contentful Paint'}
);
}
throw err;
}

const metricResult = await ComputedLcp.request(metricComputationData, context);
const options = context.options[context.settings.formFactor];


return {
score: Audit.computeLogNormalScore(
options.scoring,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import constants 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 preLcpTrace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta);
const preLcpDevtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta);

const defaultOptions = LCPAudit.defaultOptions;

Expand Down Expand Up @@ -64,29 +62,4 @@ describe('Performance: largest-contentful-paint audit', () => {
expect(outputDesktop.score).toBe(0.92);
expect(outputDesktop.displayValue).toBeDisplayString('1.1\xa0s');
});

it('throws error when old Chrome does not support LCP', async () => {
const artifactsOldChrome = generateArtifacts({
trace: preLcpTrace,
devtoolsLog: preLcpDevtoolsLog,
HostUserAgent: 'Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) ' +
'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 ' +
'Mobile Safari/537.36 Chrome-Lighthouse',
});
const contextOldChrome = getFakeContext({formFactor: 'mobile', throttlingMethod: 'provided'});

await expect(LCPAudit.audit(artifactsOldChrome, contextOldChrome))
.rejects.toThrow(/UNSUPPORTED_OLD_CHROME/);

const artifactsNewChrome = generateArtifacts({
trace: preLcpTrace,
devtoolsLog: preLcpDevtoolsLog,
HostUserAgent: 'Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) ' +
'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 ' +
'Mobile Safari/537.36 Chrome-Lighthouse',
});
const contextNewChrome = getFakeContext({formFactor: 'mobile', throttlingMethod: 'provided'});

await expect(LCPAudit.audit(artifactsNewChrome, contextNewChrome)).rejects.toThrow(/NO_LCP/);
});
});