lighthouse 9.5.0-dev.20220416 → 9.5.0-dev.20220419
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.
- package/dist/report/bundle.esm.js +117 -70
- package/dist/report/flow.js +23 -23
- package/dist/report/standalone.js +14 -14
- package/flow-report/src/summary/category.tsx +1 -1
- package/lighthouse-cli/.eslintrc.cjs +3 -4
- package/lighthouse-cli/bin.js +0 -1
- package/lighthouse-cli/cli-flags.js +0 -1
- package/lighthouse-cli/commands/commands.js +0 -1
- package/lighthouse-cli/commands/list-audits.js +0 -1
- package/lighthouse-cli/commands/list-locales.js +0 -1
- package/lighthouse-cli/commands/list-trace-categories.js +0 -1
- package/lighthouse-cli/index.js +0 -1
- package/lighthouse-cli/printer.js +0 -1
- package/lighthouse-cli/run.js +0 -1
- package/lighthouse-cli/sentry-prompt.js +0 -1
- package/lighthouse-cli/test/smokehouse/core-tests.js +0 -1
- package/lighthouse-cli/test/smokehouse/frontends/back-compat-util.js +0 -1
- package/lighthouse-cli/test/smokehouse/frontends/lib.js +0 -1
- package/lighthouse-cli/test/smokehouse/frontends/node.js +0 -1
- package/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js +0 -1
- package/lighthouse-cli/test/smokehouse/lib/child-process-error.js +0 -1
- package/lighthouse-cli/test/smokehouse/lib/concurrent-mapper.js +0 -1
- package/lighthouse-cli/test/smokehouse/lib/local-console.js +0 -1
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/bundle.js +0 -1
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/cli.js +0 -1
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/devtools.js +0 -1
- package/lighthouse-cli/test/smokehouse/report-assert.js +0 -1
- package/lighthouse-cli/test/smokehouse/smokehouse.js +0 -1
- package/lighthouse-core/audits/byte-efficiency/legacy-javascript.js +1 -1
- package/lighthouse-core/fraggle-rock/gather/navigation-runner.js +16 -2
- package/lighthouse-core/gather/gatherers/full-page-screenshot.js +3 -2
- package/lighthouse-core/index.js +2 -9
- package/lighthouse-core/lib/stack-packs.js +4 -0
- package/lighthouse-core/scripts/manual-chrome-launcher.js +0 -1
- package/lighthouse-core/util-commonjs.js +14 -8
- package/package.json +3 -3
- package/report/.eslintrc.cjs +3 -1
- package/report/assets/styles.css +5 -2
- package/report/assets/templates.html +10 -9
- package/report/clients/bundle.js +0 -1
- package/report/clients/standalone.js +0 -1
- package/report/renderer/api.js +0 -1
- package/report/renderer/category-renderer.js +0 -1
- package/report/renderer/components.js +13 -14
- package/report/renderer/crc-details-renderer.js +0 -1
- package/report/renderer/details-renderer.js +0 -1
- package/report/renderer/dom.js +0 -1
- package/report/renderer/drop-down-menu.js +0 -1
- package/report/renderer/element-screenshot-renderer.js +0 -4
- package/report/renderer/features-util.js +0 -1
- package/report/renderer/i18n.js +91 -49
- package/report/renderer/logger.js +0 -1
- package/report/renderer/open-tab.js +0 -1
- package/report/renderer/performance-category-renderer.js +0 -1
- package/report/renderer/pwa-category-renderer.js +0 -1
- package/report/renderer/report-renderer.js +0 -1
- package/report/renderer/report-ui-features.js +0 -1
- package/report/renderer/snippet-renderer.js +0 -1
- package/report/renderer/swap-locale-feature.js +0 -1
- package/report/renderer/text-encoding.js +0 -1
- package/report/renderer/topbar-features.js +0 -1
- package/report/renderer/util.js +13 -8
- package/report/test/clients/bundle-test.js +0 -1
- package/report/test/renderer/category-renderer-test.js +0 -1
- package/report/test/renderer/components-test.js +0 -1
- package/report/test/renderer/crc-details-renderer-test.js +0 -1
- package/report/test/renderer/details-renderer-test.js +0 -1
- package/report/test/renderer/dom-test.js +0 -1
- package/report/test/renderer/element-screenshot-renderer-test.js +3 -4
- package/report/test/renderer/i18n-test.js +26 -8
- package/report/test/renderer/performance-category-renderer-test.js +0 -1
- package/report/test/renderer/pwa-category-renderer-test.js +0 -1
- package/report/test/renderer/report-renderer-axe-test.js +0 -1
- package/report/test/renderer/report-renderer-test.js +0 -1
- package/report/test/renderer/report-ui-features-test.js +0 -1
- package/report/test/renderer/snippet-renderer-test.js +0 -1
- package/report/test/renderer/text-encoding-test.js +0 -1
- package/report/test/renderer/util-test.js +2 -3
- package/report/test-assets/faux-psi.js +0 -1
- package/shared/localization/locales/en-US.json +26 -5
- package/shared/localization/locales/en-XL.json +26 -5
- package/third-party/snyk/snapshot.json +2 -2
- package/types/config.d.ts +2 -0
package/report/renderer/i18n.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
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
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
5
|
*/
|
|
6
|
-
'use strict';
|
|
7
6
|
|
|
8
7
|
// Not named `NBSP` because that creates a duplicate identifier (util.js).
|
|
9
8
|
const NBSP2 = '\xa0';
|
|
@@ -22,9 +21,7 @@ export class I18n {
|
|
|
22
21
|
// When testing, use a locale with more exciting numeric formatting.
|
|
23
22
|
if (locale === 'en-XA') locale = 'de';
|
|
24
23
|
|
|
25
|
-
this.
|
|
26
|
-
this._numberFormatter = new Intl.NumberFormat(locale);
|
|
27
|
-
this._percentFormatter = new Intl.NumberFormat(locale, {style: 'percent'});
|
|
24
|
+
this._locale = locale;
|
|
28
25
|
this._strings = strings;
|
|
29
26
|
}
|
|
30
27
|
|
|
@@ -32,6 +29,32 @@ export class I18n {
|
|
|
32
29
|
return this._strings;
|
|
33
30
|
}
|
|
34
31
|
|
|
32
|
+
/**
|
|
33
|
+
* @param {number} number
|
|
34
|
+
* @param {number} granularity
|
|
35
|
+
* @param {Intl.NumberFormatOptions} opts
|
|
36
|
+
* @return {string}
|
|
37
|
+
*/
|
|
38
|
+
_formatNumberWithGranularity(number, granularity, opts = {}) {
|
|
39
|
+
opts = {...opts};
|
|
40
|
+
const log10 = -Math.log10(granularity);
|
|
41
|
+
if (!Number.isFinite(log10) || (granularity > 1 && !Number.isInteger(log10))) {
|
|
42
|
+
console.warn(`granularity of ${granularity} is invalid, defaulting to value of 1`);
|
|
43
|
+
granularity = 1;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (granularity < 1) {
|
|
47
|
+
opts.minimumFractionDigits = opts.maximumFractionDigits = Math.ceil(log10);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
number = Math.round(number / granularity) * granularity;
|
|
51
|
+
|
|
52
|
+
// Avoid displaying a negative value that rounds to zero as "0".
|
|
53
|
+
if (Object.is(number, -0)) number = 0;
|
|
54
|
+
|
|
55
|
+
return new Intl.NumberFormat(this._locale, opts).format(number).replace(' ', NBSP2);
|
|
56
|
+
}
|
|
57
|
+
|
|
35
58
|
/**
|
|
36
59
|
* Format number.
|
|
37
60
|
* @param {number} number
|
|
@@ -39,8 +62,18 @@ export class I18n {
|
|
|
39
62
|
* @return {string}
|
|
40
63
|
*/
|
|
41
64
|
formatNumber(number, granularity = 0.1) {
|
|
42
|
-
|
|
43
|
-
|
|
65
|
+
return this._formatNumberWithGranularity(number, granularity);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Format integer.
|
|
70
|
+
* Just like {@link formatNumber} but uses a granularity of 1, rounding to the nearest
|
|
71
|
+
* whole number.
|
|
72
|
+
* @param {number} number
|
|
73
|
+
* @return {string}
|
|
74
|
+
*/
|
|
75
|
+
formatInteger(number) {
|
|
76
|
+
return this._formatNumberWithGranularity(number, 1);
|
|
44
77
|
}
|
|
45
78
|
|
|
46
79
|
/**
|
|
@@ -49,7 +82,7 @@ export class I18n {
|
|
|
49
82
|
* @return {string}
|
|
50
83
|
*/
|
|
51
84
|
formatPercent(number) {
|
|
52
|
-
return this.
|
|
85
|
+
return new Intl.NumberFormat(this._locale, {style: 'percent'}).format(number);
|
|
53
86
|
}
|
|
54
87
|
|
|
55
88
|
/**
|
|
@@ -58,9 +91,7 @@ export class I18n {
|
|
|
58
91
|
* @return {string}
|
|
59
92
|
*/
|
|
60
93
|
formatBytesToKiB(size, granularity = 0.1) {
|
|
61
|
-
|
|
62
|
-
const kbs = formatter.format(Math.round(size / 1024 / granularity) * granularity);
|
|
63
|
-
return `${kbs}${NBSP2}KiB`;
|
|
94
|
+
return this._formatNumberWithGranularity(size / KiB, granularity) + `${NBSP2}KiB`;
|
|
64
95
|
}
|
|
65
96
|
|
|
66
97
|
/**
|
|
@@ -69,9 +100,7 @@ export class I18n {
|
|
|
69
100
|
* @return {string}
|
|
70
101
|
*/
|
|
71
102
|
formatBytesToMiB(size, granularity = 0.1) {
|
|
72
|
-
|
|
73
|
-
const kbs = formatter.format(Math.round(size / (1024 ** 2) / granularity) * granularity);
|
|
74
|
-
return `${kbs}${NBSP2}MiB`;
|
|
103
|
+
return this._formatNumberWithGranularity(size / MiB, granularity) + `${NBSP2}MiB`;
|
|
75
104
|
}
|
|
76
105
|
|
|
77
106
|
/**
|
|
@@ -80,9 +109,11 @@ export class I18n {
|
|
|
80
109
|
* @return {string}
|
|
81
110
|
*/
|
|
82
111
|
formatBytes(size, granularity = 1) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
112
|
+
return this._formatNumberWithGranularity(size, granularity, {
|
|
113
|
+
style: 'unit',
|
|
114
|
+
unit: 'byte',
|
|
115
|
+
unitDisplay: 'long',
|
|
116
|
+
});
|
|
86
117
|
}
|
|
87
118
|
|
|
88
119
|
/**
|
|
@@ -93,25 +124,23 @@ export class I18n {
|
|
|
93
124
|
formatBytesWithBestUnit(size, granularity = 0.1) {
|
|
94
125
|
if (size >= MiB) return this.formatBytesToMiB(size, granularity);
|
|
95
126
|
if (size >= KiB) return this.formatBytesToKiB(size, granularity);
|
|
96
|
-
return this.
|
|
127
|
+
return this._formatNumberWithGranularity(size, granularity, {
|
|
128
|
+
style: 'unit',
|
|
129
|
+
unit: 'byte',
|
|
130
|
+
unitDisplay: 'narrow',
|
|
131
|
+
});
|
|
97
132
|
}
|
|
98
133
|
|
|
99
134
|
/**
|
|
100
|
-
*
|
|
101
|
-
* @param {number} granularity Controls how coarse the displayed value is
|
|
102
|
-
* @return {
|
|
135
|
+
* @param {number} size
|
|
136
|
+
* @param {number=} granularity Controls how coarse the displayed value is, defaults to 1
|
|
137
|
+
* @return {string}
|
|
103
138
|
*/
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return new Intl.NumberFormat(this._numberDateLocale, {
|
|
112
|
-
...this._numberFormatter.resolvedOptions(),
|
|
113
|
-
maximumFractionDigits: numberOfFractionDigits,
|
|
114
|
-
minimumFractionDigits: numberOfFractionDigits,
|
|
139
|
+
formatKbps(size, granularity = 1) {
|
|
140
|
+
return this._formatNumberWithGranularity(size, granularity, {
|
|
141
|
+
style: 'unit',
|
|
142
|
+
unit: 'kilobit-per-second',
|
|
143
|
+
unitDisplay: 'short',
|
|
115
144
|
});
|
|
116
145
|
}
|
|
117
146
|
|
|
@@ -121,10 +150,11 @@ export class I18n {
|
|
|
121
150
|
* @return {string}
|
|
122
151
|
*/
|
|
123
152
|
formatMilliseconds(ms, granularity = 10) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
:
|
|
153
|
+
return this._formatNumberWithGranularity(ms, granularity, {
|
|
154
|
+
style: 'unit',
|
|
155
|
+
unit: 'millisecond',
|
|
156
|
+
unitDisplay: 'short',
|
|
157
|
+
});
|
|
128
158
|
}
|
|
129
159
|
|
|
130
160
|
/**
|
|
@@ -133,8 +163,11 @@ export class I18n {
|
|
|
133
163
|
* @return {string}
|
|
134
164
|
*/
|
|
135
165
|
formatSeconds(ms, granularity = 0.1) {
|
|
136
|
-
|
|
137
|
-
|
|
166
|
+
return this._formatNumberWithGranularity(ms / 1000, granularity, {
|
|
167
|
+
style: 'unit',
|
|
168
|
+
unit: 'second',
|
|
169
|
+
unitDisplay: 'short',
|
|
170
|
+
});
|
|
138
171
|
}
|
|
139
172
|
|
|
140
173
|
/**
|
|
@@ -154,10 +187,10 @@ export class I18n {
|
|
|
154
187
|
// and https://github.com/GoogleChrome/lighthouse/pull/9822
|
|
155
188
|
let formatter;
|
|
156
189
|
try {
|
|
157
|
-
formatter = new Intl.DateTimeFormat(this.
|
|
190
|
+
formatter = new Intl.DateTimeFormat(this._locale, options);
|
|
158
191
|
} catch (err) {
|
|
159
192
|
options.timeZone = 'UTC';
|
|
160
|
-
formatter = new Intl.DateTimeFormat(this.
|
|
193
|
+
formatter = new Intl.DateTimeFormat(this._locale, options);
|
|
161
194
|
}
|
|
162
195
|
|
|
163
196
|
return formatter.format(new Date(date));
|
|
@@ -169,6 +202,10 @@ export class I18n {
|
|
|
169
202
|
* @return {string}
|
|
170
203
|
*/
|
|
171
204
|
formatDuration(timeInMilliseconds) {
|
|
205
|
+
// There is a proposal for a Intl.DurationFormat.
|
|
206
|
+
// https://github.com/tc39/proposal-intl-duration-format
|
|
207
|
+
// Until then, we do things a bit more manually.
|
|
208
|
+
|
|
172
209
|
let timeInSeconds = timeInMilliseconds / 1000;
|
|
173
210
|
if (Math.round(timeInSeconds) === 0) {
|
|
174
211
|
return 'None';
|
|
@@ -177,19 +214,24 @@ export class I18n {
|
|
|
177
214
|
/** @type {Array<string>} */
|
|
178
215
|
const parts = [];
|
|
179
216
|
/** @type {Record<string, number>} */
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
217
|
+
const unitToSecondsPer = {
|
|
218
|
+
day: 60 * 60 * 24,
|
|
219
|
+
hour: 60 * 60,
|
|
220
|
+
minute: 60,
|
|
221
|
+
second: 1,
|
|
185
222
|
};
|
|
186
223
|
|
|
187
|
-
Object.keys(
|
|
188
|
-
const
|
|
189
|
-
const numberOfUnits = Math.floor(timeInSeconds /
|
|
224
|
+
Object.keys(unitToSecondsPer).forEach(unit => {
|
|
225
|
+
const secondsPerUnit = unitToSecondsPer[unit];
|
|
226
|
+
const numberOfUnits = Math.floor(timeInSeconds / secondsPerUnit);
|
|
190
227
|
if (numberOfUnits > 0) {
|
|
191
|
-
timeInSeconds -= numberOfUnits *
|
|
192
|
-
|
|
228
|
+
timeInSeconds -= numberOfUnits * secondsPerUnit;
|
|
229
|
+
const part = this._formatNumberWithGranularity(numberOfUnits, 1, {
|
|
230
|
+
style: 'unit',
|
|
231
|
+
unit,
|
|
232
|
+
unitDisplay: 'narrow',
|
|
233
|
+
});
|
|
234
|
+
parts.push(part);
|
|
193
235
|
}
|
|
194
236
|
});
|
|
195
237
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
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
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
5
|
*/
|
|
6
|
-
'use strict';
|
|
7
6
|
|
|
8
7
|
/** @typedef {import('./details-renderer').DetailsRenderer} DetailsRenderer */
|
|
9
8
|
/** @typedef {import('./dom').DOM} DOM */
|
|
@@ -3,7 +3,6 @@
|
|
|
3
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
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
5
|
*/
|
|
6
|
-
'use strict';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* @fileoverview Creates a <select> element, filled with all supported locales
|
|
@@ -3,7 +3,6 @@
|
|
|
3
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
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
5
|
*/
|
|
6
|
-
'use strict';
|
|
7
6
|
|
|
8
7
|
/* global CompressionStream */
|
|
9
8
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
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
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
5
|
*/
|
|
6
|
-
'use strict';
|
|
7
6
|
|
|
8
7
|
/* eslint-env browser */
|
|
9
8
|
|
package/report/renderer/util.js
CHANGED
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
'use strict';
|
|
18
17
|
|
|
19
18
|
/** @template T @typedef {import('./i18n').I18n<T>} I18n */
|
|
20
19
|
|
|
@@ -430,10 +429,13 @@ class Util {
|
|
|
430
429
|
break;
|
|
431
430
|
case 'devtools': {
|
|
432
431
|
const {cpuSlowdownMultiplier, requestLatencyMs} = throttling;
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
432
|
+
// TODO: better api in i18n formatter such that this isn't needed.
|
|
433
|
+
const cpuGranularity = Number.isInteger(cpuSlowdownMultiplier) ? 1 : 0.1;
|
|
434
|
+
// eslint-disable-next-line max-len
|
|
435
|
+
cpuThrottling = `${Util.i18n.formatNumber(cpuSlowdownMultiplier, cpuGranularity)}x slowdown (DevTools)`;
|
|
436
|
+
networkThrottling = `${Util.i18n.formatMilliseconds(requestLatencyMs, 1)} HTTP RTT, ` +
|
|
437
|
+
`${Util.i18n.formatKbps(throttling.downloadThroughputKbps)} down, ` +
|
|
438
|
+
`${Util.i18n.formatKbps(throttling.uploadThroughputKbps)} up (DevTools)`;
|
|
437
439
|
|
|
438
440
|
const isSlow4G = () => {
|
|
439
441
|
return requestLatencyMs === 150 * 3.75 &&
|
|
@@ -445,9 +447,12 @@ class Util {
|
|
|
445
447
|
}
|
|
446
448
|
case 'simulate': {
|
|
447
449
|
const {cpuSlowdownMultiplier, rttMs, throughputKbps} = throttling;
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
450
|
+
// TODO: better api in i18n formatter such that this isn't needed.
|
|
451
|
+
const cpuGranularity = Number.isInteger(cpuSlowdownMultiplier) ? 1 : 0.1;
|
|
452
|
+
// eslint-disable-next-line max-len
|
|
453
|
+
cpuThrottling = `${Util.i18n.formatNumber(cpuSlowdownMultiplier, cpuGranularity)}x slowdown (Simulated)`;
|
|
454
|
+
networkThrottling = `${Util.i18n.formatMilliseconds(rttMs)} TCP RTT, ` +
|
|
455
|
+
`${Util.i18n.formatKbps(throughputKbps)} throughput (Simulated)`;
|
|
451
456
|
|
|
452
457
|
const isSlow4G = () => {
|
|
453
458
|
return rttMs === 150 && throughputKbps === 1.6 * 1024;
|
|
@@ -4,7 +4,6 @@
|
|
|
4
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
5
|
*/
|
|
6
6
|
|
|
7
|
-
'use strict';
|
|
8
7
|
|
|
9
8
|
import fs from 'fs';
|
|
10
9
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
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
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
5
|
*/
|
|
6
|
-
'use strict';
|
|
7
6
|
|
|
8
7
|
/* eslint-env jest */
|
|
9
8
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
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
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
5
|
*/
|
|
6
|
-
'use strict';
|
|
7
6
|
|
|
8
7
|
/* eslint-env jest */
|
|
9
8
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
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
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
5
|
*/
|
|
6
|
-
'use strict';
|
|
7
6
|
|
|
8
7
|
/* eslint-env jest */
|
|
9
8
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
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
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
5
|
*/
|
|
6
|
-
'use strict';
|
|
7
6
|
|
|
8
7
|
import {strict as assert} from 'assert';
|
|
9
8
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
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
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
5
|
*/
|
|
6
|
-
'use strict';
|
|
7
6
|
|
|
8
7
|
import {strict as assert} from 'assert';
|
|
9
8
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
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
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
5
|
*/
|
|
6
|
-
'use strict';
|
|
7
6
|
|
|
8
7
|
/* eslint-env jest */
|
|
9
8
|
|
|
@@ -66,7 +65,8 @@ describe('ElementScreenshotRenderer', () => {
|
|
|
66
65
|
/* eslint-disable max-len */
|
|
67
66
|
expect(htmlFormatted).toMatchInlineSnapshot(`
|
|
68
67
|
"
|
|
69
|
-
<div class=\\"lh-element-screenshot__content\\"
|
|
68
|
+
<div class=\\"lh-element-screenshot__content\\">
|
|
69
|
+
<div class=\\"lh-element-screenshot__image\\" style=\\"width: 500px; height: 500px; background-position-y: 0px; background-position-x: 0px; background-size: 1000px 1000px;\\">
|
|
70
70
|
<div class=\\"lh-element-screenshot__mask\\" style=\\"width: 500px; height: 500px; clip-path: url(#clip-0);\\">
|
|
71
71
|
<svg height=\\"0\\" width=\\"0\\"> <defs>
|
|
72
72
|
<clipPath clipPathUnits=\\"objectBoundingBox\\" id=\\"clip-0\\">
|
|
@@ -74,8 +74,7 @@ describe('ElementScreenshotRenderer', () => {
|
|
|
74
74
|
<polygon points=\\"0,0.7 1,0.7 1,1 0,1\\"></polygon>
|
|
75
75
|
<polygon points=\\"0,0.1 0.1,0.1 0.1,0.7 0,0.7\\"></polygon>
|
|
76
76
|
<polygon points=\\"0.5,0.1 1,0.1 1,0.7 0.5,0.7\\"></polygon></clipPath> </defs> </svg> </div>
|
|
77
|
-
<div class=\\"lh-element-
|
|
78
|
-
<div class=\\"lh-element-screenshot__element-marker\\" style=\\"width: 200px; height: 300px; left: 50px; top: 50px;\\"></div> </div> "
|
|
77
|
+
<div class=\\"lh-element-screenshot__element-marker\\" style=\\"width: 200px; height: 300px; left: 50px; top: 50px;\\"></div> </div> </div> "
|
|
79
78
|
`);
|
|
80
79
|
/* eslint-enable max-len */
|
|
81
80
|
});
|
|
@@ -3,7 +3,6 @@
|
|
|
3
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
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
5
|
*/
|
|
6
|
-
'use strict';
|
|
7
6
|
|
|
8
7
|
import {strict as assert} from 'assert';
|
|
9
8
|
|
|
@@ -22,9 +21,12 @@ const NBSP = '\xa0';
|
|
|
22
21
|
describe('util helpers', () => {
|
|
23
22
|
it('formats a number', () => {
|
|
24
23
|
const i18n = new I18n('en', {...Util.UIStrings});
|
|
25
|
-
assert.strictEqual(i18n.formatNumber(10), '10');
|
|
26
|
-
assert.strictEqual(i18n.formatNumber(100.01), '100');
|
|
24
|
+
assert.strictEqual(i18n.formatNumber(10), '10.0');
|
|
25
|
+
assert.strictEqual(i18n.formatNumber(100.01), '100.0');
|
|
27
26
|
assert.strictEqual(i18n.formatNumber(13000.456), '13,000.5');
|
|
27
|
+
assert.strictEqual(i18n.formatInteger(10), '10');
|
|
28
|
+
assert.strictEqual(i18n.formatInteger(100.01), '100');
|
|
29
|
+
assert.strictEqual(i18n.formatInteger(13000.6), '13,001');
|
|
28
30
|
});
|
|
29
31
|
|
|
30
32
|
it('formats a date', () => {
|
|
@@ -101,9 +103,25 @@ describe('util helpers', () => {
|
|
|
101
103
|
|
|
102
104
|
it('formats a duration', () => {
|
|
103
105
|
const i18n = new I18n('en', {...Util.UIStrings});
|
|
104
|
-
assert.equal(i18n.formatDuration(60 * 1000),
|
|
105
|
-
assert.equal(i18n.formatDuration(60 * 60 * 1000 + 5000),
|
|
106
|
-
assert.equal(i18n.formatDuration(28 * 60 * 60 * 1000 + 5000),
|
|
106
|
+
assert.equal(i18n.formatDuration(60 * 1000), '1m');
|
|
107
|
+
assert.equal(i18n.formatDuration(60 * 60 * 1000 + 5000), '1h 5s');
|
|
108
|
+
assert.equal(i18n.formatDuration(28 * 60 * 60 * 1000 + 5000), '1d 4h 5s');
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('formats a duration based on locale', () => {
|
|
112
|
+
let i18n = new I18n('de', {...Util.UIStrings});
|
|
113
|
+
assert.equal(i18n.formatDuration(60 * 1000), `1${NBSP}Min.`);
|
|
114
|
+
assert.equal(i18n.formatDuration(60 * 60 * 1000 + 5000), `1${NBSP}Std. 5${NBSP}Sek.`);
|
|
115
|
+
assert.equal(
|
|
116
|
+
i18n.formatDuration(28 * 60 * 60 * 1000 + 5000), `1${NBSP}T 4${NBSP}Std. 5${NBSP}Sek.`);
|
|
117
|
+
|
|
118
|
+
// Yes, this is actually backwards (s h d).
|
|
119
|
+
i18n = new I18n('ar', {...Util.UIStrings});
|
|
120
|
+
/* eslint-disable no-irregular-whitespace */
|
|
121
|
+
assert.equal(i18n.formatDuration(60 * 1000), `١${NBSP}د`);
|
|
122
|
+
assert.equal(i18n.formatDuration(60 * 60 * 1000 + 5000), `١${NBSP}س ٥${NBSP}ث`);
|
|
123
|
+
assert.equal(i18n.formatDuration(28 * 60 * 60 * 1000 + 5000), `١ ي ٤ س ٥ ث`);
|
|
124
|
+
/* eslint-enable no-irregular-whitespace */
|
|
107
125
|
});
|
|
108
126
|
|
|
109
127
|
it('formats numbers based on locale', () => {
|
|
@@ -114,7 +132,7 @@ describe('util helpers', () => {
|
|
|
114
132
|
assert.strictEqual(i18n.formatNumber(number), '12.346,9');
|
|
115
133
|
assert.strictEqual(i18n.formatBytesToKiB(number), `12,1${NBSP}KiB`);
|
|
116
134
|
assert.strictEqual(i18n.formatMilliseconds(number), `12.350${NBSP}ms`);
|
|
117
|
-
assert.strictEqual(i18n.formatSeconds(number), `12,3${NBSP}
|
|
135
|
+
assert.strictEqual(i18n.formatSeconds(number), `12,3${NBSP}Sek.`);
|
|
118
136
|
});
|
|
119
137
|
|
|
120
138
|
it('uses decimal comma with en-XA test locale', () => {
|
|
@@ -125,7 +143,7 @@ describe('util helpers', () => {
|
|
|
125
143
|
assert.strictEqual(i18n.formatNumber(number), '12.346,9');
|
|
126
144
|
assert.strictEqual(i18n.formatBytesToKiB(number), `12,1${NBSP}KiB`);
|
|
127
145
|
assert.strictEqual(i18n.formatMilliseconds(number), `12.350${NBSP}ms`);
|
|
128
|
-
assert.strictEqual(i18n.formatSeconds(number), `12,3${NBSP}
|
|
146
|
+
assert.strictEqual(i18n.formatSeconds(number), `12,3${NBSP}Sek.`);
|
|
129
147
|
});
|
|
130
148
|
|
|
131
149
|
it('should not crash on unknown locales', () => {
|
|
@@ -3,7 +3,6 @@
|
|
|
3
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
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
5
|
*/
|
|
6
|
-
'use strict';
|
|
7
6
|
|
|
8
7
|
/* eslint-env jest */
|
|
9
8
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
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
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
5
|
*/
|
|
6
|
-
'use strict';
|
|
7
6
|
|
|
8
7
|
/* eslint-env jest */
|
|
9
8
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
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
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
5
|
*/
|
|
6
|
-
'use strict';
|
|
7
6
|
|
|
8
7
|
/* eslint-env jest */
|
|
9
8
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
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
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
5
|
*/
|
|
6
|
-
'use strict';
|
|
7
6
|
|
|
8
7
|
/* eslint-env jest */
|
|
9
8
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
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
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
5
|
*/
|
|
6
|
-
'use strict';
|
|
7
6
|
|
|
8
7
|
/* eslint-env jest */
|
|
9
8
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
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
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
5
|
*/
|
|
6
|
-
'use strict';
|
|
7
6
|
|
|
8
7
|
/* eslint-env jest */
|
|
9
8
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
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
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
5
|
*/
|
|
6
|
-
'use strict';
|
|
7
6
|
|
|
8
7
|
import fs from 'fs';
|
|
9
8
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
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
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
5
|
*/
|
|
6
|
-
'use strict';
|
|
7
6
|
|
|
8
7
|
import {strict as assert} from 'assert';
|
|
9
8
|
|
|
@@ -57,7 +56,7 @@ describe('util helpers', () => {
|
|
|
57
56
|
});
|
|
58
57
|
|
|
59
58
|
// eslint-disable-next-line max-len
|
|
60
|
-
assert.equal(descriptions.networkThrottling, '565\xa0ms HTTP RTT, 1,400\
|
|
59
|
+
assert.equal(descriptions.networkThrottling, '565\xa0ms HTTP RTT, 1,400\xa0kb/s down, 600\xa0kb/s up (DevTools)');
|
|
61
60
|
assert.equal(descriptions.cpuThrottling, '4.5x slowdown (DevTools)');
|
|
62
61
|
});
|
|
63
62
|
|
|
@@ -72,7 +71,7 @@ describe('util helpers', () => {
|
|
|
72
71
|
});
|
|
73
72
|
|
|
74
73
|
// eslint-disable-next-line max-len
|
|
75
|
-
assert.equal(descriptions.networkThrottling, '150\xa0ms TCP RTT, 1,600\
|
|
74
|
+
assert.equal(descriptions.networkThrottling, '150\xa0ms TCP RTT, 1,600\xa0kb/s throughput (Simulated)');
|
|
76
75
|
assert.equal(descriptions.cpuThrottling, '2x slowdown (Simulated)');
|
|
77
76
|
});
|
|
78
77
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
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
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
5
|
*/
|
|
6
|
-
'use strict';
|
|
7
6
|
|
|
8
7
|
/** @fileoverview This file exercises two LH reports within the same DOM. */
|
|
9
8
|
|