lighthouse 11.7.1 → 12.0.0

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 (272) hide show
  1. package/CONTRIBUTING.md +2 -2
  2. package/cli/bin.js +0 -7
  3. package/cli/cli-flags.d.ts +1 -5
  4. package/cli/cli-flags.js +4 -8
  5. package/cli/test/smokehouse/__snapshots__/report-assert-test.js.snap +14 -14
  6. package/cli/test/smokehouse/config/exclusions.js +3 -0
  7. package/cli/test/smokehouse/core-tests.js +6 -20
  8. package/cli/test/smokehouse/frontends/smokehouse-bin.js +2 -2
  9. package/core/audits/accessibility/aria-conditional-attr.d.ts +10 -0
  10. package/core/audits/accessibility/aria-conditional-attr.js +43 -0
  11. package/core/audits/accessibility/{duplicate-id-active.d.ts → aria-deprecated-role.d.ts} +3 -3
  12. package/core/audits/accessibility/aria-deprecated-role.js +43 -0
  13. package/core/audits/accessibility/aria-prohibited-attr.d.ts +10 -0
  14. package/core/audits/accessibility/aria-prohibited-attr.js +44 -0
  15. package/core/audits/accessibility/target-size.js +0 -1
  16. package/core/audits/byte-efficiency/byte-efficiency-audit.d.ts +0 -16
  17. package/core/audits/byte-efficiency/byte-efficiency-audit.js +1 -38
  18. package/core/audits/byte-efficiency/offscreen-images.d.ts +0 -11
  19. package/core/audits/byte-efficiency/offscreen-images.js +0 -15
  20. package/core/audits/byte-efficiency/render-blocking-resources.js +27 -26
  21. package/core/audits/byte-efficiency/unminified-css.js +2 -2
  22. package/core/audits/byte-efficiency/unused-css-rules.js +3 -1
  23. package/core/audits/dobetterweb/uses-http2.d.ts +0 -13
  24. package/core/audits/dobetterweb/uses-http2.js +4 -38
  25. package/core/audits/font-display.js +2 -2
  26. package/core/audits/layout-shifts.js +1 -1
  27. package/core/audits/preload-fonts.d.ts +1 -5
  28. package/core/audits/preload-fonts.js +1 -10
  29. package/core/audits/prioritize-lcp-image.js +2 -2
  30. package/core/audits/redirects-http.d.ts +19 -0
  31. package/core/audits/redirects-http.js +75 -0
  32. package/core/audits/resource-summary.d.ts +2 -0
  33. package/core/audits/resource-summary.js +5 -4
  34. package/core/audits/seo/is-crawlable.d.ts +2 -1
  35. package/core/audits/seo/link-text.js +12 -0
  36. package/core/audits/uses-rel-preload.d.ts +1 -5
  37. package/core/audits/uses-rel-preload.js +5 -15
  38. package/core/audits/work-during-interaction.d.ts +2 -2
  39. package/core/audits/work-during-interaction.js +2 -2
  40. package/core/computed/js-bundles.d.ts +1 -1
  41. package/core/computed/metrics/lantern-first-contentful-paint.d.ts +13 -82
  42. package/core/computed/metrics/lantern-first-contentful-paint.js +16 -178
  43. package/core/computed/metrics/lantern-first-meaningful-paint.d.ts +13 -12
  44. package/core/computed/metrics/lantern-first-meaningful-paint.js +11 -49
  45. package/core/computed/metrics/lantern-interactive.d.ts +13 -21
  46. package/core/computed/metrics/lantern-interactive.js +12 -84
  47. package/core/computed/metrics/lantern-largest-contentful-paint.d.ts +13 -25
  48. package/core/computed/metrics/lantern-largest-contentful-paint.js +13 -80
  49. package/core/computed/metrics/lantern-max-potential-fid.d.ts +13 -24
  50. package/core/computed/metrics/lantern-max-potential-fid.js +12 -64
  51. package/core/computed/metrics/lantern-metric.d.ts +14 -18
  52. package/core/computed/metrics/lantern-metric.js +34 -30
  53. package/core/computed/metrics/lantern-speed-index.d.ts +13 -32
  54. package/core/computed/metrics/lantern-speed-index.js +13 -116
  55. package/core/computed/metrics/lantern-total-blocking-time.d.ts +13 -25
  56. package/core/computed/metrics/lantern-total-blocking-time.js +10 -94
  57. package/core/computed/metrics/metric.js +1 -3
  58. package/core/computed/module-duplication.d.ts +1 -1
  59. package/core/computed/navigation-insights.d.ts +36 -0
  60. package/core/computed/navigation-insights.js +35 -0
  61. package/core/computed/page-dependency-graph.js +3 -7
  62. package/core/computed/resource-summary.d.ts +10 -12
  63. package/core/computed/resource-summary.js +12 -19
  64. package/core/computed/trace-engine-result.d.ts +16 -3
  65. package/core/computed/trace-engine-result.js +19 -14
  66. package/core/computed/unused-css.d.ts +3 -1
  67. package/core/computed/unused-css.js +6 -5
  68. package/core/config/config-helpers.js +0 -4
  69. package/core/config/constants.js +0 -1
  70. package/core/config/default-config.js +63 -142
  71. package/core/config/experimental-config.js +11 -0
  72. package/core/config/filters.js +0 -1
  73. package/core/gather/driver/navigation.js +4 -1
  74. package/core/gather/driver/prepare.js +1 -1
  75. package/core/gather/driver/target-manager.js +4 -3
  76. package/core/gather/driver/wait-for-condition.js +2 -3
  77. package/core/gather/driver.d.ts +12 -0
  78. package/core/gather/driver.js +27 -0
  79. package/core/gather/gatherers/accessibility.js +4 -6
  80. package/core/gather/gatherers/css-usage.d.ts +0 -21
  81. package/core/gather/gatherers/css-usage.js +9 -119
  82. package/core/gather/gatherers/root-causes.d.ts +2 -2
  83. package/core/gather/gatherers/root-causes.js +6 -5
  84. package/core/gather/gatherers/stylesheets.d.ts +26 -0
  85. package/core/gather/gatherers/stylesheets.js +138 -0
  86. package/core/gather/gatherers/trace-elements.d.ts +2 -12
  87. package/core/gather/gatherers/trace-elements.js +2 -21
  88. package/core/gather/navigation-runner.js +3 -1
  89. package/core/gather/session.d.ts +8 -0
  90. package/core/gather/session.js +14 -1
  91. package/core/lib/emulation.js +2 -2
  92. package/core/lib/i18n/i18n.d.ts +0 -1
  93. package/core/lib/i18n/i18n.js +0 -2
  94. package/core/lib/lantern/cpu-node.d.ts +7 -1
  95. package/core/lib/lantern/cpu-node.js +12 -2
  96. package/core/lib/lantern/lantern-error.d.ts +8 -0
  97. package/core/lib/lantern/lantern-error.js +9 -0
  98. package/core/lib/lantern/metric.js +2 -6
  99. package/core/lib/lantern/metrics/first-contentful-paint.d.ts +79 -0
  100. package/core/lib/lantern/metrics/first-contentful-paint.js +200 -0
  101. package/core/lib/lantern/metrics/first-meaningful-paint.d.ts +6 -0
  102. package/core/lib/lantern/metrics/first-meaningful-paint.js +64 -0
  103. package/core/lib/lantern/metrics/interactive.d.ts +26 -0
  104. package/core/lib/lantern/metrics/interactive.js +112 -0
  105. package/core/lib/lantern/metrics/largest-contentful-paint.d.ts +19 -0
  106. package/core/lib/lantern/metrics/largest-contentful-paint.js +108 -0
  107. package/core/lib/lantern/metrics/max-potential-fid.d.ts +30 -0
  108. package/core/lib/lantern/metrics/max-potential-fid.js +92 -0
  109. package/core/lib/lantern/metrics/speed-index.d.ts +38 -0
  110. package/core/lib/lantern/metrics/speed-index.js +144 -0
  111. package/core/lib/lantern/metrics/total-blocking-time.d.ts +31 -0
  112. package/core/lib/lantern/metrics/total-blocking-time.js +128 -0
  113. package/core/lib/lantern/network-node.js +28 -4
  114. package/core/lib/lantern/page-dependency-graph.d.ts +4 -4
  115. package/core/lib/lantern/page-dependency-graph.js +19 -7
  116. package/core/lib/lantern/simulator/connection-pool.d.ts +2 -12
  117. package/core/lib/lantern/simulator/connection-pool.js +3 -22
  118. package/core/lib/lantern/simulator/network-analyzer.js +1 -12
  119. package/core/lib/lantern/simulator/simulator.d.ts +2 -4
  120. package/core/lib/lantern/simulator/simulator.js +7 -14
  121. package/core/lib/lantern/types/lantern.d.ts +5 -3
  122. package/core/lib/lantern-trace-saver.js +0 -1
  123. package/core/lib/lh-error.d.ts +9 -0
  124. package/core/lib/lh-error.js +13 -3
  125. package/core/lib/lighthouse-compatibility.js +53 -10
  126. package/core/lib/navigation-error.js +3 -0
  127. package/core/lib/network-request.d.ts +1 -0
  128. package/core/lib/network-request.js +28 -0
  129. package/core/runner.js +18 -25
  130. package/dist/report/bundle.esm.js +11 -112
  131. package/dist/report/flow.js +16 -117
  132. package/dist/report/standalone.js +12 -113
  133. package/flow-report/src/help-dialog.tsx +0 -1
  134. package/flow-report/src/i18n/i18n.d.ts +0 -4
  135. package/flow-report/src/i18n/ui-strings.d.ts +0 -1
  136. package/flow-report/src/i18n/ui-strings.js +0 -2
  137. package/flow-report/src/summary/category.tsx +10 -12
  138. package/package.json +5 -5
  139. package/readme.md +4 -4
  140. package/report/assets/styles.css +1 -60
  141. package/report/assets/templates.html +0 -95
  142. package/report/renderer/category-renderer.js +1 -1
  143. package/report/renderer/components.d.ts +2 -2
  144. package/report/renderer/components.js +2 -103
  145. package/report/renderer/dom.d.ts +1 -1
  146. package/report/renderer/dom.js +1 -1
  147. package/report/renderer/performance-category-renderer.d.ts +0 -7
  148. package/report/renderer/performance-category-renderer.js +1 -32
  149. package/report/renderer/report-renderer.js +3 -13
  150. package/report/renderer/report-ui-features.js +1 -1
  151. package/report/renderer/report-utils.d.ts +0 -1
  152. package/report/renderer/report-utils.js +13 -13
  153. package/shared/localization/locales/ar-XB.json +62 -329
  154. package/shared/localization/locales/ar.json +62 -329
  155. package/shared/localization/locales/bg.json +62 -329
  156. package/shared/localization/locales/ca.json +62 -329
  157. package/shared/localization/locales/cs.json +62 -329
  158. package/shared/localization/locales/da.json +62 -329
  159. package/shared/localization/locales/de.json +62 -329
  160. package/shared/localization/locales/el.json +62 -329
  161. package/shared/localization/locales/en-GB.json +62 -329
  162. package/shared/localization/locales/en-US.json +41 -272
  163. package/shared/localization/locales/en-XA.json +62 -329
  164. package/shared/localization/locales/en-XL.json +41 -272
  165. package/shared/localization/locales/es-419.json +62 -329
  166. package/shared/localization/locales/es.json +62 -329
  167. package/shared/localization/locales/fi.json +62 -329
  168. package/shared/localization/locales/fil.json +61 -328
  169. package/shared/localization/locales/fr.json +62 -329
  170. package/shared/localization/locales/he.json +62 -329
  171. package/shared/localization/locales/hi.json +62 -329
  172. package/shared/localization/locales/hr.json +63 -330
  173. package/shared/localization/locales/hu.json +62 -329
  174. package/shared/localization/locales/id.json +62 -329
  175. package/shared/localization/locales/it.json +62 -329
  176. package/shared/localization/locales/ja.json +62 -329
  177. package/shared/localization/locales/ko.json +62 -329
  178. package/shared/localization/locales/lt.json +62 -329
  179. package/shared/localization/locales/lv.json +62 -329
  180. package/shared/localization/locales/nl.json +62 -329
  181. package/shared/localization/locales/no.json +62 -329
  182. package/shared/localization/locales/pl.json +61 -328
  183. package/shared/localization/locales/pt-PT.json +62 -329
  184. package/shared/localization/locales/pt.json +64 -331
  185. package/shared/localization/locales/ro.json +62 -329
  186. package/shared/localization/locales/ru.json +62 -329
  187. package/shared/localization/locales/sk.json +62 -329
  188. package/shared/localization/locales/sl.json +62 -329
  189. package/shared/localization/locales/sr-Latn.json +62 -329
  190. package/shared/localization/locales/sr.json +62 -329
  191. package/shared/localization/locales/sv.json +62 -329
  192. package/shared/localization/locales/ta.json +61 -328
  193. package/shared/localization/locales/te.json +62 -329
  194. package/shared/localization/locales/th.json +62 -329
  195. package/shared/localization/locales/tr.json +62 -329
  196. package/shared/localization/locales/uk.json +62 -329
  197. package/shared/localization/locales/vi.json +61 -328
  198. package/shared/localization/locales/zh-HK.json +62 -329
  199. package/shared/localization/locales/zh-TW.json +61 -328
  200. package/shared/localization/locales/zh.json +62 -329
  201. package/tsconfig.json +1 -3
  202. package/types/artifacts.d.ts +21 -110
  203. package/types/audit.d.ts +0 -10
  204. package/types/config.d.ts +0 -1
  205. package/types/externs.d.ts +0 -2
  206. package/types/gatherer.d.ts +3 -0
  207. package/types/internal/smokehouse.d.ts +1 -1
  208. package/types/lh.d.ts +0 -2
  209. package/types/lhr/audit-details.d.ts +9 -4
  210. package/types/lhr/lhr.d.ts +0 -4
  211. package/types/lhr/settings.d.ts +0 -4
  212. package/core/audits/accessibility/duplicate-id-active.js +0 -42
  213. package/core/audits/content-width.d.ts +0 -17
  214. package/core/audits/content-width.js +0 -76
  215. package/core/audits/installable-manifest.d.ts +0 -111
  216. package/core/audits/installable-manifest.js +0 -248
  217. package/core/audits/layout-shift-elements.d.ts +0 -16
  218. package/core/audits/layout-shift-elements.js +0 -101
  219. package/core/audits/manual/pwa-cross-browser.d.ts +0 -12
  220. package/core/audits/manual/pwa-cross-browser.js +0 -40
  221. package/core/audits/manual/pwa-each-page-has-url.d.ts +0 -12
  222. package/core/audits/manual/pwa-each-page-has-url.js +0 -38
  223. package/core/audits/manual/pwa-page-transitions.d.ts +0 -12
  224. package/core/audits/manual/pwa-page-transitions.js +0 -38
  225. package/core/audits/maskable-icon.d.ts +0 -25
  226. package/core/audits/maskable-icon.js +0 -70
  227. package/core/audits/multi-check-audit.d.ts +0 -28
  228. package/core/audits/multi-check-audit.js +0 -82
  229. package/core/audits/no-unload-listeners.d.ts +0 -16
  230. package/core/audits/no-unload-listeners.js +0 -86
  231. package/core/audits/performance-budget.d.ts +0 -39
  232. package/core/audits/performance-budget.js +0 -154
  233. package/core/audits/script-elements-test-audit.d.ts +0 -14
  234. package/core/audits/script-elements-test-audit.js +0 -29
  235. package/core/audits/seo/plugins.d.ts +0 -15
  236. package/core/audits/seo/plugins.js +0 -150
  237. package/core/audits/seo/tap-targets.d.ts +0 -50
  238. package/core/audits/seo/tap-targets.js +0 -352
  239. package/core/audits/splash-screen.d.ts +0 -37
  240. package/core/audits/splash-screen.js +0 -98
  241. package/core/audits/themed-omnibox.d.ts +0 -42
  242. package/core/audits/themed-omnibox.js +0 -102
  243. package/core/audits/timing-budget.d.ts +0 -43
  244. package/core/audits/timing-budget.js +0 -175
  245. package/core/computed/manifest-values.d.ts +0 -24
  246. package/core/computed/manifest-values.js +0 -136
  247. package/core/config/budget.d.ts +0 -74
  248. package/core/config/budget.js +0 -340
  249. package/core/config/metrics-to-audits.d.ts +0 -19
  250. package/core/config/metrics-to-audits.js +0 -62
  251. package/core/gather/driver/service-workers.d.ts +0 -16
  252. package/core/gather/driver/service-workers.js +0 -52
  253. package/core/gather/gatherers/dobetterweb/tags-blocking-first-paint.d.ts +0 -47
  254. package/core/gather/gatherers/dobetterweb/tags-blocking-first-paint.js +0 -233
  255. package/core/gather/gatherers/global-listeners.d.ts +0 -27
  256. package/core/gather/gatherers/global-listeners.js +0 -108
  257. package/core/gather/gatherers/installability-errors.d.ts +0 -17
  258. package/core/gather/gatherers/installability-errors.js +0 -56
  259. package/core/gather/gatherers/script-elements.d.ts +0 -21
  260. package/core/gather/gatherers/script-elements.js +0 -100
  261. package/core/gather/gatherers/seo/embedded-content.d.ts +0 -10
  262. package/core/gather/gatherers/seo/embedded-content.js +0 -63
  263. package/core/gather/gatherers/seo/tap-targets.d.ts +0 -21
  264. package/core/gather/gatherers/seo/tap-targets.js +0 -389
  265. package/core/gather/gatherers/service-worker.d.ts +0 -10
  266. package/core/gather/gatherers/service-worker.js +0 -32
  267. package/core/gather/gatherers/web-app-manifest.d.ts +0 -32
  268. package/core/gather/gatherers/web-app-manifest.js +0 -106
  269. package/report/renderer/pwa-category-renderer.d.ts +0 -55
  270. package/report/renderer/pwa-category-renderer.js +0 -184
  271. package/third-party/chromium-synchronization/installability-errors-test.js +0 -79
  272. package/types/lhr/budget.d.ts +0 -60
@@ -1,184 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2018 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- import {CategoryRenderer} from './category-renderer.js';
8
- import {ReportUtils} from './report-utils.js';
9
- import {Globals} from './report-globals.js';
10
-
11
- export class PwaCategoryRenderer extends CategoryRenderer {
12
- /**
13
- * @param {LH.ReportResult.Category} category
14
- * @param {Object<string, LH.Result.ReportGroup>} [groupDefinitions]
15
- * @return {Element}
16
- */
17
- render(category, groupDefinitions = {}) {
18
- const categoryElem = this.dom.createElement('div', 'lh-category');
19
- categoryElem.id = category.id;
20
- // Deprecation warning banner.
21
- const pwaMessageContainer = this.dom.createComponent('warningsToplevel');
22
- const pwaMessageEl = this.dom.find('.lh-warnings__msg', pwaMessageContainer);
23
- pwaMessageEl.append(this.dom.convertMarkdownLinkSnippets(Globals.strings.pwaRemovalMessage));
24
-
25
- categoryElem.append(pwaMessageContainer);
26
- categoryElem.append(this.renderCategoryHeader(category, groupDefinitions));
27
-
28
- const auditRefs = category.auditRefs;
29
-
30
- // Regular audits aren't split up into pass/fail/notApplicable clumps, they're
31
- // all put in a top-level clump that isn't expandable/collapsible.
32
- const regularAuditRefs = auditRefs.filter(ref => ref.result.scoreDisplayMode !== 'manual');
33
- const auditsElem = this._renderAudits(regularAuditRefs, groupDefinitions);
34
- categoryElem.append(auditsElem);
35
-
36
- // Manual audits are still in a manual clump.
37
- const manualAuditRefs = auditRefs.filter(ref => ref.result.scoreDisplayMode === 'manual');
38
- const manualElem = this.renderClump('manual', {
39
- auditRefsOrEls: manualAuditRefs,
40
- description: category.manualDescription,
41
- openByDefault: true,
42
- });
43
- categoryElem.append(manualElem);
44
-
45
- return categoryElem;
46
- }
47
-
48
- /**
49
- * @param {LH.ReportResult.Category} category
50
- * @param {Record<string, LH.Result.ReportGroup>} groupDefinitions
51
- * @return {DocumentFragment}
52
- */
53
- renderCategoryScore(category, groupDefinitions) {
54
- // Defer to parent-gauge style if category error.
55
- if (category.score === null) {
56
- return super.renderScoreGauge(category, groupDefinitions);
57
- }
58
-
59
- const tmpl = this.dom.createComponent('gaugePwa');
60
- const wrapper = this.dom.find('a.lh-gauge--pwa__wrapper', tmpl);
61
-
62
- // Correct IDs in case multiple instances end up in the page.
63
- const svgRoot = tmpl.querySelector('svg');
64
- if (!svgRoot) throw new Error('no SVG element found in PWA score gauge template');
65
- PwaCategoryRenderer._makeSvgReferencesUnique(svgRoot);
66
-
67
- const allGroups = this._getGroupIds(category.auditRefs);
68
- const passingGroupIds = this._getPassingGroupIds(category.auditRefs);
69
-
70
- if (passingGroupIds.size === allGroups.size) {
71
- wrapper.classList.add('lh-badged--all');
72
- } else {
73
- for (const passingGroupId of passingGroupIds) {
74
- wrapper.classList.add(`lh-badged--${passingGroupId}`);
75
- }
76
- }
77
-
78
- this.dom.find('.lh-gauge__label', tmpl).textContent = category.title;
79
- wrapper.title = this._getGaugeTooltip(category.auditRefs, groupDefinitions);
80
- return tmpl;
81
- }
82
-
83
- /**
84
- * Returns the group IDs found in auditRefs.
85
- * @param {Array<LH.ReportResult.AuditRef>} auditRefs
86
- * @return {!Set<string>}
87
- */
88
- _getGroupIds(auditRefs) {
89
- const groupIds = auditRefs.map(ref => ref.group).filter(/** @return {g is string} */ g => !!g);
90
- return new Set(groupIds);
91
- }
92
-
93
- /**
94
- * Returns the group IDs whose audits are all considered passing.
95
- * @param {Array<LH.ReportResult.AuditRef>} auditRefs
96
- * @return {Set<string>}
97
- */
98
- _getPassingGroupIds(auditRefs) {
99
- const uniqueGroupIds = this._getGroupIds(auditRefs);
100
-
101
- // Remove any that have a failing audit.
102
- for (const auditRef of auditRefs) {
103
- if (!ReportUtils.showAsPassed(auditRef.result) && auditRef.group) {
104
- uniqueGroupIds.delete(auditRef.group);
105
- }
106
- }
107
-
108
- return uniqueGroupIds;
109
- }
110
-
111
- /**
112
- * Returns a tooltip string summarizing group pass rates.
113
- * @param {Array<LH.ReportResult.AuditRef>} auditRefs
114
- * @param {Record<string, LH.Result.ReportGroup>} groupDefinitions
115
- * @return {string}
116
- */
117
- _getGaugeTooltip(auditRefs, groupDefinitions) {
118
- const groupIds = this._getGroupIds(auditRefs);
119
-
120
- const tips = [];
121
- for (const groupId of groupIds) {
122
- const groupAuditRefs = auditRefs.filter(ref => ref.group === groupId);
123
- const auditCount = groupAuditRefs.length;
124
- const passedCount = groupAuditRefs.filter(ref => ReportUtils.showAsPassed(ref.result)).length;
125
-
126
- const title = groupDefinitions[groupId].title;
127
- tips.push(`${title}: ${passedCount}/${auditCount}`);
128
- }
129
-
130
- return tips.join(', ');
131
- }
132
-
133
- /**
134
- * Render non-manual audits in groups, giving a badge to any group that has
135
- * all passing audits.
136
- * @param {Array<LH.ReportResult.AuditRef>} auditRefs
137
- * @param {Object<string, LH.Result.ReportGroup>} groupDefinitions
138
- * @return {Element}
139
- */
140
- _renderAudits(auditRefs, groupDefinitions) {
141
- const auditsElem = this.renderUnexpandableClump(auditRefs, groupDefinitions);
142
-
143
- // Add a 'badged' class to group if all audits in that group pass.
144
- const passsingGroupIds = this._getPassingGroupIds(auditRefs);
145
- for (const groupId of passsingGroupIds) {
146
- const groupElem = this.dom.find(`.lh-audit-group--${groupId}`, auditsElem);
147
- groupElem.classList.add('lh-badged');
148
- }
149
-
150
- return auditsElem;
151
- }
152
-
153
- /**
154
- * Alters SVG id references so multiple instances of an SVG element can coexist
155
- * in a single page. If `svgRoot` has a `<defs>` block, gives all elements defined
156
- * in it unique ids, then updates id references (`<use xlink:href="...">`,
157
- * `fill="url(#...)"`) to the altered ids in all descendents of `svgRoot`.
158
- * @param {SVGElement} svgRoot
159
- */
160
- static _makeSvgReferencesUnique(svgRoot) {
161
- const defsEl = svgRoot.querySelector('defs');
162
- if (!defsEl) return;
163
-
164
- const idSuffix = Globals.getUniqueSuffix();
165
- const elementsToUpdate = defsEl.querySelectorAll('[id]');
166
- for (const el of elementsToUpdate) {
167
- const oldId = el.id;
168
- const newId = `${oldId}-${idSuffix}`;
169
- el.id = newId;
170
-
171
- // Update all <use>s.
172
- const useEls = svgRoot.querySelectorAll(`use[href="#${oldId}"]`);
173
- for (const useEl of useEls) {
174
- useEl.setAttribute('href', `#${newId}`);
175
- }
176
-
177
- // Update all fill="url(#...)"s.
178
- const fillEls = svgRoot.querySelectorAll(`[fill="url(#${oldId})"]`);
179
- for (const fillEl of fillEls) {
180
- fillEl.setAttribute('fill', `url(#${newId})`);
181
- }
182
- }
183
- }
184
- }
@@ -1,79 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2020 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- 'use strict';
7
-
8
- import fetch from 'node-fetch';
9
-
10
- import {UIStrings} from '../../core/audits/installable-manifest.js';
11
-
12
- describe('installabilityErrors', () => {
13
- let chromiumErrorIds;
14
-
15
- before(async () => {
16
- const installableLoggingGitTilesUrl =
17
- 'https://chromium.googlesource.com/chromium/src/+/main/components/webapps/browser/installable/installable_logging.cc?format=TEXT';
18
- const resp = await fetch(installableLoggingGitTilesUrl);
19
- if (!resp.ok) {
20
- throw new Error(`Chromium source fetch failed: ${resp.status} ${resp.statusText}`);
21
- }
22
- const base64 = await resp.text();
23
- const buff = Buffer.from(base64, 'base64');
24
- const text = buff.toString('utf-8');
25
-
26
- // Apply some *beautiful* regexes to parse the C++ of https://chromium.googlesource.com/chromium/src/+/main/chrome/browser/installable/installable_logging.cc
27
- const handledErrorConsts = [...text.matchAll(/error_id = (k.*?);/g)].map(([_, match]) => match);
28
- const errorConstsToIdsCode = [...text.matchAll(/static const char k.*?Id\[\](.|\n)*?;/g)].map(
29
- ([match]) => match.replace(/\n/, '')
30
- );
31
- const errorConstsToIds = errorConstsToIdsCode.map(txt => [
32
- txt.match(/char (k.*?)\[/)[1],
33
- txt.match(/ "(.*?)"/)[1],
34
- ]);
35
- const errorConstsToIdsDict = Object.fromEntries(errorConstsToIds);
36
-
37
- chromiumErrorIds = handledErrorConsts.map(varName => {
38
- if (!errorConstsToIdsDict[varName]) throw new Error(`Error const (${varName}) not found!`);
39
- return errorConstsToIdsDict[varName];
40
- }).sort();
41
- });
42
-
43
- it('should notify us if something changed', () => {
44
- expect(chromiumErrorIds).toMatchInlineSnapshot(`
45
- Array [
46
- "already-installed",
47
- "cannot-download-icon",
48
- "ids-do-not-match",
49
- "in-incognito",
50
- "manifest-display-not-supported",
51
- "manifest-display-override-not-supported",
52
- "manifest-location-changed",
53
- "manifest-missing-name-or-short-name",
54
- "manifest-missing-suitable-icon",
55
- "manifest-parsing-or-network-error",
56
- "no-acceptable-icon",
57
- "no-icon-available",
58
- "no-id-specified",
59
- "no-manifest",
60
- "no-url-for-service-worker",
61
- "not-from-secure-origin",
62
- "not-offline-capable",
63
- "pipeline-restarted",
64
- "platform-not-supported-on-android",
65
- "prefer-related-applications",
66
- "prefer-related-applications-only-beta-stable",
67
- "start-url-not-valid",
68
- "url-not-supported-for-webapk",
69
- ]
70
- `);
71
- });
72
-
73
- it('are each handled explicitly in the gatherer', () => {
74
- const errorStrings = Object.keys(UIStrings)
75
- .filter(key => chromiumErrorIds.includes(key))
76
- .sort();
77
- expect(errorStrings).toEqual(chromiumErrorIds);
78
- });
79
- });
@@ -1,60 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2019 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- /**
8
- * The performance budget interface.
9
- * More info: https://github.com/GoogleChrome/budget.json
10
- */
11
- interface Budget {
12
- /** Budget options */
13
- options?: Budget.Options;
14
- /**
15
- * Indicates which pages a budget applies to. Uses the robots.txt format.
16
- * If it is not supplied, the budget applies to all pages.
17
- * More info on robots.txt: https://developers.google.com/search/reference/robots_txt#url-matching-based-on-path-values
18
- */
19
- path?: string;
20
- /** Budgets based on resource count. */
21
- resourceCounts?: Array<Budget.ResourceBudget>;
22
- /** Budgets based on resource size. */
23
- resourceSizes?: Array<Budget.ResourceBudget>;
24
- /** Budgets based on timing metrics. */
25
- timings?: Array<Budget.TimingBudget>;
26
- }
27
-
28
- declare module Budget {
29
- interface ResourceBudget {
30
- /** The resource type that a budget applies to. */
31
- resourceType: ResourceType;
32
- /** Budget for resource. Depending on context, this is either the count or size (KiB) of a resource. */
33
- budget: number;
34
- }
35
-
36
- interface TimingBudget {
37
- /** The type of timing metric. */
38
- metric: TimingMetric;
39
- /** Budget for timing measurement, in milliseconds. */
40
- budget: number;
41
- }
42
-
43
- interface Options {
44
- /**
45
- * List of hostnames used to classify resources as 1st or 3rd party.
46
- * Wildcards can optionally be used to match a hostname and all of its subdomains.
47
- * For example e.g.: "*.news.gov.uk" matches both "news.gov.uk" and "en.news.gov.uk"
48
- * If this property is not set, the root domain and all its subdomains are considered first party.
49
- */
50
- firstPartyHostnames?: Array<string>;
51
- }
52
-
53
- /** Supported timing metrics. */
54
- type TimingMetric = 'first-contentful-paint' | 'interactive' | 'first-meaningful-paint' | 'max-potential-fid' | 'total-blocking-time' | 'speed-index' | 'largest-contentful-paint' | 'cumulative-layout-shift';
55
-
56
- /** Supported values for the resourceType property of a ResourceBudget. */
57
- type ResourceType = 'stylesheet' | 'image' | 'media' | 'font' | 'script' | 'document' | 'other' | 'total' | 'third-party';
58
- }
59
-
60
- export default Budget;