lighthouse 9.5.0-dev.20220610 → 9.5.0-dev.20220613
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
const Audit = require('../audit.js');
|
|
9
9
|
const i18n = require('../../lib/i18n/i18n.js');
|
|
10
10
|
const ComputedLcp = require('../../computed/metrics/largest-contentful-paint.js');
|
|
11
|
-
const LHError = require('../../lib/lh-error.js');
|
|
12
11
|
|
|
13
12
|
const UIStrings = {
|
|
14
13
|
/** 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. */
|
|
@@ -77,28 +76,9 @@ class LargestContentfulPaint extends Audit {
|
|
|
77
76
|
const metricComputationData = {trace, devtoolsLog, gatherContext,
|
|
78
77
|
settings: context.settings, URL: artifacts.URL};
|
|
79
78
|
|
|
80
|
-
|
|
81
|
-
try {
|
|
82
|
-
metricResult = await ComputedLcp.request(metricComputationData, context);
|
|
83
|
-
} catch (err) {
|
|
84
|
-
const match = artifacts.HostUserAgent.match(/Chrome\/(\d+)/);
|
|
85
|
-
if (!match) throw err;
|
|
86
|
-
const milestone = Number(match[1]);
|
|
87
|
-
|
|
88
|
-
// m79 is the minimum version which supports LCP
|
|
89
|
-
// https://chromium.googlesource.com/chromium/src/+/master/docs/speed/metrics_changelog/lcp.md
|
|
90
|
-
if (milestone < 79 && err.code === 'NO_LCP') {
|
|
91
|
-
throw new LHError(
|
|
92
|
-
LHError.errors.UNSUPPORTED_OLD_CHROME,
|
|
93
|
-
{featureName: 'Largest Contentful Paint'}
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
throw err;
|
|
97
|
-
}
|
|
98
|
-
|
|
79
|
+
const metricResult = await ComputedLcp.request(metricComputationData, context);
|
|
99
80
|
const options = context.options[context.settings.formFactor];
|
|
100
81
|
|
|
101
|
-
|
|
102
82
|
return {
|
|
103
83
|
score: Audit.computeLogNormalScore(
|
|
104
84
|
options.scoring,
|
|
@@ -294,6 +294,8 @@ function filterConfigByExplicitFilters(config, filters) {
|
|
|
294
294
|
baseAuditIds = getAuditIdsInCategories(config.categories, onlyCategories);
|
|
295
295
|
} else if (onlyAudits) {
|
|
296
296
|
baseAuditIds = new Set();
|
|
297
|
+
} else if (!config.categories || !Object.keys(config.categories).length) {
|
|
298
|
+
baseAuditIds = new Set(config.audits?.map(audit => audit.implementation.meta.id));
|
|
297
299
|
}
|
|
298
300
|
|
|
299
301
|
const auditIdsToKeep = new Set(
|
|
@@ -327,6 +327,7 @@ async function navigationGather(requestor, options) {
|
|
|
327
327
|
const artifacts = await Runner.gather(
|
|
328
328
|
async () => {
|
|
329
329
|
let {page} = options;
|
|
330
|
+
const normalizedRequestor = isCallback ? requestor : URL.normalizeUrl(requestor);
|
|
330
331
|
|
|
331
332
|
// For navigation mode, we shouldn't connect to a browser in audit mode,
|
|
332
333
|
// therefore we connect to the browser in the gatherFn callback.
|
|
@@ -340,7 +341,7 @@ async function navigationGather(requestor, options) {
|
|
|
340
341
|
const context = {
|
|
341
342
|
driver,
|
|
342
343
|
config,
|
|
343
|
-
requestor:
|
|
344
|
+
requestor: normalizedRequestor,
|
|
344
345
|
options: internalOptions,
|
|
345
346
|
};
|
|
346
347
|
const {baseArtifacts} = await _setup(context);
|
|
@@ -65,29 +65,15 @@ class Scripts extends FRGatherer {
|
|
|
65
65
|
|
|
66
66
|
constructor() {
|
|
67
67
|
super();
|
|
68
|
-
this.
|
|
68
|
+
this.onScriptParsed = this.onScriptParsed.bind(this);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
-
* @param {LH.
|
|
72
|
+
* @param {LH.Crdp.Debugger.ScriptParsedEvent} params
|
|
73
73
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (this._mainSessionId === null) {
|
|
78
|
-
this._mainSessionId = sessionId;
|
|
79
|
-
}
|
|
80
|
-
if (this._mainSessionId === sessionId) {
|
|
81
|
-
sessionId = undefined;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// We want to ignore scripts from OOPIFs. In reality, this does more than block just OOPIFs,
|
|
85
|
-
// it also blocks scripts from the same origin but that happen to run in a different process,
|
|
86
|
-
// like a worker.
|
|
87
|
-
if (event.method === 'Debugger.scriptParsed' && !sessionId) {
|
|
88
|
-
if (!isLighthouseRuntimeEvaluateScript(event.params)) {
|
|
89
|
-
this._scriptParsedEvents.push(event.params);
|
|
90
|
-
}
|
|
74
|
+
onScriptParsed(params) {
|
|
75
|
+
if (!isLighthouseRuntimeEvaluateScript(params)) {
|
|
76
|
+
this._scriptParsedEvents.push(params);
|
|
91
77
|
}
|
|
92
78
|
}
|
|
93
79
|
|
|
@@ -96,7 +82,7 @@ class Scripts extends FRGatherer {
|
|
|
96
82
|
*/
|
|
97
83
|
async startInstrumentation(context) {
|
|
98
84
|
const session = context.driver.defaultSession;
|
|
99
|
-
session.
|
|
85
|
+
session.on('Debugger.scriptParsed', this.onScriptParsed);
|
|
100
86
|
await session.sendCommand('Debugger.enable');
|
|
101
87
|
}
|
|
102
88
|
|
|
@@ -107,7 +93,7 @@ class Scripts extends FRGatherer {
|
|
|
107
93
|
const session = context.driver.defaultSession;
|
|
108
94
|
const formFactor = context.baseArtifacts.HostFormFactor;
|
|
109
95
|
|
|
110
|
-
session.
|
|
96
|
+
session.off('Debugger.scriptParsed', this.onScriptParsed);
|
|
111
97
|
|
|
112
98
|
// Without this line the Debugger domain will be off in FR runner,
|
|
113
99
|
// because only the legacy gatherer has special handling for multiple,
|
package/package.json
CHANGED