lighthouse 9.5.0-dev.20220509 → 9.6.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.
- package/changelog.md +70 -0
- package/dist/report/bundle.esm.js +400 -808
- package/dist/report/flow.js +22 -27
- package/dist/report/standalone.js +18 -23
- package/flow-report/src/summary/category.tsx +1 -1
- 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/experimental-interaction-to-next-paint.js +3 -1
- 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 +280 -0
- 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/responsiveness.js +12 -9
- 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/config/metrics-to-audits.js +5 -0
- package/lighthouse-core/fraggle-rock/api.js +1 -1
- package/lighthouse-core/fraggle-rock/config/default-config.js +8 -5
- 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 +2 -2
- 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 +0 -1
- package/lighthouse-core/gather/driver/execution-context.js +2 -4
- package/lighthouse-core/gather/driver/navigation.js +9 -9
- 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/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 -3
- package/lighthouse-core/gather/gatherers/trace-elements.js +21 -2
- 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/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 +24 -28
- package/package.json +12 -12
- package/readme.md +1 -1
- package/report/.eslintrc.cjs +1 -3
- package/report/assets/styles.css +10 -12
- 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 +1 -0
- package/report/renderer/category-renderer.js +1 -0
- package/report/renderer/components.js +304 -303
- package/report/renderer/crc-details-renderer.js +1 -0
- package/report/renderer/details-renderer.js +10 -10
- package/report/renderer/dom.js +1 -0
- package/report/renderer/drop-down-menu.js +1 -0
- package/report/renderer/element-screenshot-renderer.js +4 -0
- 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 +1 -0
- package/report/renderer/pwa-category-renderer.js +1 -0
- package/report/renderer/report-renderer.js +1 -0
- package/report/renderer/report-ui-features.js +1 -0
- package/report/renderer/snippet-renderer.js +1 -0
- 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 +24 -27
- package/report/test/clients/bundle-test.js +4 -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 +3 -0
- 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 +12 -58
- 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 +4 -11
- package/report/test/renderer/pwa-category-renderer-test.js +3 -0
- package/report/test/renderer/report-renderer-axe-test.js +3 -0
- package/report/test/renderer/report-renderer-test.js +3 -0
- package/report/test/renderer/report-ui-features-test.js +3 -0
- 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 -2
- package/report/test-assets/faux-psi.js +1 -2
- package/shared/localization/locales/en-US.json +260 -53
- package/shared/localization/locales/en-XL.json +260 -53
- package/shared/test/localization/format-test.js +2 -0
- 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 +9 -48
- package/types/config.d.ts +0 -2
- package/types/externs.d.ts +2 -2
- package/types/gatherer.d.ts +2 -1
- package/types/global-lh.d.ts +0 -3
- package/types/lhr/audit-details.d.ts +3 -1
- package/types/lhr/lhr.d.ts +2 -2
- package/types/lhr/treemap.d.ts +1 -0
- package/lighthouse-core/audits/script-elements-test-audit.js +0 -30
- package/lighthouse-core/gather/gatherers/scripts.js +0 -154
- package/report/test/.eslintrc.cjs +0 -11
- package/shared/test/localization/.eslintrc.cjs +0 -11
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
'use strict';
|
|
17
18
|
|
|
18
19
|
/** @typedef {import('./dom.js').DOM} DOM */
|
|
19
20
|
|
|
@@ -26,7 +27,6 @@
|
|
|
26
27
|
|
|
27
28
|
import {Util} from './util.js';
|
|
28
29
|
import {CriticalRequestChainRenderer} from './crc-details-renderer.js';
|
|
29
|
-
import {SnippetRenderer} from './snippet-renderer.js';
|
|
30
30
|
import {ElementScreenshotRenderer} from './element-screenshot-renderer.js';
|
|
31
31
|
|
|
32
32
|
const URL_PREFIXES = ['http://', 'https://', 'data:'];
|
|
@@ -78,8 +78,9 @@ export class DetailsRenderer {
|
|
|
78
78
|
* @return {Element}
|
|
79
79
|
*/
|
|
80
80
|
_renderBytes(details) {
|
|
81
|
-
// TODO: handle displayUnit once we have something other than '
|
|
82
|
-
|
|
81
|
+
// TODO: handle displayUnit once we have something other than 'kb'
|
|
82
|
+
// Note that 'kb' is historical and actually represents KiB.
|
|
83
|
+
const value = Util.i18n.formatBytesToKiB(details.value, details.granularity);
|
|
83
84
|
const textEl = this._renderText(value);
|
|
84
85
|
textEl.title = Util.i18n.formatBytes(details.value);
|
|
85
86
|
return textEl;
|
|
@@ -90,11 +91,9 @@ export class DetailsRenderer {
|
|
|
90
91
|
* @return {Element}
|
|
91
92
|
*/
|
|
92
93
|
_renderMilliseconds(details) {
|
|
93
|
-
let value;
|
|
94
|
+
let value = Util.i18n.formatMilliseconds(details.value, details.granularity);
|
|
94
95
|
if (details.displayUnit === 'duration') {
|
|
95
96
|
value = Util.i18n.formatDuration(details.value);
|
|
96
|
-
} else {
|
|
97
|
-
value = Util.i18n.formatMilliseconds(details.value, details.granularity || 10);
|
|
98
97
|
}
|
|
99
98
|
|
|
100
99
|
return this._renderText(value);
|
|
@@ -173,7 +172,7 @@ export class DetailsRenderer {
|
|
|
173
172
|
* @return {Element}
|
|
174
173
|
*/
|
|
175
174
|
_renderNumeric(details) {
|
|
176
|
-
const value = Util.i18n.formatNumber(details.value, details.granularity
|
|
175
|
+
const value = Util.i18n.formatNumber(details.value, details.granularity);
|
|
177
176
|
const element = this._dom.createElement('div', 'lh-numeric');
|
|
178
177
|
element.textContent = value;
|
|
179
178
|
return element;
|
|
@@ -472,15 +471,16 @@ export class DetailsRenderer {
|
|
|
472
471
|
}
|
|
473
472
|
|
|
474
473
|
/**
|
|
475
|
-
* @param {LH.Audit.Details.List} details
|
|
474
|
+
* @param {LH.FormattedIcu<LH.Audit.Details.List>} details
|
|
476
475
|
* @return {Element}
|
|
477
476
|
*/
|
|
478
477
|
_renderList(details) {
|
|
479
478
|
const listContainer = this._dom.createElement('div', 'lh-list');
|
|
480
479
|
|
|
481
480
|
details.items.forEach(item => {
|
|
482
|
-
const
|
|
483
|
-
|
|
481
|
+
const listItem = this.render(item);
|
|
482
|
+
if (!listItem) return;
|
|
483
|
+
listContainer.append(listItem);
|
|
484
484
|
});
|
|
485
485
|
|
|
486
486
|
return listContainer;
|
package/report/renderer/dom.js
CHANGED
|
@@ -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
|
/* eslint-env browser */
|
|
8
9
|
|
|
@@ -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
|
/**
|
|
8
9
|
* @fileoverview These functions define {Rect}s and {Size}s using two different coordinate spaces:
|
|
@@ -252,6 +253,9 @@ export class ElementScreenshotRenderer {
|
|
|
252
253
|
{width: screenshot.width, height: screenshot.height}
|
|
253
254
|
);
|
|
254
255
|
|
|
256
|
+
const contentEl = dom.find('div.lh-element-screenshot__content', containerEl);
|
|
257
|
+
contentEl.style.top = `-${elementPreviewSizeDC.height}px`;
|
|
258
|
+
|
|
255
259
|
const imageEl = dom.find('div.lh-element-screenshot__image', containerEl);
|
|
256
260
|
imageEl.style.width = elementPreviewSizeDC.width + 'px';
|
|
257
261
|
imageEl.style.height = elementPreviewSizeDC.height + 'px';
|
|
@@ -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
|
/* eslint-env browser */
|
|
8
9
|
|
package/report/renderer/i18n.js
CHANGED
|
@@ -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
|
// Not named `NBSP` because that creates a duplicate identifier (util.js).
|
|
8
9
|
const NBSP2 = '\xa0';
|
|
@@ -21,7 +22,9 @@ export class I18n {
|
|
|
21
22
|
// When testing, use a locale with more exciting numeric formatting.
|
|
22
23
|
if (locale === 'en-XA') locale = 'de';
|
|
23
24
|
|
|
24
|
-
this.
|
|
25
|
+
this._numberDateLocale = locale;
|
|
26
|
+
this._numberFormatter = new Intl.NumberFormat(locale);
|
|
27
|
+
this._percentFormatter = new Intl.NumberFormat(locale, {style: 'percent'});
|
|
25
28
|
this._strings = strings;
|
|
26
29
|
}
|
|
27
30
|
|
|
@@ -29,58 +32,15 @@ export class I18n {
|
|
|
29
32
|
return this._strings;
|
|
30
33
|
}
|
|
31
34
|
|
|
32
|
-
/**
|
|
33
|
-
* @param {number} number
|
|
34
|
-
* @param {number|undefined} granularity
|
|
35
|
-
* @param {Intl.NumberFormatOptions=} opts
|
|
36
|
-
* @return {string}
|
|
37
|
-
*/
|
|
38
|
-
_formatNumberWithGranularity(number, granularity, opts = {}) {
|
|
39
|
-
if (granularity !== undefined) {
|
|
40
|
-
const log10 = -Math.log10(granularity);
|
|
41
|
-
if (!Number.isInteger(log10)) {
|
|
42
|
-
console.warn(`granularity of ${granularity} is invalid. Using 1 instead`);
|
|
43
|
-
granularity = 1;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (granularity < 1) {
|
|
47
|
-
opts = {...opts};
|
|
48
|
-
opts.minimumFractionDigits = opts.maximumFractionDigits = Math.ceil(log10);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
number = Math.round(number / granularity) * granularity;
|
|
52
|
-
|
|
53
|
-
// Avoid displaying a negative value that rounds to zero as "0".
|
|
54
|
-
if (Object.is(number, -0)) number = 0;
|
|
55
|
-
} else if (Math.abs(number) < 0.0005) {
|
|
56
|
-
// Also avoids "-0".
|
|
57
|
-
number = 0;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return new Intl.NumberFormat(this._locale, opts).format(number).replace(' ', NBSP2);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
35
|
/**
|
|
64
36
|
* Format number.
|
|
65
37
|
* @param {number} number
|
|
66
|
-
* @param {number=} granularity
|
|
67
|
-
* If undefined, the number will be displayed as described
|
|
68
|
-
* by the Intl defaults: tinyurl.com/7s67w5x7
|
|
69
|
-
* @return {string}
|
|
70
|
-
*/
|
|
71
|
-
formatNumber(number, granularity) {
|
|
72
|
-
return this._formatNumberWithGranularity(number, granularity);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Format integer.
|
|
77
|
-
* Just like {@link formatNumber} but uses a granularity of 1, rounding to the nearest
|
|
78
|
-
* whole number.
|
|
79
|
-
* @param {number} number
|
|
38
|
+
* @param {number=} granularity Number of decimal places to include. Defaults to 0.1.
|
|
80
39
|
* @return {string}
|
|
81
40
|
*/
|
|
82
|
-
|
|
83
|
-
|
|
41
|
+
formatNumber(number, granularity = 0.1) {
|
|
42
|
+
const coarseValue = Math.round(number / granularity) * granularity;
|
|
43
|
+
return this._numberFormatter.format(coarseValue);
|
|
84
44
|
}
|
|
85
45
|
|
|
86
46
|
/**
|
|
@@ -89,99 +49,92 @@ export class I18n {
|
|
|
89
49
|
* @return {string}
|
|
90
50
|
*/
|
|
91
51
|
formatPercent(number) {
|
|
92
|
-
return
|
|
52
|
+
return this._percentFormatter.format(number);
|
|
93
53
|
}
|
|
94
54
|
|
|
95
55
|
/**
|
|
96
56
|
* @param {number} size
|
|
97
|
-
* @param {number=} granularity Controls how coarse the displayed value is.
|
|
98
|
-
* If undefined, the number will be displayed in full.
|
|
57
|
+
* @param {number=} granularity Controls how coarse the displayed value is, defaults to 0.1
|
|
99
58
|
* @return {string}
|
|
100
59
|
*/
|
|
101
|
-
formatBytesToKiB(size, granularity =
|
|
102
|
-
|
|
60
|
+
formatBytesToKiB(size, granularity = 0.1) {
|
|
61
|
+
const formatter = this._byteFormatterForGranularity(granularity);
|
|
62
|
+
const kbs = formatter.format(Math.round(size / 1024 / granularity) * granularity);
|
|
63
|
+
return `${kbs}${NBSP2}KiB`;
|
|
103
64
|
}
|
|
104
65
|
|
|
105
66
|
/**
|
|
106
67
|
* @param {number} size
|
|
107
|
-
* @param {number=} granularity Controls how coarse the displayed value is.
|
|
108
|
-
* If undefined, the number will be displayed in full.
|
|
68
|
+
* @param {number=} granularity Controls how coarse the displayed value is, defaults to 0.1
|
|
109
69
|
* @return {string}
|
|
110
70
|
*/
|
|
111
|
-
formatBytesToMiB(size, granularity =
|
|
112
|
-
|
|
71
|
+
formatBytesToMiB(size, granularity = 0.1) {
|
|
72
|
+
const formatter = this._byteFormatterForGranularity(granularity);
|
|
73
|
+
const kbs = formatter.format(Math.round(size / (1024 ** 2) / granularity) * granularity);
|
|
74
|
+
return `${kbs}${NBSP2}MiB`;
|
|
113
75
|
}
|
|
114
76
|
|
|
115
77
|
/**
|
|
116
78
|
* @param {number} size
|
|
117
|
-
* @param {number=} granularity Controls how coarse the displayed value is
|
|
118
|
-
* If undefined, the number will be displayed in full.
|
|
79
|
+
* @param {number=} granularity Controls how coarse the displayed value is, defaults to 1
|
|
119
80
|
* @return {string}
|
|
120
81
|
*/
|
|
121
82
|
formatBytes(size, granularity = 1) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
unitDisplay: 'long',
|
|
126
|
-
});
|
|
83
|
+
const formatter = this._byteFormatterForGranularity(granularity);
|
|
84
|
+
const kbs = formatter.format(Math.round(size / granularity) * granularity);
|
|
85
|
+
return `${kbs}${NBSP2}bytes`;
|
|
127
86
|
}
|
|
128
87
|
|
|
129
88
|
/**
|
|
130
89
|
* @param {number} size
|
|
131
|
-
* @param {number=} granularity Controls how coarse the displayed value is.
|
|
132
|
-
* If undefined, the number will be displayed in full.
|
|
90
|
+
* @param {number=} granularity Controls how coarse the displayed value is, defaults to 0.1
|
|
133
91
|
* @return {string}
|
|
134
92
|
*/
|
|
135
|
-
formatBytesWithBestUnit(size, granularity =
|
|
93
|
+
formatBytesWithBestUnit(size, granularity = 0.1) {
|
|
136
94
|
if (size >= MiB) return this.formatBytesToMiB(size, granularity);
|
|
137
95
|
if (size >= KiB) return this.formatBytesToKiB(size, granularity);
|
|
138
|
-
return this.
|
|
139
|
-
style: 'unit',
|
|
140
|
-
unit: 'byte',
|
|
141
|
-
unitDisplay: 'narrow',
|
|
142
|
-
});
|
|
96
|
+
return this.formatNumber(size, granularity) + '\xa0B';
|
|
143
97
|
}
|
|
144
98
|
|
|
145
99
|
/**
|
|
146
|
-
*
|
|
147
|
-
* @param {number
|
|
148
|
-
*
|
|
149
|
-
* @return {string}
|
|
100
|
+
* Format bytes with a constant number of fractional digits, i.e. for a granularity of 0.1, 10 becomes '10.0'
|
|
101
|
+
* @param {number} granularity Controls how coarse the displayed value is
|
|
102
|
+
* @return {Intl.NumberFormat}
|
|
150
103
|
*/
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
104
|
+
_byteFormatterForGranularity(granularity) {
|
|
105
|
+
// assume any granularity above 1 will not contain fractional parts, i.e. will never be 1.5
|
|
106
|
+
let numberOfFractionDigits = 0;
|
|
107
|
+
if (granularity < 1) {
|
|
108
|
+
numberOfFractionDigits = -Math.floor(Math.log10(granularity));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return new Intl.NumberFormat(this._numberDateLocale, {
|
|
112
|
+
...this._numberFormatter.resolvedOptions(),
|
|
113
|
+
maximumFractionDigits: numberOfFractionDigits,
|
|
114
|
+
minimumFractionDigits: numberOfFractionDigits,
|
|
156
115
|
});
|
|
157
116
|
}
|
|
158
117
|
|
|
159
118
|
/**
|
|
160
119
|
* @param {number} ms
|
|
161
|
-
* @param {number=} granularity Controls how coarse the displayed value is
|
|
162
|
-
* If undefined, the number will be displayed in full.
|
|
120
|
+
* @param {number=} granularity Controls how coarse the displayed value is, defaults to 10
|
|
163
121
|
* @return {string}
|
|
164
122
|
*/
|
|
165
|
-
formatMilliseconds(ms, granularity =
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
});
|
|
123
|
+
formatMilliseconds(ms, granularity = 10) {
|
|
124
|
+
const coarseTime = Math.round(ms / granularity) * granularity;
|
|
125
|
+
return coarseTime === 0
|
|
126
|
+
? `${this._numberFormatter.format(0)}${NBSP2}ms`
|
|
127
|
+
: `${this._numberFormatter.format(coarseTime)}${NBSP2}ms`;
|
|
171
128
|
}
|
|
172
129
|
|
|
173
130
|
/**
|
|
174
131
|
* @param {number} ms
|
|
175
|
-
* @param {number=} granularity Controls how coarse the displayed value is.
|
|
176
|
-
* If undefined, the number will be displayed in full.
|
|
132
|
+
* @param {number=} granularity Controls how coarse the displayed value is, defaults to 0.1
|
|
177
133
|
* @return {string}
|
|
178
134
|
*/
|
|
179
|
-
formatSeconds(ms, granularity =
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
unit: 'second',
|
|
183
|
-
unitDisplay: 'short',
|
|
184
|
-
});
|
|
135
|
+
formatSeconds(ms, granularity = 0.1) {
|
|
136
|
+
const coarseTime = Math.round(ms / 1000 / granularity) * granularity;
|
|
137
|
+
return `${this._numberFormatter.format(coarseTime)}${NBSP2}s`;
|
|
185
138
|
}
|
|
186
139
|
|
|
187
140
|
/**
|
|
@@ -201,10 +154,10 @@ export class I18n {
|
|
|
201
154
|
// and https://github.com/GoogleChrome/lighthouse/pull/9822
|
|
202
155
|
let formatter;
|
|
203
156
|
try {
|
|
204
|
-
formatter = new Intl.DateTimeFormat(this.
|
|
157
|
+
formatter = new Intl.DateTimeFormat(this._numberDateLocale, options);
|
|
205
158
|
} catch (err) {
|
|
206
159
|
options.timeZone = 'UTC';
|
|
207
|
-
formatter = new Intl.DateTimeFormat(this.
|
|
160
|
+
formatter = new Intl.DateTimeFormat(this._numberDateLocale, options);
|
|
208
161
|
}
|
|
209
162
|
|
|
210
163
|
return formatter.format(new Date(date));
|
|
@@ -216,10 +169,6 @@ export class I18n {
|
|
|
216
169
|
* @return {string}
|
|
217
170
|
*/
|
|
218
171
|
formatDuration(timeInMilliseconds) {
|
|
219
|
-
// There is a proposal for a Intl.DurationFormat.
|
|
220
|
-
// https://github.com/tc39/proposal-intl-duration-format
|
|
221
|
-
// Until then, we do things a bit more manually.
|
|
222
|
-
|
|
223
172
|
let timeInSeconds = timeInMilliseconds / 1000;
|
|
224
173
|
if (Math.round(timeInSeconds) === 0) {
|
|
225
174
|
return 'None';
|
|
@@ -228,24 +177,19 @@ export class I18n {
|
|
|
228
177
|
/** @type {Array<string>} */
|
|
229
178
|
const parts = [];
|
|
230
179
|
/** @type {Record<string, number>} */
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
180
|
+
const unitLabels = {
|
|
181
|
+
d: 60 * 60 * 24,
|
|
182
|
+
h: 60 * 60,
|
|
183
|
+
m: 60,
|
|
184
|
+
s: 1,
|
|
236
185
|
};
|
|
237
186
|
|
|
238
|
-
Object.keys(
|
|
239
|
-
const
|
|
240
|
-
const numberOfUnits = Math.floor(timeInSeconds /
|
|
187
|
+
Object.keys(unitLabels).forEach(label => {
|
|
188
|
+
const unit = unitLabels[label];
|
|
189
|
+
const numberOfUnits = Math.floor(timeInSeconds / unit);
|
|
241
190
|
if (numberOfUnits > 0) {
|
|
242
|
-
timeInSeconds -= numberOfUnits *
|
|
243
|
-
|
|
244
|
-
style: 'unit',
|
|
245
|
-
unit,
|
|
246
|
-
unitDisplay: 'narrow',
|
|
247
|
-
});
|
|
248
|
-
parts.push(part);
|
|
191
|
+
timeInSeconds -= numberOfUnits * unit;
|
|
192
|
+
parts.push(`${numberOfUnits}\xa0${label}`);
|
|
249
193
|
}
|
|
250
194
|
});
|
|
251
195
|
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
'use strict';
|
|
17
18
|
|
|
18
19
|
import {TextEncoding} from './text-encoding.js';
|
|
19
20
|
|
|
@@ -37,7 +38,7 @@ function computeWindowNameSuffix(json) {
|
|
|
37
38
|
// @ts-expect-error - If this is a v2 LHR, use old `generatedTime`.
|
|
38
39
|
const fallbackFetchTime = /** @type {string} */ (json.generatedTime);
|
|
39
40
|
const fetchTime = json.fetchTime || fallbackFetchTime;
|
|
40
|
-
return `${json.lighthouseVersion}-${json.
|
|
41
|
+
return `${json.lighthouseVersion}-${json.requestedUrl}-${fetchTime}`;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
/**
|
|
@@ -119,6 +120,7 @@ function openTreemap(json) {
|
|
|
119
120
|
/** @type {LH.Treemap.Options} */
|
|
120
121
|
const treemapOptions = {
|
|
121
122
|
lhr: {
|
|
123
|
+
requestedUrl: json.requestedUrl,
|
|
122
124
|
finalUrl: json.finalUrl,
|
|
123
125
|
audits: {
|
|
124
126
|
'script-treemap-data': json.audits['script-treemap-data'],
|
|
@@ -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
|
/** @typedef {import('./details-renderer').DetailsRenderer} DetailsRenderer */
|
|
8
9
|
/** @typedef {import('./dom').DOM} DOM */
|
|
@@ -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
|
/**
|
|
8
9
|
* @fileoverview Creates a <select> element, filled with all supported locales
|
|
@@ -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
|
/* global CompressionStream */
|
|
8
9
|
|
|
@@ -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
|
/* eslint-env browser */
|
|
8
9
|
|
package/report/renderer/util.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
'use strict';
|
|
17
18
|
|
|
18
19
|
/** @template T @typedef {import('./i18n').I18n<T>} I18n */
|
|
19
20
|
|
|
@@ -314,26 +315,24 @@ class Util {
|
|
|
314
315
|
}
|
|
315
316
|
|
|
316
317
|
const MAX_LENGTH = 64;
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
name = name.replace(/\?.*/, `?${ELLIPSIS}`);
|
|
336
|
-
}
|
|
318
|
+
// Always elide hexadecimal hash
|
|
319
|
+
name = name.replace(/([a-f0-9]{7})[a-f0-9]{13}[a-f0-9]*/g, `$1${ELLIPSIS}`);
|
|
320
|
+
// Also elide other hash-like mixed-case strings
|
|
321
|
+
name = name.replace(/([a-zA-Z0-9-_]{9})(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9-_]{10,}/g,
|
|
322
|
+
`$1${ELLIPSIS}`);
|
|
323
|
+
// Also elide long number sequences
|
|
324
|
+
name = name.replace(/(\d{3})\d{6,}/g, `$1${ELLIPSIS}`);
|
|
325
|
+
// Merge any adjacent ellipses
|
|
326
|
+
name = name.replace(/\u2026+/g, ELLIPSIS);
|
|
327
|
+
|
|
328
|
+
// Elide query params first
|
|
329
|
+
if (name.length > MAX_LENGTH && name.includes('?')) {
|
|
330
|
+
// Try to leave the first query parameter intact
|
|
331
|
+
name = name.replace(/\?([^=]*)(=)?.*/, `?$1$2${ELLIPSIS}`);
|
|
332
|
+
|
|
333
|
+
// Remove it all if it's still too long
|
|
334
|
+
if (name.length > MAX_LENGTH) {
|
|
335
|
+
name = name.replace(/\?.*/, `?${ELLIPSIS}`);
|
|
337
336
|
}
|
|
338
337
|
}
|
|
339
338
|
|
|
@@ -429,11 +428,10 @@ class Util {
|
|
|
429
428
|
break;
|
|
430
429
|
case 'devtools': {
|
|
431
430
|
const {cpuSlowdownMultiplier, requestLatencyMs} = throttling;
|
|
432
|
-
// eslint-disable-next-line max-len
|
|
433
431
|
cpuThrottling = `${Util.i18n.formatNumber(cpuSlowdownMultiplier)}x slowdown (DevTools)`;
|
|
434
|
-
networkThrottling = `${Util.i18n.
|
|
435
|
-
`${Util.i18n.
|
|
436
|
-
`${Util.i18n.
|
|
432
|
+
networkThrottling = `${Util.i18n.formatNumber(requestLatencyMs)}${NBSP}ms HTTP RTT, ` +
|
|
433
|
+
`${Util.i18n.formatNumber(throttling.downloadThroughputKbps)}${NBSP}Kbps down, ` +
|
|
434
|
+
`${Util.i18n.formatNumber(throttling.uploadThroughputKbps)}${NBSP}Kbps up (DevTools)`;
|
|
437
435
|
|
|
438
436
|
const isSlow4G = () => {
|
|
439
437
|
return requestLatencyMs === 150 * 3.75 &&
|
|
@@ -445,10 +443,9 @@ class Util {
|
|
|
445
443
|
}
|
|
446
444
|
case 'simulate': {
|
|
447
445
|
const {cpuSlowdownMultiplier, rttMs, throughputKbps} = throttling;
|
|
448
|
-
// eslint-disable-next-line max-len
|
|
449
446
|
cpuThrottling = `${Util.i18n.formatNumber(cpuSlowdownMultiplier)}x slowdown (Simulated)`;
|
|
450
|
-
networkThrottling = `${Util.i18n.
|
|
451
|
-
`${Util.i18n.
|
|
447
|
+
networkThrottling = `${Util.i18n.formatNumber(rttMs)}${NBSP}ms TCP RTT, ` +
|
|
448
|
+
`${Util.i18n.formatNumber(throughputKbps)}${NBSP}Kbps throughput (Simulated)`;
|
|
452
449
|
|
|
453
450
|
const isSlow4G = () => {
|
|
454
451
|
return rttMs === 150 && throughputKbps === 1.6 * 1024;
|
|
@@ -4,6 +4,7 @@
|
|
|
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';
|
|
7
8
|
|
|
8
9
|
import fs from 'fs';
|
|
9
10
|
|
|
@@ -16,6 +17,9 @@ import {LH_ROOT} from '../../../root.js';
|
|
|
16
17
|
const sampleResultsStr =
|
|
17
18
|
fs.readFileSync(LH_ROOT + '/lighthouse-core/test/results/sample_v2.json', 'utf-8');
|
|
18
19
|
|
|
20
|
+
|
|
21
|
+
/* eslint-env jest */
|
|
22
|
+
|
|
19
23
|
describe('lighthouseRenderer bundle', () => {
|
|
20
24
|
let document;
|
|
21
25
|
beforeAll(() => {
|
|
@@ -9,6 +9,7 @@ const assert = require('assert').strict;
|
|
|
9
9
|
|
|
10
10
|
const getLhrFilenamePrefix = require('../../generator/file-namer.js').getLhrFilenamePrefix;
|
|
11
11
|
|
|
12
|
+
/* eslint-env jest */
|
|
12
13
|
describe('file-namer helper', () => {
|
|
13
14
|
it('generates filename prefixes', () => {
|
|
14
15
|
const results = {
|