lighthouse 9.5.0-dev.20220502 → 9.5.0-dev.20220503

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.
@@ -6108,4 +6108,6 @@ function renderReport(lhr, opts = {}) {
6108
6108
  return rootEl;
6109
6109
  }
6110
6110
 
6111
- export { DOM, ReportRenderer, ReportUIFeatures, renderReport };
6111
+ const swapLocale = _ => {}; const format = _ => {};
6112
+
6113
+ export { DOM, ReportRenderer, ReportUIFeatures, format, renderReport, swapLocale };
package/jest.config.js CHANGED
@@ -6,7 +6,7 @@
6
6
  'use strict';
7
7
 
8
8
  module.exports = {
9
- setupFilesAfterEnv: ['./lighthouse-core/test/test-utils.js'],
9
+ setupFilesAfterEnv: ['./lighthouse-core/test/jest-setup/setup.js'],
10
10
  testEnvironment: 'node',
11
11
  testMatch: [
12
12
  '**/lighthouse-core/**/*-test.js',
@@ -123,10 +123,10 @@ function getFlags(manualArgv, options = {}) {
123
123
  type: 'boolean',
124
124
  describe: 'Pause after page load to wait for permission to continue the run, evaluate `continueLighthouseRun` in the console to continue.',
125
125
  },
126
- 'fraggle-rock': {
126
+ 'legacy-navigation': {
127
127
  type: 'boolean',
128
128
  default: false,
129
- describe: '[EXPERIMENTAL] Use the new Fraggle Rock navigation runner to gather results.',
129
+ describe: '[DEPRECATED] Use the legacy navigation runner to gather results. Only use this if you are using a pre-10.0 custom Lighthouse config, or if Lighthouse unexpectedly fails after updating to 10.0. Please file a bug if you need this flag for Lighthouse to work.',
130
130
  },
131
131
  'additional-trace-categories': {
132
132
  type: 'string',
@@ -225,15 +225,16 @@ async function runLighthouse(url, flags, config) {
225
225
  flags.port = launchedChrome.port;
226
226
  }
227
227
 
228
- if (flags.fraggleRock) {
229
- flags.channel = 'fraggle-rock-cli';
228
+ if (flags.legacyNavigation) {
229
+ log.warn('CLI', 'Legacy navigation CLI is deprecated');
230
+ flags.channel = 'legacy-navigation-cli';
230
231
  } else {
231
232
  flags.channel = 'cli';
232
233
  }
233
234
 
234
- const runnerResult = flags.fraggleRock ?
235
- await lighthouse(url, flags, config) :
236
- await lighthouse.legacyNavigation(url, flags, config);
235
+ const runnerResult = flags.legacyNavigation ?
236
+ await lighthouse.legacyNavigation(url, flags, config) :
237
+ await lighthouse(url, flags, config);
237
238
 
238
239
  // If in gatherMode only, there will be no runnerResult.
239
240
  if (runnerResult) {
@@ -82,8 +82,9 @@ async function internalRun(url, tmpPath, configJson, options) {
82
82
  ];
83
83
 
84
84
  if (useFraggleRock) {
85
- args.push('--fraggle-rock');
86
85
  configJson = convertToFraggleRockConfig(configJson);
86
+ } else {
87
+ args.push('--legacy-navigation');
87
88
  }
88
89
 
89
90
  // Config can be optionally provided.
@@ -15,13 +15,13 @@ const i18n = require('../../lib/i18n/i18n.js');
15
15
 
16
16
  const UIStrings = {
17
17
  /** Title of an accesibility audit that evaluates if any list item elements do not have list parent elements. This title is descriptive of the successful state and is shown to users when no user action is required. */
18
- title: 'List items (`<li>`) are contained within `<ul>` or `<ol>` parent elements',
18
+ title: 'List items (`<li>`) are contained within `<ul>`, `<ol>` or `<menu>` parent elements',
19
19
  /** Title of an accesibility audit that evaluates if any list item elements do not have list parent elements. This title is descriptive of the failing state and is shown to users when there is a failure that needs to be addressed. */
20
- failureTitle: 'List items (`<li>`) are not contained within `<ul>` ' +
21
- 'or `<ol>` parent elements.',
20
+ failureTitle: 'List items (`<li>`) are not contained within `<ul>`, ' +
21
+ '`<ol>` or `<menu>` parent elements.',
22
22
  /** Description of a Lighthouse audit that tells the user *why* they should try to pass. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */
23
23
  description: 'Screen readers require list items (`<li>`) to be contained within a ' +
24
- 'parent `<ul>` or `<ol>` to be announced properly. ' +
24
+ 'parent `<ul>`, `<ol>` or `<menu>` to be announced properly. ' +
25
25
  '[Learn more](https://dequeuniversity.com/rules/axe/4.4/listitem).',
26
26
  };
27
27
 
@@ -117,6 +117,9 @@ class CriticalRequestChains {
117
117
  // Ignore if some ancestor is not a critical request.
118
118
  if (networkPath.some(r => !CriticalRequestChains.isCritical(r, mainResource))) return;
119
119
 
120
+ // Ignore non-network things (like data urls).
121
+ if (NetworkRequest.isNonNetworkRequest(node.record)) return;
122
+
120
123
  addChain(networkPath);
121
124
  }, getNextNodes);
122
125
 
@@ -96,7 +96,7 @@ class ProtocolSession {
96
96
  /** @param {LH.Puppeteer.CDPSession} session */
97
97
  const listener = session => callback(new ProtocolSession(session));
98
98
  this._callbackMap.set(callback, listener);
99
- this._session.connection().on('sessionattached', listener);
99
+ this._getConnection().on('sessionattached', listener);
100
100
  }
101
101
 
102
102
  /**
@@ -106,7 +106,7 @@ class ProtocolSession {
106
106
  removeSessionAttachedListener(callback) {
107
107
  const listener = this._callbackMap.get(callback);
108
108
  if (!listener) return;
109
- this._session.connection().off('sessionattached', listener);
109
+ this._getConnection().off('sessionattached', listener);
110
110
  }
111
111
 
112
112
  /**
@@ -171,6 +171,12 @@ class ProtocolSession {
171
171
  this._session.removeAllListeners();
172
172
  await this._session.detach();
173
173
  }
174
+
175
+ _getConnection() {
176
+ const connection = this._session.connection();
177
+ if (!connection) throw new Error('Connection has been closed.');
178
+ return connection;
179
+ }
174
180
  }
175
181
 
176
182
  module.exports = ProtocolSession;
@@ -94,7 +94,7 @@ lighthouse.generateConfig = generateConfig;
94
94
  lighthouse.getAuditList = Runner.getAuditList;
95
95
  lighthouse.traceCategories = require('./gather/driver.js').traceCategories;
96
96
  lighthouse.Audit = require('./audits/audit.js');
97
- lighthouse.Gatherer = require('./gather/gatherers/gatherer.js');
97
+ lighthouse.Gatherer = require('./fraggle-rock/gather/base-gatherer.js');
98
98
 
99
99
  // Explicit type reference (hidden by makeComputedArtifact) for d.ts export.
100
100
  // TODO(esmodules): should be a workaround for module.export and can be removed when in esm.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lighthouse",
3
- "version": "9.5.0-dev.20220502",
3
+ "version": "9.5.0-dev.20220503",
4
4
  "description": "Automated auditing, performance metrics, and best practices for the web.",
5
5
  "main": "./lighthouse-core/index.js",
6
6
  "bin": {
@@ -163,7 +163,7 @@
163
163
  "pako": "^2.0.3",
164
164
  "preact": "^10.5.14",
165
165
  "pretty-json-stringify": "^0.0.2",
166
- "puppeteer": "10.2.0",
166
+ "puppeteer": "13.7.0",
167
167
  "resolve": "^1.20.0",
168
168
  "rollup": "^2.52.7",
169
169
  "rollup-plugin-node-resolve": "^5.2.0",
@@ -199,7 +199,7 @@
199
199
  "open": "^8.4.0",
200
200
  "parse-cache-control": "1.0.1",
201
201
  "ps-list": "^8.0.0",
202
- "puppeteer-core": "^10.2.0",
202
+ "puppeteer-core": "^13.7.0",
203
203
  "robots-parser": "^3.0.0",
204
204
  "semver": "^5.3.0",
205
205
  "speedline-core": "^1.4.3",
@@ -15,3 +15,4 @@ export {DOM} from '../renderer/dom.js';
15
15
  export {ReportRenderer} from '../renderer/report-renderer.js';
16
16
  export {ReportUIFeatures} from '../renderer/report-ui-features.js';
17
17
  export {renderReport} from '../renderer/api.js';
18
+ export {swapLocale, format} from '../../shared/localization/i18n-module.js';
@@ -1,107 +1,15 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`ReportRendererAxe with aXe renders without axe violations 2`] = `
3
+ exports[`ReportRendererAxe with aXe renders without axe violations 1`] = `
4
4
  Array [
5
5
  Object {
6
- "description": "Ensures every id attribute value is unique",
7
- "help": "id attribute value must be unique",
8
- "helpUrl": "https://dequeuniversity.com/rules/axe/4.4/duplicate-id?application=axeAPI",
9
6
  "id": "duplicate-id",
10
- "impact": "minor",
11
- "nodes": Array [
12
- Object {
13
- "all": Array [],
14
- "any": Array [
15
- Object {
16
- "data": "viewport",
17
- "id": "duplicate-id",
18
- "impact": "minor",
19
- "message": "Document has multiple static elements with the same id attribute: viewport",
20
- "relatedNodes": Array [
21
- Object {
22
- "html": "<div class=\\"lh-audit lh-audit--binary lh-audit--pass\\" id=\\"viewport\\">",
23
- "target": Array [
24
- "#seo > .lh-audit-group:nth-child(4) > .lh-clump--passed.lh-clump > .lh-audit--binary.lh-audit--pass.lh-audit:nth-child(2)",
25
- ],
26
- },
27
- Object {
28
- "html": "<div class=\\"lh-audit lh-audit--binary lh-audit--pass\\" id=\\"viewport\\">",
29
- "target": Array [
30
- ".lh-audit-group--pwa-optimized > .lh-audit--binary.lh-audit--pass.lh-audit:nth-child(6)",
31
- ],
32
- },
33
- ],
34
- },
35
- ],
36
- "failureSummary": "Fix any of the following:
37
- Document has multiple static elements with the same id attribute: viewport",
38
- "html": "<div class=\\"lh-audit lh-audit--binary lh-audit--pass\\" id=\\"viewport\\">",
39
- "impact": "minor",
40
- "none": Array [],
41
- "target": Array [
42
- ".lh-audit--binary.lh-audit--pass.lh-audit:nth-child(20)",
43
- ],
44
- },
45
- Object {
46
- "all": Array [],
47
- "any": Array [
48
- Object {
49
- "data": "image-alt",
50
- "id": "duplicate-id",
51
- "impact": "minor",
52
- "message": "Document has multiple static elements with the same id attribute: image-alt",
53
- "relatedNodes": Array [
54
- Object {
55
- "html": "<div class=\\"lh-audit lh-audit--binary lh-audit--fail\\" id=\\"image-alt\\">",
56
- "target": Array [
57
- ".lh-audit-group--seo-content > .lh-audit--fail.lh-audit--binary.lh-audit:nth-child(3)",
58
- ],
59
- },
60
- ],
61
- },
62
- ],
63
- "failureSummary": "Fix any of the following:
64
- Document has multiple static elements with the same id attribute: image-alt",
65
- "html": "<div class=\\"lh-audit lh-audit--binary lh-audit--fail\\" id=\\"image-alt\\">",
66
- "impact": "minor",
67
- "none": Array [],
68
- "target": Array [
69
- ".lh-audit-group--a11y-names-labels > .lh-audit--fail.lh-audit--binary.lh-audit:nth-child(2)",
70
- ],
71
- },
72
- Object {
73
- "all": Array [],
74
- "any": Array [
75
- Object {
76
- "data": "document-title",
77
- "id": "duplicate-id",
78
- "impact": "minor",
79
- "message": "Document has multiple static elements with the same id attribute: document-title",
80
- "relatedNodes": Array [
81
- Object {
82
- "html": "<div class=\\"lh-audit lh-audit--binary lh-audit--pass\\" id=\\"document-title\\">",
83
- "target": Array [
84
- "#seo > .lh-audit-group:nth-child(4) > .lh-clump--passed.lh-clump > .lh-audit--binary.lh-audit--pass.lh-audit:nth-child(3)",
85
- ],
86
- },
87
- ],
88
- },
89
- ],
90
- "failureSummary": "Fix any of the following:
7
+ "message": "Fix any of the following:
8
+ Document has multiple static elements with the same id attribute: viewport
9
+ Fix any of the following:
10
+ Document has multiple static elements with the same id attribute: image-alt
11
+ Fix any of the following:
91
12
  Document has multiple static elements with the same id attribute: document-title",
92
- "html": "<div class=\\"lh-audit lh-audit--binary lh-audit--pass\\" id=\\"document-title\\">",
93
- "impact": "minor",
94
- "none": Array [],
95
- "target": Array [
96
- ".lh-audit--binary.lh-audit--pass.lh-audit:nth-child(13)",
97
- ],
98
- },
99
- ],
100
- "tags": Array [
101
- "cat.parsing",
102
- "wcag2a",
103
- "wcag411",
104
- ],
105
13
  },
106
14
  ]
107
15
  `;
@@ -45,6 +45,8 @@ describe('ReportRendererAxe', () => {
45
45
  'heading-order': {enabled: true},
46
46
  'meta-viewport': {enabled: true},
47
47
  'aria-treeitem-name': {enabled: true},
48
+ // TODO: re-enable. https://github.com/GoogleChrome/lighthouse/issues/13918
49
+ 'color-contrast': {enabled: false},
48
50
  },
49
51
  };
50
52
 
@@ -75,21 +77,7 @@ describe('ReportRendererAxe', () => {
75
77
  message: v.nodes.map((n) => n.failureSummary).join('\n'),
76
78
  };
77
79
  });
78
- expect(axeSummary).toMatchInlineSnapshot(`
79
- Array [
80
- Object {
81
- "id": "duplicate-id",
82
- "message": "Fix any of the following:
83
- Document has multiple static elements with the same id attribute: viewport
84
- Fix any of the following:
85
- Document has multiple static elements with the same id attribute: image-alt
86
- Fix any of the following:
87
- Document has multiple static elements with the same id attribute: document-title",
88
- },
89
- ]
90
- `);
91
-
92
- expect(axeResults.violations).toMatchSnapshot();
80
+ expect(axeSummary).toMatchSnapshot();
93
81
  },
94
82
  // This test takes 10s on fast hardware, but can take longer in CI.
95
83
  // https://github.com/dequelabs/axe-core/tree/b573b1c1/doc/examples/jest_react#timeout-issues
@@ -119,7 +119,7 @@ body {
119
119
  border-width: 1px 0;
120
120
  padding: 4px;
121
121
  }
122
- button {
122
+ #reanalyze {
123
123
  background-color: hsl(216deg 100% 50%);
124
124
  border-radius: 4px;
125
125
  color: white;
@@ -133,8 +133,9 @@ button {
133
133
  </head>
134
134
  <body >
135
135
  <noscript>PSI requires JavaScript. Please enable.</noscript>
136
+ <button type=button id="translate">→ Español</button>
136
137
  <div class="page">
137
- <button type=button>Reanalyze</button>
138
+ <button type=button id="reanalyze">Reanalyze</button>
138
139
  <div class="tabset">
139
140
  <input type="radio" name="tabset" id="tab1" aria-controls="mobile" checked />
140
141
  <label for="tab1">Mobile</label>
@@ -17,7 +17,12 @@ const wait = (ms = 100) => new Promise(resolve => setTimeout(resolve, ms));
17
17
  (async function __initPsiReports__() {
18
18
  renderLHReport();
19
19
 
20
- document.querySelector('button')?.addEventListener('click', () => {
20
+ document.querySelector('button#reanalyze')?.addEventListener('click', () => {
21
+ renderLHReport();
22
+ });
23
+
24
+ document.querySelector('button#translate')?.addEventListener('click', async () => {
25
+ await swapLhrLocale('es');
21
26
  renderLHReport();
22
27
  });
23
28
  })();
@@ -82,6 +87,22 @@ async function renderLHReport() {
82
87
  }
83
88
  }
84
89
 
90
+ /**
91
+ * @param {LH.Locale} locale
92
+ */
93
+ async function swapLhrLocale(locale) {
94
+ const response = await fetch(`https://www.gstatic.com/pagespeed/insights/ui/locales/${locale}.json`);
95
+ /** @type {import('../../shared/localization/locales').LhlMessages} */
96
+ const lhlMessages = await response.json();
97
+ console.log(lhlMessages);
98
+ if (!lhlMessages) throw new Error(`could not fetch data for locale: ${locale}`);
99
+
100
+ lighthouseRenderer.format.registerLocaleData(locale, lhlMessages);
101
+ // @ts-expect-error LHR global
102
+ window.__LIGHTHOUSE_JSON__ = lighthouseRenderer.swapLocale(window.__LIGHTHOUSE_JSON__, locale)
103
+ .lhr;
104
+ }
105
+
85
106
 
86
107
  /**
87
108
  * Tweak the LHR to make the desktop and mobile reports easier to identify.
@@ -450,13 +450,13 @@
450
450
  "message": "Lists contain only `<li>` elements and script supporting elements (`<script>` and `<template>`)."
451
451
  },
452
452
  "lighthouse-core/audits/accessibility/listitem.js | description": {
453
- "message": "Screen readers require list items (`<li>`) to be contained within a parent `<ul>` or `<ol>` to be announced properly. [Learn more](https://dequeuniversity.com/rules/axe/4.4/listitem)."
453
+ "message": "Screen readers require list items (`<li>`) to be contained within a parent `<ul>`, `<ol>` or `<menu>` to be announced properly. [Learn more](https://dequeuniversity.com/rules/axe/4.4/listitem)."
454
454
  },
455
455
  "lighthouse-core/audits/accessibility/listitem.js | failureTitle": {
456
- "message": "List items (`<li>`) are not contained within `<ul>` or `<ol>` parent elements."
456
+ "message": "List items (`<li>`) are not contained within `<ul>`, `<ol>` or `<menu>` parent elements."
457
457
  },
458
458
  "lighthouse-core/audits/accessibility/listitem.js | title": {
459
- "message": "List items (`<li>`) are contained within `<ul>` or `<ol>` parent elements"
459
+ "message": "List items (`<li>`) are contained within `<ul>`, `<ol>` or `<menu>` parent elements"
460
460
  },
461
461
  "lighthouse-core/audits/accessibility/meta-refresh.js | description": {
462
462
  "message": "Users do not expect a page to refresh automatically, and doing so will move focus back to the top of the page. This may create a frustrating or confusing experience. [Learn more](https://dequeuniversity.com/rules/axe/4.4/meta-refresh)."
@@ -450,13 +450,13 @@
450
450
  "message": "L̂íŝt́ŝ ćôńt̂áîń ôńl̂ý `<li>` êĺêḿêńt̂ś âńd̂ śĉŕîṕt̂ śûṕp̂ór̂t́îńĝ él̂ém̂én̂t́ŝ (`<script>` án̂d́ `<template>`)."
451
451
  },
452
452
  "lighthouse-core/audits/accessibility/listitem.js | description": {
453
- "message": "Ŝćr̂éêń r̂éâd́êŕŝ ŕêq́ûír̂é l̂íŝt́ ît́êḿŝ (`<li>`) t́ô b́ê ćôńt̂áîńêd́ ŵít̂h́îń â ṕâŕêńt̂ `<ul>` ór̂ `<ol>` t́ô b́ê án̂ńôún̂ćêd́ p̂ŕôṕêŕl̂ý. [L̂éâŕn̂ ḿôŕê](https://dequeuniversity.com/rules/axe/4.4/listitem)."
453
+ "message": "Ŝćr̂éêń r̂éâd́êŕŝ ŕêq́ûír̂é l̂íŝt́ ît́êḿŝ (`<li>`) t́ô b́ê ćôńt̂áîńêd́ ŵít̂h́îń â ṕâŕêńt̂ `<ul>`, `<ol>` ór̂ `<menu>` t́ô b́ê án̂ńôún̂ćêd́ p̂ŕôṕêŕl̂ý. [L̂éâŕn̂ ḿôŕê](https://dequeuniversity.com/rules/axe/4.4/listitem)."
454
454
  },
455
455
  "lighthouse-core/audits/accessibility/listitem.js | failureTitle": {
456
- "message": "L̂íŝt́ ît́êḿŝ (`<li>`) ár̂é n̂ót̂ ćôńt̂áîńêd́ ŵít̂h́îń `<ul>` ôŕ `<ol>` p̂ár̂én̂t́ êĺêḿêńt̂ś."
456
+ "message": "L̂íŝt́ ît́êḿŝ (`<li>`) ár̂é n̂ót̂ ćôńt̂áîńêd́ ŵít̂h́îń `<ul>`, `<ol>` ôŕ `<menu>` p̂ár̂én̂t́ êĺêḿêńt̂ś."
457
457
  },
458
458
  "lighthouse-core/audits/accessibility/listitem.js | title": {
459
- "message": "L̂íŝt́ ît́êḿŝ (`<li>`) ár̂é ĉón̂t́âín̂éd̂ ẃît́ĥín̂ `<ul>` ór̂ `<ol>` ṕâŕêńt̂ él̂ém̂én̂t́ŝ"
459
+ "message": "L̂íŝt́ ît́êḿŝ (`<li>`) ár̂é ĉón̂t́âín̂éd̂ ẃît́ĥín̂ `<ul>`, `<ol>` ór̂ `<menu>` ṕâŕêńt̂ él̂ém̂én̂t́ŝ"
460
460
  },
461
461
  "lighthouse-core/audits/accessibility/meta-refresh.js | description": {
462
462
  "message": "Ûśêŕŝ d́ô ńôt́ êx́p̂éĉt́ â ṕâǵê t́ô ŕêf́r̂éŝh́ âút̂óm̂át̂íĉál̂ĺŷ, án̂d́ d̂óîńĝ śô ẃîĺl̂ ḿôv́ê f́ôćûś b̂áĉḱ t̂ó t̂h́ê t́ôṕ ôf́ t̂h́ê ṕâǵê. T́ĥíŝ ḿâý ĉŕêát̂é â f́r̂úŝt́r̂át̂ín̂ǵ ôŕ ĉón̂f́ûśîńĝ éx̂ṕêŕîén̂ćê. [Ĺêár̂ń m̂ór̂é](https://dequeuniversity.com/rules/axe/4.4/meta-refresh)."
@@ -149,8 +149,8 @@ export interface CliFlags extends Flags {
149
149
  quiet: boolean;
150
150
  /** A flag to print the normalized config for the given config and options, then exit. */
151
151
  printConfig: boolean;
152
- /** Use the new Fraggle Rock navigation runner to gather CLI results. */
153
- fraggleRock: boolean;
152
+ /** Use the legacy navigation runner to gather CLI results. */
153
+ legacyNavigation: boolean;
154
154
  /** Path to the file where precomputed lantern data should be read from. */
155
155
  precomputedLanternDataPath?: string;
156
156
  /** Path to the file where precomputed lantern data should be written to. */