lighthouse 9.5.0-dev.20220607 → 9.6.2
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 +467 -520
- package/dist/report/flow.js +22 -22
- package/dist/report/standalone.js +19 -19
- package/flow-report/src/summary/category.tsx +1 -1
- package/flow-report/src/topbar.tsx +2 -10
- package/flow-report/src/util.ts +1 -1
- package/flow-report/test/topbar-test.tsx +8 -7
- package/jest.config.js +1 -1
- package/lighthouse-cli/.eslintrc.cjs +4 -3
- package/lighthouse-cli/bin.js +1 -0
- package/lighthouse-cli/cli-flags.js +4 -3
- package/lighthouse-cli/commands/commands.js +1 -0
- package/lighthouse-cli/commands/list-audits.js +1 -0
- package/lighthouse-cli/commands/list-locales.js +1 -0
- package/lighthouse-cli/commands/list-trace-categories.js +1 -0
- package/lighthouse-cli/index.js +1 -0
- package/lighthouse-cli/printer.js +1 -0
- package/lighthouse-cli/run.js +24 -9
- package/lighthouse-cli/sentry-prompt.js +1 -0
- package/lighthouse-cli/test/smokehouse/core-tests.js +1 -0
- package/lighthouse-cli/test/smokehouse/frontends/back-compat-util.js +1 -0
- package/lighthouse-cli/test/smokehouse/frontends/lib.js +1 -0
- package/lighthouse-cli/test/smokehouse/frontends/node.js +1 -0
- package/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js +1 -0
- package/lighthouse-cli/test/smokehouse/lib/child-process-error.js +1 -0
- package/lighthouse-cli/test/smokehouse/lib/concurrent-mapper.js +1 -0
- package/lighthouse-cli/test/smokehouse/lib/local-console.js +1 -0
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/bundle.js +23 -109
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/cli.js +3 -2
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/devtools.js +19 -28
- package/lighthouse-cli/test/smokehouse/report-assert.js +4 -3
- package/lighthouse-cli/test/smokehouse/smokehouse.js +1 -1
- package/lighthouse-cli/test/smokehouse/version-check-test.js +3 -0
- package/lighthouse-cli/test/smokehouse/version-check.js +1 -0
- package/lighthouse-core/audits/accessibility/accesskeys.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-allowed-attr.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-command-name.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-hidden-body.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-hidden-focus.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-input-field-name.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-meter-name.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-progressbar-name.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-required-attr.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-required-children.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-required-parent.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-roles.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-toggle-field-name.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-tooltip-name.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-treeitem-name.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-valid-attr-value.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-valid-attr.js +1 -1
- package/lighthouse-core/audits/accessibility/button-name.js +1 -1
- package/lighthouse-core/audits/accessibility/bypass.js +1 -1
- package/lighthouse-core/audits/accessibility/color-contrast.js +1 -1
- package/lighthouse-core/audits/accessibility/definition-list.js +1 -1
- package/lighthouse-core/audits/accessibility/dlitem.js +1 -1
- package/lighthouse-core/audits/accessibility/document-title.js +1 -1
- package/lighthouse-core/audits/accessibility/duplicate-id-active.js +1 -1
- package/lighthouse-core/audits/accessibility/duplicate-id-aria.js +1 -1
- package/lighthouse-core/audits/accessibility/form-field-multiple-labels.js +1 -1
- package/lighthouse-core/audits/accessibility/frame-title.js +1 -1
- package/lighthouse-core/audits/accessibility/heading-order.js +1 -1
- package/lighthouse-core/audits/accessibility/html-has-lang.js +1 -1
- package/lighthouse-core/audits/accessibility/html-lang-valid.js +1 -1
- package/lighthouse-core/audits/accessibility/image-alt.js +1 -1
- package/lighthouse-core/audits/accessibility/input-image-alt.js +1 -1
- package/lighthouse-core/audits/accessibility/label.js +1 -1
- package/lighthouse-core/audits/accessibility/link-name.js +1 -1
- package/lighthouse-core/audits/accessibility/list.js +1 -1
- package/lighthouse-core/audits/accessibility/listitem.js +5 -5
- package/lighthouse-core/audits/accessibility/meta-refresh.js +1 -1
- package/lighthouse-core/audits/accessibility/meta-viewport.js +1 -1
- package/lighthouse-core/audits/accessibility/object-alt.js +1 -1
- package/lighthouse-core/audits/accessibility/tabindex.js +1 -1
- package/lighthouse-core/audits/accessibility/td-headers-attr.js +1 -1
- package/lighthouse-core/audits/accessibility/th-has-data-cells.js +1 -1
- package/lighthouse-core/audits/accessibility/valid-lang.js +1 -1
- package/lighthouse-core/audits/accessibility/video-caption.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js +1 -2
- package/lighthouse-core/audits/byte-efficiency/duplicated-javascript.js +12 -11
- package/lighthouse-core/audits/byte-efficiency/efficient-animated-content.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/legacy-javascript.js +24 -22
- package/lighthouse-core/audits/byte-efficiency/offscreen-images.js +2 -3
- package/lighthouse-core/audits/byte-efficiency/render-blocking-resources.js +3 -2
- package/lighthouse-core/audits/byte-efficiency/unminified-css.js +5 -3
- package/lighthouse-core/audits/byte-efficiency/unminified-javascript.js +11 -10
- package/lighthouse-core/audits/byte-efficiency/unused-css-rules.js +1 -0
- package/lighthouse-core/audits/byte-efficiency/unused-javascript.js +8 -11
- package/lighthouse-core/audits/byte-efficiency/uses-responsive-images.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/uses-text-compression.js +1 -1
- package/lighthouse-core/audits/deprecations.js +598 -8
- package/lighthouse-core/audits/diagnostics.js +3 -4
- package/lighthouse-core/audits/dobetterweb/doctype.js +9 -20
- package/lighthouse-core/audits/dobetterweb/geolocation-on-start.js +1 -1
- package/lighthouse-core/audits/dobetterweb/no-document-write.js +1 -1
- package/lighthouse-core/audits/dobetterweb/notification-on-start.js +1 -1
- package/lighthouse-core/audits/dobetterweb/uses-http2.js +1 -2
- package/lighthouse-core/audits/dobetterweb/uses-passive-event-listeners.js +1 -1
- package/lighthouse-core/audits/errors-in-console.js +2 -2
- package/lighthouse-core/audits/long-tasks.js +2 -3
- package/lighthouse-core/audits/metrics/first-contentful-paint-3g.js +2 -2
- package/lighthouse-core/audits/metrics/first-contentful-paint.js +2 -3
- package/lighthouse-core/audits/metrics/first-meaningful-paint.js +2 -3
- package/lighthouse-core/audits/metrics/interactive.js +2 -3
- package/lighthouse-core/audits/metrics/largest-contentful-paint.js +2 -3
- package/lighthouse-core/audits/metrics/max-potential-fid.js +2 -3
- package/lighthouse-core/audits/metrics/speed-index.js +2 -3
- package/lighthouse-core/audits/metrics/total-blocking-time.js +2 -3
- package/lighthouse-core/audits/metrics.js +2 -3
- package/lighthouse-core/audits/no-unload-listeners.js +15 -7
- package/lighthouse-core/audits/predictive-perf.js +1 -2
- package/lighthouse-core/audits/preload-lcp-image.js +3 -3
- package/lighthouse-core/audits/redirects.js +1 -1
- package/lighthouse-core/audits/script-treemap-data.js +45 -45
- package/lighthouse-core/audits/seo/http-status-code.js +4 -2
- package/lighthouse-core/audits/seo/link-text.js +0 -2
- package/lighthouse-core/audits/server-response-time.js +17 -2
- package/lighthouse-core/audits/service-worker.js +2 -7
- package/lighthouse-core/audits/timing-budget.js +2 -3
- package/lighthouse-core/audits/uses-rel-preconnect.js +1 -1
- package/lighthouse-core/audits/uses-rel-preload.js +1 -1
- package/lighthouse-core/audits/valid-source-maps.js +14 -12
- package/lighthouse-core/audits/violation-audit.js +1 -1
- package/lighthouse-core/audits/work-during-interaction.js +2 -2
- package/lighthouse-core/computed/critical-request-chains.js +9 -5
- package/lighthouse-core/computed/js-bundles.js +11 -11
- package/lighthouse-core/computed/main-resource.js +2 -3
- package/lighthouse-core/computed/metrics/first-contentful-paint-all-frames.js +1 -1
- package/lighthouse-core/computed/metrics/first-contentful-paint.js +1 -1
- package/lighthouse-core/computed/metrics/first-meaningful-paint.js +1 -1
- package/lighthouse-core/computed/metrics/interactive.js +1 -1
- package/lighthouse-core/computed/metrics/lantern-first-contentful-paint.js +1 -1
- package/lighthouse-core/computed/metrics/lantern-first-meaningful-paint.js +1 -1
- package/lighthouse-core/computed/metrics/lantern-interactive.js +1 -1
- package/lighthouse-core/computed/metrics/lantern-largest-contentful-paint.js +1 -1
- package/lighthouse-core/computed/metrics/lantern-max-potential-fid.js +1 -1
- package/lighthouse-core/computed/metrics/lantern-metric.js +5 -3
- package/lighthouse-core/computed/metrics/lantern-speed-index.js +1 -1
- package/lighthouse-core/computed/metrics/lantern-total-blocking-time.js +1 -1
- package/lighthouse-core/computed/metrics/largest-contentful-paint-all-frames.js +1 -1
- package/lighthouse-core/computed/metrics/largest-contentful-paint.js +1 -1
- package/lighthouse-core/computed/metrics/max-potential-fid.js +1 -1
- package/lighthouse-core/computed/metrics/metric.js +0 -1
- package/lighthouse-core/computed/metrics/speed-index.js +1 -1
- package/lighthouse-core/computed/metrics/timing-summary.js +6 -13
- package/lighthouse-core/computed/metrics/total-blocking-time.js +1 -1
- package/lighthouse-core/computed/module-duplication.js +5 -6
- package/lighthouse-core/computed/page-dependency-graph.js +28 -55
- package/lighthouse-core/computed/resource-summary.js +5 -5
- package/lighthouse-core/computed/unused-css.js +7 -6
- package/lighthouse-core/computed/unused-javascript-summary.js +36 -16
- package/lighthouse-core/config/budget.js +2 -2
- package/lighthouse-core/config/default-config.js +1 -2
- package/lighthouse-core/fraggle-rock/api.js +1 -1
- package/lighthouse-core/fraggle-rock/config/default-config.js +0 -3
- package/lighthouse-core/fraggle-rock/gather/base-artifacts.js +3 -6
- package/lighthouse-core/fraggle-rock/gather/driver.js +2 -2
- package/lighthouse-core/fraggle-rock/gather/navigation-runner.js +26 -51
- package/lighthouse-core/fraggle-rock/gather/runner-helpers.js +3 -0
- package/lighthouse-core/fraggle-rock/gather/session.js +22 -23
- package/lighthouse-core/fraggle-rock/gather/snapshot-runner.js +4 -5
- package/lighthouse-core/fraggle-rock/gather/timespan-runner.js +6 -6
- package/lighthouse-core/gather/connections/cri.js +1 -5
- package/lighthouse-core/gather/driver/execution-context.js +2 -5
- package/lighthouse-core/gather/driver/navigation.js +10 -13
- package/lighthouse-core/gather/driver/network-monitor.js +3 -16
- package/lighthouse-core/gather/driver.js +1 -6
- package/lighthouse-core/gather/fetcher.js +210 -34
- package/lighthouse-core/gather/gather-runner.js +17 -13
- package/lighthouse-core/gather/gatherers/accessibility.js +4 -16
- package/lighthouse-core/gather/gatherers/console-messages.js +2 -4
- package/lighthouse-core/gather/gatherers/dobetterweb/doctype.js +2 -4
- package/lighthouse-core/gather/gatherers/full-page-screenshot.js +2 -3
- package/lighthouse-core/gather/gatherers/iframe-elements.js +1 -4
- package/lighthouse-core/gather/gatherers/image-elements.js +0 -2
- package/lighthouse-core/gather/gatherers/js-usage.js +87 -12
- package/lighthouse-core/gather/gatherers/link-elements.js +14 -12
- package/lighthouse-core/gather/gatherers/main-document-content.js +8 -8
- package/lighthouse-core/gather/gatherers/script-elements.js +56 -7
- package/lighthouse-core/gather/gatherers/seo/robots-txt.js +30 -2
- package/lighthouse-core/gather/gatherers/source-maps.js +1 -8
- package/lighthouse-core/gather/gatherers/web-app-manifest.js +2 -2
- package/lighthouse-core/index.js +2 -26
- package/lighthouse-core/lib/cdt/generated/SourceMap.js +1 -1
- package/lighthouse-core/lib/dependency-graph/simulator/network-analyzer.js +29 -8
- package/lighthouse-core/lib/navigation-error.js +4 -13
- package/lighthouse-core/lib/page-functions.js +1 -3
- package/lighthouse-core/lib/script-helpers.js +6 -11
- package/lighthouse-core/lib/url-shim.js +2 -2
- package/lighthouse-core/runner.js +5 -0
- package/lighthouse-core/scripts/manual-chrome-launcher.js +1 -0
- package/lighthouse-core/util-commonjs.js +6 -8
- package/package.json +13 -13
- package/readme.md +1 -1
- package/report/.eslintrc.cjs +1 -3
- package/report/assets/styles.css +5 -10
- package/report/assets/templates.html +9 -10
- package/report/clients/bundle.js +1 -0
- package/report/clients/standalone.js +1 -0
- package/report/generator/report-generator.js +21 -46
- package/report/renderer/api.js +2 -0
- package/report/renderer/category-renderer.js +24 -20
- package/report/renderer/components.js +304 -303
- package/report/renderer/crc-details-renderer.js +24 -21
- package/report/renderer/details-renderer.js +12 -12
- package/report/renderer/dom.js +7 -6
- package/report/renderer/drop-down-menu.js +1 -0
- package/report/renderer/element-screenshot-renderer.js +5 -1
- package/report/renderer/features-util.js +1 -0
- package/report/renderer/i18n.js +62 -118
- package/report/renderer/logger.js +1 -0
- package/report/renderer/open-tab.js +3 -1
- package/report/renderer/performance-category-renderer.js +11 -10
- package/report/renderer/pwa-category-renderer.js +4 -3
- package/report/renderer/report-renderer.js +17 -17
- package/report/renderer/report-ui-features.js +1 -0
- package/report/renderer/snippet-renderer.js +3 -2
- package/report/renderer/swap-locale-feature.js +1 -0
- package/report/renderer/text-encoding.js +1 -0
- package/report/renderer/topbar-features.js +1 -0
- package/report/renderer/util.js +6 -7
- package/report/test/clients/bundle-test.js +5 -0
- package/report/test/generator/file-namer-test.js +1 -0
- package/report/test/generator/report-generator-test.js +20 -25
- package/report/test/renderer/category-renderer-test.js +4 -3
- package/report/test/renderer/components-test.js +3 -0
- package/report/test/renderer/crc-details-renderer-test.js +3 -0
- package/report/test/renderer/details-renderer-test.js +3 -49
- package/report/test/renderer/dom-test.js +3 -0
- package/report/test/renderer/element-screenshot-renderer-test.js +6 -3
- package/report/test/renderer/i18n-test.js +25 -70
- package/report/test/renderer/performance-category-renderer-test.js +5 -14
- package/report/test/renderer/pwa-category-renderer-test.js +4 -3
- package/report/test/renderer/report-renderer-axe-test.js +4 -3
- package/report/test/renderer/report-renderer-test.js +4 -3
- package/report/test/renderer/report-ui-features-test.js +4 -3
- package/report/test/renderer/snippet-renderer-test.js +3 -0
- package/report/test/renderer/text-encoding-test.js +3 -0
- package/report/test/renderer/util-test.js +5 -4
- package/report/test-assets/faux-psi.js +1 -2
- package/shared/localization/format.js +3 -7
- package/shared/localization/locales/en-US.json +238 -55
- package/shared/localization/locales/en-XL.json +238 -55
- package/shared/test/localization/format-test.js +2 -8
- package/shared/test/localization/locales-test.js +2 -0
- package/shared/test/localization/swap-locale-test.js +2 -0
- package/third-party/chromium-synchronization/inspector-issueAdded-types-test.js +2 -0
- package/third-party/chromium-synchronization/installability-errors-test.js +2 -0
- package/tsconfig.json +0 -1
- package/types/artifacts.d.ts +8 -47
- package/types/config.d.ts +0 -2
- package/types/externs.d.ts +2 -3
- package/types/gatherer.d.ts +2 -1
- package/types/global-lh.d.ts +0 -3
- package/types/lhr/lhr.d.ts +2 -2
- package/types/lhr/treemap.d.ts +1 -0
- package/changelog.md +0 -5902
- package/lighthouse-core/audits/script-elements-test-audit.js +0 -30
- package/lighthouse-core/gather/gatherers/scripts.js +0 -154
- package/lighthouse-core/scripts/package.json +0 -4
- package/report/test/.eslintrc.cjs +0 -11
- package/shared/test/localization/.eslintrc.cjs +0 -11
|
@@ -3,6 +3,7 @@
|
|
|
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';
|
|
6
7
|
|
|
7
8
|
import {strict as assert} from 'assert';
|
|
8
9
|
|
|
@@ -16,33 +17,14 @@ import '../../../lighthouse-core/lib/i18n/i18n.js';
|
|
|
16
17
|
|
|
17
18
|
const NBSP = '\xa0';
|
|
18
19
|
|
|
20
|
+
/* eslint-env jest */
|
|
21
|
+
|
|
19
22
|
describe('util helpers', () => {
|
|
20
23
|
it('formats a number', () => {
|
|
21
24
|
const i18n = new I18n('en', {...Util.UIStrings});
|
|
22
25
|
assert.strictEqual(i18n.formatNumber(10), '10');
|
|
23
|
-
assert.strictEqual(i18n.formatNumber(100.01), '100
|
|
24
|
-
assert.strictEqual(i18n.formatNumber(13000.456), '13,000.
|
|
25
|
-
assert.strictEqual(i18n.formatNumber(13000.456444), '13,000.456');
|
|
26
|
-
|
|
27
|
-
assert.strictEqual(i18n.formatNumber(10, 0.1), '10.0');
|
|
28
|
-
assert.strictEqual(i18n.formatNumber(100.01, 0.1), '100.0');
|
|
29
|
-
assert.strictEqual(i18n.formatNumber(13000.456, 0.1), '13,000.5');
|
|
30
|
-
|
|
31
|
-
assert.strictEqual(i18n.formatNumber(0), '0');
|
|
32
|
-
assert.strictEqual(i18n.formatNumber(-0), '0');
|
|
33
|
-
assert.strictEqual(i18n.formatNumber(-0, 0.1), '0.0');
|
|
34
|
-
assert.strictEqual(i18n.formatNumber(0.000001), '0');
|
|
35
|
-
assert.strictEqual(i18n.formatNumber(-0.000001), '0');
|
|
36
|
-
assert.strictEqual(i18n.formatNumber(0.000001, 0.1), '0.0');
|
|
37
|
-
assert.strictEqual(i18n.formatNumber(-0.000001, 0.1), '0.0');
|
|
38
|
-
|
|
39
|
-
assert.strictEqual(i18n.formatNumber(10), '10');
|
|
40
|
-
assert.strictEqual(i18n.formatNumber(100.01), '100.01');
|
|
41
|
-
assert.strictEqual(i18n.formatNumber(13000.456, 0.1), '13,000.5');
|
|
42
|
-
|
|
43
|
-
assert.strictEqual(i18n.formatInteger(10), '10');
|
|
44
|
-
assert.strictEqual(i18n.formatInteger(100.01), '100');
|
|
45
|
-
assert.strictEqual(i18n.formatInteger(13000.6), '13,001');
|
|
26
|
+
assert.strictEqual(i18n.formatNumber(100.01), '100');
|
|
27
|
+
assert.strictEqual(i18n.formatNumber(13000.456), '13,000.5');
|
|
46
28
|
});
|
|
47
29
|
|
|
48
30
|
it('formats a date', () => {
|
|
@@ -57,10 +39,9 @@ describe('util helpers', () => {
|
|
|
57
39
|
|
|
58
40
|
it('formats bytes', () => {
|
|
59
41
|
const i18n = new I18n('en', {...Util.UIStrings});
|
|
60
|
-
assert.equal(i18n.formatBytesToKiB(100), `0.
|
|
61
|
-
assert.equal(i18n.formatBytesToKiB(
|
|
62
|
-
assert.equal(i18n.formatBytesToKiB(
|
|
63
|
-
assert.equal(i18n.formatBytesToKiB(1014 * 1024, 0.1), `1,014.0${NBSP}KiB`);
|
|
42
|
+
assert.equal(i18n.formatBytesToKiB(100), `0.1${NBSP}KiB`);
|
|
43
|
+
assert.equal(i18n.formatBytesToKiB(2000), `2.0${NBSP}KiB`);
|
|
44
|
+
assert.equal(i18n.formatBytesToKiB(1014 * 1024), `1,014.0${NBSP}KiB`);
|
|
64
45
|
});
|
|
65
46
|
|
|
66
47
|
it('formats bytes with different granularities', () => {
|
|
@@ -76,6 +57,11 @@ describe('util helpers', () => {
|
|
|
76
57
|
assert.strictEqual(i18n.formatBytes(15.12345, granularity), `15${NBSP}bytes`);
|
|
77
58
|
assert.strictEqual(i18n.formatBytes(15.54321, granularity), `16${NBSP}bytes`);
|
|
78
59
|
|
|
60
|
+
granularity = 0.5;
|
|
61
|
+
assert.strictEqual(i18n.formatBytes(15.0, granularity), `15.0${NBSP}bytes`);
|
|
62
|
+
assert.strictEqual(i18n.formatBytes(15.12345, granularity), `15.0${NBSP}bytes`);
|
|
63
|
+
assert.strictEqual(i18n.formatBytes(15.54321, granularity), `15.5${NBSP}bytes`);
|
|
64
|
+
|
|
79
65
|
granularity = 0.1;
|
|
80
66
|
assert.strictEqual(i18n.formatBytes(15.0, granularity), `15.0${NBSP}bytes`);
|
|
81
67
|
assert.strictEqual(i18n.formatBytes(15.12345, granularity), `15.1${NBSP}bytes`);
|
|
@@ -87,21 +73,6 @@ describe('util helpers', () => {
|
|
|
87
73
|
assert.strictEqual(i18n.formatBytes(15.19999, granularity), `15.20${NBSP}bytes`);
|
|
88
74
|
});
|
|
89
75
|
|
|
90
|
-
it('formats bytes with invalid granularity', () => {
|
|
91
|
-
const i18n = new I18n('en', {...Util.UIStrings});
|
|
92
|
-
const granularity = 0.5;
|
|
93
|
-
const originalWarn = console.warn;
|
|
94
|
-
|
|
95
|
-
try {
|
|
96
|
-
console.warn = () => {};
|
|
97
|
-
assert.strictEqual(i18n.formatBytes(15.0, granularity), `15${NBSP}bytes`);
|
|
98
|
-
assert.strictEqual(i18n.formatBytes(15.12345, granularity), `15${NBSP}bytes`);
|
|
99
|
-
assert.strictEqual(i18n.formatBytes(15.54321, granularity), `16${NBSP}bytes`);
|
|
100
|
-
} finally {
|
|
101
|
-
console.warn = originalWarn;
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
|
|
105
76
|
it('formats kibibytes with different granularities', () => {
|
|
106
77
|
const i18n = new I18n('en', {...Util.UIStrings});
|
|
107
78
|
|
|
@@ -122,7 +93,7 @@ describe('util helpers', () => {
|
|
|
122
93
|
|
|
123
94
|
it('formats ms', () => {
|
|
124
95
|
const i18n = new I18n('en', {...Util.UIStrings});
|
|
125
|
-
assert.equal(i18n.formatMilliseconds(123
|
|
96
|
+
assert.equal(i18n.formatMilliseconds(123), `120${NBSP}ms`);
|
|
126
97
|
assert.equal(i18n.formatMilliseconds(2456.5, 0.1), `2,456.5${NBSP}ms`);
|
|
127
98
|
assert.equal(i18n.formatMilliseconds(0.000001), `0${NBSP}ms`);
|
|
128
99
|
assert.equal(i18n.formatMilliseconds(-0.000001), `0${NBSP}ms`);
|
|
@@ -130,25 +101,9 @@ describe('util helpers', () => {
|
|
|
130
101
|
|
|
131
102
|
it('formats a duration', () => {
|
|
132
103
|
const i18n = new I18n('en', {...Util.UIStrings});
|
|
133
|
-
assert.equal(i18n.formatDuration(60 * 1000),
|
|
134
|
-
assert.equal(i18n.formatDuration(60 * 60 * 1000 + 5000),
|
|
135
|
-
assert.equal(i18n.formatDuration(28 * 60 * 60 * 1000 + 5000),
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it('formats a duration based on locale', () => {
|
|
139
|
-
let i18n = new I18n('de', {...Util.UIStrings});
|
|
140
|
-
assert.equal(i18n.formatDuration(60 * 1000), `1${NBSP}Min.`);
|
|
141
|
-
assert.equal(i18n.formatDuration(60 * 60 * 1000 + 5000), `1${NBSP}Std. 5${NBSP}Sek.`);
|
|
142
|
-
assert.equal(
|
|
143
|
-
i18n.formatDuration(28 * 60 * 60 * 1000 + 5000), `1${NBSP}T 4${NBSP}Std. 5${NBSP}Sek.`);
|
|
144
|
-
|
|
145
|
-
// Yes, this is actually backwards (s h d).
|
|
146
|
-
i18n = new I18n('ar', {...Util.UIStrings});
|
|
147
|
-
/* eslint-disable no-irregular-whitespace */
|
|
148
|
-
assert.equal(i18n.formatDuration(60 * 1000), `١${NBSP}د`);
|
|
149
|
-
assert.equal(i18n.formatDuration(60 * 60 * 1000 + 5000), `١${NBSP}س ٥${NBSP}ث`);
|
|
150
|
-
assert.equal(i18n.formatDuration(28 * 60 * 60 * 1000 + 5000), `١ ي ٤ س ٥ ث`);
|
|
151
|
-
/* eslint-enable no-irregular-whitespace */
|
|
104
|
+
assert.equal(i18n.formatDuration(60 * 1000), `1${NBSP}m`);
|
|
105
|
+
assert.equal(i18n.formatDuration(60 * 60 * 1000 + 5000), `1${NBSP}h 5${NBSP}s`);
|
|
106
|
+
assert.equal(i18n.formatDuration(28 * 60 * 60 * 1000 + 5000), `1${NBSP}d 4${NBSP}h 5${NBSP}s`);
|
|
152
107
|
});
|
|
153
108
|
|
|
154
109
|
it('formats numbers based on locale', () => {
|
|
@@ -156,10 +111,10 @@ describe('util helpers', () => {
|
|
|
156
111
|
const number = 12346.858558;
|
|
157
112
|
|
|
158
113
|
const i18n = new I18n('de', {...Util.UIStrings});
|
|
159
|
-
assert.strictEqual(i18n.formatNumber(number), '12.346,
|
|
160
|
-
assert.strictEqual(i18n.formatBytesToKiB(number
|
|
161
|
-
assert.strictEqual(i18n.formatMilliseconds(number
|
|
162
|
-
assert.strictEqual(i18n.formatSeconds(number), `12,
|
|
114
|
+
assert.strictEqual(i18n.formatNumber(number), '12.346,9');
|
|
115
|
+
assert.strictEqual(i18n.formatBytesToKiB(number), `12,1${NBSP}KiB`);
|
|
116
|
+
assert.strictEqual(i18n.formatMilliseconds(number), `12.350${NBSP}ms`);
|
|
117
|
+
assert.strictEqual(i18n.formatSeconds(number), `12,3${NBSP}s`);
|
|
163
118
|
});
|
|
164
119
|
|
|
165
120
|
it('uses decimal comma with en-XA test locale', () => {
|
|
@@ -167,10 +122,10 @@ describe('util helpers', () => {
|
|
|
167
122
|
const number = 12346.858558;
|
|
168
123
|
|
|
169
124
|
const i18n = new I18n('en-XA', {...Util.UIStrings});
|
|
170
|
-
assert.strictEqual(i18n.formatNumber(number), '12.346,
|
|
171
|
-
assert.strictEqual(i18n.formatBytesToKiB(number
|
|
172
|
-
assert.strictEqual(i18n.formatMilliseconds(number
|
|
173
|
-
assert.strictEqual(i18n.formatSeconds(number
|
|
125
|
+
assert.strictEqual(i18n.formatNumber(number), '12.346,9');
|
|
126
|
+
assert.strictEqual(i18n.formatBytesToKiB(number), `12,1${NBSP}KiB`);
|
|
127
|
+
assert.strictEqual(i18n.formatMilliseconds(number), `12.350${NBSP}ms`);
|
|
128
|
+
assert.strictEqual(i18n.formatSeconds(number), `12,3${NBSP}s`);
|
|
174
129
|
});
|
|
175
130
|
|
|
176
131
|
it('should not crash on unknown locales', () => {
|
|
@@ -3,6 +3,9 @@
|
|
|
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
|
+
|
|
8
|
+
/* eslint-env jest */
|
|
6
9
|
|
|
7
10
|
import {strict as assert} from 'assert';
|
|
8
11
|
|
|
@@ -14,9 +17,7 @@ import URL from '../../../lighthouse-core/lib/url-shim.js';
|
|
|
14
17
|
import {DOM} from '../../renderer/dom.js';
|
|
15
18
|
import {DetailsRenderer} from '../../renderer/details-renderer.js';
|
|
16
19
|
import {PerformanceCategoryRenderer} from '../../renderer/performance-category-renderer.js';
|
|
17
|
-
import
|
|
18
|
-
|
|
19
|
-
const sampleResultsOrig = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta);
|
|
20
|
+
import sampleResultsOrig from '../../../lighthouse-core/test/results/sample_v2.json';
|
|
20
21
|
|
|
21
22
|
describe('PerfCategoryRenderer', () => {
|
|
22
23
|
let category;
|
|
@@ -359,7 +360,7 @@ Array [
|
|
|
359
360
|
}
|
|
360
361
|
});
|
|
361
362
|
|
|
362
|
-
it('uses null if the metric
|
|
363
|
+
it('uses null if the metric is missing its value', () => {
|
|
363
364
|
const categoryClone = JSON.parse(JSON.stringify(category));
|
|
364
365
|
const lcp = categoryClone.auditRefs.find(audit => audit.id === 'largest-contentful-paint');
|
|
365
366
|
lcp.result.numericValue = undefined;
|
|
@@ -367,16 +368,6 @@ Array [
|
|
|
367
368
|
const href = renderer._getScoringCalculatorHref(categoryClone.auditRefs);
|
|
368
369
|
expect(href).toContain('LCP=null');
|
|
369
370
|
});
|
|
370
|
-
|
|
371
|
-
it('uses null if the metric\'s value is null (LR)', () => {
|
|
372
|
-
const categoryClone = JSON.parse(JSON.stringify(category));
|
|
373
|
-
const lcp = categoryClone.auditRefs.find(audit => audit.id === 'largest-contentful-paint');
|
|
374
|
-
// In LR, we think there might be some case where undefined becomes null, but we can't prove it.
|
|
375
|
-
lcp.result.numericValue = null;
|
|
376
|
-
lcp.result.score = null;
|
|
377
|
-
const href = renderer._getScoringCalculatorHref(categoryClone.auditRefs);
|
|
378
|
-
expect(href).toContain('LCP=null');
|
|
379
|
-
});
|
|
380
371
|
});
|
|
381
372
|
|
|
382
373
|
// This is done all in CSS, but tested here.
|
|
@@ -3,6 +3,9 @@
|
|
|
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
|
+
|
|
8
|
+
/* eslint-env jest */
|
|
6
9
|
|
|
7
10
|
import {strict as assert} from 'assert';
|
|
8
11
|
|
|
@@ -13,9 +16,7 @@ import {I18n} from '../../renderer/i18n.js';
|
|
|
13
16
|
import {DOM} from '../../renderer/dom.js';
|
|
14
17
|
import {DetailsRenderer} from '../../renderer/details-renderer.js';
|
|
15
18
|
import {PwaCategoryRenderer} from '../../renderer/pwa-category-renderer.js';
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
const sampleResultsOrig = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta);
|
|
19
|
+
import sampleResultsOrig from '../../../lighthouse-core/test/results/sample_v2.json';
|
|
19
20
|
|
|
20
21
|
describe('PwaCategoryRenderer', () => {
|
|
21
22
|
let category;
|
|
@@ -3,14 +3,15 @@
|
|
|
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
|
+
|
|
8
|
+
/* eslint-env jest */
|
|
6
9
|
|
|
7
10
|
import puppeteer from 'puppeteer';
|
|
8
11
|
|
|
12
|
+
import sampleResults from '../../../lighthouse-core/test/results/sample_v2.json';
|
|
9
13
|
import reportGenerator from '../../generator/report-generator.js';
|
|
10
14
|
import axeLib from '../../../lighthouse-core/lib/axe.js';
|
|
11
|
-
import {readJson} from '../../../root.js';
|
|
12
|
-
|
|
13
|
-
const sampleResults = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta);
|
|
14
15
|
|
|
15
16
|
describe('ReportRendererAxe', () => {
|
|
16
17
|
describe('with aXe', () => {
|
|
@@ -3,6 +3,9 @@
|
|
|
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
|
+
|
|
8
|
+
/* eslint-env jest */
|
|
6
9
|
|
|
7
10
|
import {strict as assert} from 'assert';
|
|
8
11
|
|
|
@@ -15,9 +18,7 @@ import {DOM} from '../../renderer/dom.js';
|
|
|
15
18
|
import {DetailsRenderer} from '../../renderer/details-renderer.js';
|
|
16
19
|
import {CategoryRenderer} from '../../renderer/category-renderer.js';
|
|
17
20
|
import {ReportRenderer} from '../../renderer/report-renderer.js';
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
const sampleResultsOrig = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta);
|
|
21
|
+
import sampleResultsOrig from '../../../lighthouse-core/test/results/sample_v2.json';
|
|
21
22
|
|
|
22
23
|
const TIMESTAMP_REGEX = /\d+, \d{4}.*\d+:\d+/;
|
|
23
24
|
|
|
@@ -3,6 +3,9 @@
|
|
|
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
|
+
|
|
8
|
+
/* eslint-env jest */
|
|
6
9
|
|
|
7
10
|
import {strict as assert} from 'assert';
|
|
8
11
|
|
|
@@ -16,9 +19,7 @@ import {DetailsRenderer} from '../../renderer/details-renderer.js';
|
|
|
16
19
|
import {ReportUIFeatures} from '../../renderer/report-ui-features.js';
|
|
17
20
|
import {CategoryRenderer} from '../../renderer/category-renderer.js';
|
|
18
21
|
import {ReportRenderer} from '../../renderer/report-renderer.js';
|
|
19
|
-
import
|
|
20
|
-
|
|
21
|
-
const sampleResultsOrig = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta);
|
|
22
|
+
import sampleResultsOrig from '../../../lighthouse-core/test/results/sample_v2.json';
|
|
22
23
|
|
|
23
24
|
describe('ReportUIFeatures', () => {
|
|
24
25
|
let sampleResults;
|
|
@@ -3,6 +3,9 @@
|
|
|
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
|
+
|
|
8
|
+
/* eslint-env jest */
|
|
6
9
|
|
|
7
10
|
import {strict as assert} from 'assert';
|
|
8
11
|
|
|
@@ -3,6 +3,7 @@
|
|
|
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';
|
|
6
7
|
|
|
7
8
|
import fs from 'fs';
|
|
8
9
|
|
|
@@ -11,6 +12,8 @@ import pako from 'pako';
|
|
|
11
12
|
import {TextEncoding} from '../../renderer/text-encoding.js';
|
|
12
13
|
import {LH_ROOT} from '../../../root.js';
|
|
13
14
|
|
|
15
|
+
/* eslint-env jest */
|
|
16
|
+
|
|
14
17
|
describe('TextEncoding', () => {
|
|
15
18
|
beforeAll(() => {
|
|
16
19
|
global.window = {pako};
|
|
@@ -3,14 +3,15 @@
|
|
|
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';
|
|
6
7
|
|
|
7
8
|
import {strict as assert} from 'assert';
|
|
8
9
|
|
|
9
10
|
import {Util} from '../../renderer/util.js';
|
|
10
11
|
import {I18n} from '../../renderer/i18n.js';
|
|
11
|
-
import
|
|
12
|
+
import sampleResult from '../../../lighthouse-core/test/results/sample_v2.json';
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
/* eslint-env jest */
|
|
14
15
|
|
|
15
16
|
describe('util helpers', () => {
|
|
16
17
|
beforeEach(() => {
|
|
@@ -56,7 +57,7 @@ describe('util helpers', () => {
|
|
|
56
57
|
});
|
|
57
58
|
|
|
58
59
|
// eslint-disable-next-line max-len
|
|
59
|
-
assert.equal(descriptions.networkThrottling, '565\xa0ms HTTP RTT, 1,400\
|
|
60
|
+
assert.equal(descriptions.networkThrottling, '565\xa0ms HTTP RTT, 1,400\xa0Kbps down, 600\xa0Kbps up (DevTools)');
|
|
60
61
|
assert.equal(descriptions.cpuThrottling, '4.5x slowdown (DevTools)');
|
|
61
62
|
});
|
|
62
63
|
|
|
@@ -71,7 +72,7 @@ describe('util helpers', () => {
|
|
|
71
72
|
});
|
|
72
73
|
|
|
73
74
|
// eslint-disable-next-line max-len
|
|
74
|
-
assert.equal(descriptions.networkThrottling, '150\xa0ms TCP RTT, 1,600\
|
|
75
|
+
assert.equal(descriptions.networkThrottling, '150\xa0ms TCP RTT, 1,600\xa0Kbps throughput (Simulated)');
|
|
75
76
|
assert.equal(descriptions.cpuThrottling, '2x slowdown (Simulated)');
|
|
76
77
|
});
|
|
77
78
|
|
|
@@ -3,6 +3,7 @@
|
|
|
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';
|
|
6
7
|
|
|
7
8
|
/** @fileoverview This file exercises two LH reports within the same DOM. */
|
|
8
9
|
|
|
@@ -65,8 +66,6 @@ async function renderLHReport() {
|
|
|
65
66
|
metaItemsEl,
|
|
66
67
|
reportRootEl.querySelector('.lh-buttons')
|
|
67
68
|
);
|
|
68
|
-
reportRootEl.querySelector('.lh-metrics-container')?.closest('.lh-category')?.classList
|
|
69
|
-
.add('lh--hoisted-meta');
|
|
70
69
|
}
|
|
71
70
|
|
|
72
71
|
container.append(reportRootEl);
|
|
@@ -100,7 +100,7 @@ function collectAllCustomElementsFromICU(icuElements, seenElementsById = new Map
|
|
|
100
100
|
* @param {string} lhlMessage Used for clear error logging.
|
|
101
101
|
* @return {Record<string, string | number>}
|
|
102
102
|
*/
|
|
103
|
-
function _preformatValues(messageFormatter, values
|
|
103
|
+
function _preformatValues(messageFormatter, values, lhlMessage) {
|
|
104
104
|
const elementMap = collectAllCustomElementsFromICU(messageFormatter.getAst().elements);
|
|
105
105
|
const argumentElements = [...elementMap.values()];
|
|
106
106
|
|
|
@@ -165,15 +165,11 @@ function _preformatValues(messageFormatter, values = {}, lhlMessage) {
|
|
|
165
165
|
* is assumed to already be in the given locale.
|
|
166
166
|
* If you need to localize a messagem `getFormatted` is probably what you want.
|
|
167
167
|
* @param {string} message
|
|
168
|
-
* @param {Record<string, string | number
|
|
168
|
+
* @param {Record<string, string | number>} values
|
|
169
169
|
* @param {LH.Locale} locale
|
|
170
170
|
* @return {string}
|
|
171
171
|
*/
|
|
172
|
-
function formatMessage(message, values, locale) {
|
|
173
|
-
// Parsing and formatting can be slow. Don't attempt if the string can't
|
|
174
|
-
// contain ICU placeholders, in which case formatting is already complete.
|
|
175
|
-
if (!message.includes('{') && values === undefined) return message;
|
|
176
|
-
|
|
172
|
+
function formatMessage(message, values = {}, locale) {
|
|
177
173
|
// When using accented english, force the use of a different locale for number formatting.
|
|
178
174
|
const localeForMessageFormat = (locale === 'en-XA' || locale === 'en-XL') ? 'de-DE' : locale;
|
|
179
175
|
|