lighthouse 9.5.0-dev.20220314 → 9.5.0-dev.20220317

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 (32) hide show
  1. package/lighthouse-cli/test/smokehouse/core-tests.js +2 -0
  2. package/lighthouse-cli/test/smokehouse/lighthouse-runners/cli.js +1 -1
  3. package/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js +1 -0
  4. package/lighthouse-core/audits/byte-efficiency/duplicated-javascript.js +11 -13
  5. package/lighthouse-core/audits/byte-efficiency/legacy-javascript.js +12 -16
  6. package/lighthouse-core/audits/byte-efficiency/unminified-javascript.js +10 -10
  7. package/lighthouse-core/audits/byte-efficiency/unused-javascript.js +11 -6
  8. package/lighthouse-core/audits/deprecations.js +3 -3
  9. package/lighthouse-core/audits/dobetterweb/geolocation-on-start.js +1 -1
  10. package/lighthouse-core/audits/dobetterweb/no-document-write.js +1 -1
  11. package/lighthouse-core/audits/dobetterweb/notification-on-start.js +1 -1
  12. package/lighthouse-core/audits/dobetterweb/uses-passive-event-listeners.js +1 -1
  13. package/lighthouse-core/audits/errors-in-console.js +2 -2
  14. package/lighthouse-core/audits/no-unload-listeners.js +7 -15
  15. package/lighthouse-core/audits/script-elements-test-audit.js +30 -0
  16. package/lighthouse-core/audits/script-treemap-data.js +22 -21
  17. package/lighthouse-core/audits/valid-source-maps.js +12 -14
  18. package/lighthouse-core/audits/violation-audit.js +1 -1
  19. package/lighthouse-core/computed/js-bundles.js +11 -11
  20. package/lighthouse-core/computed/module-duplication.js +6 -5
  21. package/lighthouse-core/computed/unused-javascript-summary.js +16 -36
  22. package/lighthouse-core/config/default-config.js +1 -0
  23. package/lighthouse-core/fraggle-rock/config/default-config.js +3 -0
  24. package/lighthouse-core/gather/gatherers/console-messages.js +4 -2
  25. package/lighthouse-core/gather/gatherers/js-usage.js +6 -52
  26. package/lighthouse-core/gather/gatherers/script-elements.js +7 -56
  27. package/lighthouse-core/gather/gatherers/scripts.js +136 -0
  28. package/lighthouse-core/gather/gatherers/source-maps.js +3 -0
  29. package/lighthouse-core/lib/script-helpers.js +22 -0
  30. package/lighthouse-core/lib/url-shim.js +2 -2
  31. package/package.json +3 -2
  32. package/types/artifacts.d.ts +22 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lighthouse",
3
- "version": "9.5.0-dev.20220314",
3
+ "version": "9.5.0-dev.20220317",
4
4
  "description": "Automated auditing, performance metrics, and best practices for the web.",
5
5
  "main": "./lighthouse-core/index.js",
6
6
  "bin": {
@@ -75,13 +75,14 @@
75
75
  "update:lantern-baseline": "node lighthouse-core/scripts/lantern/update-baseline-lantern-values.js",
76
76
  "update:sample-artifacts": "node lighthouse-core/scripts/update-report-fixtures.js",
77
77
  "update:sample-json": "yarn i18n:collect-strings && node ./lighthouse-cli -A=./lighthouse-core/test/results/artifacts --config-path=./lighthouse-core/test/results/sample-config.js --output=json --output-path=./lighthouse-core/test/results/sample_v2.json && node lighthouse-core/scripts/cleanup-LHR-for-diff.js ./lighthouse-core/test/results/sample_v2.json --only-remove-timing",
78
- "update:flow-sample-json": "node ./lighthouse-core/scripts/update-flow-fixtures.js",
78
+ "update:flow-sample-json": "yarn i18n:collect-strings && node ./lighthouse-core/scripts/update-flow-fixtures.js",
79
79
  "update:snapshot-sample-json": "node ./lighthouse-core/scripts/update-snapshot-sample.js",
80
80
  "update:test-devtools": "bash lighthouse-core/test/chromium-web-tests/test-locally.sh --reset-results",
81
81
  "test-devtools": "bash lighthouse-core/test/chromium-web-tests/test-locally.sh",
82
82
  "open-devtools": "bash lighthouse-core/scripts/open-devtools.sh",
83
83
  "run-devtools": "node lighthouse-core/scripts/pptr-run-devtools.js",
84
84
  "diff:sample-json": "yarn i18n:checks && bash lighthouse-core/scripts/assert-golden-lhr-unchanged.sh",
85
+ "diff:flow-sample-json": "yarn i18n:collect-strings && bash lighthouse-core/scripts/assert-baseline-flow-result-unchanged.sh",
85
86
  "computeBenchmarkIndex": "./lighthouse-core/scripts/benchmark.js",
86
87
  "minify-latest-run": "./lighthouse-core/scripts/lantern/minify-trace.js ./latest-run/defaultPass.trace.json ./latest-run/defaultPass.trace.min.json && ./lighthouse-core/scripts/lantern/minify-devtoolslog.js ./latest-run/defaultPass.devtoolslog.json ./latest-run/defaultPass.devtoolslog.min.json",
87
88
  "save-latest-run": "./lighthouse-core/scripts/save-latest-run.sh",
@@ -147,8 +147,9 @@ export interface GathererArtifacts extends PublicGathererArtifacts,LegacyBaseArt
147
147
  GlobalListeners: Array<Artifacts.GlobalListener>;
148
148
  /** The issues surfaced in the devtools Issues panel */
149
149
  InspectorIssues: Artifacts.InspectorIssues;
150
- /** JS coverage information for code used during page load. Keyed by network URL. */
151
- JsUsage: Record<string, Array<Omit<LH.Crdp.Profiler.ScriptCoverage, 'url'>>>;
150
+ /** JS coverage information for code used during audit. Keyed by script id. */
151
+ // 'url' is excluded because it can be overriden by a magic sourceURL= comment, which makes keeping it a dangerous footgun!
152
+ JsUsage: Record<string, Omit<LH.Crdp.Profiler.ScriptCoverage, 'url'>>;
152
153
  /** Parsed version of the page's Web App Manifest, or null if none found. */
153
154
  Manifest: Artifacts.Manifest | null;
154
155
  /** The URL loaded with interception */
@@ -161,6 +162,8 @@ export interface GathererArtifacts extends PublicGathererArtifacts,LegacyBaseArt
161
162
  ResponseCompression: {requestId: string, url: string, mimeType: string, transferSize: number, resourceSize: number, gzipSize?: number}[];
162
163
  /** Information on fetching and the content of the /robots.txt file. */
163
164
  RobotsTxt: {status: number|null, content: string|null, errorMessage?: string};
165
+ /** Information on all scripts in the page. */
166
+ Scripts: Artifacts.Script[];
164
167
  /** Version information for all ServiceWorkers active after the first page load. */
165
168
  ServiceWorker: {versions: LH.Crdp.ServiceWorker.ServiceWorkerVersion[], registrations: LH.Crdp.ServiceWorker.ServiceWorkerRegistration[]};
166
169
  /** Source maps of scripts executed in the page. */
@@ -287,6 +290,16 @@ declare module Artifacts {
287
290
 
288
291
  interface PasswordInputsWithPreventedPaste {node: NodeDetails}
289
292
 
293
+ interface Script extends Omit<LH.Crdp.Debugger.ScriptParsedEvent, 'url'|'embedderName'> {
294
+ /**
295
+ * Set by a sourceURL= magic comment if present, otherwise this is the same as the URL.
296
+ * Use this field for presentational purposes only.
297
+ */
298
+ name: string;
299
+ url: string;
300
+ content?: string;
301
+ }
302
+
290
303
  interface ScriptElement {
291
304
  type: string | null
292
305
  src: string | null
@@ -298,10 +311,6 @@ declare module Artifacts {
298
311
  node: NodeDetails | null
299
312
  /** Where the script was discovered, either in the head, the body, or network records. */
300
313
  source: 'head'|'body'|'network'
301
- /** The content of the inline script or the network record with the matching URL, null if the script had a src and no network record could be found. */
302
- content: string | null
303
- /** The ID of the network request that matched the URL of the src or the main document if inline, null if no request could be found. */
304
- requestId: string | null
305
314
  }
306
315
 
307
316
  /** @see https://sourcemaps.info/spec.html#h.qz3o9nc69um5 */
@@ -333,6 +342,8 @@ declare module Artifacts {
333
342
  * parsing the map, errorMessage will be defined instead of map.
334
343
  */
335
344
  type SourceMap = {
345
+ /** The DevTools protocol script identifier. */
346
+ scriptId: string;
336
347
  /** URL of code that source map applies to. */
337
348
  scriptUrl: string
338
349
  /** URL of the source map. undefined if from data URL. */
@@ -340,6 +351,8 @@ declare module Artifacts {
340
351
  /** Source map data structure. */
341
352
  map: RawSourceMap
342
353
  } | {
354
+ /** The DevTools protocol script identifier. */
355
+ scriptId: string;
343
356
  /** URL of code that source map applies to. */
344
357
  scriptUrl: string
345
358
  /** URL of the source map. undefined if from data URL. */
@@ -352,7 +365,7 @@ declare module Artifacts {
352
365
 
353
366
  interface Bundle {
354
367
  rawMap: RawSourceMap;
355
- script: ScriptElement;
368
+ script: LH.Artifacts.Script;
356
369
  map: TextSourceMap;
357
370
  sizes: {
358
371
  // TODO(cjamcl): Rename to `sources`.
@@ -848,6 +861,8 @@ declare module Artifacts {
848
861
  stackTrace?: LH.Crdp.Runtime.StackTrace;
849
862
  /** The URL of the log/exception, if known. */
850
863
  url?: string;
864
+ /** The script id of the log/exception, if known. */
865
+ scriptId?: string;
851
866
  /** Line number in the script (0-indexed), if known. */
852
867
  lineNumber?: number;
853
868
  /** Column number in the script (0-indexed), if known. */