lighthouse 9.5.0-dev.20230115 → 9.5.0-dev.20230117

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/.codecov.yml CHANGED
@@ -20,3 +20,8 @@ coverage:
20
20
  patch:
21
21
  default:
22
22
  if_not_found: success
23
+
24
+ # docs:
25
+ # https://docs.codecov.com/docs/ignoring-paths
26
+ ignore:
27
+ - "core/util.cjs" # file is a copy of report/renderer/util.js
@@ -39,10 +39,7 @@ async function getBaseArtifacts(resolvedConfig, driver, context) {
39
39
  PageLoadError: null,
40
40
  GatherContext: context,
41
41
  // Artifacts that have been replaced by regular gatherers in Fraggle Rock.
42
- Stacks: [],
43
42
  NetworkUserAgent: '',
44
- WebAppManifest: null,
45
- InstallabilityErrors: {errors: []},
46
43
  traces: {},
47
44
  devtoolsLogs: {},
48
45
  };
@@ -38,10 +38,18 @@ class InstallabilityErrors extends FRGatherer {
38
38
  * @param {LH.Gatherer.FRTransitionalContext} context
39
39
  * @return {Promise<LH.Artifacts['InstallabilityErrors']>}
40
40
  */
41
- getArtifact(context) {
41
+ async getArtifact(context) {
42
42
  const driver = context.driver;
43
43
 
44
- return InstallabilityErrors.getInstallabilityErrors(driver.defaultSession);
44
+ try {
45
+ return await InstallabilityErrors.getInstallabilityErrors(driver.defaultSession);
46
+ } catch {
47
+ return {
48
+ errors: [
49
+ {errorId: 'protocol-timeout', errorArguments: []},
50
+ ],
51
+ };
52
+ }
45
53
  }
46
54
  }
47
55
 
@@ -126,7 +126,11 @@ class Stacks extends FRGatherer {
126
126
  * @return {Promise<LH.Artifacts['Stacks']>}
127
127
  */
128
128
  async getArtifact(context) {
129
- return Stacks.collectStacks(context.driver.executionContext);
129
+ try {
130
+ return await Stacks.collectStacks(context.driver.executionContext);
131
+ } catch {
132
+ return [];
133
+ }
130
134
  }
131
135
  }
132
136
 
@@ -92,10 +92,14 @@ class WebAppManifest extends FRGatherer {
92
92
  * @param {LH.Gatherer.FRTransitionalContext} context
93
93
  * @return {Promise<LH.Artifacts['WebAppManifest']>}
94
94
  */
95
- getArtifact(context) {
95
+ async getArtifact(context) {
96
96
  const driver = context.driver;
97
97
  const {finalDisplayedUrl} = context.baseArtifacts.URL;
98
- return WebAppManifest.getWebAppManifest(driver.defaultSession, finalDisplayedUrl);
98
+ try {
99
+ return await WebAppManifest.getWebAppManifest(driver.defaultSession, finalDisplayedUrl);
100
+ } catch {
101
+ return null;
102
+ }
99
103
  }
100
104
  }
101
105
 
@@ -41,10 +41,7 @@ const BASE_ARTIFACT_BLANKS = {
41
41
  NetworkUserAgent: '',
42
42
  BenchmarkIndex: '',
43
43
  BenchmarkIndexes: '',
44
- WebAppManifest: '',
45
44
  GatherContext: '',
46
- InstallabilityErrors: '',
47
- Stacks: '',
48
45
  traces: '',
49
46
  devtoolsLogs: '',
50
47
  settings: '',
@@ -54,6 +51,15 @@ const BASE_ARTIFACT_BLANKS = {
54
51
  };
55
52
  const BASE_ARTIFACT_NAMES = Object.keys(BASE_ARTIFACT_BLANKS);
56
53
 
54
+ // These were legacy base artifacts, but we need certain gatherers (e.g. bfcache) to run after them.
55
+ // The order is controlled by the config, but still need to force them to run every time.
56
+ const alwaysRunArtifactIds = [
57
+ 'WebAppManifest',
58
+ 'InstallabilityErrors',
59
+ 'Stacks',
60
+ 'FullPageScreenshot',
61
+ ];
62
+
57
63
  /**
58
64
  * @param {LegacyResolvedConfig['passes']} passes
59
65
  * @param {LegacyResolvedConfig['audits']} audits
@@ -79,7 +85,8 @@ function assertValidPasses(passes, audits) {
79
85
  const gatherer = gathererDefn.instance;
80
86
  foundGatherers.add(gatherer.name);
81
87
  const isGatherRequiredByAudits = requestedGatherers.has(gatherer.name);
82
- if (!isGatherRequiredByAudits && gatherer.name !== 'FullPageScreenshot') {
88
+ const isAlwaysRunArtifact = alwaysRunArtifactIds.includes(gatherer.name);
89
+ if (!isGatherRequiredByAudits && !isAlwaysRunArtifact) {
83
90
  const msg = `${gatherer.name} gatherer requested, however no audit requires it.`;
84
91
  log.warn('config', msg);
85
92
  }
@@ -328,10 +335,13 @@ class LegacyResolvedConfig {
328
335
 
329
336
  // 3. Resolve which gatherers will need to run
330
337
  const requestedGathererIds = LegacyResolvedConfig.getGatherersRequestedByAudits(audits);
338
+ for (const gathererId of alwaysRunArtifactIds) {
339
+ requestedGathererIds.add(gathererId);
340
+ }
331
341
 
332
- // Always include FullPageScreenshot, unless explictly told not to.
333
- if (!settings.disableFullPageScreenshot) {
334
- requestedGathererIds.add('FullPageScreenshot');
342
+ // Remove FullPageScreenshot if we explicitly exclude it.
343
+ if (settings.disableFullPageScreenshot) {
344
+ requestedGathererIds.delete('FullPageScreenshot');
335
345
  }
336
346
 
337
347
  // 4. Filter to only the neccessary passes
@@ -70,6 +70,9 @@ legacyDefaultConfig.passes = [{
70
70
  'trace-elements',
71
71
  'inspector-issues',
72
72
  'source-maps',
73
+ 'web-app-manifest',
74
+ 'installability-errors',
75
+ 'stacks',
73
76
  'full-page-screenshot',
74
77
  'bf-cache-failures',
75
78
  ],
@@ -16,10 +16,7 @@ import * as prepare from '../../gather/driver/prepare.js';
16
16
  import * as storage from '../../gather/driver/storage.js';
17
17
  import * as navigation from '../../gather/driver/navigation.js';
18
18
  import * as serviceWorkers from '../../gather/driver/service-workers.js';
19
- import WebAppManifest from '../../gather/gatherers/web-app-manifest.js';
20
- import InstallabilityErrors from '../../gather/gatherers/installability-errors.js';
21
19
  import NetworkUserAgent from '../../gather/gatherers/network-user-agent.js';
22
- import Stacks from '../../gather/gatherers/stacks.js';
23
20
  import {finalizeArtifacts} from '../../gather/base-artifacts.js';
24
21
  import UrlUtils from '../../lib/url-utils.js';
25
22
 
@@ -395,9 +392,6 @@ class GatherRunner {
395
392
  HostUserAgent: hostUserAgent,
396
393
  NetworkUserAgent: '', // updated later
397
394
  BenchmarkIndex: 0, // updated later
398
- WebAppManifest: null, // updated later
399
- InstallabilityErrors: {errors: []}, // updated later
400
- Stacks: [], // updated later
401
395
  traces: {},
402
396
  devtoolsLogs: {},
403
397
  settings: options.settings,
@@ -424,37 +418,6 @@ class GatherRunner {
424
418
 
425
419
  const baseArtifacts = passContext.baseArtifacts;
426
420
 
427
- // Fetch the manifest, if it exists.
428
- try {
429
- baseArtifacts.WebAppManifest = await WebAppManifest.getWebAppManifest(
430
- passContext.driver.defaultSession, passContext.url);
431
- } catch (err) {
432
- log.error('GatherRunner WebAppManifest', err);
433
- baseArtifacts.WebAppManifest = null;
434
- }
435
-
436
- try {
437
- baseArtifacts.InstallabilityErrors = await InstallabilityErrors.getInstallabilityErrors(
438
- passContext.driver.defaultSession);
439
- } catch (err) {
440
- log.error('GatherRunner InstallabilityErrors', err);
441
- baseArtifacts.InstallabilityErrors = {
442
- errors: [
443
- {
444
- errorId: 'protocol-timeout',
445
- errorArguments: [],
446
- },
447
- ],
448
- };
449
- }
450
-
451
- try {
452
- baseArtifacts.Stacks = await Stacks.collectStacks(passContext.driver.executionContext);
453
- } catch (err) {
454
- log.error('GatherRunner Stacks', err);
455
- baseArtifacts.Stacks = [];
456
- }
457
-
458
421
  // Find the NetworkUserAgent actually used in the devtoolsLogs.
459
422
  const devtoolsLog = baseArtifacts.devtoolsLogs[passContext.passConfig.passName];
460
423
  baseArtifacts.NetworkUserAgent = NetworkUserAgent.getNetworkUserAgent(devtoolsLog);
@@ -63,10 +63,12 @@ const stackPacksToInclude = [
63
63
 
64
64
  /**
65
65
  * Returns all packs that match the stacks found in the page.
66
- * @param {LH.Artifacts['Stacks']} pageStacks
66
+ * @param {LH.Artifacts['Stacks']|undefined} pageStacks
67
67
  * @return {LH.RawIcu<Array<LH.Result.StackPack>>}
68
68
  */
69
69
  function getStackPacks(pageStacks) {
70
+ if (!pageStacks) return [];
71
+
70
72
  /** @type {LH.RawIcu<Array<LH.Result.StackPack>>} */
71
73
  const packs = [];
72
74
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lighthouse",
3
3
  "type": "module",
4
- "version": "9.5.0-dev.20230115",
4
+ "version": "9.5.0-dev.20230117",
5
5
  "description": "Automated auditing, performance metrics, and best practices for the web.",
6
6
  "main": "./core/index.js",
7
7
  "bin": {
@@ -79,12 +79,6 @@ interface ContextualBaseArtifacts {
79
79
  interface LegacyBaseArtifacts {
80
80
  /** The user agent string that Lighthouse used to load the page. Set to the empty string if unknown. */
81
81
  NetworkUserAgent: string;
82
- /** Information on detected tech stacks (e.g. JS libraries) used by the page. */
83
- Stacks: Artifacts.DetectedStack[];
84
- /** Parsed version of the page's Web App Manifest, or null if none found. This moved to a regular artifact in Fraggle Rock. */
85
- WebAppManifest: Artifacts.Manifest | null;
86
- /** Errors preventing page being installable as PWA. This moved to a regular artifact in Fraggle Rock. */
87
- InstallabilityErrors: Artifacts.InstallabilityErrors;
88
82
  /** A set of page-load traces, keyed by passName. */
89
83
  traces: {[passName: string]: Trace};
90
84
  /** A set of DevTools debugger protocol records, keyed by passName. */
@@ -151,6 +145,8 @@ export interface GathererArtifacts extends PublicGathererArtifacts,LegacyBaseArt
151
145
  GlobalListeners: Array<Artifacts.GlobalListener>;
152
146
  /** The issues surfaced in the devtools Issues panel */
153
147
  InspectorIssues: Artifacts.InspectorIssues;
148
+ /** Errors preventing page being installable as PWA. */
149
+ InstallabilityErrors: Artifacts.InstallabilityErrors;
154
150
  /** JS coverage information for code used during audit. Keyed by script id. */
155
151
  // 'url' is excluded because it can be overriden by a magic sourceURL= comment, which makes keeping it a dangerous footgun!
156
152
  JsUsage: Record<string, Omit<LH.Crdp.Profiler.ScriptCoverage, 'url'>>;
@@ -172,6 +168,8 @@ export interface GathererArtifacts extends PublicGathererArtifacts,LegacyBaseArt
172
168
  ServiceWorker: {versions: LH.Crdp.ServiceWorker.ServiceWorkerVersion[], registrations: LH.Crdp.ServiceWorker.ServiceWorkerRegistration[]};
173
169
  /** Source maps of scripts executed in the page. */
174
170
  SourceMaps: Array<Artifacts.SourceMap>;
171
+ /** Information on detected tech stacks (e.g. JS libraries) used by the page. */
172
+ Stacks: Artifacts.DetectedStack[];
175
173
  /** Information on <script> and <link> tags blocking first paint. */
176
174
  TagsBlockingFirstPaint: Artifacts.TagBlockingFirstPaint[];
177
175
  /** Information about tap targets including their position and size. */
@@ -180,6 +178,8 @@ export interface GathererArtifacts extends PublicGathererArtifacts,LegacyBaseArt
180
178
  Trace: Trace;
181
179
  /** Elements associated with metrics (ie: Largest Contentful Paint element). */
182
180
  TraceElements: Artifacts.TraceElement[];
181
+ /** Parsed version of the page's Web App Manifest, or null if none found. */
182
+ WebAppManifest: Artifacts.Manifest | null;
183
183
  }
184
184
 
185
185
  declare module Artifacts {