lighthouse 9.5.0-dev.20221005 → 9.5.0-dev.20221007

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 (44) hide show
  1. package/cli/test/smokehouse/smokehouse.js +1 -1
  2. package/core/audits/accessibility/aria-meter-name.js +2 -2
  3. package/core/audits/accessibility/aria-tooltip-name.js +2 -2
  4. package/core/audits/accessibility/manual/custom-controls-labels.js +1 -1
  5. package/core/audits/accessibility/manual/custom-controls-roles.js +1 -1
  6. package/core/audits/accessibility/manual/focus-traps.js +1 -1
  7. package/core/audits/accessibility/manual/focusable-controls.js +1 -1
  8. package/core/audits/accessibility/manual/interactive-element-affordance.js +1 -1
  9. package/core/audits/accessibility/manual/logical-tab-order.js +1 -1
  10. package/core/audits/accessibility/manual/managed-focus.js +1 -1
  11. package/core/audits/accessibility/manual/offscreen-content-hidden.js +1 -1
  12. package/core/audits/accessibility/manual/use-landmarks.js +1 -1
  13. package/core/audits/accessibility/manual/visual-order-follows-dom.js +1 -1
  14. package/core/config/default-config.js +1 -1
  15. package/core/lib/i18n/README.md +22 -5
  16. package/dist/report/bundle.esm.js +1 -1
  17. package/dist/report/flow.js +23 -28
  18. package/dist/report/standalone.js +1 -1
  19. package/flow-report/src/i18n/i18n.tsx +1 -1
  20. package/flow-report/test/flow-report-pptr-test.ts +16 -0
  21. package/package.json +2 -2
  22. package/readme.md +2 -2
  23. package/report/generator/report-generator.js +4 -1
  24. package/report/renderer/dom.js +1 -1
  25. package/report/test/generator/file-namer-test.js +1 -1
  26. package/report/test/generator/report-generator-test.js +1 -1
  27. package/report/test/renderer/category-renderer-test.js +1 -1
  28. package/report/test/renderer/crc-details-renderer-test.js +1 -1
  29. package/report/test/renderer/details-renderer-test.js +1 -1
  30. package/report/test/renderer/dom-test.js +1 -1
  31. package/report/test/renderer/i18n-test.js +1 -1
  32. package/report/test/renderer/performance-category-renderer-test.js +1 -1
  33. package/report/test/renderer/pwa-category-renderer-test.js +1 -1
  34. package/report/test/renderer/report-renderer-test.js +2 -2
  35. package/report/test/renderer/report-ui-features-test.js +1 -1
  36. package/report/test/renderer/snippet-renderer-test.js +1 -1
  37. package/report/test/renderer/util-test.js +1 -1
  38. package/shared/localization/locales/en-US.json +3 -3
  39. package/shared/localization/locales/en-XL.json +3 -3
  40. package/shared/test/localization/locales-test.js +1 -1
  41. package/tsconfig.json +0 -1
  42. package/types/global-lh.d.ts +2 -2
  43. package/types/puppeteer.d.ts +22 -0
  44. package/changelog.md +0 -5902
@@ -31,7 +31,7 @@
31
31
  * @property {Run[]} runs
32
32
  */
33
33
 
34
- import assert from 'assert';
34
+ import assert from 'assert/strict';
35
35
 
36
36
  import log from 'lighthouse-logger';
37
37
 
@@ -17,8 +17,8 @@ const UIStrings = {
17
17
  title: 'ARIA `meter` elements have accessible names',
18
18
  /** Title of an accessibility audit that evaluates if meter HTML elements do not have accessible names. This title is descriptive of the failing state and is shown to users when there is a failure that needs to be addressed. */
19
19
  failureTitle: 'ARIA `meter` elements do not have accessible names.',
20
- /** Description of a Lighthouse audit that tells the user *why* they should have accessible names for HTML elements. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */
21
- description: 'When an element doesn\'t have an accessible name, screen readers announce it with a generic name, making it unusable for users who rely on screen readers. [Learn how to name `meter` elements](https://dequeuniversity.com/rules/axe/4.4/aria-meter-name).',
20
+ /** Description of a Lighthouse audit that tells the user *why* they should have accessible names for HTML 'meter' elements. This is displayed after a user expands the section to see more. No character length limits. 'Learn how...' becomes link text to additional documentation. */
21
+ description: 'When a meter element doesn\'t have an accessible name, screen readers announce it with a generic name, making it unusable for users who rely on screen readers. [Learn how to name `meter` elements](https://dequeuniversity.com/rules/axe/4.4/aria-meter-name).',
22
22
  };
23
23
 
24
24
  const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
@@ -17,8 +17,8 @@ const UIStrings = {
17
17
  title: 'ARIA `tooltip` elements have accessible names',
18
18
  /** Title of an accessibility audit that evaluates if tooltip HTML elements do not have accessible names. This title is descriptive of the failing state and is shown to users when there is a failure that needs to be addressed. */
19
19
  failureTitle: 'ARIA `tooltip` elements do not have accessible names.',
20
- /** Description of a Lighthouse audit that tells the user *why* they should have accessible names for HTML elements. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */
21
- description: 'When an element doesn\'t have an accessible name, screen readers announce it with a generic name, making it unusable for users who rely on screen readers. [Learn how to name `tooltip` elements](https://dequeuniversity.com/rules/axe/4.4/aria-tooltip-name).',
20
+ /** Description of a Lighthouse audit that tells the user *why* they should have accessible names for HTML 'tooltip' elements. This is displayed after a user expands the section to see more. No character length limits. 'Learn how...' becomes link text to additional documentation. */
21
+ description: 'When a tooltip element doesn\'t have an accessible name, screen readers announce it with a generic name, making it unusable for users who rely on screen readers. [Learn how to name `tooltip` elements](https://dequeuniversity.com/rules/axe/4.4/aria-tooltip-name).',
22
22
  };
23
23
 
24
24
  const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
@@ -18,7 +18,7 @@ class CustomControlsLabels extends ManualAudit {
18
18
  static get meta() {
19
19
  return Object.assign({
20
20
  id: 'custom-controls-labels',
21
- description: 'Custom interactive controls have associated labels, provided by aria-label or aria-labelledby. [Learn more about custom controls and labels](https://web.dev/custom-controls-labels/).',
21
+ description: 'Custom interactive controls have associated labels, provided by aria-label or aria-labelledby. [Learn more about custom controls and labels](https://developer.chrome.com/docs/lighthouse/accessibility/custom-controls-labels/).',
22
22
  title: 'Custom controls have associated labels',
23
23
  }, super.partialMeta);
24
24
  }
@@ -18,7 +18,7 @@ class CustomControlsRoles extends ManualAudit {
18
18
  static get meta() {
19
19
  return Object.assign({
20
20
  id: 'custom-controls-roles',
21
- description: 'Custom interactive controls have appropriate ARIA roles. [Learn how to add roles to custom controls](https://web.dev/custom-control-roles/).',
21
+ description: 'Custom interactive controls have appropriate ARIA roles. [Learn how to add roles to custom controls](https://developer.chrome.com/docs/lighthouse/accessibility/custom-control-roles/).',
22
22
  title: 'Custom controls have ARIA roles',
23
23
  }, super.partialMeta);
24
24
  }
@@ -18,7 +18,7 @@ class FocusTraps extends ManualAudit {
18
18
  static get meta() {
19
19
  return Object.assign({
20
20
  id: 'focus-traps',
21
- description: 'A user can tab into and out of any control or region without accidentally trapping their focus. [Learn how to avoid focus traps](https://web.dev/focus-traps/).',
21
+ description: 'A user can tab into and out of any control or region without accidentally trapping their focus. [Learn how to avoid focus traps](https://developer.chrome.com/docs/lighthouse/accessibility/focus-traps/).',
22
22
  title: 'User focus is not accidentally trapped in a region',
23
23
  }, super.partialMeta);
24
24
  }
@@ -18,7 +18,7 @@ class FocusableControls extends ManualAudit {
18
18
  static get meta() {
19
19
  return Object.assign({
20
20
  id: 'focusable-controls',
21
- description: 'Custom interactive controls are keyboard focusable and display a focus indicator. [Learn how to make custom controls focusable](https://web.dev/focusable-controls/).',
21
+ description: 'Custom interactive controls are keyboard focusable and display a focus indicator. [Learn how to make custom controls focusable](https://developer.chrome.com/docs/lighthouse/accessibility/focusable-controls/).',
22
22
  title: 'Interactive controls are keyboard focusable',
23
23
  }, super.partialMeta);
24
24
  }
@@ -18,7 +18,7 @@ class InteractiveElementAffordance extends ManualAudit {
18
18
  static get meta() {
19
19
  return Object.assign({
20
20
  id: 'interactive-element-affordance',
21
- description: 'Interactive elements, such as links and buttons, should indicate their state and be distinguishable from non-interactive elements. [Learn how to decorate interactive elements with affordance hints](https://web.dev/interactive-element-affordance/).',
21
+ description: 'Interactive elements, such as links and buttons, should indicate their state and be distinguishable from non-interactive elements. [Learn how to decorate interactive elements with affordance hints](https://developer.chrome.com/docs/lighthouse/accessibility/interactive-element-affordance/).',
22
22
  title: 'Interactive elements indicate their purpose and state',
23
23
  }, super.partialMeta);
24
24
  }
@@ -18,7 +18,7 @@ class LogicalTabOrder extends ManualAudit {
18
18
  static get meta() {
19
19
  return Object.assign({
20
20
  id: 'logical-tab-order',
21
- description: 'Tabbing through the page follows the visual layout. Users cannot focus elements that are offscreen. [Learn more about logical tab ordering](https://web.dev/logical-tab-order/).',
21
+ description: 'Tabbing through the page follows the visual layout. Users cannot focus elements that are offscreen. [Learn more about logical tab ordering](https://developer.chrome.com/docs/lighthouse/accessibility/logical-tab-order/).',
22
22
  title: 'The page has a logical tab order',
23
23
  }, super.partialMeta);
24
24
  }
@@ -18,7 +18,7 @@ class ManagedFocus extends ManualAudit {
18
18
  static get meta() {
19
19
  return Object.assign({
20
20
  id: 'managed-focus',
21
- description: 'If new content, such as a dialog, is added to the page, the user\'s focus is directed to it. [Learn how to direct focus to new content](https://web.dev/managed-focus/).',
21
+ description: 'If new content, such as a dialog, is added to the page, the user\'s focus is directed to it. [Learn how to direct focus to new content](https://developer.chrome.com/docs/lighthouse/accessibility/managed-focus/).',
22
22
  title: 'The user\'s focus is directed to new content added to the page',
23
23
  }, super.partialMeta);
24
24
  }
@@ -19,7 +19,7 @@ class OffscreenContentHidden extends ManualAudit {
19
19
  static get meta() {
20
20
  return Object.assign({
21
21
  id: 'offscreen-content-hidden',
22
- description: 'Offscreen content is hidden with display: none or aria-hidden=true. [Learn how to properly hide offscreen content](https://web.dev/offscreen-content-hidden/).',
22
+ description: 'Offscreen content is hidden with display: none or aria-hidden=true. [Learn how to properly hide offscreen content](https://developer.chrome.com/docs/lighthouse/accessibility/offscreen-content-hidden/).',
23
23
  title: 'Offscreen content is hidden from assistive technology',
24
24
  }, super.partialMeta);
25
25
  }
@@ -18,7 +18,7 @@ class UseLandmarks extends ManualAudit {
18
18
  static get meta() {
19
19
  return Object.assign({
20
20
  id: 'use-landmarks',
21
- description: 'Landmark elements (<main>, <nav>, etc.) are used to improve the keyboard navigation of the page for assistive technology. [Learn more about landmark elements](https://web.dev/use-landmarks/).',
21
+ description: 'Landmark elements (<main>, <nav>, etc.) are used to improve the keyboard navigation of the page for assistive technology. [Learn more about landmark elements](https://developer.chrome.com/docs/lighthouse/accessibility/use-landmarks/).',
22
22
  title: 'HTML5 landmark elements are used to improve navigation',
23
23
  }, super.partialMeta);
24
24
  }
@@ -18,7 +18,7 @@ class VisualOrderFollowsDOM extends ManualAudit {
18
18
  static get meta() {
19
19
  return Object.assign({
20
20
  id: 'visual-order-follows-dom',
21
- description: 'DOM order matches the visual order, improving navigation for assistive technology. [Learn more about DOM and visual ordering](https://web.dev/visual-order-follows-dom/).',
21
+ description: 'DOM order matches the visual order, improving navigation for assistive technology. [Learn more about DOM and visual ordering](https://developer.chrome.com/docs/lighthouse/accessibility/visual-order-follows-dom/).',
22
22
  title: 'Visual order on the page follows DOM order',
23
23
  }, super.partialMeta);
24
24
  }
@@ -38,7 +38,7 @@ const UIStrings = {
38
38
  /** Title of the Accessibility category of audits. This section contains audits focused on making web content accessible to all users. Also used as a label of a score gauge; try to limit to 20 characters. */
39
39
  a11yCategoryTitle: 'Accessibility',
40
40
  /** Description of the Accessibility category. This is displayed at the top of a list of audits focused on making web content accessible to all users. No character length limits. 'improve the accessibility of your web app' becomes link text to additional documentation. */
41
- a11yCategoryDescription: 'These checks highlight opportunities to [improve the accessibility of your web app](https://web.dev/lighthouse-accessibility/). Only a subset of accessibility issues can be automatically detected so manual testing is also encouraged.',
41
+ a11yCategoryDescription: 'These checks highlight opportunities to [improve the accessibility of your web app](https://developer.chrome.com/docs/lighthouse/accessibility/). Only a subset of accessibility issues can be automatically detected so manual testing is also encouraged.',
42
42
  /** Description of the Accessibility manual checks category. This description is displayed above a list of accessibility audits that currently have no automated test and so must be verified manually by the user. No character length limits. 'conducting an accessibility review' becomes link text to additional documentation. */
43
43
  a11yCategoryManualDescription: 'These items address areas which an automated testing tool cannot cover. Learn more in our guide on [conducting an accessibility review](https://web.dev/how-to-review/).',
44
44
  /** Title of the best practices section of the Accessibility category. Within this section are audits with descriptive titles that highlight common accessibility best practices. */
@@ -12,11 +12,11 @@ The collection and translation pipeline:
12
12
  ```
13
13
  Source files: Locale files:
14
14
  +---------------------------+ +----------------------------------------------
15
- | ++ | shared/localization/locales/en-US.json |
16
- | const UIStrings = { ... };|-+ +---> | shared/localization/locales/en-XL.json |
15
+ | ++ | shared/localization/locales/en-US.json |
16
+ | const UIStrings = { ... };|-+ +---> | shared/localization/locales/en-XL.json |
17
17
  | |-| | +----------------------------------------------+
18
18
  +-----------------------------| | | ||
19
- +----------------------------| | | shared/localization/locales/*.json |-<+
19
+ +----------------------------| | | shared/localization/locales/*.json |-<+
20
20
  +---------------------------+ | | || |
21
21
  | | +----------------------------------------------| |
22
22
  $ yarn | | +---------------------------------------------+ |
@@ -198,11 +198,11 @@ CTC is a name that is distinct and identifies this as the Chrome translation for
198
198
  ```json
199
199
  {
200
200
  "name": {
201
- "message": "Message text, with optional placeholders.",
201
+ "message": "Message text, with optional placeholders, which can be $PLACEHOLDER_TEXT$",
202
202
  "description": "Translator-aimed description of the message.",
203
203
  "meaning": "Description given when a message is duplicated, in order to give context to the message. Lighthouse uses a copy of the description for this.",
204
204
  "placeholders": {
205
- "placeholder_name": {
205
+ "PLACEHOLDER_TEXT": {
206
206
  "content": "A string to be placed within the message.",
207
207
  "example": "Translator-aimed example of the placeholder string."
208
208
  },
@@ -211,6 +211,23 @@ CTC is a name that is distinct and identifies this as the Chrome translation for
211
211
  }
212
212
  ```
213
213
 
214
+ ### Collisions
215
+ Collisions happen when two CTC messages have the same `message`. For Lighthouse, there are two relevant collision types in TC:
216
+ - Allowed: the CTC `message`, `description`, and `placeholders` are exactly the same. These collisions are deduped on the TC side and the translation cost is the same as for a single string.
217
+ - Disallowed: `message` is the same but one or more of the other properties differ.
218
+
219
+ When the `message` needs to be the same as another string but another property must differ, that disallowed collision can be fixed by adding a unique `meaning` property to each colliding CTC message. TC will then consider those as separate strings and not a collision.
220
+
221
+ In Lighthouse, this is done by having a different `description` for the strings, which is then copied to `meaning` in `resolveMessageCollisions()`. `meaning` cannot be manually set.
222
+
223
+ For instance, the string "Potential Savings" currently refers to both saved KiB and saved milliseconds in different audits. The string is defined twice, each with a different `description` describing the units being saved, in case some locales' translations will use a different word choice depending on the unit.
224
+
225
+ Internally, TC uses a message ID that's a hash of `message` and `meaning` to check for collisions. Somewhat confusingly, if two messages do have colliding IDs, then `message`, `meaning`, `description`, and `placeholders` are all required to match or an error is thrown. This is why all message properties could cause a collision but `meaning` is the only way to dedupe them.
226
+
227
+ We treat it as an error if `placeholders` differ between messages in a collision: if there is a need for placeholders to differ, then the strings aren't really the same, and at least the `description` should be changed to explain that context. Placeholders must match in user-controlled data (e.g. if a placeholder has an `@example`, it must be the same example in all instances) and in Lighthouse-controlled data (e.g. the token used to replace it in the CTC `message`, like `$PLACEHOLDER_TEXT$` in the example above).
228
+
229
+ Finally, identical messages made to not collide by Lighthouse with a `meaning` cost real money and shouldn't be confused with allowed collisions which cost nothing for each additional collision. Fixed collisions are checked against a known list to add a little friction and motivate keeping them few in number. An error is thrown if a collision is fixed that hasn't yet been added to that list.
230
+
214
231
  # Appendix
215
232
 
216
233
  ## Appendix A: How runtime string replacement works
@@ -1661,7 +1661,7 @@ class DOM {
1661
1661
  // Otherwise, append any links found.
1662
1662
  const url = new URL(segment.linkHref);
1663
1663
 
1664
- const DOCS_ORIGINS = ['https://developers.google.com', 'https://web.dev'];
1664
+ const DOCS_ORIGINS = ['https://developers.google.com', 'https://web.dev', 'https://developer.chrome.com'];
1665
1665
  if (DOCS_ORIGINS.includes(url.origin)) {
1666
1666
  url.searchParams.set('utm_source', 'lighthouse');
1667
1667
  url.searchParams.set('utm_medium', this._lighthouseChannel);