lighthouse 9.1.0 → 9.2.0

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.
Files changed (104) hide show
  1. package/changelog.md +51 -4
  2. package/dist/report/bundle.esm.js +3 -3
  3. package/dist/report/flow.js +1 -1
  4. package/dist/report/standalone.js +1 -1
  5. package/flow-report/assets/styles.css +1 -1
  6. package/lighthouse-cli/test/smokehouse/core-tests.js +124 -0
  7. package/lighthouse-cli/test/smokehouse/frontends/lib.js +6 -4
  8. package/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js +2 -49
  9. package/lighthouse-cli/test/smokehouse/readme.md +1 -1
  10. package/lighthouse-cli/test/smokehouse/smokehouse.js +50 -0
  11. package/lighthouse-core/audits/apple-touch-icon.js +2 -2
  12. package/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js +1 -14
  13. package/lighthouse-core/audits/byte-efficiency/legacy-javascript.js +0 -4
  14. package/lighthouse-core/audits/no-unload-listeners.js +1 -1
  15. package/lighthouse-core/computed/computed-artifact.js +14 -7
  16. package/lighthouse-core/computed/critical-request-chains.js +3 -3
  17. package/lighthouse-core/computed/image-records.js +1 -1
  18. package/lighthouse-core/computed/js-bundles.js +1 -1
  19. package/lighthouse-core/computed/load-simulator.js +2 -1
  20. package/lighthouse-core/computed/main-resource.js +1 -1
  21. package/lighthouse-core/computed/main-thread-tasks.js +1 -1
  22. package/lighthouse-core/computed/manifest-values.js +1 -1
  23. package/lighthouse-core/computed/metrics/cumulative-layout-shift.js +1 -1
  24. package/lighthouse-core/computed/metrics/first-contentful-paint-all-frames.js +4 -1
  25. package/lighthouse-core/computed/metrics/first-contentful-paint.js +4 -1
  26. package/lighthouse-core/computed/metrics/first-meaningful-paint.js +4 -1
  27. package/lighthouse-core/computed/metrics/interactive.js +4 -1
  28. package/lighthouse-core/computed/metrics/lantern-first-contentful-paint.js +7 -2
  29. package/lighthouse-core/computed/metrics/lantern-first-meaningful-paint.js +4 -1
  30. package/lighthouse-core/computed/metrics/lantern-interactive.js +4 -1
  31. package/lighthouse-core/computed/metrics/lantern-largest-contentful-paint.js +4 -1
  32. package/lighthouse-core/computed/metrics/lantern-max-potential-fid.js +4 -1
  33. package/lighthouse-core/computed/metrics/lantern-speed-index.js +4 -1
  34. package/lighthouse-core/computed/metrics/lantern-total-blocking-time.js +4 -1
  35. package/lighthouse-core/computed/metrics/largest-contentful-paint-all-frames.js +4 -1
  36. package/lighthouse-core/computed/metrics/largest-contentful-paint.js +4 -1
  37. package/lighthouse-core/computed/metrics/max-potential-fid.js +4 -1
  38. package/lighthouse-core/computed/metrics/speed-index.js +4 -1
  39. package/lighthouse-core/computed/metrics/timing-summary.js +4 -1
  40. package/lighthouse-core/computed/metrics/total-blocking-time.js +4 -1
  41. package/lighthouse-core/computed/module-duplication.js +2 -2
  42. package/lighthouse-core/computed/network-analysis.js +1 -1
  43. package/lighthouse-core/computed/network-records.js +1 -1
  44. package/lighthouse-core/computed/page-dependency-graph.js +26 -16
  45. package/lighthouse-core/computed/processed-navigation.js +1 -1
  46. package/lighthouse-core/computed/processed-trace.js +1 -1
  47. package/lighthouse-core/computed/resource-summary.js +1 -1
  48. package/lighthouse-core/computed/screenshots.js +1 -1
  49. package/lighthouse-core/computed/speedline.js +1 -1
  50. package/lighthouse-core/computed/trace-of-tab.js +1 -1
  51. package/lighthouse-core/computed/unused-css.js +4 -4
  52. package/lighthouse-core/computed/unused-javascript-summary.js +4 -1
  53. package/lighthouse-core/computed/user-timings.js +1 -1
  54. package/lighthouse-core/computed/viewport-meta.js +1 -1
  55. package/lighthouse-core/config/default-config.js +1 -1
  56. package/lighthouse-core/fraggle-rock/gather/base-gatherer.js +1 -1
  57. package/lighthouse-core/fraggle-rock/gather/navigation-runner.js +19 -8
  58. package/lighthouse-core/fraggle-rock/user-flow.js +9 -5
  59. package/lighthouse-core/gather/driver/execution-context.js +2 -0
  60. package/lighthouse-core/gather/driver/wait-for-condition.js +1 -1
  61. package/lighthouse-core/gather/gatherers/accessibility.js +1 -1
  62. package/lighthouse-core/gather/gatherers/anchor-elements.js +1 -1
  63. package/lighthouse-core/gather/gatherers/cache-contents.js +1 -1
  64. package/lighthouse-core/gather/gatherers/console-messages.js +1 -1
  65. package/lighthouse-core/gather/gatherers/dobetterweb/doctype.js +1 -1
  66. package/lighthouse-core/gather/gatherers/dobetterweb/domstats.js +1 -1
  67. package/lighthouse-core/gather/gatherers/dobetterweb/optimized-images.js +1 -1
  68. package/lighthouse-core/gather/gatherers/dobetterweb/password-inputs-with-prevented-paste.js +1 -1
  69. package/lighthouse-core/gather/gatherers/dobetterweb/response-compression.js +1 -1
  70. package/lighthouse-core/gather/gatherers/dobetterweb/tags-blocking-first-paint.js +2 -2
  71. package/lighthouse-core/gather/gatherers/form-elements.js +3 -3
  72. package/lighthouse-core/gather/gatherers/full-page-screenshot.js +1 -1
  73. package/lighthouse-core/gather/gatherers/global-listeners.js +1 -1
  74. package/lighthouse-core/gather/gatherers/iframe-elements.js +1 -1
  75. package/lighthouse-core/gather/gatherers/inspector-issues.js +1 -1
  76. package/lighthouse-core/gather/gatherers/js-usage.js +1 -1
  77. package/lighthouse-core/gather/gatherers/main-document-content.js +1 -1
  78. package/lighthouse-core/gather/gatherers/meta-elements.js +1 -1
  79. package/lighthouse-core/gather/gatherers/script-elements.js +1 -1
  80. package/lighthouse-core/gather/gatherers/seo/embedded-content.js +1 -1
  81. package/lighthouse-core/gather/gatherers/seo/font-size.js +8 -5
  82. package/lighthouse-core/gather/gatherers/seo/robots-txt.js +1 -1
  83. package/lighthouse-core/gather/gatherers/service-worker.js +1 -1
  84. package/lighthouse-core/gather/gatherers/source-maps.js +1 -1
  85. package/lighthouse-core/gather/gatherers/trace-elements.js +1 -1
  86. package/lighthouse-core/gather/gatherers/viewport-dimensions.js +1 -1
  87. package/lighthouse-core/lib/dependency-graph/base-node.js +8 -0
  88. package/lighthouse-core/lib/dependency-graph/simulator/network-analyzer.js +3 -2
  89. package/lighthouse-core/lib/dependency-graph/simulator/simulator.js +17 -0
  90. package/package.json +10 -9
  91. package/report/assets/styles.css +15 -12
  92. package/report/assets/templates.html +1 -1
  93. package/report/renderer/components.js +2 -2
  94. package/report/renderer/report-renderer.js +1 -1
  95. package/report/test/renderer/report-renderer-axe-test.js +48 -53
  96. package/report/test-assets/faux-psi-template.html +85 -26
  97. package/report/test-assets/faux-psi.js +44 -8
  98. package/shared/localization/locales/en-US.json +1 -1
  99. package/shared/localization/locales/en-XL.json +1 -1
  100. package/third-party/chromium-synchronization/inspector-issueAdded-types-test.js +1 -0
  101. package/types/config.d.ts +1 -0
  102. package/types/externs.d.ts +1 -0
  103. package/types/gatherer.d.ts +1 -0
  104. package/types/smokehouse.d.ts +2 -0
@@ -0,0 +1,124 @@
1
+ /**
2
+ * @license Copyright 2019 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 a11y from './test-definitions/a11y.js';
9
+ import byteEfficiency from './test-definitions/byte-efficiency.js';
10
+ import byteGzip from './test-definitions/byte-gzip.js';
11
+ import cspAllowAll from './test-definitions/csp-allow-all.js';
12
+ import cspBlockAll from './test-definitions/csp-block-all.js';
13
+ import cspBlockAllM91 from './test-definitions/csp-block-all-m91.js';
14
+ import dbw from './test-definitions/dobetterweb.js';
15
+ import errorsExpiredSsl from './test-definitions/errors-expired-ssl.js';
16
+ import errorsIframeExpiredSsl from './test-definitions/errors-iframe-expired-ssl.js';
17
+ import errorsInfiniteLoop from './test-definitions/errors-infinite-loop.js';
18
+ // import formsAutoComplete from './test-definitions/forms-autocomplete.js';
19
+ import issuesMixedContent from './test-definitions/issues-mixed-content.js';
20
+ import lanternFetch from './test-definitions/lantern-fetch.js';
21
+ import lanternIdleCallbackLong from './test-definitions/lantern-idle-callback-long.js';
22
+ import lanternIdleCallbackShort from './test-definitions/lantern-idle-callback-short.js';
23
+ import lanternOnline from './test-definitions/lantern-online.js';
24
+ import lanternSetTimeout from './test-definitions/lantern-set-timeout.js';
25
+ import lanternXhr from './test-definitions/lantern-xhr.js';
26
+ import legacyJavascript from './test-definitions/legacy-javascript.js';
27
+ import metricsDebugger from './test-definitions/metrics-debugger.js';
28
+ import metricsDelayedFcp from './test-definitions/metrics-delayed-fcp.js';
29
+ import metricsDelayedLcp from './test-definitions/metrics-delayed-lcp.js';
30
+ import metricsTrickyTti from './test-definitions/metrics-tricky-tti.js';
31
+ import metricsTrickyTtiLateFcp from './test-definitions/metrics-tricky-tti-late-fcp.js';
32
+ import offlineOnlineOnly from './test-definitions/offline-online-only.js';
33
+ import offlineReady from './test-definitions/offline-ready.js';
34
+ import offlineSwBroken from './test-definitions/offline-sw-broken.js';
35
+ import offlineSwSlow from './test-definitions/offline-sw-slow.js';
36
+ import oopifRequests from './test-definitions/oopif-requests.js';
37
+ import perfBudgets from './test-definitions/perf-budgets.js';
38
+ import perfDebug from './test-definitions/perf-debug.js';
39
+ import perfDiagnosticsAnimations from './test-definitions/perf-diagnostics-animations.js';
40
+ import perfDiagnosticsThirdParty from './test-definitions/perf-diagnostics-third-party.js';
41
+ import perfDiagnosticsUnsizedImages from './test-definitions/perf-diagnostics-unsized-images.js';
42
+ import perfFonts from './test-definitions/perf-fonts.js';
43
+ import perfFrameMetrics from './test-definitions/perf-frame-metrics.js';
44
+ import perfPreload from './test-definitions/perf-preload.js';
45
+ import perfTraceElements from './test-definitions/perf-trace-elements.js';
46
+ import pubads from './test-definitions/pubads.js';
47
+ import pwaAirhorner from './test-definitions/pwa-airhorner.js';
48
+ import pwaCaltrain from './test-definitions/pwa-caltrain.js';
49
+ import pwaChromestatus from './test-definitions/pwa-chromestatus.js';
50
+ import pwaRocks from './test-definitions/pwa-rocks.js';
51
+ import pwaSvgomg from './test-definitions/pwa-svgomg.js';
52
+ import redirectsClientPaintServer from './test-definitions/redirects-client-paint-server.js';
53
+ import redirectsHistoryPushState from './test-definitions/redirects-history-push-state.js';
54
+ import redirectsMultipleServer from './test-definitions/redirects-multiple-server.js';
55
+ import redirectsSingleClient from './test-definitions/redirects-single-client.js';
56
+ import redirectsSingleServer from './test-definitions/redirects-single-server.js';
57
+ import screenshot from './test-definitions/screenshot.js';
58
+ import seoFailing from './test-definitions/seo-failing.js';
59
+ import seoPassing from './test-definitions/seo-passing.js';
60
+ import seoStatus403 from './test-definitions/seo-status-403.js';
61
+ import seoTapTargets from './test-definitions/seo-tap-targets.js';
62
+ import sourceMaps from './test-definitions/source-maps.js';
63
+
64
+ /** @type {ReadonlyArray<Smokehouse.TestDfn>} */
65
+ const smokeTests = [
66
+ a11y,
67
+ byteEfficiency,
68
+ byteGzip,
69
+ cspAllowAll,
70
+ cspBlockAll,
71
+ cspBlockAllM91,
72
+ dbw,
73
+ errorsExpiredSsl,
74
+ errorsIframeExpiredSsl,
75
+ errorsInfiniteLoop,
76
+ // TODO: restore when --enable-features=AutofillShowTypePredictions is not needed.
77
+ // formsAutoComplete,
78
+ issuesMixedContent,
79
+ lanternOnline,
80
+ lanternSetTimeout,
81
+ lanternFetch,
82
+ lanternXhr,
83
+ lanternIdleCallbackShort,
84
+ lanternIdleCallbackLong,
85
+ legacyJavascript,
86
+ metricsDebugger,
87
+ metricsDelayedFcp,
88
+ metricsDelayedLcp,
89
+ metricsTrickyTtiLateFcp,
90
+ metricsTrickyTti,
91
+ offlineOnlineOnly,
92
+ offlineReady,
93
+ offlineSwBroken,
94
+ offlineSwSlow,
95
+ oopifRequests,
96
+ perfBudgets,
97
+ perfDebug,
98
+ perfDiagnosticsAnimations,
99
+ perfDiagnosticsThirdParty,
100
+ perfDiagnosticsUnsizedImages,
101
+ perfFonts,
102
+ perfFrameMetrics,
103
+ perfPreload,
104
+ perfTraceElements,
105
+ pubads,
106
+ pwaAirhorner,
107
+ pwaChromestatus,
108
+ pwaSvgomg,
109
+ pwaCaltrain,
110
+ pwaRocks,
111
+ redirectsClientPaintServer,
112
+ redirectsHistoryPushState,
113
+ redirectsMultipleServer,
114
+ redirectsSingleClient,
115
+ redirectsSingleServer,
116
+ screenshot,
117
+ seoFailing,
118
+ seoPassing,
119
+ seoStatus403,
120
+ seoTapTargets,
121
+ sourceMaps,
122
+ ];
123
+
124
+ export default smokeTests;
@@ -15,14 +15,14 @@
15
15
 
16
16
  import cloneDeep from 'lodash.clonedeep';
17
17
 
18
- import smokeTests from '../test-definitions/core-tests.js';
19
- import {runSmokehouse} from '../smokehouse.js';
18
+ import smokeTests from '../core-tests.js';
19
+ import {runSmokehouse, getShardedDefinitions} from '../smokehouse.js';
20
20
 
21
21
  /**
22
22
  * @param {Smokehouse.SmokehouseLibOptions} options
23
23
  */
24
24
  async function smokehouse(options) {
25
- const {urlFilterRegex, skip, modify, ...smokehouseOptions} = options;
25
+ const {urlFilterRegex, skip, modify, shardArg, ...smokehouseOptions} = options;
26
26
 
27
27
  const clonedTests = cloneDeep(smokeTests);
28
28
  const modifiedTests = [];
@@ -41,7 +41,9 @@ async function smokehouse(options) {
41
41
  modifiedTests.push(test);
42
42
  }
43
43
 
44
- return runSmokehouse(modifiedTests, smokehouseOptions);
44
+ const shardedTests = getShardedDefinitions(modifiedTests, shardArg);
45
+
46
+ return runSmokehouse(shardedTests, smokehouseOptions);
45
47
  }
46
48
 
47
49
  export {smokehouse};
@@ -13,7 +13,6 @@
13
13
 
14
14
  /* eslint-disable no-console */
15
15
 
16
- import {strict as assert} from 'assert';
17
16
  import path from 'path';
18
17
  import fs from 'fs';
19
18
  import url from 'url';
@@ -23,12 +22,12 @@ import yargs from 'yargs';
23
22
  import * as yargsHelpers from 'yargs/helpers';
24
23
  import log from 'lighthouse-logger';
25
24
 
26
- import {runSmokehouse} from '../smokehouse.js';
25
+ import {runSmokehouse, getShardedDefinitions} from '../smokehouse.js';
27
26
  import {updateTestDefnFormat} from './back-compat-util.js';
28
27
  import {LH_ROOT} from '../../../../root.js';
29
28
 
30
29
  const coreTestDefnsPath =
31
- path.join(LH_ROOT, 'lighthouse-cli/test/smokehouse/test-definitions/core-tests.js');
30
+ path.join(LH_ROOT, 'lighthouse-cli/test/smokehouse/core-tests.js');
32
31
 
33
32
  /**
34
33
  * Possible Lighthouse runners. Loaded dynamically so e.g. a CLI run isn't
@@ -80,52 +79,6 @@ function getDefinitionsToRun(allTestDefns, requestedIds, {invertMatch}) {
80
79
  return smokes;
81
80
  }
82
81
 
83
- /**
84
- * Parses the cli `shardArg` flag into `shardNumber/shardTotal`. Splits
85
- * `testDefns` into `shardTotal` shards and returns the `shardNumber`th shard.
86
- * Shards will differ in size by at most 1.
87
- * Shard params must be 1 ≤ shardNumber ≤ shardTotal.
88
- * @param {Array<Smokehouse.TestDfn>} testDefns
89
- * @param {string=} shardArg
90
- * @return {Array<Smokehouse.TestDfn>}
91
- */
92
- function getShardedDefinitions(testDefns, shardArg) {
93
- if (!shardArg) return testDefns;
94
-
95
- // eslint-disable-next-line max-len
96
- const errorMessage = `'shard' must be of the form 'n/d' and n and d must be positive integers with 1 ≤ n ≤ d. Got '${shardArg}'`;
97
- const match = /^(?<shardNumber>\d+)\/(?<shardTotal>\d+)$/.exec(shardArg);
98
- assert(match && match.groups, errorMessage);
99
- const shardNumber = Number(match.groups.shardNumber);
100
- const shardTotal = Number(match.groups.shardTotal);
101
- assert(shardNumber > 0 && Number.isInteger(shardNumber), errorMessage);
102
- assert(shardTotal > 0 && Number.isInteger(shardTotal));
103
- assert(shardNumber <= shardTotal, errorMessage);
104
-
105
- // Array is sharded with `Math.ceil(length / shardTotal)` shards first
106
- // and then the remaining `Math.floor(length / shardTotal) shards.
107
- // e.g. `[0, 1, 2, 3]` split into 3 shards is `[[0, 1], [2], [3]]`.
108
- const baseSize = Math.floor(testDefns.length / shardTotal);
109
- const biggerSize = baseSize + 1;
110
- const biggerShardCount = testDefns.length % shardTotal;
111
-
112
- // Since we don't have tests for this file, construct all shards so correct
113
- // structure can be asserted.
114
- const shards = [];
115
- let index = 0;
116
- for (let i = 0; i < shardTotal; i++) {
117
- const shardSize = i < biggerShardCount ? biggerSize : baseSize;
118
- shards.push(testDefns.slice(index, index + shardSize));
119
- index += shardSize;
120
- }
121
- assert.equal(shards.length, shardTotal);
122
- assert.deepEqual(shards.flat(), testDefns);
123
-
124
- const shardDefns = shards[shardNumber - 1];
125
- console.log(`In this shard (${shardArg}), running: ${shardDefns.map(d => d.id).join(' ')}\n`);
126
- return shardDefns;
127
- }
128
-
129
82
  /**
130
83
  * Prune the `networkRequests` from the test expectations when `takeNetworkRequestUrls`
131
84
  * is not defined. Custom servers may not have this method available in-process.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Smokehouse is the Lighthouse end-to-end/smoke test runner. It takes in a set of URLs (usually pointing to custom-built test sites), runs Lighthouse on them, and compares the results against a set of expectations.
4
4
 
5
- By default this is done using the Lighthouse CLI (to exercise the full pipeline) with the tests listed in [`smokehouse/test-definitions/core-tests.js`](./test-definitions/core-tests.js).
5
+ By default this is done using the Lighthouse CLI (to exercise the full pipeline) with the tests listed in [`smokehouse/core-tests.js`](./core-tests.js).
6
6
 
7
7
  ## Options
8
8
 
@@ -32,6 +32,8 @@
32
32
  * @property {Run[]} runs
33
33
  */
34
34
 
35
+ import {strict as assert} from 'assert';
36
+
35
37
  import log from 'lighthouse-logger';
36
38
 
37
39
  import {runLighthouse as cliLighthouseRunner} from './lighthouse-runners/cli.js';
@@ -227,6 +229,54 @@ function getAssertionLog(count) {
227
229
  return `${count} assertion${plural}`;
228
230
  }
229
231
 
232
+ /**
233
+ * Parses the cli `shardArg` flag into `shardNumber/shardTotal`. Splits
234
+ * `testDefns` into `shardTotal` shards and returns the `shardNumber`th shard.
235
+ * Shards will differ in size by at most 1.
236
+ * Shard params must be 1 ≤ shardNumber ≤ shardTotal.
237
+ * @param {Array<Smokehouse.TestDfn>} testDefns
238
+ * @param {string=} shardArg
239
+ * @return {Array<Smokehouse.TestDfn>}
240
+ */
241
+ function getShardedDefinitions(testDefns, shardArg) {
242
+ if (!shardArg) return testDefns;
243
+
244
+ // eslint-disable-next-line max-len
245
+ const errorMessage = `'shard' must be of the form 'n/d' and n and d must be positive integers with 1 ≤ n ≤ d. Got '${shardArg}'`;
246
+ const match = /^(?<shardNumber>\d+)\/(?<shardTotal>\d+)$/.exec(shardArg);
247
+ assert(match && match.groups, errorMessage);
248
+ const shardNumber = Number(match.groups.shardNumber);
249
+ const shardTotal = Number(match.groups.shardTotal);
250
+ assert(shardNumber > 0 && Number.isInteger(shardNumber), errorMessage);
251
+ assert(shardTotal > 0 && Number.isInteger(shardTotal));
252
+ assert(shardNumber <= shardTotal, errorMessage);
253
+
254
+ // Array is sharded with `Math.ceil(length / shardTotal)` shards first
255
+ // and then the remaining `Math.floor(length / shardTotal) shards.
256
+ // e.g. `[0, 1, 2, 3]` split into 3 shards is `[[0, 1], [2], [3]]`.
257
+ const baseSize = Math.floor(testDefns.length / shardTotal);
258
+ const biggerSize = baseSize + 1;
259
+ const biggerShardCount = testDefns.length % shardTotal;
260
+
261
+ // Since we don't have tests for this file, construct all shards so correct
262
+ // structure can be asserted.
263
+ const shards = [];
264
+ let index = 0;
265
+ for (let i = 0; i < shardTotal; i++) {
266
+ const shardSize = i < biggerShardCount ? biggerSize : baseSize;
267
+ shards.push(testDefns.slice(index, index + shardSize));
268
+ index += shardSize;
269
+ }
270
+ assert.equal(shards.length, shardTotal);
271
+ assert.deepEqual(shards.flat(), testDefns);
272
+
273
+ const shardDefns = shards[shardNumber - 1];
274
+ console.log(`In this shard (${shardArg}), running: ${shardDefns.map(d => d.id).join(' ')}\n`);
275
+ return shardDefns;
276
+ }
277
+
278
+
230
279
  export {
231
280
  runSmokehouse,
281
+ getShardedDefinitions,
232
282
  };
@@ -56,8 +56,8 @@ class AppleTouchIcon extends Audit {
56
56
  const passed = appleTouchIcons.length !== 0;
57
57
 
58
58
  const warnings = [];
59
- if (appleTouchIcons.filter(el => el.rel === 'apple-touch-icon-precomposed').length !== 0
60
- && appleTouchIcons.filter(el => el.rel === 'apple-touch-icon').length === 0) {
59
+ if (appleTouchIcons.filter(el => el.rel === 'apple-touch-icon-precomposed').length !== 0 &&
60
+ appleTouchIcons.filter(el => el.rel === 'apple-touch-icon').length === 0) {
61
61
  warnings.push(str_(UIStrings.precomposedWarning));
62
62
  }
63
63
 
@@ -200,19 +200,6 @@ class UnusedBytes extends Audit {
200
200
  return Math.round(Math.max(savings, 0) / 10) * 10;
201
201
  }
202
202
 
203
- /**
204
- * @param {number} wastedBytes
205
- * @param {Simulator} simulator
206
- */
207
- static computeWastedMsWithThroughput(wastedBytes, simulator) {
208
- const bitsPerSecond = simulator.getOptions().throughput;
209
- // https://github.com/GoogleChrome/lighthouse/pull/13323#issuecomment-962031709
210
- if (bitsPerSecond === 0) return 0;
211
- const wastedBits = wastedBytes * 8;
212
- const wastedMs = wastedBits / bitsPerSecond * 1000;
213
- return wastedMs;
214
- }
215
-
216
203
  /**
217
204
  * @param {ByteEfficiencyProduct} result
218
205
  * @param {Node|null} graph
@@ -232,7 +219,7 @@ class UnusedBytes extends Audit {
232
219
  providedWastedBytesByUrl: result.wastedBytesByUrl,
233
220
  });
234
221
  } else {
235
- wastedMs = this.computeWastedMsWithThroughput(wastedBytes, simulator);
222
+ wastedMs = simulator.computeWastedMsFromWastedBytes(wastedBytes);
236
223
  }
237
224
 
238
225
  let displayValue = result.displayValue || '';
@@ -178,8 +178,6 @@ class LegacyJavascript extends ByteEfficiencyAudit {
178
178
  ['Array.isArray', 'es6.array.is-array'],
179
179
  ['Array.prototype.map', 'es6.array.map'],
180
180
  ['Array.of', 'es6.array.of'],
181
- ['Array.prototype.reduce', 'es6.array.reduce'],
182
- ['Array.prototype.reduceRight', 'es6.array.reduce-right'],
183
181
  ['Array.prototype.some', 'es6.array.some'],
184
182
  ['Date.now', 'es6.date.now'],
185
183
  ['Date.prototype.toISOString', 'es6.date.to-iso-string'],
@@ -188,11 +186,9 @@ class LegacyJavascript extends ByteEfficiencyAudit {
188
186
  ['Function.prototype.name', 'es6.function.name'],
189
187
  ['Number.isInteger', 'es6.number.is-integer'],
190
188
  ['Number.isSafeInteger', 'es6.number.is-safe-integer'],
191
- ['Number.parseInt', 'es6.number.parse-int'],
192
189
  ['Object.defineProperties', 'es6.object.define-properties'],
193
190
  ['Object.defineProperty', 'es6.object.define-property'],
194
191
  ['Object.freeze', 'es6.object.freeze'],
195
- ['Object.getOwnPropertyNames', 'es6.object.get-own-property-names'],
196
192
  ['Object.getPrototypeOf', 'es6.object.get-prototype-of'],
197
193
  ['Object.isExtensible', 'es6.object.is-extensible'],
198
194
  ['Object.isFrozen', 'es6.object.is-frozen'],
@@ -15,7 +15,7 @@ const UIStrings = {
15
15
  /** Descriptive title of a Lighthouse audit that checks if a web page has 'unload' event listeners and finds that it is using them. */
16
16
  failureTitle: 'Registers an `unload` listener',
17
17
  /** Description of a Lighthouse audit that tells the user why pages should not use the 'unload' event. This is displayed after a user expands the section to see more. 'Learn More' becomes link text to additional documentation. */
18
- description: 'The `unload` event does not fire reliably and listening for it can prevent browser optimizations like the Back-Forward Cache. Consider using the `pagehide` or `visibilitychange` events instead. [Learn more](https://developers.google.com/web/updates/2018/07/page-lifecycle-api#the-unload-event)',
18
+ description: 'The `unload` event does not fire reliably and listening for it can prevent browser optimizations like the Back-Forward Cache. Use `pagehide` or `visibilitychange` events instead. [Learn more](https://web.dev/bfcache/#never-use-the-unload-event)',
19
19
  };
20
20
 
21
21
  const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
@@ -11,20 +11,26 @@ const log = require('lighthouse-logger');
11
11
  /**
12
12
  * Decorate computableArtifact with a caching `request()` method which will
13
13
  * automatically call `computableArtifact.compute_()` under the hood.
14
- * @template {{name: string, compute_(artifacts: unknown, context: LH.Artifacts.ComputedContext): Promise<unknown>}} C
14
+ * @template {{name: string, compute_(dependencies: unknown, context: LH.Artifacts.ComputedContext): Promise<unknown>}} C
15
+ * @template {Array<keyof FirstParamType<C['compute_']>>} K
15
16
  * @param {C} computableArtifact
17
+ * @param {(K & ([keyof FirstParamType<C['compute_']>] extends [K[number]] ? unknown : never)) | null} keys List of properties of `dependencies` used by `compute_`; other properties are filtered out. Use `null` to allow all properties. Ensures that only required properties are used for caching result.
16
18
  */
17
- function makeComputedArtifact(computableArtifact) {
19
+ function makeComputedArtifact(computableArtifact, keys) {
18
20
  // tsc (3.1) has more difficulty with template inter-references in jsdoc, so
19
21
  // give types to params and return value the long way, essentially recreating
20
22
  // polymorphic-this behavior for C.
21
23
  /**
22
24
  * Return an automatically cached result from the computed artifact.
23
- * @param {FirstParamType<C['compute_']>} artifacts
25
+ * @param {FirstParamType<C['compute_']>} dependencies
24
26
  * @param {LH.Artifacts.ComputedContext} context
25
27
  * @return {ReturnType<C['compute_']>}
26
28
  */
27
- const request = (artifacts, context) => {
29
+ const request = (dependencies, context) => {
30
+ const pickedDependencies = keys ?
31
+ Object.fromEntries(keys.map(key => [key, dependencies[key]])) :
32
+ dependencies;
33
+
28
34
  // NOTE: break immutability solely for this caching-controller function.
29
35
  const computedCache = /** @type {Map<string, ArbitraryEqualityMap>} */ (context.computedCache);
30
36
  const computedName = computableArtifact.name;
@@ -32,7 +38,8 @@ function makeComputedArtifact(computableArtifact) {
32
38
  const cache = computedCache.get(computedName) || new ArbitraryEqualityMap();
33
39
  computedCache.set(computedName, cache);
34
40
 
35
- const computed = /** @type {ReturnType<C['compute_']>|undefined} */ (cache.get(artifacts));
41
+ /** @type {ReturnType<C['compute_']>|undefined} */
42
+ const computed = cache.get(pickedDependencies);
36
43
  if (computed) {
37
44
  return computed;
38
45
  }
@@ -41,8 +48,8 @@ function makeComputedArtifact(computableArtifact) {
41
48
  log.time(status, 'verbose');
42
49
 
43
50
  const artifactPromise = /** @type {ReturnType<C['compute_']>} */
44
- (computableArtifact.compute_(artifacts, context));
45
- cache.set(artifacts, artifactPromise);
51
+ (computableArtifact.compute_(pickedDependencies, context));
52
+ cache.set(pickedDependencies, artifactPromise);
46
53
 
47
54
  artifactPromise.then(() => log.timeEnd(status)).catch(() => log.timeEnd(status));
48
55
 
@@ -41,8 +41,8 @@ class CriticalRequestChains {
41
41
  }
42
42
 
43
43
  // Iframes are considered High Priority but they are not render blocking
44
- const isIframe = request.resourceType === NetworkRequest.TYPES.Document
45
- && request.frameId !== mainResource.frameId;
44
+ const isIframe = request.resourceType === NetworkRequest.TYPES.Document &&
45
+ request.frameId !== mainResource.frameId;
46
46
  // XHRs are fetched at High priority, but we exclude them, as they are unlikely to be critical
47
47
  // Images are also non-critical.
48
48
  // Treat any missed images, primarily favicons, as non-critical resources
@@ -143,4 +143,4 @@ class CriticalRequestChains {
143
143
  }
144
144
  }
145
145
 
146
- module.exports = makeComputedArtifact(CriticalRequestChains);
146
+ module.exports = makeComputedArtifact(CriticalRequestChains, ['URL', 'devtoolsLog', 'trace']);
@@ -59,5 +59,5 @@ class ImageRecords {
59
59
  }
60
60
  }
61
61
 
62
- module.exports = makeComputedArtifact(ImageRecords);
62
+ module.exports = makeComputedArtifact(ImageRecords, ['ImageElements', 'networkRecords']);
63
63
 
@@ -116,4 +116,4 @@ class JSBundles {
116
116
  }
117
117
  }
118
118
 
119
- module.exports = makeComputedArtifact(JSBundles);
119
+ module.exports = makeComputedArtifact(JSBundles, ['ScriptElements', 'SourceMaps']);
@@ -24,6 +24,7 @@ class LoadSimulator {
24
24
  const options = {
25
25
  additionalRttByOrigin: networkAnalysis.additionalRttByOrigin,
26
26
  serverResponseTimeByOrigin: networkAnalysis.serverResponseTimeByOrigin,
27
+ observedThroughput: networkAnalysis.throughput,
27
28
  };
28
29
 
29
30
  // If we have precomputed lantern data, overwrite our observed estimates and use precomputed instead
@@ -88,4 +89,4 @@ class LoadSimulator {
88
89
  }
89
90
  }
90
91
 
91
- module.exports = makeComputedArtifact(LoadSimulator);
92
+ module.exports = makeComputedArtifact(LoadSimulator, ['devtoolsLog', 'settings']);
@@ -31,4 +31,4 @@ class MainResource {
31
31
  }
32
32
  }
33
33
 
34
- module.exports = makeComputedArtifact(MainResource);
34
+ module.exports = makeComputedArtifact(MainResource, ['URL', 'devtoolsLog']);
@@ -21,4 +21,4 @@ class MainThreadTasks {
21
21
  }
22
22
  }
23
23
 
24
- module.exports = makeComputedArtifact(MainThreadTasks);
24
+ module.exports = makeComputedArtifact(MainThreadTasks, null);
@@ -132,4 +132,4 @@ class ManifestValues {
132
132
  }
133
133
  }
134
134
 
135
- module.exports = makeComputedArtifact(ManifestValues);
135
+ module.exports = makeComputedArtifact(ManifestValues, ['InstallabilityErrors', 'WebAppManifest']);
@@ -126,4 +126,4 @@ class CumulativeLayoutShift {
126
126
  }
127
127
  }
128
128
 
129
- module.exports = makeComputedArtifact(CumulativeLayoutShift);
129
+ module.exports = makeComputedArtifact(CumulativeLayoutShift, null);
@@ -31,4 +31,7 @@ class FirstContentfulPaintAllFrames extends NavigationMetric {
31
31
  }
32
32
  }
33
33
 
34
- module.exports = makeComputedArtifact(FirstContentfulPaintAllFrames);
34
+ module.exports = makeComputedArtifact(
35
+ FirstContentfulPaintAllFrames,
36
+ ['devtoolsLog', 'gatherContext', 'settings', 'simulator', 'trace']
37
+ );
@@ -34,4 +34,7 @@ class FirstContentfulPaint extends NavigationMetric {
34
34
  }
35
35
  }
36
36
 
37
- module.exports = makeComputedArtifact(FirstContentfulPaint);
37
+ module.exports = makeComputedArtifact(
38
+ FirstContentfulPaint,
39
+ ['devtoolsLog', 'gatherContext', 'settings', 'simulator', 'trace']
40
+ );
@@ -38,4 +38,7 @@ class FirstMeaningfulPaint extends NavigationMetric {
38
38
  }
39
39
  }
40
40
 
41
- module.exports = makeComputedArtifact(FirstMeaningfulPaint);
41
+ module.exports = makeComputedArtifact(
42
+ FirstMeaningfulPaint,
43
+ ['devtoolsLog', 'gatherContext', 'settings', 'simulator', 'trace']
44
+ );
@@ -181,7 +181,10 @@ class Interactive extends NavigationMetric {
181
181
  }
182
182
  }
183
183
 
184
- module.exports = makeComputedArtifact(Interactive);
184
+ module.exports = makeComputedArtifact(
185
+ Interactive,
186
+ ['devtoolsLog', 'gatherContext', 'settings', 'simulator', 'trace']
187
+ );
185
188
 
186
189
  /**
187
190
  * @typedef TimePeriod
@@ -150,7 +150,9 @@ class LanternFirstContentfulPaint extends LanternMetric {
150
150
  return dependencyGraph.cloneWithRelationships(node => {
151
151
  if (node.type === BaseNode.TYPES.NETWORK) {
152
152
  // Exclude all nodes that ended after paintTs (except for the main document which we always consider necessary)
153
- if (node.endTime > paintTs && !node.isMainDocument()) return false;
153
+ // endTime is negative if request does not finish, make sure startTime isn't after paintTs in this case.
154
+ const endedAfterPaint = node.endTime > paintTs || node.startTime > paintTs;
155
+ if (endedAfterPaint && !node.isMainDocument()) return false;
154
156
 
155
157
  const url = node.record.url;
156
158
  // If the URL definitely wasn't render-blocking then we filter it out.
@@ -196,4 +198,7 @@ class LanternFirstContentfulPaint extends LanternMetric {
196
198
  }
197
199
  }
198
200
 
199
- module.exports = makeComputedArtifact(LanternFirstContentfulPaint);
201
+ module.exports = makeComputedArtifact(
202
+ LanternFirstContentfulPaint,
203
+ ['devtoolsLog', 'gatherContext', 'settings', 'simulator', 'trace']
204
+ );
@@ -77,4 +77,7 @@ class LanternFirstMeaningfulPaint extends LanternMetric {
77
77
  }
78
78
  }
79
79
 
80
- module.exports = makeComputedArtifact(LanternFirstMeaningfulPaint);
80
+ module.exports = makeComputedArtifact(
81
+ LanternFirstMeaningfulPaint,
82
+ ['devtoolsLog', 'gatherContext', 'settings', 'simulator', 'trace']
83
+ );
@@ -107,4 +107,7 @@ class LanternInteractive extends LanternMetric {
107
107
  }
108
108
  }
109
109
 
110
- module.exports = makeComputedArtifact(LanternInteractive);
110
+ module.exports = makeComputedArtifact(
111
+ LanternInteractive,
112
+ ['devtoolsLog', 'gatherContext', 'settings', 'simulator', 'trace']
113
+ );
@@ -105,4 +105,7 @@ class LanternLargestContentfulPaint extends LanternMetric {
105
105
  }
106
106
  }
107
107
 
108
- module.exports = makeComputedArtifact(LanternLargestContentfulPaint);
108
+ module.exports = makeComputedArtifact(
109
+ LanternLargestContentfulPaint,
110
+ ['devtoolsLog', 'gatherContext', 'settings', 'simulator', 'trace']
111
+ );
@@ -87,4 +87,7 @@ class LanternMaxPotentialFID extends LanternMetricArtifact {
87
87
  }
88
88
  }
89
89
 
90
- module.exports = makeComputedArtifact(LanternMaxPotentialFID);
90
+ module.exports = makeComputedArtifact(
91
+ LanternMaxPotentialFID,
92
+ ['devtoolsLog', 'gatherContext', 'settings', 'simulator', 'trace']
93
+ );
@@ -144,4 +144,7 @@ class LanternSpeedIndex extends LanternMetric {
144
144
  }
145
145
  }
146
146
 
147
- module.exports = makeComputedArtifact(LanternSpeedIndex);
147
+ module.exports = makeComputedArtifact(
148
+ LanternSpeedIndex,
149
+ ['devtoolsLog', 'gatherContext', 'settings', 'simulator', 'trace']
150
+ );
@@ -120,4 +120,7 @@ class LanternTotalBlockingTime extends LanternMetric {
120
120
  }
121
121
  }
122
122
 
123
- module.exports = makeComputedArtifact(LanternTotalBlockingTime);
123
+ module.exports = makeComputedArtifact(
124
+ LanternTotalBlockingTime,
125
+ ['devtoolsLog', 'gatherContext', 'settings', 'simulator', 'trace']
126
+ );
@@ -39,4 +39,7 @@ class LargestContentfulPaintAllFrames extends NavigationMetric {
39
39
  }
40
40
  }
41
41
 
42
- module.exports = makeComputedArtifact(LargestContentfulPaintAllFrames);
42
+ module.exports = makeComputedArtifact(
43
+ LargestContentfulPaintAllFrames,
44
+ ['devtoolsLog', 'gatherContext', 'settings', 'simulator', 'trace']
45
+ );