lighthouse 9.5.0-dev.20220327 → 9.5.0-dev.20220330

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 (70) hide show
  1. package/dist/report/bundle.esm.js +20 -18
  2. package/dist/report/flow.js +1 -1
  3. package/dist/report/standalone.js +1 -1
  4. package/lighthouse-cli/test/smokehouse/lighthouse-runners/devtools.js +26 -18
  5. package/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js +2 -2
  6. package/lighthouse-core/audits/byte-efficiency/duplicated-javascript.js +1 -1
  7. package/lighthouse-core/audits/byte-efficiency/efficient-animated-content.js +1 -1
  8. package/lighthouse-core/audits/byte-efficiency/legacy-javascript.js +15 -16
  9. package/lighthouse-core/audits/byte-efficiency/offscreen-images.js +3 -2
  10. package/lighthouse-core/audits/byte-efficiency/render-blocking-resources.js +2 -2
  11. package/lighthouse-core/audits/byte-efficiency/unused-javascript.js +1 -1
  12. package/lighthouse-core/audits/byte-efficiency/uses-responsive-images.js +1 -1
  13. package/lighthouse-core/audits/byte-efficiency/uses-text-compression.js +1 -1
  14. package/lighthouse-core/audits/dobetterweb/uses-http2.js +2 -1
  15. package/lighthouse-core/audits/long-tasks.js +3 -2
  16. package/lighthouse-core/audits/metrics/first-contentful-paint-3g.js +2 -2
  17. package/lighthouse-core/audits/metrics/first-contentful-paint.js +3 -2
  18. package/lighthouse-core/audits/metrics/first-meaningful-paint.js +3 -2
  19. package/lighthouse-core/audits/metrics/interactive.js +3 -2
  20. package/lighthouse-core/audits/metrics/largest-contentful-paint.js +3 -2
  21. package/lighthouse-core/audits/metrics/max-potential-fid.js +3 -2
  22. package/lighthouse-core/audits/metrics/speed-index.js +3 -2
  23. package/lighthouse-core/audits/metrics/total-blocking-time.js +3 -2
  24. package/lighthouse-core/audits/metrics.js +3 -2
  25. package/lighthouse-core/audits/predictive-perf.js +2 -1
  26. package/lighthouse-core/audits/preload-lcp-image.js +1 -1
  27. package/lighthouse-core/audits/redirects.js +1 -1
  28. package/lighthouse-core/audits/timing-budget.js +3 -2
  29. package/lighthouse-core/audits/uses-rel-preconnect.js +1 -1
  30. package/lighthouse-core/audits/uses-rel-preload.js +1 -1
  31. package/lighthouse-core/computed/critical-request-chains.js +2 -9
  32. package/lighthouse-core/computed/main-resource.js +1 -1
  33. package/lighthouse-core/computed/metrics/first-contentful-paint-all-frames.js +1 -1
  34. package/lighthouse-core/computed/metrics/first-contentful-paint.js +1 -1
  35. package/lighthouse-core/computed/metrics/first-meaningful-paint.js +1 -1
  36. package/lighthouse-core/computed/metrics/interactive.js +1 -1
  37. package/lighthouse-core/computed/metrics/lantern-first-contentful-paint.js +1 -1
  38. package/lighthouse-core/computed/metrics/lantern-first-meaningful-paint.js +1 -1
  39. package/lighthouse-core/computed/metrics/lantern-interactive.js +1 -1
  40. package/lighthouse-core/computed/metrics/lantern-largest-contentful-paint.js +1 -1
  41. package/lighthouse-core/computed/metrics/lantern-max-potential-fid.js +1 -1
  42. package/lighthouse-core/computed/metrics/lantern-metric.js +3 -5
  43. package/lighthouse-core/computed/metrics/lantern-speed-index.js +1 -1
  44. package/lighthouse-core/computed/metrics/lantern-total-blocking-time.js +1 -1
  45. package/lighthouse-core/computed/metrics/largest-contentful-paint-all-frames.js +1 -1
  46. package/lighthouse-core/computed/metrics/largest-contentful-paint.js +1 -1
  47. package/lighthouse-core/computed/metrics/max-potential-fid.js +1 -1
  48. package/lighthouse-core/computed/metrics/metric.js +1 -0
  49. package/lighthouse-core/computed/metrics/speed-index.js +1 -1
  50. package/lighthouse-core/computed/metrics/timing-summary.js +13 -6
  51. package/lighthouse-core/computed/metrics/total-blocking-time.js +1 -1
  52. package/lighthouse-core/computed/page-dependency-graph.js +54 -31
  53. package/lighthouse-core/fraggle-rock/gather/base-artifacts.js +8 -1
  54. package/lighthouse-core/fraggle-rock/gather/navigation-runner.js +32 -22
  55. package/lighthouse-core/fraggle-rock/gather/snapshot-runner.js +6 -2
  56. package/lighthouse-core/fraggle-rock/gather/timespan-runner.js +8 -4
  57. package/lighthouse-core/gather/driver/execution-context.js +4 -2
  58. package/lighthouse-core/gather/driver/navigation.js +9 -9
  59. package/lighthouse-core/gather/driver/network-monitor.js +16 -3
  60. package/lighthouse-core/gather/driver.js +5 -0
  61. package/lighthouse-core/gather/gather-runner.js +13 -7
  62. package/lighthouse-core/gather/gatherers/js-usage.js +7 -6
  63. package/lighthouse-core/gather/gatherers/scripts.js +20 -2
  64. package/lighthouse-core/lib/dependency-graph/simulator/network-analyzer.js +8 -29
  65. package/lighthouse-core/lib/navigation-error.js +13 -4
  66. package/lighthouse-core/util-commonjs.js +20 -18
  67. package/package.json +1 -1
  68. package/report/renderer/util.js +20 -18
  69. package/types/artifacts.d.ts +25 -2
  70. package/types/gatherer.d.ts +1 -0
@@ -7,6 +7,7 @@
7
7
 
8
8
  const LHError = require('./lh-error.js');
9
9
  const NetworkAnalyzer = require('./dependency-graph/simulator/network-analyzer.js');
10
+ const NetworkRequest = require('./network-request.js');
10
11
 
11
12
  /**
12
13
  * Returns an error if the original network request failed or wasn't found.
@@ -100,10 +101,18 @@ function getNonHtmlError(finalRecord) {
100
101
  function getPageLoadError(navigationError, context) {
101
102
  const {url, loadFailureMode, networkRecords} = context;
102
103
  /** @type {LH.Artifacts.NetworkRequest|undefined} */
103
- let mainRecord;
104
- try {
105
- mainRecord = NetworkAnalyzer.findMainDocument(networkRecords, url);
106
- } catch (_) {}
104
+ let mainRecord = NetworkAnalyzer.findResourceForUrl(networkRecords, url);
105
+
106
+ // If the url doesn't give us a network request, it's possible we landed on a chrome-error:// page
107
+ // In this case, just get the first document request.
108
+ if (!mainRecord) {
109
+ const documentRequests = networkRecords.filter(record =>
110
+ record.resourceType === NetworkRequest.TYPES.Document
111
+ );
112
+ if (documentRequests.length) {
113
+ mainRecord = documentRequests.reduce((min, r) => (r.startTime < min.startTime ? r : min));
114
+ }
115
+ }
107
116
 
108
117
  // MIME Type is only set on the final redirected document request. Use this for the HTML check instead of root.
109
118
  let finalRecord;
@@ -318,24 +318,26 @@ class Util {
318
318
  }
319
319
 
320
320
  const MAX_LENGTH = 64;
321
- // Always elide hexadecimal hash
322
- name = name.replace(/([a-f0-9]{7})[a-f0-9]{13}[a-f0-9]*/g, `$1${ELLIPSIS}`);
323
- // Also elide other hash-like mixed-case strings
324
- name = name.replace(/([a-zA-Z0-9-_]{9})(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9-_]{10,}/g,
325
- `$1${ELLIPSIS}`);
326
- // Also elide long number sequences
327
- name = name.replace(/(\d{3})\d{6,}/g, `$1${ELLIPSIS}`);
328
- // Merge any adjacent ellipses
329
- name = name.replace(/\u2026+/g, ELLIPSIS);
330
-
331
- // Elide query params first
332
- if (name.length > MAX_LENGTH && name.includes('?')) {
333
- // Try to leave the first query parameter intact
334
- name = name.replace(/\?([^=]*)(=)?.*/, `?$1$2${ELLIPSIS}`);
335
-
336
- // Remove it all if it's still too long
337
- if (name.length > MAX_LENGTH) {
338
- name = name.replace(/\?.*/, `?${ELLIPSIS}`);
321
+ if (parsedUrl.protocol !== 'data:') {
322
+ // Always elide hexadecimal hash
323
+ name = name.replace(/([a-f0-9]{7})[a-f0-9]{13}[a-f0-9]*/g, `$1${ELLIPSIS}`);
324
+ // Also elide other hash-like mixed-case strings
325
+ name = name.replace(/([a-zA-Z0-9-_]{9})(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9-_]{10,}/g,
326
+ `$1${ELLIPSIS}`);
327
+ // Also elide long number sequences
328
+ name = name.replace(/(\d{3})\d{6,}/g, `$1${ELLIPSIS}`);
329
+ // Merge any adjacent ellipses
330
+ name = name.replace(/\u2026+/g, ELLIPSIS);
331
+
332
+ // Elide query params first
333
+ if (name.length > MAX_LENGTH && name.includes('?')) {
334
+ // Try to leave the first query parameter intact
335
+ name = name.replace(/\?([^=]*)(=)?.*/, `?$1$2${ELLIPSIS}`);
336
+
337
+ // Remove it all if it's still too long
338
+ if (name.length > MAX_LENGTH) {
339
+ name = name.replace(/\?.*/, `?${ELLIPSIS}`);
340
+ }
339
341
  }
340
342
  }
341
343
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lighthouse",
3
- "version": "9.5.0-dev.20220327",
3
+ "version": "9.5.0-dev.20220330",
4
4
  "description": "Automated auditing, performance metrics, and best practices for the web.",
5
5
  "main": "./lighthouse-core/index.js",
6
6
  "bin": {
@@ -315,24 +315,26 @@ class Util {
315
315
  }
316
316
 
317
317
  const MAX_LENGTH = 64;
318
- // Always elide hexadecimal hash
319
- name = name.replace(/([a-f0-9]{7})[a-f0-9]{13}[a-f0-9]*/g, `$1${ELLIPSIS}`);
320
- // Also elide other hash-like mixed-case strings
321
- name = name.replace(/([a-zA-Z0-9-_]{9})(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9-_]{10,}/g,
322
- `$1${ELLIPSIS}`);
323
- // Also elide long number sequences
324
- name = name.replace(/(\d{3})\d{6,}/g, `$1${ELLIPSIS}`);
325
- // Merge any adjacent ellipses
326
- name = name.replace(/\u2026+/g, ELLIPSIS);
327
-
328
- // Elide query params first
329
- if (name.length > MAX_LENGTH && name.includes('?')) {
330
- // Try to leave the first query parameter intact
331
- name = name.replace(/\?([^=]*)(=)?.*/, `?$1$2${ELLIPSIS}`);
332
-
333
- // Remove it all if it's still too long
334
- if (name.length > MAX_LENGTH) {
335
- name = name.replace(/\?.*/, `?${ELLIPSIS}`);
318
+ if (parsedUrl.protocol !== 'data:') {
319
+ // Always elide hexadecimal hash
320
+ name = name.replace(/([a-f0-9]{7})[a-f0-9]{13}[a-f0-9]*/g, `$1${ELLIPSIS}`);
321
+ // Also elide other hash-like mixed-case strings
322
+ name = name.replace(/([a-zA-Z0-9-_]{9})(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9-_]{10,}/g,
323
+ `$1${ELLIPSIS}`);
324
+ // Also elide long number sequences
325
+ name = name.replace(/(\d{3})\d{6,}/g, `$1${ELLIPSIS}`);
326
+ // Merge any adjacent ellipses
327
+ name = name.replace(/\u2026+/g, ELLIPSIS);
328
+
329
+ // Elide query params first
330
+ if (name.length > MAX_LENGTH && name.includes('?')) {
331
+ // Try to leave the first query parameter intact
332
+ name = name.replace(/\?([^=]*)(=)?.*/, `?$1$2${ELLIPSIS}`);
333
+
334
+ // Remove it all if it's still too long
335
+ if (name.length > MAX_LENGTH) {
336
+ name = name.replace(/\?.*/, `?${ELLIPSIS}`);
337
+ }
336
338
  }
337
339
  }
338
340
 
@@ -66,7 +66,7 @@ interface UniversalBaseArtifacts {
66
66
  */
67
67
  interface ContextualBaseArtifacts {
68
68
  /** The URL initially requested and the post-redirects URL that was actually loaded. */
69
- URL: {requestedUrl: string, finalUrl: string};
69
+ URL: Artifacts.URL;
70
70
  /** If loading the page failed, value is the error that caused it. Otherwise null. */
71
71
  PageLoadError: LighthouseError | null;
72
72
  }
@@ -187,6 +187,28 @@ declare module Artifacts {
187
187
  type TaskNode = _TaskNode;
188
188
  type MetaElement = Artifacts['MetaElements'][0];
189
189
 
190
+ interface URL {
191
+ /** URL of the main frame before Lighthouse starts. */
192
+ initialUrl: string;
193
+ /**
194
+ * URL of the first document request during a Lighthouse navigation.
195
+ * Will be the same as `initialUrl` in timespan/snapshot.
196
+ * TODO: Make this property `undefined` in timespan/snapshot.
197
+ */
198
+ requestedUrl: string;
199
+ /**
200
+ * URL of the last document request during a Lighthouse navigation.
201
+ * Will be `undefined` in timespan/snapshot.
202
+ */
203
+ mainDocumentUrl?: string;
204
+ /**
205
+ * Will be the same as `mainDocumentUrl` in navigation mode.
206
+ * Wil be the URL of the main frame after Lighthouse finishes in timespan/snapshot.
207
+ * TODO: Use the main frame URL in navigation mode as well.
208
+ */
209
+ finalUrl: string;
210
+ }
211
+
190
212
  interface NodeDetails {
191
213
  lhId: string,
192
214
  devtoolsNodePath: string,
@@ -299,7 +321,7 @@ declare module Artifacts {
299
321
  url: string;
300
322
  content?: string;
301
323
  }
302
-
324
+
303
325
  interface ScriptElement {
304
326
  type: string | null
305
327
  src: string | null
@@ -619,6 +641,7 @@ declare module Artifacts {
619
641
  settings: Immutable<Config.Settings>;
620
642
  gatherContext: Artifacts['GatherContext'];
621
643
  simulator?: InstanceType<typeof LanternSimulator>;
644
+ URL: Artifacts['URL'];
622
645
  }
623
646
 
624
647
  interface MetricComputationData extends MetricComputationDataInput {
@@ -42,6 +42,7 @@ declare module Gatherer {
42
42
  defaultSession: FRProtocolSession;
43
43
  executionContext: ExecutionContext;
44
44
  fetcher: Fetcher;
45
+ url: () => Promise<string>;
45
46
  }
46
47
 
47
48
  /** The limited context interface shared between pre and post Fraggle Rock Lighthouse. */