lighthouse 9.5.0 → 9.6.3
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.
- package/dist/report/bundle.esm.js +67 -384
- package/dist/report/flow.js +20 -25
- package/dist/report/standalone.js +18 -23
- package/lighthouse-cli/test/smokehouse/core-tests.js +2 -0
- package/lighthouse-cli/test/smokehouse/frontends/lib.js +1 -3
- package/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js +1 -3
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/cli.js +1 -0
- package/lighthouse-cli/test/smokehouse/readme.md +5 -4
- package/lighthouse-cli/test/smokehouse/report-assert.js +16 -13
- package/lighthouse-cli/test/smokehouse/version-check-test.js +46 -0
- package/lighthouse-cli/test/smokehouse/version-check.js +49 -0
- package/lighthouse-core/audits/bootup-time.js +2 -70
- package/lighthouse-core/audits/byte-efficiency/duplicated-javascript.js +3 -5
- package/lighthouse-core/audits/byte-efficiency/legacy-javascript.js +2 -5
- package/lighthouse-core/audits/byte-efficiency/unminified-javascript.js +4 -2
- package/lighthouse-core/audits/byte-efficiency/unused-javascript.js +3 -1
- package/lighthouse-core/audits/deprecations.js +603 -28
- package/lighthouse-core/audits/installable-manifest.js +27 -6
- package/lighthouse-core/audits/long-tasks.js +3 -3
- package/lighthouse-core/audits/metrics/experimental-interaction-to-next-paint.js +88 -0
- package/lighthouse-core/audits/network-requests.js +79 -62
- package/lighthouse-core/audits/preload-lcp-image.js +33 -7
- package/lighthouse-core/audits/third-party-summary.js +3 -3
- package/lighthouse-core/audits/work-during-interaction.js +280 -0
- package/lighthouse-core/computed/metrics/responsiveness.js +157 -0
- package/lighthouse-core/config/config-helpers.js +1 -1
- package/lighthouse-core/config/metrics-to-audits.js +5 -0
- package/lighthouse-core/fraggle-rock/config/default-config.js +9 -1
- package/lighthouse-core/fraggle-rock/gather/base-artifacts.js +2 -2
- package/lighthouse-core/fraggle-rock/gather/session.js +8 -2
- package/lighthouse-core/gather/driver.js +21 -14
- package/lighthouse-core/gather/gather-runner.js +2 -4
- package/lighthouse-core/gather/gatherers/css-usage.js +59 -34
- package/lighthouse-core/gather/gatherers/trace-elements.js +21 -2
- package/lighthouse-core/lib/arbitrary-equality-map.js +2 -2
- package/lighthouse-core/lib/dependency-graph/network-node.js +1 -1
- package/lighthouse-core/lib/i18n/i18n.js +2 -0
- package/lighthouse-core/lib/minify-trace.js +2 -0
- package/lighthouse-core/lib/script-helpers.js +24 -0
- package/lighthouse-core/lib/stack-packs.js +8 -5
- package/lighthouse-core/lib/tracehouse/task-groups.js +1 -0
- package/lighthouse-core/lib/tracehouse/task-summary.js +87 -0
- package/lighthouse-core/lib/tracehouse/trace-processor.js +39 -14
- package/lighthouse-core/runner.js +1 -1
- package/lighthouse-core/util-commonjs.js +20 -18
- package/package.json +10 -8
- package/report/assets/styles.css +5 -2
- package/report/clients/bundle.js +1 -0
- package/report/renderer/components.js +1 -1
- package/report/renderer/details-renderer.js +4 -4
- package/report/renderer/performance-category-renderer.js +15 -11
- package/report/renderer/util.js +20 -18
- package/report/test/renderer/__snapshots__/report-renderer-axe-test.js.snap +6 -98
- package/report/test/renderer/details-renderer-test.js +9 -9
- package/report/test/renderer/performance-category-renderer-test.js +31 -0
- package/report/test/renderer/report-renderer-axe-test.js +3 -15
- package/report/test-assets/faux-psi-template.html +3 -2
- package/report/test-assets/faux-psi.js +22 -1
- package/shared/localization/locales/en-US.json +244 -4
- package/shared/localization/locales/en-XL.json +244 -4
- package/shared/localization/swap-locale.js +2 -1
- package/third-party/chromium-synchronization/installability-errors-test.js +1 -0
- package/third-party/snyk/snapshot.json +2 -3
- package/tsconfig.json +1 -0
- package/types/artifacts.d.ts +40 -1
- package/types/lhr/audit-details.d.ts +3 -1
- package/types/smokehouse.d.ts +1 -1
- package/changelog.md +0 -5902
- package/lighthouse-core/scripts/package.json +0 -4
|
@@ -52,6 +52,7 @@ import pwaSvgomg from './test-definitions/pwa-svgomg.js';
|
|
|
52
52
|
import redirectsClientPaintServer from './test-definitions/redirects-client-paint-server.js';
|
|
53
53
|
import redirectsHistoryPushState from './test-definitions/redirects-history-push-state.js';
|
|
54
54
|
import redirectsMultipleServer from './test-definitions/redirects-multiple-server.js';
|
|
55
|
+
import redirectScripts from './test-definitions/redirects-scripts.js';
|
|
55
56
|
import redirectsSingleClient from './test-definitions/redirects-single-client.js';
|
|
56
57
|
import redirectsSingleServer from './test-definitions/redirects-single-server.js';
|
|
57
58
|
import redirectsSelf from './test-definitions/redirects-self.js';
|
|
@@ -112,6 +113,7 @@ const smokeTests = [
|
|
|
112
113
|
redirectsClientPaintServer,
|
|
113
114
|
redirectsHistoryPushState,
|
|
114
115
|
redirectsMultipleServer,
|
|
116
|
+
redirectScripts,
|
|
115
117
|
redirectsSingleClient,
|
|
116
118
|
redirectsSingleServer,
|
|
117
119
|
redirectsSelf,
|
|
@@ -13,13 +13,11 @@
|
|
|
13
13
|
|
|
14
14
|
/* eslint-disable no-console */
|
|
15
15
|
|
|
16
|
-
import
|
|
16
|
+
import cloneDeep from 'lodash/cloneDeep.js';
|
|
17
17
|
|
|
18
18
|
import smokeTests from '../core-tests.js';
|
|
19
19
|
import {runSmokehouse, getShardedDefinitions} from '../smokehouse.js';
|
|
20
20
|
|
|
21
|
-
const {cloneDeep} = _;
|
|
22
|
-
|
|
23
21
|
/**
|
|
24
22
|
* @param {Smokehouse.SmokehouseLibOptions} options
|
|
25
23
|
*/
|
|
@@ -17,7 +17,7 @@ import path from 'path';
|
|
|
17
17
|
import fs from 'fs';
|
|
18
18
|
import url from 'url';
|
|
19
19
|
|
|
20
|
-
import
|
|
20
|
+
import cloneDeep from 'lodash/cloneDeep.js';
|
|
21
21
|
import yargs from 'yargs';
|
|
22
22
|
import * as yargsHelpers from 'yargs/helpers';
|
|
23
23
|
import log from 'lighthouse-logger';
|
|
@@ -26,8 +26,6 @@ import {runSmokehouse, getShardedDefinitions} from '../smokehouse.js';
|
|
|
26
26
|
import {updateTestDefnFormat} from './back-compat-util.js';
|
|
27
27
|
import {LH_ROOT} from '../../../../root.js';
|
|
28
28
|
|
|
29
|
-
const {cloneDeep} = _;
|
|
30
|
-
|
|
31
29
|
const coreTestDefnsPath =
|
|
32
30
|
path.join(LH_ROOT, 'lighthouse-cli/test/smokehouse/core-tests.js');
|
|
33
31
|
|
|
@@ -82,7 +82,8 @@ Arrays can be asserted to not match any elements using the special `_excludes` p
|
|
|
82
82
|
|
|
83
83
|
### Special environment checks
|
|
84
84
|
|
|
85
|
-
If an expectation requires a minimum version of Chromium, use `
|
|
85
|
+
If an expectation requires a minimum version of Chromium, use `_minChromiumVersion: xx.x.x.x` to conditionally ignore that entire object in the expectation.
|
|
86
|
+
Can be as specific as you like (`_minChromiumVersion: xx` works too).
|
|
86
87
|
|
|
87
88
|
**Examples**:
|
|
88
89
|
```js
|
|
@@ -90,7 +91,7 @@ If an expectation requires a minimum version of Chromium, use `_minChromiumMiles
|
|
|
90
91
|
artifacts: {
|
|
91
92
|
InspectorIssues: {
|
|
92
93
|
// Mixed Content issues weren't added to the protocol until M84.
|
|
93
|
-
|
|
94
|
+
_minChromiumVersion: '84', // The entire `InspectorIssues` is ignored for older Chrome.
|
|
94
95
|
mixedContent: [
|
|
95
96
|
{
|
|
96
97
|
resourceType: 'Image',
|
|
@@ -111,8 +112,8 @@ If an expectation requires a minimum version of Chromium, use `_minChromiumMiles
|
|
|
111
112
|
|
|
112
113
|
All pruning checks:
|
|
113
114
|
|
|
114
|
-
- `
|
|
115
|
-
- `
|
|
115
|
+
- `_minChromiumVersion`
|
|
116
|
+
- `_maxChromiumVersion`
|
|
116
117
|
- `_legacyOnly`
|
|
117
118
|
- `_fraggleRockOnly`
|
|
118
119
|
- `_skipInBundled`
|
|
@@ -10,12 +10,11 @@
|
|
|
10
10
|
* against the results actually collected from Lighthouse.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import
|
|
13
|
+
import cloneDeep from 'lodash/cloneDeep.js';
|
|
14
14
|
import log from 'lighthouse-logger';
|
|
15
15
|
|
|
16
16
|
import {LocalConsole} from './lib/local-console.js';
|
|
17
|
-
|
|
18
|
-
const {cloneDeep} = _;
|
|
17
|
+
import {chromiumVersionCheck} from './version-check.js';
|
|
19
18
|
|
|
20
19
|
/**
|
|
21
20
|
* @typedef Difference
|
|
@@ -228,22 +227,26 @@ function pruneExpectations(localConsole, lhr, expected, reportOptions) {
|
|
|
228
227
|
|
|
229
228
|
/**
|
|
230
229
|
* Lazily compute the Chrome version because some reports are explicitly asserting error conditions.
|
|
231
|
-
* @returns {
|
|
230
|
+
* @returns {string}
|
|
232
231
|
*/
|
|
233
|
-
function
|
|
232
|
+
function getChromeVersionString() {
|
|
234
233
|
const userAgent = lhr.environment.hostUserAgent;
|
|
235
|
-
const userAgentMatch = /Chrome\/(\d+)/.exec(userAgent); // Chrome/85.0.4174.0
|
|
234
|
+
const userAgentMatch = /Chrome\/([\d.]+)/.exec(userAgent); // Chrome/85.0.4174.0
|
|
236
235
|
if (!userAgentMatch) throw new Error('Could not get chrome version.');
|
|
237
|
-
|
|
236
|
+
const versionString = userAgentMatch[1];
|
|
237
|
+
if (versionString.split('.').length !== 4) throw new Error(`unexpected ua: ${userAgent}`);
|
|
238
|
+
return versionString;
|
|
238
239
|
}
|
|
239
240
|
|
|
240
241
|
/**
|
|
241
242
|
* @param {*} obj
|
|
242
243
|
*/
|
|
243
244
|
function failsChromeVersionCheck(obj) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
245
|
+
return !chromiumVersionCheck({
|
|
246
|
+
version: getChromeVersionString(),
|
|
247
|
+
min: obj._minChromiumVersion,
|
|
248
|
+
max: obj._maxChromiumVersion,
|
|
249
|
+
});
|
|
247
250
|
}
|
|
248
251
|
|
|
249
252
|
/**
|
|
@@ -272,7 +275,7 @@ function pruneExpectations(localConsole, lhr, expected, reportOptions) {
|
|
|
272
275
|
localConsole.log([
|
|
273
276
|
`[${key}] failed chrome version check, pruning expectation:`,
|
|
274
277
|
JSON.stringify(value, null, 2),
|
|
275
|
-
`Actual Chromium version: ${
|
|
278
|
+
`Actual Chromium version: ${getChromeVersionString()}`,
|
|
276
279
|
].join(' '));
|
|
277
280
|
remove(key);
|
|
278
281
|
} else if (value._legacyOnly && isFraggleRock) {
|
|
@@ -308,8 +311,8 @@ function pruneExpectations(localConsole, lhr, expected, reportOptions) {
|
|
|
308
311
|
delete obj._legacyOnly;
|
|
309
312
|
delete obj._fraggleRockOnly;
|
|
310
313
|
delete obj._skipInBundled;
|
|
311
|
-
delete obj.
|
|
312
|
-
delete obj.
|
|
314
|
+
delete obj._minChromiumVersion;
|
|
315
|
+
delete obj._maxChromiumVersion;
|
|
313
316
|
delete obj._runner;
|
|
314
317
|
}
|
|
315
318
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright 2022 The Lighthouse Authors. All Rights Reserved.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
4
|
+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
5
|
+
*/
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
import {chromiumVersionCheck, compareVersions} from './version-check.js';
|
|
9
|
+
|
|
10
|
+
/* eslint-env jest */
|
|
11
|
+
|
|
12
|
+
describe('version check', () => {
|
|
13
|
+
it('compareVersions', async () => {
|
|
14
|
+
expect(compareVersions([100, 0, 0, 0], [100, 0, 0, 0])).toBe(0);
|
|
15
|
+
expect(compareVersions([101, 0, 0, 0], [100, 0, 0, 0])).toBe(1);
|
|
16
|
+
expect(compareVersions([99, 0, 0, 0], [100, 0, 0, 0])).toBe(-1);
|
|
17
|
+
|
|
18
|
+
expect(compareVersions([100, 0, 10, 0], [100, 0, 10, 0])).toBe(0);
|
|
19
|
+
expect(compareVersions([100, 0, 11, 0], [100, 0, 10, 0])).toBe(1);
|
|
20
|
+
expect(compareVersions([100, 0, 9, 0], [100, 0, 10, 0])).toBe(-1);
|
|
21
|
+
|
|
22
|
+
expect(compareVersions([100, 0, 0, 0], [100])).toBe(0);
|
|
23
|
+
expect(compareVersions([100, 0, 0, 1], [100])).toBe(1);
|
|
24
|
+
expect(compareVersions([99, 0, 0, 0], [100])).toBe(-1);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('chromiumVersionCheck', async () => {
|
|
28
|
+
expect(chromiumVersionCheck({version: '100'})).toBe(true);
|
|
29
|
+
expect(chromiumVersionCheck({version: '100', min: '100'})).toBe(true);
|
|
30
|
+
expect(chromiumVersionCheck({version: '100', max: '100'})).toBe(true);
|
|
31
|
+
expect(chromiumVersionCheck({version: '100', min: '101'})).toBe(false);
|
|
32
|
+
expect(chromiumVersionCheck({version: '100', max: '99'})).toBe(false);
|
|
33
|
+
|
|
34
|
+
expect(chromiumVersionCheck({version: '100.0.2331.3'})).toBe(true);
|
|
35
|
+
expect(chromiumVersionCheck({version: '100.0.2331.3', min: '100.0.2331.3'})).toBe(true);
|
|
36
|
+
expect(chromiumVersionCheck({version: '100.0.2331.3', min: '100.0.0.0'})).toBe(true);
|
|
37
|
+
expect(chromiumVersionCheck({version: '100.0.2331.3', max: '100.0.3333.3'})).toBe(true);
|
|
38
|
+
expect(chromiumVersionCheck({version: '100.0.2331.3', min: '100.0.2331.2'})).toBe(true);
|
|
39
|
+
expect(chromiumVersionCheck({version: '100.0.2331.3', max: '99'})).toBe(false);
|
|
40
|
+
|
|
41
|
+
expect(chromiumVersionCheck({
|
|
42
|
+
version: '100.0.2331.3', min: '100.0.2331.0', max: '100.0.2331.10'})).toBe(true);
|
|
43
|
+
expect(chromiumVersionCheck({
|
|
44
|
+
version: '100.3.2331.3', min: '100.0.2331.0', max: '100.0.2331.10'})).toBe(false);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright 2022 The Lighthouse Authors. All Rights Reserved.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
4
|
+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
5
|
+
*/
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @fileoverview Compares chromium version strings: 103.0.5017.0
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param {string} versionString
|
|
14
|
+
* @return {number[]}
|
|
15
|
+
*/
|
|
16
|
+
function parseVersion(versionString) {
|
|
17
|
+
const versionParts = versionString.split('.');
|
|
18
|
+
return versionParts.map(Number);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {number[]} versionA
|
|
23
|
+
* @param {number[]} versionB
|
|
24
|
+
*/
|
|
25
|
+
function compareVersions(versionA, versionB) {
|
|
26
|
+
for (let i = 0; i < versionA.length; i++) {
|
|
27
|
+
if ((versionA[i] ?? 0) > (versionB[i] ?? 0)) return 1;
|
|
28
|
+
if ((versionA[i] ?? 0) < (versionB[i] ?? 0)) return -1;
|
|
29
|
+
}
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Returns false if fails check.
|
|
35
|
+
* @param {{version: string, min?: string, max?: string}} opts
|
|
36
|
+
*/
|
|
37
|
+
function chromiumVersionCheck(opts) {
|
|
38
|
+
const version = parseVersion(opts.version);
|
|
39
|
+
const min = opts.min && parseVersion(opts.min);
|
|
40
|
+
const max = opts.max && parseVersion(opts.max);
|
|
41
|
+
if (min && compareVersions(version, min) === -1) return false;
|
|
42
|
+
if (max && compareVersions(version, max) === 1) return false;
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
chromiumVersionCheck,
|
|
48
|
+
compareVersions,
|
|
49
|
+
};
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const Audit = require('./audit.js');
|
|
9
|
-
const NetworkRequest = require('../lib/network-request.js');
|
|
10
9
|
const {taskGroups} = require('../lib/tracehouse/task-groups.js');
|
|
11
10
|
const i18n = require('../lib/i18n/i18n.js');
|
|
12
11
|
const NetworkRecords = require('../computed/network-records.js');
|
|
13
12
|
const MainThreadTasks = require('../computed/main-thread-tasks.js');
|
|
13
|
+
const {getExecutionTimingsByURL} = require('../lib/tracehouse/task-summary.js');
|
|
14
14
|
|
|
15
15
|
const UIStrings = {
|
|
16
16
|
/** Title of a diagnostic audit that provides detail on the time spent executing javascript files during the load. This descriptive title is shown to users when the amount is acceptable and no user action is required. */
|
|
@@ -34,18 +34,6 @@ const UIStrings = {
|
|
|
34
34
|
|
|
35
35
|
const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
|
|
36
36
|
|
|
37
|
-
// These trace events, when not triggered by a script inside a particular task, are just general Chrome overhead.
|
|
38
|
-
const BROWSER_TASK_NAMES_SET = new Set([
|
|
39
|
-
'CpuProfiler::StartProfiling',
|
|
40
|
-
]);
|
|
41
|
-
|
|
42
|
-
// These trace events, when not triggered by a script inside a particular task, are GC Chrome overhead.
|
|
43
|
-
const BROWSER_GC_TASK_NAMES_SET = new Set([
|
|
44
|
-
'V8.GCCompactor',
|
|
45
|
-
'MajorGC',
|
|
46
|
-
'MinorGC',
|
|
47
|
-
]);
|
|
48
|
-
|
|
49
37
|
class BootupTime extends Audit {
|
|
50
38
|
/**
|
|
51
39
|
* @return {LH.Audit.Meta}
|
|
@@ -74,61 +62,6 @@ class BootupTime extends Audit {
|
|
|
74
62
|
};
|
|
75
63
|
}
|
|
76
64
|
|
|
77
|
-
/**
|
|
78
|
-
* @param {LH.Artifacts.NetworkRequest[]} records
|
|
79
|
-
*/
|
|
80
|
-
static getJavaScriptURLs(records) {
|
|
81
|
-
/** @type {Set<string>} */
|
|
82
|
-
const urls = new Set();
|
|
83
|
-
for (const record of records) {
|
|
84
|
-
if (record.resourceType === NetworkRequest.TYPES.Script) {
|
|
85
|
-
urls.add(record.url);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return urls;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* @param {LH.Artifacts.TaskNode} task
|
|
94
|
-
* @param {Set<string>} jsURLs
|
|
95
|
-
* @return {string}
|
|
96
|
-
*/
|
|
97
|
-
static getAttributableURLForTask(task, jsURLs) {
|
|
98
|
-
const jsURL = task.attributableURLs.find(url => jsURLs.has(url));
|
|
99
|
-
const fallbackURL = task.attributableURLs[0];
|
|
100
|
-
let attributableURL = jsURL || fallbackURL;
|
|
101
|
-
// If we can't find what URL was responsible for this execution, attribute it to the root page
|
|
102
|
-
// or Chrome depending on the type of work.
|
|
103
|
-
if (!attributableURL || attributableURL === 'about:blank') {
|
|
104
|
-
if (BROWSER_TASK_NAMES_SET.has(task.event.name)) attributableURL = 'Browser';
|
|
105
|
-
else if (BROWSER_GC_TASK_NAMES_SET.has(task.event.name)) attributableURL = 'Browser GC';
|
|
106
|
-
else attributableURL = 'Unattributable';
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return attributableURL;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* @param {LH.Artifacts.TaskNode[]} tasks
|
|
114
|
-
* @param {Set<string>} jsURLs
|
|
115
|
-
* @return {Map<string, Object<string, number>>}
|
|
116
|
-
*/
|
|
117
|
-
static getExecutionTimingsByURL(tasks, jsURLs) {
|
|
118
|
-
/** @type {Map<string, Object<string, number>>} */
|
|
119
|
-
const result = new Map();
|
|
120
|
-
|
|
121
|
-
for (const task of tasks) {
|
|
122
|
-
const attributableURL = BootupTime.getAttributableURLForTask(task, jsURLs);
|
|
123
|
-
const timingByGroupId = result.get(attributableURL) || {};
|
|
124
|
-
const originalTime = timingByGroupId[task.group.id] || 0;
|
|
125
|
-
timingByGroupId[task.group.id] = originalTime + task.selfTime;
|
|
126
|
-
result.set(attributableURL, timingByGroupId);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return result;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
65
|
/**
|
|
133
66
|
* @param {LH.Artifacts} artifacts
|
|
134
67
|
* @param {LH.Audit.Context} context
|
|
@@ -143,8 +76,7 @@ class BootupTime extends Audit {
|
|
|
143
76
|
const multiplier = settings.throttlingMethod === 'simulate' ?
|
|
144
77
|
settings.throttling.cpuSlowdownMultiplier : 1;
|
|
145
78
|
|
|
146
|
-
const
|
|
147
|
-
const executionTimings = BootupTime.getExecutionTimingsByURL(tasks, jsURLs);
|
|
79
|
+
const executionTimings = getExecutionTimingsByURL(tasks, networkRecords);
|
|
148
80
|
|
|
149
81
|
let hadExcessiveChromeExtension = false;
|
|
150
82
|
let totalBootupTime = 0;
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
const ByteEfficiencyAudit = require('./byte-efficiency-audit.js');
|
|
13
13
|
const ModuleDuplication = require('../../computed/module-duplication.js');
|
|
14
|
-
const NetworkAnalyzer = require('../../lib/dependency-graph/simulator/network-analyzer.js');
|
|
15
14
|
const i18n = require('../../lib/i18n/i18n.js');
|
|
15
|
+
const {getRequestForScript} = require('../../lib/script-helpers.js');
|
|
16
16
|
|
|
17
17
|
const UIStrings = {
|
|
18
18
|
/** Imperative title of a Lighthouse audit that tells the user to remove duplicate JavaScript from their code. This is displayed in a list of audit titles that Lighthouse generates. */
|
|
@@ -130,7 +130,6 @@ class DuplicatedJavascript extends ByteEfficiencyAudit {
|
|
|
130
130
|
context.options?.ignoreThresholdInBytes || IGNORE_THRESHOLD_IN_BYTES;
|
|
131
131
|
const duplication =
|
|
132
132
|
await DuplicatedJavascript._getDuplicationGroupedByNodeModules(artifacts, context);
|
|
133
|
-
const mainDocumentRecord = NetworkAnalyzer.findOptionalMainDocument(networkRecords);
|
|
134
133
|
|
|
135
134
|
/** @type {Map<string, number>} */
|
|
136
135
|
const transferRatioByUrl = new Map();
|
|
@@ -162,9 +161,8 @@ class DuplicatedJavascript extends ByteEfficiencyAudit {
|
|
|
162
161
|
/** @type {number|undefined} */
|
|
163
162
|
let transferRatio = transferRatioByUrl.get(url);
|
|
164
163
|
if (transferRatio === undefined) {
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
networkRecords.find(n => n.url === url);
|
|
164
|
+
const fakeScript = /** @type {LH.Artifacts.ScriptElement} */ ({src: url});
|
|
165
|
+
const networkRecord = getRequestForScript(networkRecords, fakeScript);
|
|
168
166
|
|
|
169
167
|
const script = artifacts.ScriptElements.find(script => script.src === url);
|
|
170
168
|
if (!script || script.content === null) {
|
|
@@ -22,7 +22,7 @@ const ByteEfficiencyAudit = require('./byte-efficiency-audit.js');
|
|
|
22
22
|
const JsBundles = require('../../computed/js-bundles.js');
|
|
23
23
|
const i18n = require('../../lib/i18n/i18n.js');
|
|
24
24
|
const thirdPartyWeb = require('../../lib/third-party-web.js');
|
|
25
|
-
const
|
|
25
|
+
const {getRequestForScript} = require('../../lib/script-helpers.js');
|
|
26
26
|
|
|
27
27
|
const UIStrings = {
|
|
28
28
|
/** Title of a Lighthouse audit that tells the user about legacy polyfills and transforms used on the page. This is displayed in a list of audit titles that Lighthouse generates. */
|
|
@@ -373,11 +373,8 @@ class LegacyJavascript extends ByteEfficiencyAudit {
|
|
|
373
373
|
let transferRatio = transferRatioByUrl.get(url);
|
|
374
374
|
if (transferRatio !== undefined) return transferRatio;
|
|
375
375
|
|
|
376
|
-
const mainDocumentRecord = NetworkAnalyzer.findOptionalMainDocument(networkRecords);
|
|
377
|
-
const networkRecord = url === artifacts.URL.finalUrl ?
|
|
378
|
-
mainDocumentRecord :
|
|
379
|
-
networkRecords.find(n => n.url === url);
|
|
380
376
|
const script = artifacts.ScriptElements.find(script => script.src === url);
|
|
377
|
+
const networkRecord = getRequestForScript(networkRecords, script);
|
|
381
378
|
|
|
382
379
|
if (!script || script.content === null) {
|
|
383
380
|
// Can't find content, so just use 1.
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
const ByteEfficiencyAudit = require('./byte-efficiency-audit.js');
|
|
9
9
|
const i18n = require('../../lib/i18n/i18n.js');
|
|
10
10
|
const computeTokenLength = require('../../lib/minification-estimator.js').computeJSTokenLength;
|
|
11
|
+
const {getRequestForScript} = require('../../lib/script-helpers.js');
|
|
11
12
|
|
|
12
13
|
const UIStrings = {
|
|
13
14
|
/** Imperative title of a Lighthouse audit that tells the user to minify the page’s JS code to reduce file size. This is displayed in a list of audit titles that Lighthouse generates. */
|
|
@@ -78,10 +79,11 @@ class UnminifiedJavaScript extends ByteEfficiencyAudit {
|
|
|
78
79
|
/** @type {Array<LH.Audit.ByteEfficiencyItem>} */
|
|
79
80
|
const items = [];
|
|
80
81
|
const warnings = [];
|
|
81
|
-
for (const
|
|
82
|
+
for (const script of artifacts.ScriptElements) {
|
|
83
|
+
const {src, content} = script;
|
|
82
84
|
if (!content) continue;
|
|
83
85
|
|
|
84
|
-
const networkRecord = networkRecords
|
|
86
|
+
const networkRecord = getRequestForScript(networkRecords, script);
|
|
85
87
|
const displayUrl = !src || !networkRecord ?
|
|
86
88
|
`inline: ${content.substr(0, 40)}...` :
|
|
87
89
|
networkRecord.url;
|
|
@@ -9,6 +9,7 @@ const ByteEfficiencyAudit = require('./byte-efficiency-audit.js');
|
|
|
9
9
|
const UnusedJavaScriptSummary = require('../../computed/unused-javascript-summary.js');
|
|
10
10
|
const JsBundles = require('../../computed/js-bundles.js');
|
|
11
11
|
const i18n = require('../../lib/i18n/i18n.js');
|
|
12
|
+
const {getRequestForScript} = require('../../lib/script-helpers.js');
|
|
12
13
|
|
|
13
14
|
const UIStrings = {
|
|
14
15
|
/** Imperative title of a Lighthouse audit that tells the user to reduce JavaScript that is never evaluated during page load. This is displayed in a list of audit titles that Lighthouse generates. */
|
|
@@ -87,7 +88,8 @@ class UnusedJavaScript extends ByteEfficiencyAudit {
|
|
|
87
88
|
|
|
88
89
|
const items = [];
|
|
89
90
|
for (const [url, scriptCoverages] of Object.entries(artifacts.JsUsage)) {
|
|
90
|
-
const
|
|
91
|
+
const fakeScript = /** @type {LH.Artifacts.ScriptElement} */ ({src: url});
|
|
92
|
+
const networkRecord = getRequestForScript(networkRecords, fakeScript);
|
|
91
93
|
if (!networkRecord) continue;
|
|
92
94
|
const bundle = bundles.find(b => b.script.src === url);
|
|
93
95
|
const unusedJsSummary =
|