lighthouse 11.7.1 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +2 -2
- package/cli/bin.js +0 -7
- package/cli/cli-flags.d.ts +1 -5
- package/cli/cli-flags.js +4 -8
- package/cli/test/smokehouse/__snapshots__/report-assert-test.js.snap +14 -14
- package/cli/test/smokehouse/config/exclusions.js +3 -0
- package/cli/test/smokehouse/core-tests.js +6 -20
- package/cli/test/smokehouse/frontends/smokehouse-bin.js +2 -2
- package/core/audits/accessibility/aria-conditional-attr.d.ts +10 -0
- package/core/audits/accessibility/aria-conditional-attr.js +43 -0
- package/core/audits/accessibility/{duplicate-id-active.d.ts → aria-deprecated-role.d.ts} +3 -3
- package/core/audits/accessibility/aria-deprecated-role.js +43 -0
- package/core/audits/accessibility/aria-prohibited-attr.d.ts +10 -0
- package/core/audits/accessibility/aria-prohibited-attr.js +44 -0
- package/core/audits/accessibility/target-size.js +0 -1
- package/core/audits/byte-efficiency/byte-efficiency-audit.d.ts +0 -16
- package/core/audits/byte-efficiency/byte-efficiency-audit.js +1 -38
- package/core/audits/byte-efficiency/offscreen-images.d.ts +0 -11
- package/core/audits/byte-efficiency/offscreen-images.js +0 -15
- package/core/audits/byte-efficiency/render-blocking-resources.js +27 -26
- package/core/audits/byte-efficiency/unminified-css.js +2 -2
- package/core/audits/byte-efficiency/unused-css-rules.js +3 -1
- package/core/audits/dobetterweb/uses-http2.d.ts +0 -13
- package/core/audits/dobetterweb/uses-http2.js +4 -38
- package/core/audits/font-display.js +2 -2
- package/core/audits/layout-shifts.js +1 -1
- package/core/audits/preload-fonts.d.ts +1 -5
- package/core/audits/preload-fonts.js +1 -10
- package/core/audits/prioritize-lcp-image.js +2 -2
- package/core/audits/redirects-http.d.ts +19 -0
- package/core/audits/redirects-http.js +75 -0
- package/core/audits/resource-summary.d.ts +2 -0
- package/core/audits/resource-summary.js +5 -4
- package/core/audits/seo/is-crawlable.d.ts +2 -1
- package/core/audits/seo/link-text.js +12 -0
- package/core/audits/uses-rel-preload.d.ts +1 -5
- package/core/audits/uses-rel-preload.js +5 -15
- package/core/audits/work-during-interaction.d.ts +2 -2
- package/core/audits/work-during-interaction.js +2 -2
- package/core/computed/js-bundles.d.ts +1 -1
- package/core/computed/metrics/lantern-first-contentful-paint.d.ts +13 -82
- package/core/computed/metrics/lantern-first-contentful-paint.js +16 -178
- package/core/computed/metrics/lantern-first-meaningful-paint.d.ts +13 -12
- package/core/computed/metrics/lantern-first-meaningful-paint.js +11 -49
- package/core/computed/metrics/lantern-interactive.d.ts +13 -21
- package/core/computed/metrics/lantern-interactive.js +12 -84
- package/core/computed/metrics/lantern-largest-contentful-paint.d.ts +13 -25
- package/core/computed/metrics/lantern-largest-contentful-paint.js +13 -80
- package/core/computed/metrics/lantern-max-potential-fid.d.ts +13 -24
- package/core/computed/metrics/lantern-max-potential-fid.js +12 -64
- package/core/computed/metrics/lantern-metric.d.ts +14 -18
- package/core/computed/metrics/lantern-metric.js +34 -30
- package/core/computed/metrics/lantern-speed-index.d.ts +13 -32
- package/core/computed/metrics/lantern-speed-index.js +13 -116
- package/core/computed/metrics/lantern-total-blocking-time.d.ts +13 -25
- package/core/computed/metrics/lantern-total-blocking-time.js +10 -94
- package/core/computed/metrics/metric.js +1 -3
- package/core/computed/module-duplication.d.ts +1 -1
- package/core/computed/navigation-insights.d.ts +36 -0
- package/core/computed/navigation-insights.js +35 -0
- package/core/computed/page-dependency-graph.js +3 -7
- package/core/computed/resource-summary.d.ts +10 -12
- package/core/computed/resource-summary.js +12 -19
- package/core/computed/trace-engine-result.d.ts +16 -3
- package/core/computed/trace-engine-result.js +19 -14
- package/core/computed/unused-css.d.ts +3 -1
- package/core/computed/unused-css.js +6 -5
- package/core/config/config-helpers.js +0 -4
- package/core/config/constants.js +0 -1
- package/core/config/default-config.js +63 -142
- package/core/config/experimental-config.js +11 -0
- package/core/config/filters.js +0 -1
- package/core/gather/driver/navigation.js +4 -1
- package/core/gather/driver/prepare.js +1 -1
- package/core/gather/driver/target-manager.js +4 -3
- package/core/gather/driver/wait-for-condition.js +2 -3
- package/core/gather/driver.d.ts +12 -0
- package/core/gather/driver.js +27 -0
- package/core/gather/gatherers/accessibility.js +4 -6
- package/core/gather/gatherers/css-usage.d.ts +0 -21
- package/core/gather/gatherers/css-usage.js +9 -119
- package/core/gather/gatherers/root-causes.d.ts +2 -2
- package/core/gather/gatherers/root-causes.js +6 -5
- package/core/gather/gatherers/stylesheets.d.ts +26 -0
- package/core/gather/gatherers/stylesheets.js +138 -0
- package/core/gather/gatherers/trace-elements.d.ts +2 -12
- package/core/gather/gatherers/trace-elements.js +2 -21
- package/core/gather/navigation-runner.js +3 -1
- package/core/gather/session.d.ts +8 -0
- package/core/gather/session.js +14 -1
- package/core/lib/emulation.js +2 -2
- package/core/lib/i18n/i18n.d.ts +0 -1
- package/core/lib/i18n/i18n.js +0 -2
- package/core/lib/lantern/cpu-node.d.ts +7 -1
- package/core/lib/lantern/cpu-node.js +12 -2
- package/core/lib/lantern/lantern-error.d.ts +8 -0
- package/core/lib/lantern/lantern-error.js +9 -0
- package/core/lib/lantern/metric.js +2 -6
- package/core/lib/lantern/metrics/first-contentful-paint.d.ts +79 -0
- package/core/lib/lantern/metrics/first-contentful-paint.js +200 -0
- package/core/lib/lantern/metrics/first-meaningful-paint.d.ts +6 -0
- package/core/lib/lantern/metrics/first-meaningful-paint.js +64 -0
- package/core/lib/lantern/metrics/interactive.d.ts +26 -0
- package/core/lib/lantern/metrics/interactive.js +112 -0
- package/core/lib/lantern/metrics/largest-contentful-paint.d.ts +19 -0
- package/core/lib/lantern/metrics/largest-contentful-paint.js +108 -0
- package/core/lib/lantern/metrics/max-potential-fid.d.ts +30 -0
- package/core/lib/lantern/metrics/max-potential-fid.js +92 -0
- package/core/lib/lantern/metrics/speed-index.d.ts +38 -0
- package/core/lib/lantern/metrics/speed-index.js +144 -0
- package/core/lib/lantern/metrics/total-blocking-time.d.ts +31 -0
- package/core/lib/lantern/metrics/total-blocking-time.js +128 -0
- package/core/lib/lantern/network-node.js +28 -4
- package/core/lib/lantern/page-dependency-graph.d.ts +4 -4
- package/core/lib/lantern/page-dependency-graph.js +19 -7
- package/core/lib/lantern/simulator/connection-pool.d.ts +2 -12
- package/core/lib/lantern/simulator/connection-pool.js +3 -22
- package/core/lib/lantern/simulator/network-analyzer.js +1 -12
- package/core/lib/lantern/simulator/simulator.d.ts +2 -4
- package/core/lib/lantern/simulator/simulator.js +7 -14
- package/core/lib/lantern/types/lantern.d.ts +5 -3
- package/core/lib/lantern-trace-saver.js +0 -1
- package/core/lib/lh-error.d.ts +9 -0
- package/core/lib/lh-error.js +13 -3
- package/core/lib/lighthouse-compatibility.js +53 -10
- package/core/lib/navigation-error.js +3 -0
- package/core/lib/network-request.d.ts +1 -0
- package/core/lib/network-request.js +28 -0
- package/core/runner.js +18 -25
- package/dist/report/bundle.esm.js +11 -112
- package/dist/report/flow.js +16 -117
- package/dist/report/standalone.js +12 -113
- package/flow-report/src/help-dialog.tsx +0 -1
- package/flow-report/src/i18n/i18n.d.ts +0 -4
- package/flow-report/src/i18n/ui-strings.d.ts +0 -1
- package/flow-report/src/i18n/ui-strings.js +0 -2
- package/flow-report/src/summary/category.tsx +10 -12
- package/package.json +5 -5
- package/readme.md +4 -4
- package/report/assets/styles.css +1 -60
- package/report/assets/templates.html +0 -95
- package/report/renderer/category-renderer.js +1 -1
- package/report/renderer/components.d.ts +2 -2
- package/report/renderer/components.js +2 -103
- package/report/renderer/dom.d.ts +1 -1
- package/report/renderer/dom.js +1 -1
- package/report/renderer/performance-category-renderer.d.ts +0 -7
- package/report/renderer/performance-category-renderer.js +1 -32
- package/report/renderer/report-renderer.js +3 -13
- package/report/renderer/report-ui-features.js +1 -1
- package/report/renderer/report-utils.d.ts +0 -1
- package/report/renderer/report-utils.js +13 -13
- package/shared/localization/locales/ar-XB.json +62 -329
- package/shared/localization/locales/ar.json +62 -329
- package/shared/localization/locales/bg.json +62 -329
- package/shared/localization/locales/ca.json +62 -329
- package/shared/localization/locales/cs.json +62 -329
- package/shared/localization/locales/da.json +62 -329
- package/shared/localization/locales/de.json +62 -329
- package/shared/localization/locales/el.json +62 -329
- package/shared/localization/locales/en-GB.json +62 -329
- package/shared/localization/locales/en-US.json +41 -272
- package/shared/localization/locales/en-XA.json +62 -329
- package/shared/localization/locales/en-XL.json +41 -272
- package/shared/localization/locales/es-419.json +62 -329
- package/shared/localization/locales/es.json +62 -329
- package/shared/localization/locales/fi.json +62 -329
- package/shared/localization/locales/fil.json +61 -328
- package/shared/localization/locales/fr.json +62 -329
- package/shared/localization/locales/he.json +62 -329
- package/shared/localization/locales/hi.json +62 -329
- package/shared/localization/locales/hr.json +63 -330
- package/shared/localization/locales/hu.json +62 -329
- package/shared/localization/locales/id.json +62 -329
- package/shared/localization/locales/it.json +62 -329
- package/shared/localization/locales/ja.json +62 -329
- package/shared/localization/locales/ko.json +62 -329
- package/shared/localization/locales/lt.json +62 -329
- package/shared/localization/locales/lv.json +62 -329
- package/shared/localization/locales/nl.json +62 -329
- package/shared/localization/locales/no.json +62 -329
- package/shared/localization/locales/pl.json +61 -328
- package/shared/localization/locales/pt-PT.json +62 -329
- package/shared/localization/locales/pt.json +64 -331
- package/shared/localization/locales/ro.json +62 -329
- package/shared/localization/locales/ru.json +62 -329
- package/shared/localization/locales/sk.json +62 -329
- package/shared/localization/locales/sl.json +62 -329
- package/shared/localization/locales/sr-Latn.json +62 -329
- package/shared/localization/locales/sr.json +62 -329
- package/shared/localization/locales/sv.json +62 -329
- package/shared/localization/locales/ta.json +61 -328
- package/shared/localization/locales/te.json +62 -329
- package/shared/localization/locales/th.json +62 -329
- package/shared/localization/locales/tr.json +62 -329
- package/shared/localization/locales/uk.json +62 -329
- package/shared/localization/locales/vi.json +61 -328
- package/shared/localization/locales/zh-HK.json +62 -329
- package/shared/localization/locales/zh-TW.json +61 -328
- package/shared/localization/locales/zh.json +62 -329
- package/tsconfig.json +1 -3
- package/types/artifacts.d.ts +21 -110
- package/types/audit.d.ts +0 -10
- package/types/config.d.ts +0 -1
- package/types/externs.d.ts +0 -2
- package/types/gatherer.d.ts +3 -0
- package/types/internal/smokehouse.d.ts +1 -1
- package/types/lh.d.ts +0 -2
- package/types/lhr/audit-details.d.ts +9 -4
- package/types/lhr/lhr.d.ts +0 -4
- package/types/lhr/settings.d.ts +0 -4
- package/core/audits/accessibility/duplicate-id-active.js +0 -42
- package/core/audits/content-width.d.ts +0 -17
- package/core/audits/content-width.js +0 -76
- package/core/audits/installable-manifest.d.ts +0 -111
- package/core/audits/installable-manifest.js +0 -248
- package/core/audits/layout-shift-elements.d.ts +0 -16
- package/core/audits/layout-shift-elements.js +0 -101
- package/core/audits/manual/pwa-cross-browser.d.ts +0 -12
- package/core/audits/manual/pwa-cross-browser.js +0 -40
- package/core/audits/manual/pwa-each-page-has-url.d.ts +0 -12
- package/core/audits/manual/pwa-each-page-has-url.js +0 -38
- package/core/audits/manual/pwa-page-transitions.d.ts +0 -12
- package/core/audits/manual/pwa-page-transitions.js +0 -38
- package/core/audits/maskable-icon.d.ts +0 -25
- package/core/audits/maskable-icon.js +0 -70
- package/core/audits/multi-check-audit.d.ts +0 -28
- package/core/audits/multi-check-audit.js +0 -82
- package/core/audits/no-unload-listeners.d.ts +0 -16
- package/core/audits/no-unload-listeners.js +0 -86
- package/core/audits/performance-budget.d.ts +0 -39
- package/core/audits/performance-budget.js +0 -154
- package/core/audits/script-elements-test-audit.d.ts +0 -14
- package/core/audits/script-elements-test-audit.js +0 -29
- package/core/audits/seo/plugins.d.ts +0 -15
- package/core/audits/seo/plugins.js +0 -150
- package/core/audits/seo/tap-targets.d.ts +0 -50
- package/core/audits/seo/tap-targets.js +0 -352
- package/core/audits/splash-screen.d.ts +0 -37
- package/core/audits/splash-screen.js +0 -98
- package/core/audits/themed-omnibox.d.ts +0 -42
- package/core/audits/themed-omnibox.js +0 -102
- package/core/audits/timing-budget.d.ts +0 -43
- package/core/audits/timing-budget.js +0 -175
- package/core/computed/manifest-values.d.ts +0 -24
- package/core/computed/manifest-values.js +0 -136
- package/core/config/budget.d.ts +0 -74
- package/core/config/budget.js +0 -340
- package/core/config/metrics-to-audits.d.ts +0 -19
- package/core/config/metrics-to-audits.js +0 -62
- package/core/gather/driver/service-workers.d.ts +0 -16
- package/core/gather/driver/service-workers.js +0 -52
- package/core/gather/gatherers/dobetterweb/tags-blocking-first-paint.d.ts +0 -47
- package/core/gather/gatherers/dobetterweb/tags-blocking-first-paint.js +0 -233
- package/core/gather/gatherers/global-listeners.d.ts +0 -27
- package/core/gather/gatherers/global-listeners.js +0 -108
- package/core/gather/gatherers/installability-errors.d.ts +0 -17
- package/core/gather/gatherers/installability-errors.js +0 -56
- package/core/gather/gatherers/script-elements.d.ts +0 -21
- package/core/gather/gatherers/script-elements.js +0 -100
- package/core/gather/gatherers/seo/embedded-content.d.ts +0 -10
- package/core/gather/gatherers/seo/embedded-content.js +0 -63
- package/core/gather/gatherers/seo/tap-targets.d.ts +0 -21
- package/core/gather/gatherers/seo/tap-targets.js +0 -389
- package/core/gather/gatherers/service-worker.d.ts +0 -10
- package/core/gather/gatherers/service-worker.js +0 -32
- package/core/gather/gatherers/web-app-manifest.d.ts +0 -32
- package/core/gather/gatherers/web-app-manifest.js +0 -106
- package/report/renderer/pwa-category-renderer.d.ts +0 -55
- package/report/renderer/pwa-category-renderer.js +0 -184
- package/third-party/chromium-synchronization/installability-errors-test.js +0 -79
- package/types/lhr/budget.d.ts +0 -60
package/tsconfig.json
CHANGED
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
"cli/test/fixtures/**/*.js",
|
|
38
38
|
"core/scripts/legacy-javascript/variants",
|
|
39
39
|
// These test files require further changes before they can be type checked.
|
|
40
|
-
"core/test/config/budget-test.js",
|
|
41
40
|
"core/test/config/config-helpers-test.js",
|
|
42
41
|
"core/test/config/config-plugin-test.js",
|
|
43
42
|
"core/test/config/default-config-test.js",
|
|
@@ -48,7 +47,6 @@
|
|
|
48
47
|
"core/test/gather/gatherers/devtools-log-test.js",
|
|
49
48
|
"core/test/gather/gatherers/dobetterweb/optimized-images-test.js",
|
|
50
49
|
"core/test/gather/gatherers/dobetterweb/response-compression-test.js",
|
|
51
|
-
"core/test/gather/gatherers/dobetterweb/tags-blocking-first-paint-test.js",
|
|
52
50
|
"core/test/gather/gatherers/full-page-screenshot-test.js",
|
|
53
51
|
"core/test/gather/gatherers/global-listeners-test.js",
|
|
54
52
|
"core/test/gather/gatherers/html-without-javascript-test.js",
|
|
@@ -57,7 +55,6 @@
|
|
|
57
55
|
"core/test/gather/gatherers/offline-test.js",
|
|
58
56
|
"core/test/gather/gatherers/runtime-exceptions-test.js",
|
|
59
57
|
"core/test/gather/gatherers/seo/font-size-test.js",
|
|
60
|
-
"core/test/gather/gatherers/service-worker-test.js",
|
|
61
58
|
"core/test/gather/gatherers/source-maps-test.js",
|
|
62
59
|
"core/test/gather/gatherers/stack-collector-test.js",
|
|
63
60
|
"core/test/gather/gatherers/start-url-test.js",
|
|
@@ -70,6 +67,7 @@
|
|
|
70
67
|
"core/test/lib/i18n/i18n-test.js",
|
|
71
68
|
"core/test/lib/icons-test.js",
|
|
72
69
|
"core/test/lib/lantern/base-node-test.js",
|
|
70
|
+
"core/test/lib/lantern/metrics/*",
|
|
73
71
|
"core/test/lib/lantern/page-dependency-graph-test.js",
|
|
74
72
|
"core/test/lib/lantern/simulator/connection-pool-test.js",
|
|
75
73
|
"core/test/lib/lantern/simulator/dns-cache-test.js",
|
package/types/artifacts.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ import speedline from 'speedline-core';
|
|
|
16
16
|
import * as CDTSourceMap from '../core/lib/cdt/generated/SourceMap.js';
|
|
17
17
|
import {ArbitraryEqualityMap} from '../core/lib/arbitrary-equality-map.js';
|
|
18
18
|
import type { TaskNode as _TaskNode } from '../core/lib/tracehouse/main-thread-tasks.js';
|
|
19
|
+
import type {EnabledHandlers} from '../core/computed/trace-engine-result.js';
|
|
19
20
|
import AuditDetails from './lhr/audit-details.js'
|
|
20
21
|
import Config from './config.js';
|
|
21
22
|
import Gatherer from './gatherer.js';
|
|
@@ -45,8 +46,6 @@ interface UniversalBaseArtifacts {
|
|
|
45
46
|
LighthouseRunWarnings: Array<string | IcuMessage>;
|
|
46
47
|
/** The benchmark index that indicates rough device class. */
|
|
47
48
|
BenchmarkIndex: number;
|
|
48
|
-
/** Many benchmark indexes. Many. */
|
|
49
|
-
BenchmarkIndexes?: number[];
|
|
50
49
|
/** An object containing information about the testing configuration used by Lighthouse. */
|
|
51
50
|
settings: Config.Settings;
|
|
52
51
|
/** The timing instrumentation of the gather portion of a run. */
|
|
@@ -79,18 +78,20 @@ interface ContextualBaseArtifacts {
|
|
|
79
78
|
interface PublicGathererArtifacts {
|
|
80
79
|
/** ConsoleMessages deprecation and intervention warnings, console API calls, and exceptions logged by Chrome during page load. */
|
|
81
80
|
ConsoleMessages: Artifacts.ConsoleMessage[];
|
|
82
|
-
/**
|
|
83
|
-
|
|
84
|
-
/** The contents of the main HTML document network resource. */
|
|
85
|
-
MainDocumentContent: string;
|
|
81
|
+
/** The primary log of devtools protocol activity. */
|
|
82
|
+
DevtoolsLog: DevtoolsLog;
|
|
86
83
|
/** Information on size and loading for all the images in the page. Natural size information for `picture` and CSS images is only available if the image was one of the largest 50 images. */
|
|
87
84
|
ImageElements: Artifacts.ImageElement[];
|
|
88
85
|
/** All the link elements on the page or equivalently declared in `Link` headers. @see https://html.spec.whatwg.org/multipage/links.html */
|
|
89
86
|
LinkElements: Artifacts.LinkElement[];
|
|
87
|
+
/** The contents of the main HTML document network resource. */
|
|
88
|
+
MainDocumentContent: string;
|
|
90
89
|
/** The values of the <meta> elements in the head. */
|
|
91
90
|
MetaElements: Array<{name?: string, content?: string, property?: string, httpEquiv?: string, charset?: string, node: Artifacts.NodeDetails}>;
|
|
92
|
-
/** Information on all
|
|
93
|
-
|
|
91
|
+
/** Information on all scripts in the page. */
|
|
92
|
+
Scripts: Artifacts.Script[];
|
|
93
|
+
/** The primary trace taken over the entire run. */
|
|
94
|
+
Trace: Trace;
|
|
94
95
|
/** The dimensions and devicePixelRatio of the loaded viewport. */
|
|
95
96
|
ViewportDimensions: Artifacts.ViewportDimensions;
|
|
96
97
|
}
|
|
@@ -109,9 +110,7 @@ export interface GathererArtifacts extends PublicGathererArtifacts {
|
|
|
109
110
|
/** Array of all URLs cached in CacheStorage. */
|
|
110
111
|
CacheContents: string[];
|
|
111
112
|
/** CSS coverage information for styles used by page's final state. */
|
|
112
|
-
CSSUsage:
|
|
113
|
-
/** The primary log of devtools protocol activity. */
|
|
114
|
-
DevtoolsLog: DevtoolsLog;
|
|
113
|
+
CSSUsage: Crdp.CSS.RuleUsage[];
|
|
115
114
|
/** The log of devtools protocol activity if there was a page load error and Chrome navigated to a `chrome-error://` page. */
|
|
116
115
|
DevtoolsLogError: DevtoolsLog;
|
|
117
116
|
/** Information on the document's doctype(or null if not present), specifically the name, publicId, and systemId.
|
|
@@ -119,20 +118,16 @@ export interface GathererArtifacts extends PublicGathererArtifacts {
|
|
|
119
118
|
Doctype: Artifacts.Doctype | null;
|
|
120
119
|
/** Information on the size of all DOM nodes in the page and the most extreme members. */
|
|
121
120
|
DOMStats: Artifacts.DOMStats;
|
|
122
|
-
/** Relevant attributes and child properties of all <object>s, <embed>s and <applet>s in the page. */
|
|
123
|
-
EmbeddedContent: Artifacts.EmbeddedContentInfo[];
|
|
124
121
|
/** Information on poorly sized font usage and the text affected by it. */
|
|
125
122
|
FontSize: Artifacts.FontSize;
|
|
123
|
+
/** All the iframe elements in the page. */
|
|
124
|
+
IFrameElements: Artifacts.IFrameElement[];
|
|
126
125
|
/** All the input elements, including associated form and label elements. */
|
|
127
126
|
Inputs: {inputs: Artifacts.InputElement[]; forms: Artifacts.FormElement[]; labels: Artifacts.LabelElement[]};
|
|
128
127
|
/** Screenshot of the entire page (rather than just the above the fold content). */
|
|
129
128
|
FullPageScreenshot: LHResult.FullPageScreenshot | null;
|
|
130
|
-
/** Information about event listeners registered on the global object. */
|
|
131
|
-
GlobalListeners: Array<Artifacts.GlobalListener>;
|
|
132
129
|
/** The issues surfaced in the devtools Issues panel */
|
|
133
130
|
InspectorIssues: Artifacts.InspectorIssues;
|
|
134
|
-
/** Errors preventing page being installable as PWA. */
|
|
135
|
-
InstallabilityErrors: Artifacts.InstallabilityErrors;
|
|
136
131
|
/** JS coverage information for code used during audit. Keyed by script id. */
|
|
137
132
|
// 'url' is excluded because it can be overridden by a magic sourceURL= comment, which makes keeping it a dangerous footgun!
|
|
138
133
|
JsUsage: Record<string, Omit<Crdp.Profiler.ScriptCoverage, 'url'>>;
|
|
@@ -146,26 +141,16 @@ export interface GathererArtifacts extends PublicGathererArtifacts {
|
|
|
146
141
|
RobotsTxt: {status: number|null, content: string|null, errorMessage?: string};
|
|
147
142
|
/** The result of calling the shared trace engine root cause analysis. */
|
|
148
143
|
RootCauses: Artifacts.TraceEngineRootCauses;
|
|
149
|
-
/** Information on all scripts in the page. */
|
|
150
|
-
Scripts: Artifacts.Script[];
|
|
151
|
-
/** Version information for all ServiceWorkers active after the first page load. */
|
|
152
|
-
ServiceWorker: {versions: Crdp.ServiceWorker.ServiceWorkerVersion[], registrations: Crdp.ServiceWorker.ServiceWorkerRegistration[]};
|
|
153
144
|
/** Source maps of scripts executed in the page. */
|
|
154
145
|
SourceMaps: Array<Artifacts.SourceMap>;
|
|
155
146
|
/** Information on detected tech stacks (e.g. JS libraries) used by the page. */
|
|
156
147
|
Stacks: Artifacts.DetectedStack[];
|
|
157
|
-
/**
|
|
158
|
-
|
|
159
|
-
/** Information about tap targets including their position and size. */
|
|
160
|
-
TapTargets: Artifacts.TapTarget[];
|
|
161
|
-
/** The primary trace taken over the entire run. */
|
|
162
|
-
Trace: Trace;
|
|
148
|
+
/** CSS stylesheets found on the page. */
|
|
149
|
+
Stylesheets: Artifacts.CSSStyleSheetInfo[];
|
|
163
150
|
/** The trace if there was a page load error and Chrome navigated to a `chrome-error://` page. */
|
|
164
151
|
TraceError: Trace;
|
|
165
152
|
/** Elements associated with metrics (ie: Largest Contentful Paint element). */
|
|
166
153
|
TraceElements: Artifacts.TraceElement[];
|
|
167
|
-
/** Parsed version of the page's Web App Manifest, or null if none found. */
|
|
168
|
-
WebAppManifest: Artifacts.Manifest | null;
|
|
169
154
|
/** COMPAT: A set of traces, keyed by passName. */
|
|
170
155
|
traces: {[passName: string]: Trace};
|
|
171
156
|
/** COMPAT: A set of DevTools debugger protocol records, keyed by passName. */
|
|
@@ -197,6 +182,8 @@ declare module Artifacts {
|
|
|
197
182
|
finalDisplayedUrl: string;
|
|
198
183
|
}
|
|
199
184
|
|
|
185
|
+
type Rect = AuditDetails.Rect;
|
|
186
|
+
|
|
200
187
|
interface NodeDetails {
|
|
201
188
|
lhId: string,
|
|
202
189
|
devtoolsNodePath: string,
|
|
@@ -251,16 +238,6 @@ declare module Artifacts {
|
|
|
251
238
|
depth: NodeDetails & {max: number;};
|
|
252
239
|
}
|
|
253
240
|
|
|
254
|
-
interface EmbeddedContentInfo {
|
|
255
|
-
tagName: string;
|
|
256
|
-
type: string | null;
|
|
257
|
-
src: string | null;
|
|
258
|
-
data: string | null;
|
|
259
|
-
code: string | null;
|
|
260
|
-
params: Array<{name: string; value: string}>;
|
|
261
|
-
node: Artifacts.NodeDetails;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
241
|
interface IFrameElement {
|
|
265
242
|
/** The `id` attribute of the iframe. */
|
|
266
243
|
id: string,
|
|
@@ -312,19 +289,6 @@ declare module Artifacts {
|
|
|
312
289
|
content?: string;
|
|
313
290
|
}
|
|
314
291
|
|
|
315
|
-
interface ScriptElement {
|
|
316
|
-
type: string | null
|
|
317
|
-
src: string | null
|
|
318
|
-
/** The `id` property of the script element; null if it had no `id` or if `source` is 'network'. */
|
|
319
|
-
id: string | null
|
|
320
|
-
async: boolean
|
|
321
|
-
defer: boolean
|
|
322
|
-
/** Details for node in DOM for the script element */
|
|
323
|
-
node: NodeDetails | null
|
|
324
|
-
/** Where the script was discovered, either in the head, the body, or network records. */
|
|
325
|
-
source: 'head'|'body'|'network'
|
|
326
|
-
}
|
|
327
|
-
|
|
328
292
|
/** @see https://sourcemaps.info/spec.html#h.qz3o9nc69um5 */
|
|
329
293
|
type RawSourceMap = {
|
|
330
294
|
/** File version and must be a positive integer. */
|
|
@@ -450,10 +414,6 @@ declare module Artifacts {
|
|
|
450
414
|
// TODO(bckenny): real type for parsed manifest.
|
|
451
415
|
type Manifest = ReturnType<typeof parseManifest>;
|
|
452
416
|
|
|
453
|
-
interface InstallabilityErrors {
|
|
454
|
-
errors: Crdp.Page.InstallabilityError[];
|
|
455
|
-
}
|
|
456
|
-
|
|
457
417
|
interface ImageElement {
|
|
458
418
|
/** The resolved source URL of the image. Similar to `currentSrc`, but resolved for CSS images as well. */
|
|
459
419
|
src: string;
|
|
@@ -541,36 +501,18 @@ declare module Artifacts {
|
|
|
541
501
|
resourceSize: number;
|
|
542
502
|
}
|
|
543
503
|
|
|
544
|
-
interface TagBlockingFirstPaint {
|
|
545
|
-
startTime: number;
|
|
546
|
-
endTime: number;
|
|
547
|
-
transferSize: number;
|
|
548
|
-
tag: {
|
|
549
|
-
tagName: 'LINK'|'SCRIPT';
|
|
550
|
-
/** The value of `HTMLLinkElement.href` or `HTMLScriptElement.src`. */
|
|
551
|
-
url: string;
|
|
552
|
-
/** A record of when changes to the `HTMLLinkElement.media` attribute occurred and if the new media type matched the page. */
|
|
553
|
-
mediaChanges?: Array<{href: string, media: string, msSinceHTMLEnd: number, matches: boolean}>;
|
|
554
|
-
};
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
type Rect = AuditDetails.Rect;
|
|
558
|
-
|
|
559
|
-
interface TapTarget {
|
|
560
|
-
node: NodeDetails;
|
|
561
|
-
href: string;
|
|
562
|
-
clientRects: Rect[];
|
|
563
|
-
}
|
|
564
|
-
|
|
565
504
|
interface TraceElement {
|
|
566
|
-
traceEventType: 'largest-contentful-paint'|'layout-shift'|'
|
|
505
|
+
traceEventType: 'largest-contentful-paint'|'layout-shift'|'animation'|'responsiveness';
|
|
567
506
|
node: NodeDetails;
|
|
568
507
|
nodeId: number;
|
|
569
508
|
animations?: {name?: string, failureReasonsMask?: number, unsupportedProperties?: string[]}[];
|
|
570
509
|
type?: string;
|
|
571
510
|
}
|
|
572
511
|
|
|
573
|
-
|
|
512
|
+
interface TraceEngineResult {
|
|
513
|
+
data: TraceEngine.Handlers.Types.EnabledHandlerDataWithMeta<EnabledHandlers>;
|
|
514
|
+
insights: TraceEngine.Insights.Types.TraceInsightData<EnabledHandlers>;
|
|
515
|
+
}
|
|
574
516
|
|
|
575
517
|
interface TraceEngineRootCauses {
|
|
576
518
|
layoutShifts: Record<number, LayoutShiftRootCausesData>;
|
|
@@ -615,25 +557,6 @@ declare module Artifacts {
|
|
|
615
557
|
}
|
|
616
558
|
}
|
|
617
559
|
|
|
618
|
-
type ManifestValueCheckID = 'hasStartUrl'|'hasIconsAtLeast144px'|'hasIconsAtLeast512px'|'fetchesIcon'|'hasPWADisplayValue'|'hasBackgroundColor'|'hasThemeColor'|'hasShortName'|'hasName'|'shortNameLength'|'hasMaskableIcon';
|
|
619
|
-
|
|
620
|
-
type ManifestValues = {
|
|
621
|
-
isParseFailure: false;
|
|
622
|
-
allChecks: {
|
|
623
|
-
id: ManifestValueCheckID;
|
|
624
|
-
failureText: string;
|
|
625
|
-
passing: boolean;
|
|
626
|
-
}[];
|
|
627
|
-
} | {
|
|
628
|
-
isParseFailure: true;
|
|
629
|
-
parseFailureReason: string;
|
|
630
|
-
allChecks: {
|
|
631
|
-
id: ManifestValueCheckID;
|
|
632
|
-
failureText: string;
|
|
633
|
-
passing: boolean;
|
|
634
|
-
}[];
|
|
635
|
-
}
|
|
636
|
-
|
|
637
560
|
type MeasureEntry = LHResult.MeasureEntry;
|
|
638
561
|
|
|
639
562
|
interface MetricComputationDataInput {
|
|
@@ -852,18 +775,6 @@ declare module Artifacts {
|
|
|
852
775
|
node: NodeDetails;
|
|
853
776
|
}
|
|
854
777
|
|
|
855
|
-
/** Information about an event listener registered on the global object. */
|
|
856
|
-
interface GlobalListener {
|
|
857
|
-
/** Event listener type, limited to those events currently of interest. */
|
|
858
|
-
type: 'pagehide'|'unload'|'visibilitychange';
|
|
859
|
-
/** The DevTools protocol script identifier. */
|
|
860
|
-
scriptId: string;
|
|
861
|
-
/** Line number in the script (0-based). */
|
|
862
|
-
lineNumber: number;
|
|
863
|
-
/** Column number in the script (0-based). */
|
|
864
|
-
columnNumber: number;
|
|
865
|
-
}
|
|
866
|
-
|
|
867
778
|
/** Describes a generic console message. */
|
|
868
779
|
interface BaseConsoleMessage {
|
|
869
780
|
/**
|
package/types/audit.d.ts
CHANGED
|
@@ -117,16 +117,6 @@ declare module Audit {
|
|
|
117
117
|
|
|
118
118
|
/** Type returned by Audit.audit(). Only score is required. */
|
|
119
119
|
type Product = NonNumericProduct | NumericProduct;
|
|
120
|
-
|
|
121
|
-
type MultiCheckAuditP1 = Partial<Record<Artifacts.ManifestValueCheckID, boolean>>;
|
|
122
|
-
type MultiCheckAuditP2 = Partial<Artifacts.ManifestValues>;
|
|
123
|
-
interface MultiCheckAuditP3 {
|
|
124
|
-
failures: Array<string>;
|
|
125
|
-
manifestValues?: undefined;
|
|
126
|
-
allChecks?: undefined;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
type MultiCheckAuditDetails = MultiCheckAuditP1 & MultiCheckAuditP2 & MultiCheckAuditP3;
|
|
130
120
|
}
|
|
131
121
|
|
|
132
122
|
export default Audit;
|
package/types/config.d.ts
CHANGED
package/types/externs.d.ts
CHANGED
|
@@ -57,8 +57,6 @@ export interface CliFlags extends Flags {
|
|
|
57
57
|
precomputedLanternDataPath?: string;
|
|
58
58
|
/** Path to the file where precomputed lantern data should be written to. */
|
|
59
59
|
lanternDataOutputPath?: string;
|
|
60
|
-
/** Path to the budget.json file for LightWallet. */
|
|
61
|
-
budgetPath?: string | null;
|
|
62
60
|
|
|
63
61
|
// The following are given defaults in cli-flags, so are not optional like in Flags or SharedFlagsSettings.
|
|
64
62
|
output: OutputMode[];
|
package/types/gatherer.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ declare module Gatherer {
|
|
|
33
33
|
once<TEvent extends keyof CrdpEvents>(event: TEvent, callback: (...args: CrdpEvents[TEvent]) => void): void;
|
|
34
34
|
off<TEvent extends keyof CrdpEvents>(event: TEvent, callback: (...args: CrdpEvents[TEvent]) => void): void;
|
|
35
35
|
sendCommand<TMethod extends keyof CrdpCommands>(method: TMethod, ...params: CrdpCommands[TMethod]['paramsType']): Promise<CrdpCommands[TMethod]['returnType']>;
|
|
36
|
+
sendCommandAndIgnore<TMethod extends keyof CrdpCommands>(method: TMethod, ...params: CrdpCommands[TMethod]['paramsType']): Promise<void>;
|
|
36
37
|
dispose(): Promise<void>;
|
|
37
38
|
}
|
|
38
39
|
|
|
@@ -48,6 +49,8 @@ declare module Gatherer {
|
|
|
48
49
|
off(event: 'protocolevent', callback: (payload: Protocol.RawEventMessage) => void): void
|
|
49
50
|
};
|
|
50
51
|
networkMonitor: NetworkMonitor;
|
|
52
|
+
listenForCrashes: (() => void);
|
|
53
|
+
fatalRejection: {promise: Promise<never>, rej: (reason: Error) => void}
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
interface Context<TDependencies extends DependencyKey = DefaultDependenciesKey> {
|
|
@@ -33,7 +33,7 @@ declare global {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export interface TestDfn {
|
|
36
|
-
/** Identification of test. Can be used for group selection (e.g. `yarn smoke
|
|
36
|
+
/** Identification of test. Can be used for group selection (e.g. `yarn smoke csp` will run all tests with `id.includes('csp')`). */
|
|
37
37
|
id: string;
|
|
38
38
|
/** Expected test results. */
|
|
39
39
|
expectations: ExpectedRunnerResult;
|
package/types/lh.d.ts
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
import {ArbitraryEqualityMap as ArbitraryEqualityMap_} from '../core/lib/arbitrary-equality-map.js';
|
|
8
8
|
import * as Artifacts_ from './artifacts.js';
|
|
9
9
|
import Audit_ from './audit.js';
|
|
10
|
-
import Budget_ from './lhr/budget.js';
|
|
11
10
|
import Config_ from './config.js';
|
|
12
11
|
import {Protocol as _Crdp} from 'devtools-protocol/types/protocol.js';
|
|
13
12
|
import {ProtocolMapping as _CrdpMappings} from 'devtools-protocol/types/protocol-mapping.js';
|
|
@@ -42,7 +41,6 @@ export import TraceCpuProfile = Artifacts_.TraceCpuProfile;
|
|
|
42
41
|
export import TraceEvent = Artifacts_.TraceEvent;
|
|
43
42
|
|
|
44
43
|
export import Audit = Audit_;
|
|
45
|
-
export import Budget = Budget_;
|
|
46
44
|
export import Config = Config_;
|
|
47
45
|
export import Crdp = _Crdp;
|
|
48
46
|
export import CrdpEvents = _CrdpMappings.Events;
|
|
@@ -9,10 +9,6 @@ import Treemap from './treemap.js';
|
|
|
9
9
|
|
|
10
10
|
/** Common properties for all details types. */
|
|
11
11
|
interface BaseDetails {
|
|
12
|
-
/** If present and audit is part of the performance category, audit is treated as an Opportunity. */
|
|
13
|
-
overallSavingsMs?: number;
|
|
14
|
-
/** Optional additional Opportunity information. */
|
|
15
|
-
overallSavingsBytes?: number;
|
|
16
12
|
/** Additional information, usually used for including debug or meta information in the LHR */
|
|
17
13
|
debugData?: Details.DebugData;
|
|
18
14
|
}
|
|
@@ -85,6 +81,15 @@ declare module Details {
|
|
|
85
81
|
isEntityGrouped?: boolean;
|
|
86
82
|
/** Column keys to skip summing. If omitted, all column types supported are summed. */
|
|
87
83
|
skipSumming?: Array<string>;
|
|
84
|
+
/**
|
|
85
|
+
* @deprecated
|
|
86
|
+
* Historically this represents the time saved on the entire page load. It's mostly used as an
|
|
87
|
+
* alias for `metricSavings.LCP` now. We recommend using `metricSavings` directly for more
|
|
88
|
+
* metric-specific savings estimates.
|
|
89
|
+
*/
|
|
90
|
+
overallSavingsMs?: number;
|
|
91
|
+
/** Total byte savings covered by this audit. */
|
|
92
|
+
overallSavingsBytes?: number;
|
|
88
93
|
}
|
|
89
94
|
|
|
90
95
|
interface Screenshot extends BaseDetails {
|
package/types/lhr/lhr.d.ts
CHANGED
|
@@ -71,8 +71,6 @@ declare module Result {
|
|
|
71
71
|
networkUserAgent: string;
|
|
72
72
|
/** The benchmark index number that indicates rough device class. */
|
|
73
73
|
benchmarkIndex: number;
|
|
74
|
-
/** Many benchmark indexes. */
|
|
75
|
-
benchmarkIndexes?: number[];
|
|
76
74
|
/** The version of libraries with which these results were generated. Ex: axe-core. */
|
|
77
75
|
credits?: Record<string, string|undefined>,
|
|
78
76
|
}
|
|
@@ -116,8 +114,6 @@ declare module Result {
|
|
|
116
114
|
group?: string;
|
|
117
115
|
/** The conventional acronym for the audit/metric. */
|
|
118
116
|
acronym?: string;
|
|
119
|
-
/** Any audit IDs closely relevant to this one. */
|
|
120
|
-
relevantAudits?: string[];
|
|
121
117
|
}
|
|
122
118
|
|
|
123
119
|
interface ReportGroup {
|
package/types/lhr/settings.d.ts
CHANGED
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
import type {Protocol as Crdp} from 'devtools-protocol/types/protocol.js';
|
|
8
8
|
|
|
9
|
-
import Budget from './budget.js';
|
|
10
|
-
|
|
11
9
|
export type Locale = 'en-US'|'en'|'en-AU'|'en-GB'|'en-IE'|'en-SG'|'en-ZA'|'en-IN'|'ar-XB'|'ar'|'bg'|'ca'|'cs'|'da'|'de'|'el'|'en-XA'|'en-XL'|'es'|'es-419'|'es-AR'|'es-BO'|'es-BR'|'es-BZ'|'es-CL'|'es-CO'|'es-CR'|'es-CU'|'es-DO'|'es-EC'|'es-GT'|'es-HN'|'es-MX'|'es-NI'|'es-PA'|'es-PE'|'es-PR'|'es-PY'|'es-SV'|'es-US'|'es-UY'|'es-VE'|'fi'|'fil'|'fr'|'he'|'hi'|'hr'|'hu'|'gsw'|'id'|'in'|'it'|'iw'|'ja'|'ko'|'lt'|'lv'|'mo'|'nl'|'nb'|'no'|'pl'|'pt'|'pt-PT'|'ro'|'ru'|'sk'|'sl'|'sr'|'sr-Latn'|'sv'|'ta'|'te'|'th'|'tl'|'tr'|'uk'|'vi'|'zh'|'zh-HK'|'zh-TW';
|
|
12
10
|
|
|
13
11
|
/** Simulation settings that control the amount of network & cpu throttling in the run. */
|
|
@@ -109,8 +107,6 @@ export type ScreenEmulationSettings = {
|
|
|
109
107
|
channel?: string
|
|
110
108
|
/** Precomputed lantern estimates to use instead of observed analysis. */
|
|
111
109
|
precomputedLanternData?: PrecomputedLanternData | null;
|
|
112
|
-
/** The budget.json object for LightWallet. */
|
|
113
|
-
budgets?: Array<Budget> | null;
|
|
114
110
|
|
|
115
111
|
/** The number of milliseconds to wait after FCP until the page should be considered loaded. */
|
|
116
112
|
pauseAfterFcpMs?: number;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2019 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @fileoverview Ensures every `id` attribute value of active, focusable elements is unique.
|
|
9
|
-
* See base class in axe-audit.js for audit() implementation.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import AxeAudit from './axe-audit.js';
|
|
13
|
-
import * as i18n from '../../lib/i18n/i18n.js';
|
|
14
|
-
|
|
15
|
-
const UIStrings = {
|
|
16
|
-
/** Title of an accesibility audit that checks if there are any duplicate id HTML attributes on active, focusable elements. This title is descriptive of the successful state and is shown to users when no user action is required. */
|
|
17
|
-
title: '`[id]` attributes on active, focusable elements are unique',
|
|
18
|
-
/** Title of an accesibility audit that checks if there are any duplicate id HTML attributes on active, focusable elements. This title is descriptive of the failing state and is shown to users when there is a failure that needs to be addressed. */
|
|
19
|
-
failureTitle: '`[id]` attributes on active, focusable elements are not unique',
|
|
20
|
-
/** Description of a Lighthouse audit that tells the user *why* they should try to pass. This is displayed after a user expands the section to see more. No character length limits. The last sentence starting with 'Learn' becomes link text to additional documentation. */
|
|
21
|
-
description: 'All focusable elements must have a unique `id` to ensure that they\'re visible to assistive technologies. [Learn how to fix duplicate `id`s](https://dequeuniversity.com/rules/axe/4.9/duplicate-id-active).',
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
|
|
25
|
-
|
|
26
|
-
class DuplicateIdActive extends AxeAudit {
|
|
27
|
-
/**
|
|
28
|
-
* @return {LH.Audit.Meta}
|
|
29
|
-
*/
|
|
30
|
-
static get meta() {
|
|
31
|
-
return {
|
|
32
|
-
id: 'duplicate-id-active',
|
|
33
|
-
title: str_(UIStrings.title),
|
|
34
|
-
failureTitle: str_(UIStrings.failureTitle),
|
|
35
|
-
description: str_(UIStrings.description),
|
|
36
|
-
requiredArtifacts: ['Accessibility'],
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export default DuplicateIdActive;
|
|
42
|
-
export {UIStrings};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export default ContentWidth;
|
|
2
|
-
declare class ContentWidth extends Audit {
|
|
3
|
-
/**
|
|
4
|
-
* @param {LH.Artifacts} artifacts
|
|
5
|
-
* @param {LH.Audit.Context} context
|
|
6
|
-
* @return {LH.Audit.Product}
|
|
7
|
-
*/
|
|
8
|
-
static audit(artifacts: LH.Artifacts, context: LH.Audit.Context): LH.Audit.Product;
|
|
9
|
-
}
|
|
10
|
-
export namespace UIStrings {
|
|
11
|
-
const title: string;
|
|
12
|
-
const failureTitle: string;
|
|
13
|
-
const description: string;
|
|
14
|
-
const explanation: string;
|
|
15
|
-
}
|
|
16
|
-
import { Audit } from './audit.js';
|
|
17
|
-
//# sourceMappingURL=content-width.d.ts.map
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2016 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import {Audit} from './audit.js';
|
|
8
|
-
import * as i18n from '../lib/i18n/i18n.js';
|
|
9
|
-
|
|
10
|
-
const UIStrings = {
|
|
11
|
-
/** Title of a Lighthouse audit that provides detail on the content size of a web site compared to the viewport, which is the size of the screen the site is displayed on. This descriptive title is shown to users when the site's content is sized appropriately. */
|
|
12
|
-
title: 'Content is sized correctly for the viewport',
|
|
13
|
-
/** Title of a Lighthouse audit that provides detail on the content size of a web site compared to the viewport, which is the size of the screen the site is displayed on. This descriptive title is shown to users when the site's content is not sized appropriately. */
|
|
14
|
-
failureTitle: 'Content is not sized correctly for the viewport',
|
|
15
|
-
/** Description of a Lighthouse audit that tells the user why they should care that a site's content size should match its viewport size, which is the size of the screen the site is displayed on. This is displayed after a user expands the section to see more. No character length limits. The last sentence starting with 'Learn' becomes link text to additional documentation. */
|
|
16
|
-
description: 'If the width of your app\'s content doesn\'t match the width ' +
|
|
17
|
-
'of the viewport, your app might not be optimized for mobile screens. ' +
|
|
18
|
-
'[Learn how to size content for the viewport](https://developer.chrome.com/docs/lighthouse/pwa/content-width/).',
|
|
19
|
-
/**
|
|
20
|
-
* @description Explanatory message stating that the viewport size and window size differ.
|
|
21
|
-
* @example {100} innerWidth
|
|
22
|
-
* @example {101} outerWidth
|
|
23
|
-
* */
|
|
24
|
-
explanation: 'The viewport size of {innerWidth}px does not match the window ' +
|
|
25
|
-
'size of {outerWidth}px.',
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
|
|
29
|
-
|
|
30
|
-
class ContentWidth extends Audit {
|
|
31
|
-
/**
|
|
32
|
-
* @return {LH.Audit.Meta}
|
|
33
|
-
*/
|
|
34
|
-
static get meta() {
|
|
35
|
-
return {
|
|
36
|
-
id: 'content-width',
|
|
37
|
-
title: str_(UIStrings.title),
|
|
38
|
-
failureTitle: str_(UIStrings.failureTitle),
|
|
39
|
-
description: str_(UIStrings.description),
|
|
40
|
-
requiredArtifacts: ['ViewportDimensions'],
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @param {LH.Artifacts} artifacts
|
|
46
|
-
* @param {LH.Audit.Context} context
|
|
47
|
-
* @return {LH.Audit.Product}
|
|
48
|
-
*/
|
|
49
|
-
static audit(artifacts, context) {
|
|
50
|
-
const viewportWidth = artifacts.ViewportDimensions.innerWidth;
|
|
51
|
-
const windowWidth = artifacts.ViewportDimensions.outerWidth;
|
|
52
|
-
const widthsMatch = viewportWidth === windowWidth;
|
|
53
|
-
|
|
54
|
-
if (context.settings.formFactor === 'desktop') {
|
|
55
|
-
return {
|
|
56
|
-
score: 1,
|
|
57
|
-
notApplicable: true,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
let explanation;
|
|
62
|
-
if (!widthsMatch) {
|
|
63
|
-
explanation = str_(UIStrings.explanation,
|
|
64
|
-
{innerWidth: artifacts.ViewportDimensions.innerWidth,
|
|
65
|
-
outerWidth: artifacts.ViewportDimensions.outerWidth});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
score: Number(widthsMatch),
|
|
70
|
-
explanation,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export default ContentWidth;
|
|
76
|
-
export {UIStrings};
|