lighthouse 11.7.0-dev.20240408 → 11.7.1

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 (141) hide show
  1. package/CONTRIBUTING.md +2 -2
  2. package/cli/test/smokehouse/core-tests.js +2 -0
  3. package/core/audits/accessibility/duplicate-id-active.d.ts +10 -0
  4. package/core/audits/accessibility/duplicate-id-active.js +42 -0
  5. package/core/audits/accessibility/target-size.js +1 -0
  6. package/core/audits/byte-efficiency/byte-efficiency-audit.d.ts +16 -0
  7. package/core/audits/byte-efficiency/byte-efficiency-audit.js +38 -1
  8. package/core/audits/byte-efficiency/offscreen-images.d.ts +11 -0
  9. package/core/audits/byte-efficiency/offscreen-images.js +15 -0
  10. package/core/audits/dobetterweb/uses-http2.d.ts +13 -0
  11. package/core/audits/dobetterweb/uses-http2.js +34 -2
  12. package/core/audits/layout-shift-elements.d.ts +16 -0
  13. package/core/audits/layout-shift-elements.js +101 -0
  14. package/core/audits/no-unload-listeners.d.ts +16 -0
  15. package/core/audits/no-unload-listeners.js +86 -0
  16. package/core/audits/preload-fonts.d.ts +5 -1
  17. package/core/audits/preload-fonts.js +10 -1
  18. package/core/audits/script-elements-test-audit.d.ts +14 -0
  19. package/core/audits/script-elements-test-audit.js +29 -0
  20. package/core/audits/seo/is-crawlable.d.ts +1 -2
  21. package/core/audits/seo/plugins.d.ts +15 -0
  22. package/core/audits/seo/plugins.js +150 -0
  23. package/core/audits/seo/tap-targets.d.ts +50 -0
  24. package/core/audits/seo/tap-targets.js +352 -0
  25. package/core/audits/uses-rel-preload.d.ts +5 -1
  26. package/core/audits/uses-rel-preload.js +11 -1
  27. package/core/audits/work-during-interaction.d.ts +2 -2
  28. package/core/audits/work-during-interaction.js +2 -2
  29. package/core/computed/js-bundles.d.ts +1 -1
  30. package/core/computed/metrics/lantern-first-contentful-paint.d.ts +82 -13
  31. package/core/computed/metrics/lantern-first-contentful-paint.js +178 -15
  32. package/core/computed/metrics/lantern-first-meaningful-paint.d.ts +12 -13
  33. package/core/computed/metrics/lantern-first-meaningful-paint.js +49 -10
  34. package/core/computed/metrics/lantern-interactive.d.ts +21 -13
  35. package/core/computed/metrics/lantern-interactive.js +84 -11
  36. package/core/computed/metrics/lantern-largest-contentful-paint.d.ts +25 -13
  37. package/core/computed/metrics/lantern-largest-contentful-paint.js +80 -12
  38. package/core/computed/metrics/lantern-max-potential-fid.d.ts +24 -13
  39. package/core/computed/metrics/lantern-max-potential-fid.js +64 -11
  40. package/core/computed/metrics/lantern-metric.d.ts +18 -9
  41. package/core/computed/metrics/lantern-metric.js +31 -13
  42. package/core/computed/metrics/lantern-speed-index.d.ts +32 -13
  43. package/core/computed/metrics/lantern-speed-index.js +116 -12
  44. package/core/computed/metrics/lantern-total-blocking-time.d.ts +25 -13
  45. package/core/computed/metrics/lantern-total-blocking-time.js +94 -10
  46. package/core/computed/metrics/metric.js +3 -1
  47. package/core/computed/module-duplication.d.ts +1 -1
  48. package/core/computed/page-dependency-graph.js +1 -2
  49. package/core/config/default-config.js +74 -46
  50. package/core/config/experimental-config.js +0 -11
  51. package/core/config/metrics-to-audits.d.ts +19 -0
  52. package/core/config/metrics-to-audits.js +62 -0
  53. package/core/gather/gatherers/accessibility.js +3 -1
  54. package/core/gather/gatherers/global-listeners.d.ts +27 -0
  55. package/core/gather/gatherers/global-listeners.js +108 -0
  56. package/core/gather/gatherers/script-elements.d.ts +21 -0
  57. package/core/gather/gatherers/script-elements.js +100 -0
  58. package/core/gather/gatherers/seo/embedded-content.d.ts +10 -0
  59. package/core/gather/gatherers/seo/embedded-content.js +63 -0
  60. package/core/gather/gatherers/seo/tap-targets.d.ts +21 -0
  61. package/core/gather/gatherers/seo/tap-targets.js +389 -0
  62. package/core/gather/gatherers/trace-elements.d.ts +10 -0
  63. package/core/gather/gatherers/trace-elements.js +19 -0
  64. package/core/lib/lantern/page-dependency-graph.d.ts +4 -4
  65. package/core/lib/lantern/page-dependency-graph.js +5 -5
  66. package/core/lib/lighthouse-compatibility.js +10 -53
  67. package/dist/report/bundle.esm.js +1 -1
  68. package/dist/report/flow.js +14 -14
  69. package/dist/report/standalone.js +1 -1
  70. package/flow-report/src/summary/category.tsx +12 -10
  71. package/package.json +1 -1
  72. package/report/renderer/performance-category-renderer.d.ts +7 -0
  73. package/report/renderer/performance-category-renderer.js +11 -1
  74. package/report/renderer/report-utils.js +10 -13
  75. package/shared/localization/locales/ar-XB.json +64 -1
  76. package/shared/localization/locales/ar.json +64 -1
  77. package/shared/localization/locales/bg.json +64 -1
  78. package/shared/localization/locales/ca.json +64 -1
  79. package/shared/localization/locales/cs.json +64 -1
  80. package/shared/localization/locales/da.json +64 -1
  81. package/shared/localization/locales/de.json +64 -1
  82. package/shared/localization/locales/el.json +64 -1
  83. package/shared/localization/locales/en-GB.json +64 -1
  84. package/shared/localization/locales/en-US.json +65 -2
  85. package/shared/localization/locales/en-XA.json +64 -1
  86. package/shared/localization/locales/en-XL.json +65 -2
  87. package/shared/localization/locales/es-419.json +64 -1
  88. package/shared/localization/locales/es.json +64 -1
  89. package/shared/localization/locales/fi.json +64 -1
  90. package/shared/localization/locales/fil.json +64 -1
  91. package/shared/localization/locales/fr.json +64 -1
  92. package/shared/localization/locales/he.json +64 -1
  93. package/shared/localization/locales/hi.json +64 -1
  94. package/shared/localization/locales/hr.json +64 -1
  95. package/shared/localization/locales/hu.json +64 -1
  96. package/shared/localization/locales/id.json +64 -1
  97. package/shared/localization/locales/it.json +64 -1
  98. package/shared/localization/locales/ja.json +64 -1
  99. package/shared/localization/locales/ko.json +64 -1
  100. package/shared/localization/locales/lt.json +64 -1
  101. package/shared/localization/locales/lv.json +64 -1
  102. package/shared/localization/locales/nl.json +64 -1
  103. package/shared/localization/locales/no.json +64 -1
  104. package/shared/localization/locales/pl.json +64 -1
  105. package/shared/localization/locales/pt-PT.json +64 -1
  106. package/shared/localization/locales/pt.json +64 -1
  107. package/shared/localization/locales/ro.json +64 -1
  108. package/shared/localization/locales/ru.json +64 -1
  109. package/shared/localization/locales/sk.json +64 -1
  110. package/shared/localization/locales/sl.json +64 -1
  111. package/shared/localization/locales/sr-Latn.json +64 -1
  112. package/shared/localization/locales/sr.json +64 -1
  113. package/shared/localization/locales/sv.json +64 -1
  114. package/shared/localization/locales/ta.json +64 -1
  115. package/shared/localization/locales/te.json +64 -1
  116. package/shared/localization/locales/th.json +64 -1
  117. package/shared/localization/locales/tr.json +64 -1
  118. package/shared/localization/locales/uk.json +64 -1
  119. package/shared/localization/locales/vi.json +64 -1
  120. package/shared/localization/locales/zh-HK.json +64 -1
  121. package/shared/localization/locales/zh-TW.json +64 -1
  122. package/shared/localization/locales/zh.json +64 -1
  123. package/tsconfig.json +0 -1
  124. package/types/artifacts.d.ts +17 -3
  125. package/types/config.d.ts +1 -0
  126. package/types/lhr/audit-details.d.ts +4 -9
  127. package/types/lhr/lhr.d.ts +2 -0
  128. package/core/lib/lantern/metrics/first-contentful-paint.d.ts +0 -79
  129. package/core/lib/lantern/metrics/first-contentful-paint.js +0 -200
  130. package/core/lib/lantern/metrics/first-meaningful-paint.d.ts +0 -6
  131. package/core/lib/lantern/metrics/first-meaningful-paint.js +0 -66
  132. package/core/lib/lantern/metrics/interactive.d.ts +0 -26
  133. package/core/lib/lantern/metrics/interactive.js +0 -112
  134. package/core/lib/lantern/metrics/largest-contentful-paint.d.ts +0 -19
  135. package/core/lib/lantern/metrics/largest-contentful-paint.js +0 -108
  136. package/core/lib/lantern/metrics/max-potential-fid.d.ts +0 -30
  137. package/core/lib/lantern/metrics/max-potential-fid.js +0 -92
  138. package/core/lib/lantern/metrics/speed-index.d.ts +0 -38
  139. package/core/lib/lantern/metrics/speed-index.js +0 -145
  140. package/core/lib/lantern/metrics/total-blocking-time.d.ts +0 -31
  141. package/core/lib/lantern/metrics/total-blocking-time.js +0 -128
@@ -0,0 +1,15 @@
1
+ export default Plugins;
2
+ declare class Plugins extends Audit {
3
+ /**
4
+ * @param {LH.Artifacts} artifacts
5
+ * @return {LH.Audit.Product}
6
+ */
7
+ static audit(artifacts: LH.Artifacts): LH.Audit.Product;
8
+ }
9
+ export namespace UIStrings {
10
+ const title: string;
11
+ const failureTitle: string;
12
+ const description: string;
13
+ }
14
+ import { Audit } from '../audit.js';
15
+ //# sourceMappingURL=plugins.d.ts.map
@@ -0,0 +1,150 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2018 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import {Audit} from '../audit.js';
8
+ import * as i18n from '../../lib/i18n/i18n.js';
9
+
10
+ const JAVA_APPLET_TYPE = 'application/x-java-applet';
11
+ const JAVA_BEAN_TYPE = 'application/x-java-bean';
12
+ const TYPE_BLOCKLIST = new Set([
13
+ 'application/x-shockwave-flash',
14
+ // See https://docs.oracle.com/cd/E19683-01/816-0378/using_tags/index.html
15
+ JAVA_APPLET_TYPE,
16
+ JAVA_BEAN_TYPE,
17
+ // See https://msdn.microsoft.com/es-es/library/cc265156(v=vs.95).aspx
18
+ 'application/x-silverlight',
19
+ 'application/x-silverlight-2',
20
+ ]);
21
+ const FILE_EXTENSION_BLOCKLIST = new Set([
22
+ 'swf',
23
+ 'flv',
24
+ 'class',
25
+ 'xap',
26
+ ]);
27
+ const SOURCE_PARAMS = new Set([
28
+ 'code',
29
+ 'movie',
30
+ 'source',
31
+ 'src',
32
+ ]);
33
+
34
+ const UIStrings = {
35
+ /** Title of a Lighthouse audit that provides detail on the browser plugins used by the page. This descriptive title is shown when there is no plugin content on the page that would restrict search indexing. */
36
+ title: 'Document avoids plugins',
37
+ /** Descriptive title of a Lighthouse audit that provides detail on the browser plugins used by the page. This title is shown when there is plugin content on the page. */
38
+ failureTitle: 'Document uses plugins',
39
+ /** Description of a Lighthouse audit that tells the user *why* they need to avoid using browser plugins in their content. This is displayed after a user expands the section to see more. No character length limits. The last sentence starting with 'Learn' becomes link text to additional documentation. */
40
+ description: 'Search engines can\'t index plugin content, and ' +
41
+ 'many devices restrict plugins or don\'t support them. ' +
42
+ '[Learn more about avoiding plugins](https://developer.chrome.com/docs/lighthouse/seo/plugins/).',
43
+ };
44
+
45
+ const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
46
+
47
+ /**
48
+ * Verifies if given MIME type matches any known plugin MIME type
49
+ * @param {string} type
50
+ * @return {boolean}
51
+ */
52
+ function isPluginType(type) {
53
+ type = type.trim().toLowerCase();
54
+
55
+ return TYPE_BLOCKLIST.has(type) ||
56
+ type.startsWith(JAVA_APPLET_TYPE) || // e.g. "application/x-java-applet;jpi-version=1.4"
57
+ type.startsWith(JAVA_BEAN_TYPE);
58
+ }
59
+
60
+ /**
61
+ * Verifies if given url points to a file that has a known plugin extension
62
+ * @param {string} url
63
+ * @return {boolean}
64
+ */
65
+ function isPluginURL(url) {
66
+ try {
67
+ // in order to support relative URLs we need to provied a base URL
68
+ const filePath = new URL(url, 'http://example.com').pathname;
69
+ const parts = filePath.split('.');
70
+
71
+ if (parts.length < 2) {
72
+ return false;
73
+ }
74
+ const part = parts[parts.length - 1];
75
+ return FILE_EXTENSION_BLOCKLIST.has(part.trim().toLowerCase());
76
+ } catch (e) {
77
+ return false;
78
+ }
79
+ }
80
+
81
+ class Plugins extends Audit {
82
+ /**
83
+ * @return {LH.Audit.Meta}
84
+ */
85
+ static get meta() {
86
+ return {
87
+ id: 'plugins',
88
+ title: str_(UIStrings.title),
89
+ failureTitle: str_(UIStrings.failureTitle),
90
+ description: str_(UIStrings.description),
91
+ requiredArtifacts: ['EmbeddedContent'],
92
+ };
93
+ }
94
+
95
+ /**
96
+ * @param {LH.Artifacts} artifacts
97
+ * @return {LH.Audit.Product}
98
+ */
99
+ static audit(artifacts) {
100
+ const plugins = artifacts.EmbeddedContent
101
+ .filter(item => {
102
+ if (item.tagName === 'APPLET') {
103
+ return true;
104
+ }
105
+
106
+ if (
107
+ (item.tagName === 'EMBED' || item.tagName === 'OBJECT') &&
108
+ item.type &&
109
+ isPluginType(item.type)
110
+ ) {
111
+ return true;
112
+ }
113
+
114
+ const embedSrc = item.src || item.code;
115
+ if (item.tagName === 'EMBED' && embedSrc && isPluginURL(embedSrc)) {
116
+ return true;
117
+ }
118
+
119
+ if (item.tagName === 'OBJECT' && item.data && isPluginURL(item.data)) {
120
+ return true;
121
+ }
122
+
123
+ const failingParams = item.params.filter(param =>
124
+ SOURCE_PARAMS.has(param.name.trim().toLowerCase()) && isPluginURL(param.value)
125
+ );
126
+
127
+ return failingParams.length > 0;
128
+ })
129
+ .map(plugin => {
130
+ return {
131
+ source: Audit.makeNodeItem(plugin.node),
132
+ };
133
+ });
134
+
135
+ /** @type {LH.Audit.Details.Table['headings']} */
136
+ const headings = [
137
+ {key: 'source', valueType: 'code', label: 'Element source'},
138
+ ];
139
+
140
+ const details = Audit.makeTableDetails(headings, plugins);
141
+
142
+ return {
143
+ score: Number(plugins.length === 0),
144
+ details,
145
+ };
146
+ }
147
+ }
148
+
149
+ export default Plugins;
150
+ export {UIStrings};
@@ -0,0 +1,50 @@
1
+ export default TapTargets;
2
+ export type ClientRectOverlapFailure = {
3
+ overlapScoreRatio: number;
4
+ tapTargetScore: number;
5
+ overlappingTargetScore: number;
6
+ };
7
+ export type TapTargetOverlapFailure = {
8
+ overlapScoreRatio: number;
9
+ tapTargetScore: number;
10
+ overlappingTargetScore: number;
11
+ tapTarget: LH.Artifacts.TapTarget;
12
+ overlappingTarget: LH.Artifacts.TapTarget;
13
+ };
14
+ export type BoundedTapTarget = {
15
+ paddedBoundsRect: LH.Artifacts.Rect;
16
+ tapTarget: LH.Artifacts.TapTarget;
17
+ };
18
+ export type TapTargetTableItem = {
19
+ tapTarget: LH.Audit.Details.NodeValue;
20
+ overlappingTarget: LH.Audit.Details.NodeValue;
21
+ size: string;
22
+ overlapScoreRatio: number;
23
+ height: number;
24
+ width: number;
25
+ tapTargetScore: number;
26
+ overlappingTargetScore: number;
27
+ };
28
+ declare class TapTargets extends Audit {
29
+ /**
30
+ * @param {LH.Artifacts} artifacts
31
+ * @param {LH.Audit.Context} context
32
+ * @return {Promise<LH.Audit.Product>}
33
+ */
34
+ static audit(artifacts: LH.Artifacts, context: LH.Audit.Context): Promise<LH.Audit.Product>;
35
+ }
36
+ declare namespace TapTargets {
37
+ export { FINGER_SIZE_PX };
38
+ }
39
+ export namespace UIStrings {
40
+ const title: string;
41
+ const failureTitle: string;
42
+ const description: string;
43
+ const tapTargetHeader: string;
44
+ const overlappingTargetHeader: string;
45
+ const explanationViewportMetaNotOptimized: string;
46
+ const displayValue: string;
47
+ }
48
+ import { Audit } from '../audit.js';
49
+ declare const FINGER_SIZE_PX: 48;
50
+ //# sourceMappingURL=tap-targets.d.ts.map
@@ -0,0 +1,352 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2018 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ /**
8
+ * @fileoverview Checks that links, buttons, etc. are sufficiently large and that there's
9
+ * no other tap target that's too close so that the user might accidentally tap on.
10
+ */
11
+
12
+ import {Audit} from '../audit.js';
13
+ import {ViewportMeta} from '../../computed/viewport-meta.js';
14
+ import {
15
+ rectsTouchOrOverlap,
16
+ getRectOverlapArea,
17
+ getRectAtCenter,
18
+ allRectsContainedWithinEachOther,
19
+ getLargestRect,
20
+ getBoundingRectWithPadding,
21
+ } from '../../lib/rect-helpers.js';
22
+ import {getTappableRectsFromClientRects} from '../../lib/tappable-rects.js';
23
+ import * as i18n from '../../lib/i18n/i18n.js';
24
+
25
+ const UIStrings = {
26
+ /** Title of a Lighthouse audit that provides detail on whether tap targets (like buttons and links) on a page are big enough so they can easily be tapped on a mobile device. This descriptive title is shown when tap targets are easy to tap on. */
27
+ title: 'Tap targets are sized appropriately',
28
+ /** Descriptive title of a Lighthouse audit that provides detail on whether tap targets (like buttons and links) on a page are big enough so they can easily be tapped on a mobile device. This descriptive title is shown when tap targets are not easy to tap on. */
29
+ failureTitle: 'Tap targets are not sized appropriately',
30
+ /** Description of a Lighthouse audit that tells the user why buttons and links need to be big enough and what 'big enough' means. This is displayed after a user expands the section to see more. No character length limits. The last sentence starting with 'Learn' becomes link text to additional documentation. */
31
+ description: 'Interactive elements like buttons and links should be large enough (48x48px), or have enough space around them, to be easy enough to tap without overlapping onto other elements. [Learn more about tap targets](https://developer.chrome.com/docs/lighthouse/seo/tap-targets/).',
32
+ /** Label of a table column that identifies tap targets (like buttons and links) that have failed the audit and aren't easy to tap on. */
33
+ tapTargetHeader: 'Tap Target',
34
+ /** Label of a table column that identifies a tap target (like a link or button) that overlaps with another tap target. */
35
+ overlappingTargetHeader: 'Overlapping Target',
36
+ /** Explanatory message stating that there was a failure in an audit caused by the viewport meta tag not being optimized for mobile screens, which caused tap targets like buttons and links to be too small to tap on. */
37
+ /* eslint-disable-next-line max-len */
38
+ explanationViewportMetaNotOptimized: 'Tap targets are too small because there\'s no viewport meta tag optimized for mobile screens',
39
+ /** Explanatory message stating that a certain percentage of the tap targets (like buttons and links) on the page are of an appropriately large size. */
40
+ displayValue: '{decimalProportion, number, percent} appropriately sized tap targets',
41
+ };
42
+
43
+ const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
44
+
45
+ const FINGER_SIZE_PX = 48;
46
+ // Ratio of the finger area tapping on an unintended element
47
+ // to the finger area tapping on the intended element
48
+ const MAX_ACCEPTABLE_OVERLAP_SCORE_RATIO = 0.25;
49
+
50
+ /**
51
+ * Returns a tap target augmented with a bounding rect for quick overlapping
52
+ * rejections. Rect contains all the client rects, padded to half FINGER_SIZE_PX.
53
+ * @param {LH.Artifacts.TapTarget[]} targets
54
+ * @return {BoundedTapTarget[]}
55
+ */
56
+ function getBoundedTapTargets(targets) {
57
+ return targets.map(tapTarget => {
58
+ return {
59
+ tapTarget,
60
+ paddedBoundsRect: getBoundingRectWithPadding(tapTarget.clientRects, FINGER_SIZE_PX),
61
+ };
62
+ });
63
+ }
64
+
65
+ /**
66
+ * @param {LH.Artifacts.Rect} cr
67
+ */
68
+ function clientRectBelowMinimumSize(cr) {
69
+ return cr.width < FINGER_SIZE_PX || cr.height < FINGER_SIZE_PX;
70
+ }
71
+
72
+ /**
73
+ * A target is "too small" if none of its clientRects are at least the size of a finger.
74
+ * @param {BoundedTapTarget[]} targets
75
+ * @return {BoundedTapTarget[]}
76
+ */
77
+ function getTooSmallTargets(targets) {
78
+ return targets.filter(target => {
79
+ return target.tapTarget.clientRects.every(clientRectBelowMinimumSize);
80
+ });
81
+ }
82
+
83
+ /**
84
+ * @param {BoundedTapTarget[]} tooSmallTargets
85
+ * @param {BoundedTapTarget[]} allTargets
86
+ * @return {TapTargetOverlapFailure[]}
87
+ */
88
+ function getAllOverlapFailures(tooSmallTargets, allTargets) {
89
+ /** @type {TapTargetOverlapFailure[]} */
90
+ const failures = [];
91
+
92
+ tooSmallTargets.forEach(target => {
93
+ // Convert client rects to unique tappable areas from a user's perspective
94
+ const tappableRects = getTappableRectsFromClientRects(target.tapTarget.clientRects);
95
+
96
+ for (const maybeOverlappingTarget of allTargets) {
97
+ if (maybeOverlappingTarget === target) {
98
+ // Checking the same target with itself, skip.
99
+ continue;
100
+ }
101
+
102
+ if (!rectsTouchOrOverlap(target.paddedBoundsRect, maybeOverlappingTarget.paddedBoundsRect)) {
103
+ // Bounding boxes (padded with half FINGER_SIZE_PX) don't overlap, skip.
104
+ continue;
105
+ }
106
+
107
+ if (target.tapTarget.href === maybeOverlappingTarget.tapTarget.href) {
108
+ const isHttpOrHttpsLink = /https?:\/\//.test(target.tapTarget.href);
109
+ if (isHttpOrHttpsLink) {
110
+ // No overlap because same target action, skip.
111
+ continue;
112
+ }
113
+ }
114
+
115
+ const maybeOverlappingRects = maybeOverlappingTarget.tapTarget.clientRects;
116
+ if (allRectsContainedWithinEachOther(tappableRects, maybeOverlappingRects)) {
117
+ // If one tap target is fully contained within the other that's
118
+ // probably intentional (e.g. an item with a delete button inside).
119
+ // We'll miss some problems because of this, but that's better
120
+ // than falsely reporting a failure.
121
+ continue;
122
+ }
123
+
124
+ const rectFailure = getOverlapFailureForTargetPair(tappableRects, maybeOverlappingRects);
125
+ if (rectFailure) {
126
+ failures.push({
127
+ ...rectFailure,
128
+ tapTarget: target.tapTarget,
129
+ overlappingTarget: maybeOverlappingTarget.tapTarget,
130
+ });
131
+ }
132
+ }
133
+ });
134
+
135
+ return failures;
136
+ }
137
+
138
+ /**
139
+ * @param {LH.Artifacts.Rect[]} tappableRects
140
+ * @param {LH.Artifacts.Rect[]} maybeOverlappingRects
141
+ * @return {ClientRectOverlapFailure | null}
142
+ */
143
+ function getOverlapFailureForTargetPair(tappableRects, maybeOverlappingRects) {
144
+ /** @type ClientRectOverlapFailure | null */
145
+ let greatestFailure = null;
146
+
147
+ for (const targetCR of tappableRects) {
148
+ const fingerRect = getRectAtCenter(targetCR, FINGER_SIZE_PX);
149
+ // Score indicates how much of the finger area overlaps each target when the user
150
+ // taps on the center of targetCR
151
+ const tapTargetScore = getRectOverlapArea(fingerRect, targetCR);
152
+
153
+ for (const maybeOverlappingCR of maybeOverlappingRects) {
154
+ const overlappingTargetScore = getRectOverlapArea(fingerRect, maybeOverlappingCR);
155
+
156
+ const overlapScoreRatio = overlappingTargetScore / tapTargetScore;
157
+ if (overlapScoreRatio < MAX_ACCEPTABLE_OVERLAP_SCORE_RATIO) {
158
+ // low score means it's clear that the user tried to tap on the targetCR,
159
+ // rather than the other tap target client rect
160
+ continue;
161
+ }
162
+
163
+ // only update our state if this was the biggest failure we've seen for this pair
164
+ if (!greatestFailure || overlapScoreRatio > greatestFailure.overlapScoreRatio) {
165
+ greatestFailure = {
166
+ overlapScoreRatio,
167
+ tapTargetScore,
168
+ overlappingTargetScore,
169
+ };
170
+ }
171
+ }
172
+ }
173
+ return greatestFailure;
174
+ }
175
+
176
+ /**
177
+ * Only report one failure if two targets overlap each other
178
+ * @param {TapTargetOverlapFailure[]} overlapFailures
179
+ * @return {TapTargetOverlapFailure[]}
180
+ */
181
+ function mergeSymmetricFailures(overlapFailures) {
182
+ /** @type TapTargetOverlapFailure[] */
183
+ const failuresAfterMerging = [];
184
+
185
+ overlapFailures.forEach((failure, overlapFailureIndex) => {
186
+ const symmetricFailure = overlapFailures.find(f =>
187
+ f.tapTarget === failure.overlappingTarget &&
188
+ f.overlappingTarget === failure.tapTarget
189
+ );
190
+
191
+ if (!symmetricFailure) {
192
+ failuresAfterMerging.push(failure);
193
+ return;
194
+ }
195
+
196
+ const {overlapScoreRatio: failureOSR} = failure;
197
+ const {overlapScoreRatio: symmetricOSR} = symmetricFailure;
198
+ // Push if:
199
+ // - the current failure has a higher OSR
200
+ // - OSRs are the same, and the current failure comes before its symmetric partner in the list
201
+ // Otherwise do nothing and let the symmetric partner be pushed later.
202
+ if (failureOSR > symmetricOSR || (
203
+ failureOSR === symmetricOSR &&
204
+ overlapFailureIndex < overlapFailures.indexOf(symmetricFailure)
205
+ )) {
206
+ failuresAfterMerging.push(failure);
207
+ }
208
+ });
209
+
210
+ return failuresAfterMerging;
211
+ }
212
+
213
+ /**
214
+ * @param {TapTargetOverlapFailure[]} overlapFailures
215
+ * @return {TapTargetTableItem[]}
216
+ */
217
+ function getTableItems(overlapFailures) {
218
+ const tableItems = overlapFailures.map(failure => {
219
+ const largestCR = getLargestRect(failure.tapTarget.clientRects);
220
+ const width = Math.floor(largestCR.width);
221
+ const height = Math.floor(largestCR.height);
222
+ const size = width + 'x' + height;
223
+ return {
224
+ tapTarget: Audit.makeNodeItem(failure.tapTarget.node),
225
+ overlappingTarget: Audit.makeNodeItem(failure.overlappingTarget.node),
226
+ tapTargetScore: failure.tapTargetScore,
227
+ overlappingTargetScore: failure.overlappingTargetScore,
228
+ overlapScoreRatio: failure.overlapScoreRatio,
229
+ size,
230
+ width,
231
+ height,
232
+ };
233
+ });
234
+
235
+ tableItems.sort((a, b) => {
236
+ return b.overlapScoreRatio - a.overlapScoreRatio;
237
+ });
238
+
239
+ return tableItems;
240
+ }
241
+
242
+ class TapTargets extends Audit {
243
+ /**
244
+ * @return {LH.Audit.Meta}
245
+ */
246
+ static get meta() {
247
+ return {
248
+ id: 'tap-targets',
249
+ title: str_(UIStrings.title),
250
+ failureTitle: str_(UIStrings.failureTitle),
251
+ description: str_(UIStrings.description),
252
+ requiredArtifacts: ['MetaElements', 'TapTargets'],
253
+ };
254
+ }
255
+
256
+ /**
257
+ * @param {LH.Artifacts} artifacts
258
+ * @param {LH.Audit.Context} context
259
+ * @return {Promise<LH.Audit.Product>}
260
+ */
261
+ static async audit(artifacts, context) {
262
+ if (context.settings.formFactor === 'desktop') {
263
+ // Tap target sizes aren't important for desktop SEO, so disable the audit there.
264
+ // On desktop people also tend to have more precise pointing devices than fingers.
265
+ return {
266
+ score: 1,
267
+ notApplicable: true,
268
+ };
269
+ }
270
+
271
+ const viewportMeta = await ViewportMeta.request(artifacts.MetaElements, context);
272
+ if (!viewportMeta.isMobileOptimized) {
273
+ return {
274
+ score: 0,
275
+ explanation: str_(UIStrings.explanationViewportMetaNotOptimized),
276
+ };
277
+ }
278
+
279
+ // Augment the targets with padded bounding rects for quick intersection testing.
280
+ const boundedTapTargets = getBoundedTapTargets(artifacts.TapTargets);
281
+
282
+ const tooSmallTargets = getTooSmallTargets(boundedTapTargets);
283
+ const overlapFailures = getAllOverlapFailures(tooSmallTargets, boundedTapTargets);
284
+ const overlapFailuresForDisplay = mergeSymmetricFailures(overlapFailures);
285
+ const tableItems = getTableItems(overlapFailuresForDisplay);
286
+
287
+ /** @type {LH.Audit.Details.Table['headings']} */
288
+ const headings = [
289
+ {key: 'tapTarget', valueType: 'node', label: str_(UIStrings.tapTargetHeader)},
290
+ {key: 'size', valueType: 'text', label: str_(i18n.UIStrings.columnSize)},
291
+ {key: 'overlappingTarget', valueType: 'node', label: str_(UIStrings.overlappingTargetHeader)},
292
+ ];
293
+
294
+ const details = Audit.makeTableDetails(headings, tableItems);
295
+
296
+ const tapTargetCount = artifacts.TapTargets.length;
297
+ const failingTapTargetCount = new Set(overlapFailures.map(f => f.tapTarget)).size;
298
+ const passingTapTargetCount = tapTargetCount - failingTapTargetCount;
299
+
300
+ let score = 1;
301
+ let passingTapTargetRatio = 1;
302
+ if (failingTapTargetCount > 0) {
303
+ passingTapTargetRatio = (passingTapTargetCount / tapTargetCount);
304
+ // If there are any failures then we don't want the audit to pass,
305
+ // so keep the score below 90.
306
+ score = passingTapTargetRatio * 0.89;
307
+ }
308
+ const displayValue = str_(UIStrings.displayValue, {decimalProportion: passingTapTargetRatio});
309
+
310
+ return {
311
+ score,
312
+ details,
313
+ displayValue,
314
+ };
315
+ }
316
+ }
317
+
318
+ TapTargets.FINGER_SIZE_PX = FINGER_SIZE_PX;
319
+
320
+ export default TapTargets;
321
+ export {UIStrings};
322
+
323
+
324
+ /** @typedef {{
325
+ overlapScoreRatio: number;
326
+ tapTargetScore: number;
327
+ overlappingTargetScore: number;
328
+ }} ClientRectOverlapFailure */
329
+
330
+ /** @typedef {{
331
+ overlapScoreRatio: number;
332
+ tapTargetScore: number;
333
+ overlappingTargetScore: number;
334
+ tapTarget: LH.Artifacts.TapTarget;
335
+ overlappingTarget: LH.Artifacts.TapTarget;
336
+ }} TapTargetOverlapFailure */
337
+
338
+ /** @typedef {{
339
+ paddedBoundsRect: LH.Artifacts.Rect;
340
+ tapTarget: LH.Artifacts.TapTarget;
341
+ }} BoundedTapTarget */
342
+
343
+ /** @typedef {{
344
+ tapTarget: LH.Audit.Details.NodeValue;
345
+ overlappingTarget: LH.Audit.Details.NodeValue;
346
+ size: string;
347
+ overlapScoreRatio: number;
348
+ height: number;
349
+ width: number;
350
+ tapTargetScore: number;
351
+ overlappingTargetScore: number;
352
+ }} TapTargetTableItem */
@@ -45,7 +45,11 @@ declare class UsesRelPreloadAudit extends Audit {
45
45
  * @param {LH.Audit.Context} context
46
46
  * @return {Promise<LH.Audit.Product>}
47
47
  */
48
- static audit(artifacts: LH.Artifacts, context: LH.Audit.Context): Promise<LH.Audit.Product>;
48
+ static audit_(artifacts: LH.Artifacts, context: LH.Audit.Context): Promise<LH.Audit.Product>;
49
+ /**
50
+ * @return {Promise<LH.Audit.Product>}
51
+ */
52
+ static audit(): Promise<LH.Audit.Product>;
49
53
  }
50
54
  export namespace UIStrings {
51
55
  const title: string;
@@ -209,7 +209,7 @@ class UsesRelPreloadAudit extends Audit {
209
209
  * @param {LH.Audit.Context} context
210
210
  * @return {Promise<LH.Audit.Product>}
211
211
  */
212
- static async audit(artifacts, context) {
212
+ static async audit_(artifacts, context) {
213
213
  const trace = artifacts.traces[UsesRelPreloadAudit.DEFAULT_PASS];
214
214
  const devtoolsLog = artifacts.devtoolsLogs[UsesRelPreloadAudit.DEFAULT_PASS];
215
215
  const URL = artifacts.URL;
@@ -253,6 +253,16 @@ class UsesRelPreloadAudit extends Audit {
253
253
  warnings,
254
254
  };
255
255
  }
256
+
257
+ /**
258
+ * @return {Promise<LH.Audit.Product>}
259
+ */
260
+ static async audit() {
261
+ // Preload advice is on hold until https://github.com/GoogleChrome/lighthouse/issues/11960
262
+ // is resolved.
263
+ return {score: 1, notApplicable: true,
264
+ details: Audit.makeOpportunityDetails([], [], {overallSavingsMs: 0})};
265
+ }
256
266
  }
257
267
 
258
268
  export default UsesRelPreloadAudit;
@@ -32,7 +32,7 @@ declare class WorkDuringInteraction extends Audit {
32
32
  startTs: number;
33
33
  endTs: number;
34
34
  };
35
- processingDuration: {
35
+ processingTime: {
36
36
  startTs: number;
37
37
  endTs: number;
38
38
  };
@@ -72,7 +72,7 @@ export namespace UIStrings {
72
72
  const failureTitle: string;
73
73
  const description: string;
74
74
  const inputDelay: string;
75
- const processingDuration: string;
75
+ const processingTime: string;
76
76
  const presentationDelay: string;
77
77
  const displayValue: string;
78
78
  const eventTarget: string;
@@ -30,7 +30,7 @@ const UIStrings = {
30
30
  /** Label for a column in a data table; entries will be information on the time that the browser is delayed before responding to user input. Ideally fits within a ~40 character limit. */
31
31
  inputDelay: 'Input delay',
32
32
  /** Label for a column in a data table; entries will be information on the time taken by code processing user input that delays a response to the user. Ideally fits within a ~40 character limit. */
33
- processingDuration: 'Processing duration',
33
+ processingTime: 'Processing time',
34
34
  /** Label for a column in a data table; entries will be information on the time that the browser is delayed before presenting a response to user input on screen. Ideally fits within a ~40 character limit. */
35
35
  presentationDelay: 'Presentation delay',
36
36
  /**
@@ -115,7 +115,7 @@ class WorkDuringInteraction extends Audit {
115
115
  const endTs = startTs + interactionData.duration * 1000;
116
116
  return {
117
117
  inputDelay: {startTs, endTs: processingStartTs},
118
- processingDuration: {startTs: processingStartTs, endTs: processingEndTs},
118
+ processingTime: {startTs: processingStartTs, endTs: processingEndTs},
119
119
  presentationDelay: {startTs: processingEndTs, endTs},
120
120
  };
121
121
  }
@@ -1,6 +1,6 @@
1
1
  export { JSBundlesComputed as JSBundles };
2
2
  declare const JSBundlesComputed: typeof JSBundles & {
3
- request: (dependencies: Pick<import("../index.js").Artifacts, "SourceMaps" | "Scripts">, context: import("../../types/utility-types.js").default.ImmutableObject<{
3
+ request: (dependencies: Pick<import("../index.js").Artifacts, "Scripts" | "SourceMaps">, context: import("../../types/utility-types.js").default.ImmutableObject<{
4
4
  computedCache: Map<string, import("../lib/arbitrary-equality-map.js").ArbitraryEqualityMap>;
5
5
  }>) => Promise<import("../index.js").Artifacts.Bundle[]>;
6
6
  };