lighthouse 10.0.0-dev.20230213 → 10.0.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 (75) hide show
  1. package/core/audits/dobetterweb/doctype.d.ts +3 -2
  2. package/core/audits/dobetterweb/doctype.js +15 -4
  3. package/core/audits/dobetterweb/paste-preventing-inputs.js +2 -2
  4. package/core/gather/driver/network-monitor.js +1 -3
  5. package/core/gather/gatherers/bf-cache-failures.js +7 -8
  6. package/package.json +1 -1
  7. package/shared/localization/locales/en-US.json +1 -1
  8. package/shared/localization/locales/en-XL.json +1 -1
  9. package/.codecov.yml +0 -22
  10. package/.cz-config.js +0 -24
  11. package/.gitattributes +0 -5
  12. package/.mailmap +0 -6
  13. package/CODE_OF_CONDUCT.md +0 -93
  14. package/eslint-local-rules.cjs +0 -106
  15. package/flow-report/test/app-test.d.ts +0 -7
  16. package/flow-report/test/app-test.tsx +0 -52
  17. package/flow-report/test/common-test.d.ts +0 -7
  18. package/flow-report/test/common-test.tsx +0 -103
  19. package/flow-report/test/flow-report-pptr-test.d.ts +0 -7
  20. package/flow-report/test/flow-report-pptr-test.ts +0 -59
  21. package/flow-report/test/header-test.d.ts +0 -7
  22. package/flow-report/test/header-test.tsx +0 -55
  23. package/flow-report/test/run-flow-report-tests.sh +0 -20
  24. package/flow-report/test/sample-flow.d.ts +0 -7
  25. package/flow-report/test/sample-flow.ts +0 -17
  26. package/flow-report/test/setup/env-setup.d.ts +0 -11
  27. package/flow-report/test/setup/env-setup.ts +0 -55
  28. package/flow-report/test/sidebar/flow-test.d.ts +0 -7
  29. package/flow-report/test/sidebar/flow-test.tsx +0 -65
  30. package/flow-report/test/sidebar/sidebar-test.d.ts +0 -7
  31. package/flow-report/test/sidebar/sidebar-test.tsx +0 -116
  32. package/flow-report/test/summary/category-test.d.ts +0 -7
  33. package/flow-report/test/summary/category-test.tsx +0 -206
  34. package/flow-report/test/summary/summary-test.d.ts +0 -7
  35. package/flow-report/test/summary/summary-test.tsx +0 -124
  36. package/flow-report/test/topbar-test.d.ts +0 -7
  37. package/flow-report/test/topbar-test.tsx +0 -84
  38. package/flow-report/test/util-test.d.ts +0 -7
  39. package/flow-report/test/util-test.tsx +0 -133
  40. package/flow-report/test/wrappers/category-score-test.d.ts +0 -7
  41. package/flow-report/test/wrappers/category-score-test.tsx +0 -84
  42. package/flow-report/test/wrappers/markdown-test.d.ts +0 -7
  43. package/flow-report/test/wrappers/markdown-test.tsx +0 -17
  44. package/report/test/clients/bundle-test.js +0 -65
  45. package/report/test/generator/file-namer-test.js +0 -27
  46. package/report/test/generator/report-generator-test.js +0 -160
  47. package/report/test/renderer/__snapshots__/report-renderer-axe-test.js.snap +0 -15
  48. package/report/test/renderer/category-renderer-test.js +0 -575
  49. package/report/test/renderer/components-test.js +0 -124
  50. package/report/test/renderer/crc-details-renderer-test.js +0 -116
  51. package/report/test/renderer/details-renderer-test.js +0 -882
  52. package/report/test/renderer/dom-test.js +0 -257
  53. package/report/test/renderer/element-screenshot-renderer-test.js +0 -183
  54. package/report/test/renderer/i18n-formatter-test.js +0 -179
  55. package/report/test/renderer/performance-category-renderer-test.js +0 -417
  56. package/report/test/renderer/pwa-category-renderer-test.js +0 -301
  57. package/report/test/renderer/report-renderer-axe-test.js +0 -85
  58. package/report/test/renderer/report-renderer-test.js +0 -268
  59. package/report/test/renderer/report-ui-features-test.js +0 -773
  60. package/report/test/renderer/report-utils-test.js +0 -219
  61. package/report/test/renderer/snippet-renderer-test.js +0 -291
  62. package/report/test/renderer/text-encoding-test.js +0 -43
  63. package/report/test-assets/faux-psi-template.html +0 -177
  64. package/report/test-assets/faux-psi.d.ts +0 -34
  65. package/report/test-assets/faux-psi.js +0 -168
  66. package/report/test-assets/lhr-3.0.0.json +0 -2332
  67. package/report/test-assets/lhr-4.3.0.json +0 -4754
  68. package/report/test-assets/lhr-5.0.0.json +0 -5994
  69. package/report/test-assets/lhr-6.0.0.json +0 -7222
  70. package/report/test-assets/lhr-8.5.0.json +0 -8679
  71. package/shared/test/localization/format-test.js +0 -430
  72. package/shared/test/localization/locales-test.js +0 -45
  73. package/shared/test/localization/swap-locale-test.js +0 -127
  74. package/shared/test/util-test.js +0 -214
  75. package/vercel.json +0 -6
@@ -1,177 +0,0 @@
1
- <!--
2
- * Copyright 2021 The Lighthouse Authors. All Rights Reserved.
3
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
4
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
5
- -->
6
-
7
- <!--
8
- This fake psi page is intended to reproduce the experience of rendering two LHRs within the same DOM,
9
- like in PageSpeed Insights. This helps surface the peculiar behavior around tabs,
10
- expectations of unique IDs, and scoped report containment.
11
- -->
12
-
13
- <!doctype html>
14
- <html lang="en">
15
- <head>
16
- <meta charset="utf-8">
17
- <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
18
- <title>Faux PageSpeed Report</title>
19
-
20
- <style>
21
- /* Inspired by https://codepen.io/markcaron/pen/MvGRYV?editors=1100 but improved. s*/
22
- /*
23
- The tab visibility basics
24
- */
25
- .tabset > input[type="radio"] {
26
- position: absolute;
27
- left: -200vw;
28
- }
29
-
30
- .tabset .tab-panel {
31
- display: none;
32
- }
33
-
34
- .tabset > input:nth-of-type(1):checked ~ .tab-panels > .tab-panel:nth-of-type(1),
35
- .tabset > input:nth-of-type(2):checked ~ .tab-panels > .tab-panel:nth-of-type(2) {
36
- display: block;
37
- }
38
-
39
- /*
40
- Purdy tabs
41
- */
42
- .tabset > label {
43
- position: relative;
44
- display: inline-block;
45
- padding: 15px 55px 15px;
46
- cursor: pointer;
47
- font-weight: 600;
48
- border-bottom: 3px solid transparent;
49
- }
50
-
51
- .tabset > label:hover {
52
- background-color: hsl(0deg 0% 100% / 24%);
53
- }
54
-
55
- .tabset > label:hover,
56
- .tabset > input:focus + label {
57
- color: #06c;
58
- }
59
-
60
- .tabset > input:checked + label {
61
- margin-bottom: -1px;
62
- background: white;
63
- border-bottom: 3px solid blue;
64
- }
65
-
66
- .tab-panel {
67
- border: 1px solid #ccc;
68
- padding: 24px;
69
- row-gap: calc(8px*2);
70
- border-radius: calc(8px/2);
71
- }
72
-
73
-
74
- .tabset {
75
-
76
- }
77
-
78
- .tab-panels {
79
- background: white;
80
- }
81
-
82
- body {
83
- height: 100%;
84
- overflow: hidden;
85
- -webkit-font-smoothing: antialiased;
86
- color: rgba(0,0,0,0.87);
87
- font-family: Roboto,RobotoDraft,Helvetica,Arial,sans-serif;
88
- margin: 0;
89
- text-size-adjust: 100%;
90
- bottom: auto;
91
- right: auto;
92
- width: auto;
93
- overflow: visible;
94
- overflow-y: scroll;
95
- overscroll-behavior: contain;
96
- }
97
- .page {
98
- max-width: 960px;
99
- width: calc(100% - 24px*2);
100
- margin: auto;
101
- padding: 24px;
102
- padding-top: calc(24px*2);
103
- min-width: calc(360px - 8px *2);
104
- }
105
- @media screen and (max-width: 768px) {
106
- .page {
107
- padding:8px;
108
- width: calc(100% - 8px*2);
109
- padding-top: calc(24px/2)
110
- }
111
- .tab-panel {
112
- padding:unset;
113
- border-width: 0;
114
- }
115
- }
116
- .hrefbar {
117
- background: hsl(210deg 17% 98%);
118
- border: 1px solid hsl(0deg 0% 85%);
119
- border-width: 1px 0;
120
- padding: 4px;
121
- }
122
- #reanalyze {
123
- background-color: hsl(216deg 100% 50%);
124
- border-radius: 4px;
125
- color: white;
126
- padding: 13px;
127
- border: 0;
128
- cursor: pointer;
129
- float: right;
130
- }
131
-
132
- </style>
133
- </head>
134
- <body >
135
- <noscript>PSI requires JavaScript. Please enable.</noscript>
136
- <button type=button id="translate">rotate locale</button>
137
- <div class="page">
138
- <button type=button id="reanalyze">Reanalyze</button>
139
- <div class="tabset">
140
- <input type="radio" name="tabset" id="tab1" aria-controls="mobile" checked />
141
- <label for="tab1">Mobile</label>
142
-
143
- <input type="radio" name="tabset" id="tab2" aria-controls="desktop" />
144
- <label for="tab2">Desktop</label>
145
-
146
- <div class="tab-panels">
147
- <section id="mobile" class="tab-panel">
148
- <h2>Diagnose performance issues</h2>
149
- <h4>
150
- See detailed analysis and recommendations from loading your site in a simulated
151
- environment.
152
- </h4>
153
- <div class="hrefbar">🔗 http://thisurl.com</div>
154
- <div class="reportContainer"></div>
155
- </section>
156
-
157
- <section id="desktop" class="tab-panel">
158
- <h2>Diagnose performance issues</h2>
159
- <h4>
160
- See detailed analysis and recommendations from loading your site in a simulated
161
- environment.
162
- </h4>
163
- <div class="hrefbar">🔗 http://thisurl.com</div>
164
- <div class="reportContainer"></div>
165
- </section>
166
- </div>
167
- </div>
168
- </div>
169
-
170
- <script>window.__LIGHTHOUSE_JSON__ = %%LIGHTHOUSE_JSON%%;</script>
171
- <script type="module">
172
- %%LIGHTHOUSE_JAVASCRIPT%%
173
- //# sourceURL=psi-reportrenderer.js
174
- </script>
175
- <script>console.log('window.__LIGHTHOUSE_JSON__', __LIGHTHOUSE_JSON__);</script>
176
- </body>
177
- </html>
@@ -1,34 +0,0 @@
1
- /**
2
- * @param {any} lhr
3
- * @param {Element} container
4
- */
5
- declare function renderLHReport(lhr: any, container: Element): Promise<void>;
6
- /**
7
- * @param {LH.Locale} locale
8
- */
9
- declare function swapLhrLocale(locale: LH.Locale): Promise<void>;
10
- /**
11
- * Tweak the LHR to make the desktop and mobile reports easier to identify.
12
- * Adjusted: Perf category name and score, and emoji placed on top of key screenshots.
13
- * @param {LH.Result} lhr
14
- * @param {string} tabId
15
- */
16
- declare function distinguishLHR(lhr: LH.Result, tabId: string): Promise<void>;
17
- /**
18
- * Add 📱 and 💻 emoji on top of screenshot
19
- * @param {string} datauri
20
- * @param {string} tabId
21
- */
22
- declare function decorateScreenshot(datauri: string, tabId: string): Promise<string>;
23
- type lighthouseRenderer = typeof import("../clients/bundle.js");
24
- /**
25
- * @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
26
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
27
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
28
- */
29
- /** @fileoverview This file exercises two LH reports within the same DOM. */
30
- /** @typedef {import('../clients/bundle.js')} lighthouseRenderer */
31
- /** @type {lighthouseRenderer} */
32
- declare const lighthouseRenderer: lighthouseRenderer;
33
- declare function wait(ms?: number): Promise<any>;
34
- //# sourceMappingURL=faux-psi.d.ts.map
@@ -1,168 +0,0 @@
1
- /**
2
- * @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
3
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
4
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
5
- */
6
-
7
- /** @fileoverview This file exercises two LH reports within the same DOM. */
8
-
9
- /** @typedef {import('../clients/bundle.js')} lighthouseRenderer */
10
- /** @type {lighthouseRenderer} */
11
- // @ts-expect-error
12
- const lighthouseRenderer = window['report'];
13
-
14
- const wait = (ms = 100) => new Promise(resolve => setTimeout(resolve, ms));
15
-
16
- (async function __initPsiReports__() {
17
- document.querySelector('button#reanalyze')?.addEventListener('click', () => {
18
- __initPsiReports__();
19
- });
20
-
21
- document.querySelector('button#translate')?.addEventListener('click', async () => {
22
- const hash = location.hash.slice(1);
23
- const someLocales = ['es', 'ja', 'ru', 'ar', 'en-US'];
24
- // Just rotate to the next one
25
- const nextLocale = someLocales[(someLocales.indexOf(hash) + 1) % someLocales.length];
26
- location.hash = `#${nextLocale}`;
27
- location.reload();
28
- });
29
-
30
- const hash = location.hash.slice(1);
31
- if (hash) {
32
- // @ts-expect-error Can't do string to LH.Locale
33
- await swapLhrLocale(hash);
34
- }
35
-
36
- // We deliberately want the non-blocking await behavior w/ forEach
37
- ['mobile', 'desktop'].forEach(async id => {
38
- const container = document.querySelector(`section#${id} .reportContainer`);
39
- if (!container) throw new Error('Unexpected DOM. Bailing.');
40
- container.textContent = 'Analyzing…';
41
- await wait(id === 'desktop' ? 3000 : 500);
42
-
43
- // @ts-expect-error
44
- const lhr = JSON.parse(JSON.stringify(window.__LIGHTHOUSE_JSON__));
45
- await distinguishLHR(lhr, id);
46
-
47
- renderLHReport(lhr, container);
48
- });
49
- })();
50
-
51
- /**
52
- * @param {any} lhr
53
- * @param {Element} container
54
- */
55
- async function renderLHReport(lhr, container) {
56
- try {
57
- for (const el of container.childNodes) el.remove();
58
-
59
- const reportRootEl = lighthouseRenderer.renderReport(lhr, {
60
- omitTopbar: true,
61
- disableFireworks: true,
62
- disableDarkMode: true,
63
- });
64
- // TODO: display warnings if appropriate.
65
- for (const el of reportRootEl.querySelectorAll('.lh-warnings--toplevel')) {
66
- el.setAttribute('hidden', 'true');
67
- }
68
-
69
- // Move env block
70
- const metaItemsEl = reportRootEl.querySelector('.lh-meta__items');
71
- if (metaItemsEl) {
72
- reportRootEl.querySelector('.lh-metrics-container')?.parentNode?.insertBefore(
73
- metaItemsEl,
74
- reportRootEl.querySelector('.lh-buttons')
75
- );
76
- reportRootEl.querySelector('.lh-metrics-container')?.closest('.lh-category')?.classList
77
- .add('lh--hoisted-meta');
78
- }
79
-
80
- container.append(reportRootEl);
81
-
82
- // Override some LH styles. (To find .lh-vars we must descend from reportRootEl's parent)
83
- for (const el of container.querySelectorAll('article.lh-vars')) {
84
- // Ensure these css var names are not stale.
85
- el.style.setProperty('--report-content-max-width', '100%');
86
- el.style.setProperty('--edge-gap-padding', '0');
87
- }
88
- for (const el of reportRootEl.querySelectorAll('footer.lh-footer')) {
89
- el.style.display = 'none';
90
- }
91
- } catch (e) {
92
- console.error(e);
93
- container.textContent = 'Error: LHR failed to render.';
94
- }
95
- }
96
-
97
- /**
98
- * @param {LH.Locale} locale
99
- */
100
- async function swapLhrLocale(locale) {
101
- // @ts-expect-error LHR global
102
- const lhrLocale = window.__LIGHTHOUSE_JSON__['configSettings']['locale'];
103
-
104
- // Only fetch and swapLocale if necessary.
105
- if (lhrLocale === locale) return;
106
-
107
- if (!lighthouseRenderer.format.hasLocale(locale)) {
108
- // Requires running a server in LH root and viewing localhost:XXXX/dist/sample-reports/⌣.psi.english/index.html
109
- const response = await fetch(`/shared/localization/locales/${locale}.json`);
110
- /** @type {import('../../shared/localization/locales').LhlMessages} */
111
- const lhlMessages = await response.json();
112
- if (!lhlMessages) throw new Error(`could not fetch data for locale: ${locale}`);
113
- lighthouseRenderer.format.registerLocaleData(locale, lhlMessages);
114
- }
115
- // @ts-expect-error LHR global
116
- window.__LIGHTHOUSE_JSON__ = lighthouseRenderer.swapLocale(window.__LIGHTHOUSE_JSON__, locale)
117
- .lhr;
118
- }
119
-
120
-
121
- /**
122
- * Tweak the LHR to make the desktop and mobile reports easier to identify.
123
- * Adjusted: Perf category name and score, and emoji placed on top of key screenshots.
124
- * @param {LH.Result} lhr
125
- * @param {string} tabId
126
- */
127
- async function distinguishLHR(lhr, tabId) {
128
- if (tabId === 'desktop') {
129
- lhr.categories.performance.score = 0.81;
130
- }
131
-
132
- const finalSSDetails = lhr.audits['final-screenshot']?.details;
133
- if (finalSSDetails && finalSSDetails.type === 'screenshot') {
134
- finalSSDetails.data = await decorateScreenshot(finalSSDetails.data, tabId);
135
- }
136
-
137
- if (lhr.fullPageScreenshot) {
138
- lhr.fullPageScreenshot.screenshot.data =
139
- await decorateScreenshot(lhr.fullPageScreenshot.screenshot.data, tabId);
140
- }
141
- }
142
-
143
- /**
144
- * Add 📱 and 💻 emoji on top of screenshot
145
- * @param {string} datauri
146
- * @param {string} tabId
147
- */
148
- async function decorateScreenshot(datauri, tabId) {
149
- const img = document.createElement('img');
150
-
151
- await new Promise((resolve, reject) => {
152
- img.addEventListener('load', () => resolve(img));
153
- img.addEventListener('error', (err) => reject(err));
154
- img.src = datauri;
155
- });
156
- const c = document.createElement('canvas');
157
- c.width = tabId === 'desktop' ? 280 : img.width;
158
- c.height = tabId === 'desktop' ? 194 : img.height;
159
-
160
- const ctx = c.getContext('2d');
161
- if (!ctx) throw new Error();
162
- ctx.drawImage(img, 0, 0, c.width, c.height);
163
- ctx.font = `${c.width / 2}px serif`;
164
- ctx.textAlign = 'center';
165
- ctx.globalAlpha = 0.7;
166
- ctx.fillText(tabId === 'mobile' ? '📱' : '💻', c.width / 2, Math.min(c.height / 2, 700));
167
- return c.toDataURL();
168
- }