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
|
@@ -19,14 +19,12 @@ const UIStrings = {
|
|
|
19
19
|
'[Learn more](https://web.dev/doctype/).',
|
|
20
20
|
/** Explanatory message stating that the document has no doctype. */
|
|
21
21
|
explanationNoDoctype: 'Document must contain a doctype',
|
|
22
|
-
/** Explanatory message stating that the document has wrong doctype */
|
|
23
|
-
explanationWrongDoctype: 'Document contains a doctype that triggers quirks-mode',
|
|
24
22
|
/** Explanatory message stating that the publicId field is not empty. */
|
|
25
23
|
explanationPublicId: 'Expected publicId to be an empty string',
|
|
26
24
|
/** Explanatory message stating that the systemId field is not empty. */
|
|
27
25
|
explanationSystemId: 'Expected systemId to be an empty string',
|
|
28
26
|
/** Explanatory message stating that the doctype is set, but is not "html" and is therefore invalid. */
|
|
29
|
-
explanationBadDoctype: 'Doctype name must be the string `html`',
|
|
27
|
+
explanationBadDoctype: 'Doctype name must be the lowercase string `html`',
|
|
30
28
|
};
|
|
31
29
|
|
|
32
30
|
const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
|
|
@@ -58,10 +56,9 @@ class Doctype extends Audit {
|
|
|
58
56
|
}
|
|
59
57
|
|
|
60
58
|
// only set constants once we know there is a doctype
|
|
61
|
-
const doctypeName = artifacts.Doctype.name;
|
|
59
|
+
const doctypeName = artifacts.Doctype.name.trim();
|
|
62
60
|
const doctypePublicId = artifacts.Doctype.publicId;
|
|
63
61
|
const doctypeSystemId = artifacts.Doctype.systemId;
|
|
64
|
-
const compatMode = artifacts.Doctype.documentCompatMode;
|
|
65
62
|
|
|
66
63
|
if (doctypePublicId !== '') {
|
|
67
64
|
return {
|
|
@@ -77,25 +74,17 @@ class Doctype extends Audit {
|
|
|
77
74
|
};
|
|
78
75
|
}
|
|
79
76
|
|
|
80
|
-
/* Note that the
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
/* Note that the value for name is case sensitive,
|
|
78
|
+
and must be the string `html`. For details see:
|
|
79
|
+
https://html.spec.whatwg.org/multipage/parsing.html#the-initial-insertion-mode */
|
|
80
|
+
if (doctypeName === 'html') {
|
|
83
81
|
return {
|
|
84
|
-
score:
|
|
85
|
-
explanation: str_(UIStrings.explanationBadDoctype),
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Catch-all for any quirks-mode situations the above checks didn't get.
|
|
90
|
-
// https://github.com/GoogleChrome/lighthouse/issues/10030
|
|
91
|
-
if (compatMode === 'BackCompat') {
|
|
92
|
-
return {
|
|
93
|
-
score: 0,
|
|
94
|
-
explanation: str_(UIStrings.explanationWrongDoctype),
|
|
82
|
+
score: 1,
|
|
95
83
|
};
|
|
96
84
|
} else {
|
|
97
85
|
return {
|
|
98
|
-
score:
|
|
86
|
+
score: 0,
|
|
87
|
+
explanation: str_(UIStrings.explanationBadDoctype),
|
|
99
88
|
};
|
|
100
89
|
}
|
|
101
90
|
}
|
|
@@ -38,7 +38,7 @@ class GeolocationOnStart extends ViolationAudit {
|
|
|
38
38
|
failureTitle: str_(UIStrings.failureTitle),
|
|
39
39
|
description: str_(UIStrings.description),
|
|
40
40
|
supportedModes: ['navigation'],
|
|
41
|
-
requiredArtifacts: ['ConsoleMessages', 'SourceMaps', '
|
|
41
|
+
requiredArtifacts: ['ConsoleMessages', 'SourceMaps', 'ScriptElements'],
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -54,7 +54,7 @@ class NoDocWriteAudit extends ViolationAudit {
|
|
|
54
54
|
title: str_(UIStrings.title),
|
|
55
55
|
failureTitle: str_(UIStrings.failureTitle),
|
|
56
56
|
description: str_(UIStrings.description),
|
|
57
|
-
requiredArtifacts: ['ConsoleMessages', 'SourceMaps', '
|
|
57
|
+
requiredArtifacts: ['ConsoleMessages', 'SourceMaps', 'ScriptElements'],
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -38,7 +38,7 @@ class NotificationOnStart extends ViolationAudit {
|
|
|
38
38
|
failureTitle: str_(UIStrings.failureTitle),
|
|
39
39
|
description: str_(UIStrings.description),
|
|
40
40
|
supportedModes: ['navigation'],
|
|
41
|
-
requiredArtifacts: ['ConsoleMessages', 'SourceMaps', '
|
|
41
|
+
requiredArtifacts: ['ConsoleMessages', 'SourceMaps', 'ScriptElements'],
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -202,7 +202,6 @@ class UsesHTTP2Audit extends Audit {
|
|
|
202
202
|
static async audit(artifacts, context) {
|
|
203
203
|
const trace = artifacts.traces[Audit.DEFAULT_PASS];
|
|
204
204
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
205
|
-
const URL = artifacts.URL;
|
|
206
205
|
const networkRecords = await NetworkRecords.request(devtoolsLog, context);
|
|
207
206
|
const resources = UsesHTTP2Audit.determineNonHttp2Resources(networkRecords);
|
|
208
207
|
|
|
@@ -233,7 +232,7 @@ class UsesHTTP2Audit extends Audit {
|
|
|
233
232
|
devtoolsLog,
|
|
234
233
|
settings,
|
|
235
234
|
};
|
|
236
|
-
const graph = await PageDependencyGraph.request({trace, devtoolsLog
|
|
235
|
+
const graph = await PageDependencyGraph.request({trace, devtoolsLog}, context);
|
|
237
236
|
const simulator = await LoadSimulator.request(simulatorOptions, context);
|
|
238
237
|
const wastedMs = UsesHTTP2Audit.computeWasteWithTTIGraph(resources, graph, simulator);
|
|
239
238
|
|
|
@@ -37,7 +37,7 @@ class PassiveEventsAudit extends ViolationAudit {
|
|
|
37
37
|
title: str_(UIStrings.title),
|
|
38
38
|
failureTitle: str_(UIStrings.failureTitle),
|
|
39
39
|
description: str_(UIStrings.description),
|
|
40
|
-
requiredArtifacts: ['ConsoleMessages', 'SourceMaps', '
|
|
40
|
+
requiredArtifacts: ['ConsoleMessages', 'SourceMaps', 'ScriptElements'],
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -40,7 +40,7 @@ class ErrorLogs extends Audit {
|
|
|
40
40
|
title: str_(UIStrings.title),
|
|
41
41
|
failureTitle: str_(UIStrings.failureTitle),
|
|
42
42
|
description: str_(UIStrings.description),
|
|
43
|
-
requiredArtifacts: ['ConsoleMessages', 'SourceMaps', '
|
|
43
|
+
requiredArtifacts: ['ConsoleMessages', 'SourceMaps', 'ScriptElements'],
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -87,7 +87,7 @@ class ErrorLogs extends Audit {
|
|
|
87
87
|
const consoleRows = artifacts.ConsoleMessages
|
|
88
88
|
.filter(item => item.level === 'error')
|
|
89
89
|
.map(item => {
|
|
90
|
-
const bundle = bundles.find(bundle => bundle.script.
|
|
90
|
+
const bundle = bundles.find(bundle => bundle.script.src === item.url);
|
|
91
91
|
return {
|
|
92
92
|
source: item.source,
|
|
93
93
|
description: item.text,
|
|
@@ -42,7 +42,7 @@ class LongTasks extends Audit {
|
|
|
42
42
|
scoreDisplayMode: Audit.SCORING_MODES.INFORMATIVE,
|
|
43
43
|
title: str_(UIStrings.title),
|
|
44
44
|
description: str_(UIStrings.description),
|
|
45
|
-
requiredArtifacts: ['traces', 'devtoolsLogs'
|
|
45
|
+
requiredArtifacts: ['traces', 'devtoolsLogs'],
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -53,7 +53,6 @@ class LongTasks extends Audit {
|
|
|
53
53
|
*/
|
|
54
54
|
static async audit(artifacts, context) {
|
|
55
55
|
const settings = context.settings || {};
|
|
56
|
-
const URL = artifacts.URL;
|
|
57
56
|
const trace = artifacts.traces[Audit.DEFAULT_PASS];
|
|
58
57
|
const tasks = await MainThreadTasks.request(trace, context);
|
|
59
58
|
const devtoolsLog = artifacts.devtoolsLogs[LongTasks.DEFAULT_PASS];
|
|
@@ -64,7 +63,7 @@ class LongTasks extends Audit {
|
|
|
64
63
|
|
|
65
64
|
if (settings.throttlingMethod === 'simulate') {
|
|
66
65
|
const simulatorOptions = {devtoolsLog, settings: context.settings};
|
|
67
|
-
const pageGraph = await PageDependencyGraph.request({trace, devtoolsLog
|
|
66
|
+
const pageGraph = await PageDependencyGraph.request({trace, devtoolsLog}, context);
|
|
68
67
|
const simulator = await LoadSimulator.request(simulatorOptions, context);
|
|
69
68
|
const simulation = await simulator.simulate(pageGraph, {label: 'long-tasks-diagnostic'});
|
|
70
69
|
for (const [node, timing] of simulation.nodeTimings.entries()) {
|
|
@@ -21,7 +21,7 @@ class FirstContentfulPaint3G extends Audit {
|
|
|
21
21
|
`painted while on a 3G network. [Learn more](https://developers.google.com/web/tools/lighthouse/audits/first-contentful-paint).`,
|
|
22
22
|
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
|
|
23
23
|
supportedModes: ['navigation'],
|
|
24
|
-
requiredArtifacts: ['traces', 'devtoolsLogs', 'GatherContext'
|
|
24
|
+
requiredArtifacts: ['traces', 'devtoolsLogs', 'GatherContext'],
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -49,7 +49,7 @@ class FirstContentfulPaint3G extends Audit {
|
|
|
49
49
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
50
50
|
/** @type {Immutable<LH.Config.Settings>} */
|
|
51
51
|
const settings = {...context.settings, throttlingMethod: 'simulate', throttling: regular3G};
|
|
52
|
-
const metricComputationData = {trace, devtoolsLog, gatherContext, settings
|
|
52
|
+
const metricComputationData = {trace, devtoolsLog, gatherContext, settings};
|
|
53
53
|
const metricResult = await ComputedFcp.request(metricComputationData, context);
|
|
54
54
|
|
|
55
55
|
return {
|
|
@@ -28,7 +28,7 @@ class FirstContentfulPaint extends Audit {
|
|
|
28
28
|
description: str_(UIStrings.description),
|
|
29
29
|
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
|
|
30
30
|
supportedModes: ['navigation'],
|
|
31
|
-
requiredArtifacts: ['traces', 'devtoolsLogs', 'GatherContext'
|
|
31
|
+
requiredArtifacts: ['traces', 'devtoolsLogs', 'GatherContext'],
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -65,8 +65,7 @@ class FirstContentfulPaint extends Audit {
|
|
|
65
65
|
const trace = artifacts.traces[Audit.DEFAULT_PASS];
|
|
66
66
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
67
67
|
const gatherContext = artifacts.GatherContext;
|
|
68
|
-
const metricComputationData = {trace, devtoolsLog, gatherContext,
|
|
69
|
-
settings: context.settings, URL: artifacts.URL};
|
|
68
|
+
const metricComputationData = {trace, devtoolsLog, gatherContext, settings: context.settings};
|
|
70
69
|
const metricResult = await ComputedFcp.request(metricComputationData, context);
|
|
71
70
|
const options = context.options[context.settings.formFactor];
|
|
72
71
|
|
|
@@ -28,7 +28,7 @@ class FirstMeaningfulPaint extends Audit {
|
|
|
28
28
|
description: str_(UIStrings.description),
|
|
29
29
|
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
|
|
30
30
|
supportedModes: ['navigation'],
|
|
31
|
-
requiredArtifacts: ['traces', 'devtoolsLogs', 'GatherContext'
|
|
31
|
+
requiredArtifacts: ['traces', 'devtoolsLogs', 'GatherContext'],
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -68,8 +68,7 @@ class FirstMeaningfulPaint extends Audit {
|
|
|
68
68
|
const trace = artifacts.traces[Audit.DEFAULT_PASS];
|
|
69
69
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
70
70
|
const gatherContext = artifacts.GatherContext;
|
|
71
|
-
const metricComputationData = {trace, devtoolsLog, gatherContext,
|
|
72
|
-
settings: context.settings, URL: artifacts.URL};
|
|
71
|
+
const metricComputationData = {trace, devtoolsLog, gatherContext, settings: context.settings};
|
|
73
72
|
const metricResult = await ComputedFmp.request(metricComputationData, context);
|
|
74
73
|
const options = context.options[context.settings.formFactor];
|
|
75
74
|
|
|
@@ -34,7 +34,7 @@ class InteractiveMetric extends Audit {
|
|
|
34
34
|
description: str_(UIStrings.description),
|
|
35
35
|
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
|
|
36
36
|
supportedModes: ['navigation'],
|
|
37
|
-
requiredArtifacts: ['traces', 'devtoolsLogs', 'GatherContext'
|
|
37
|
+
requiredArtifacts: ['traces', 'devtoolsLogs', 'GatherContext'],
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -71,8 +71,7 @@ class InteractiveMetric extends Audit {
|
|
|
71
71
|
const trace = artifacts.traces[Audit.DEFAULT_PASS];
|
|
72
72
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
73
73
|
const gatherContext = artifacts.GatherContext;
|
|
74
|
-
const metricComputationData = {trace, devtoolsLog, gatherContext,
|
|
75
|
-
settings: context.settings, URL: artifacts.URL};
|
|
74
|
+
const metricComputationData = {trace, devtoolsLog, gatherContext, settings: context.settings};
|
|
76
75
|
const metricResult = await Interactive.request(metricComputationData, context);
|
|
77
76
|
const timeInMs = metricResult.timing;
|
|
78
77
|
const options = context.options[context.settings.formFactor];
|
|
@@ -29,7 +29,7 @@ class LargestContentfulPaint extends Audit {
|
|
|
29
29
|
description: str_(UIStrings.description),
|
|
30
30
|
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
|
|
31
31
|
supportedModes: ['navigation'],
|
|
32
|
-
requiredArtifacts: ['HostUserAgent', 'traces', 'devtoolsLogs', 'GatherContext'
|
|
32
|
+
requiredArtifacts: ['HostUserAgent', 'traces', 'devtoolsLogs', 'GatherContext'],
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -74,8 +74,7 @@ class LargestContentfulPaint extends Audit {
|
|
|
74
74
|
const trace = artifacts.traces[Audit.DEFAULT_PASS];
|
|
75
75
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
76
76
|
const gatherContext = artifacts.GatherContext;
|
|
77
|
-
const metricComputationData = {trace, devtoolsLog, gatherContext,
|
|
78
|
-
settings: context.settings, URL: artifacts.URL};
|
|
77
|
+
const metricComputationData = {trace, devtoolsLog, gatherContext, settings: context.settings};
|
|
79
78
|
|
|
80
79
|
let metricResult;
|
|
81
80
|
try {
|
|
@@ -33,7 +33,7 @@ class MaxPotentialFID extends Audit {
|
|
|
33
33
|
description: str_(UIStrings.description),
|
|
34
34
|
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
|
|
35
35
|
supportedModes: ['navigation'],
|
|
36
|
-
requiredArtifacts: ['traces', 'devtoolsLogs', 'GatherContext'
|
|
36
|
+
requiredArtifacts: ['traces', 'devtoolsLogs', 'GatherContext'],
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -57,8 +57,7 @@ class MaxPotentialFID extends Audit {
|
|
|
57
57
|
const trace = artifacts.traces[Audit.DEFAULT_PASS];
|
|
58
58
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
59
59
|
const gatherContext = artifacts.GatherContext;
|
|
60
|
-
const metricComputationData = {trace, devtoolsLog, gatherContext,
|
|
61
|
-
settings: context.settings, URL: artifacts.URL};
|
|
60
|
+
const metricComputationData = {trace, devtoolsLog, gatherContext, settings: context.settings};
|
|
62
61
|
const metricResult = await ComputedFid.request(metricComputationData, context);
|
|
63
62
|
|
|
64
63
|
return {
|
|
@@ -28,7 +28,7 @@ class SpeedIndex extends Audit {
|
|
|
28
28
|
description: str_(UIStrings.description),
|
|
29
29
|
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
|
|
30
30
|
supportedModes: ['navigation'],
|
|
31
|
-
requiredArtifacts: ['traces', 'devtoolsLogs', 'GatherContext'
|
|
31
|
+
requiredArtifacts: ['traces', 'devtoolsLogs', 'GatherContext'],
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -67,8 +67,7 @@ class SpeedIndex extends Audit {
|
|
|
67
67
|
const trace = artifacts.traces[Audit.DEFAULT_PASS];
|
|
68
68
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
69
69
|
const gatherContext = artifacts.GatherContext;
|
|
70
|
-
const metricComputationData = {trace, devtoolsLog, gatherContext,
|
|
71
|
-
settings: context.settings, URL: artifacts.URL};
|
|
70
|
+
const metricComputationData = {trace, devtoolsLog, gatherContext, settings: context.settings};
|
|
72
71
|
const metricResult = await ComputedSi.request(metricComputationData, context);
|
|
73
72
|
const options = context.options[context.settings.formFactor];
|
|
74
73
|
|
|
@@ -27,7 +27,7 @@ class TotalBlockingTime extends Audit {
|
|
|
27
27
|
title: str_(i18n.UIStrings.totalBlockingTimeMetric),
|
|
28
28
|
description: str_(UIStrings.description),
|
|
29
29
|
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
|
|
30
|
-
requiredArtifacts: ['traces', 'devtoolsLogs', 'GatherContext'
|
|
30
|
+
requiredArtifacts: ['traces', 'devtoolsLogs', 'GatherContext'],
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -88,8 +88,7 @@ class TotalBlockingTime extends Audit {
|
|
|
88
88
|
const trace = artifacts.traces[Audit.DEFAULT_PASS];
|
|
89
89
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
90
90
|
const gatherContext = artifacts.GatherContext;
|
|
91
|
-
const metricComputationData = {trace, devtoolsLog, gatherContext,
|
|
92
|
-
settings: context.settings, URL: artifacts.URL};
|
|
91
|
+
const metricComputationData = {trace, devtoolsLog, gatherContext, settings: context.settings};
|
|
93
92
|
if (
|
|
94
93
|
gatherContext.gatherMode === 'timespan' &&
|
|
95
94
|
context.settings.throttlingMethod === 'simulate'
|
|
@@ -29,7 +29,7 @@ class Metrics extends Audit {
|
|
|
29
29
|
title: 'Metrics',
|
|
30
30
|
description: 'Collects all available metrics.',
|
|
31
31
|
supportedModes: ['navigation'],
|
|
32
|
-
requiredArtifacts: ['traces', 'devtoolsLogs', 'GatherContext'
|
|
32
|
+
requiredArtifacts: ['traces', 'devtoolsLogs', 'GatherContext'],
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -42,9 +42,8 @@ class Metrics extends Audit {
|
|
|
42
42
|
const gatherContext = artifacts.GatherContext;
|
|
43
43
|
const trace = artifacts.traces[Audit.DEFAULT_PASS];
|
|
44
44
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
45
|
-
const URL = artifacts.URL;
|
|
46
45
|
const summary = await ComputedTimingSummary
|
|
47
|
-
.request({trace, devtoolsLog, gatherContext, settings: context.settings
|
|
46
|
+
.request({trace, devtoolsLog, gatherContext, settings: context.settings}, context);
|
|
48
47
|
const metrics = summary.metrics;
|
|
49
48
|
const debugInfo = summary.debugInfo;
|
|
50
49
|
|
|
@@ -30,7 +30,7 @@ class NoUnloadListeners extends Audit {
|
|
|
30
30
|
title: str_(UIStrings.title),
|
|
31
31
|
failureTitle: str_(UIStrings.failureTitle),
|
|
32
32
|
description: str_(UIStrings.description),
|
|
33
|
-
requiredArtifacts: ['GlobalListeners', 'SourceMaps', '
|
|
33
|
+
requiredArtifacts: ['GlobalListeners', 'JsUsage', 'SourceMaps', 'ScriptElements'],
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -54,25 +54,33 @@ class NoUnloadListeners extends Audit {
|
|
|
54
54
|
{key: 'source', itemType: 'source-location', text: str_(i18n.UIStrings.columnSource)},
|
|
55
55
|
];
|
|
56
56
|
|
|
57
|
+
// Look up scriptId to script URL via the JsUsage artifact.
|
|
58
|
+
/** @type {Map<string, string>} */
|
|
59
|
+
const scriptIdToUrl = new Map();
|
|
60
|
+
for (const [url, usages] of Object.entries(artifacts.JsUsage)) {
|
|
61
|
+
for (const usage of usages) {
|
|
62
|
+
scriptIdToUrl.set(usage.scriptId, url);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
57
66
|
/** @type {Array<{source: LH.Audit.Details.ItemValue}>} */
|
|
58
67
|
const tableItems = unloadListeners.map(listener => {
|
|
59
|
-
const
|
|
60
|
-
const script = artifacts.Scripts.find(s => s.scriptId === listener.scriptId);
|
|
68
|
+
const url = scriptIdToUrl.get(listener.scriptId);
|
|
61
69
|
|
|
62
70
|
// If we can't find a url, still show something so the user can manually
|
|
63
71
|
// look for where an `unload` handler is being created.
|
|
64
|
-
if (!
|
|
72
|
+
if (!url) {
|
|
65
73
|
return {
|
|
66
74
|
source: {
|
|
67
75
|
type: 'url',
|
|
68
|
-
value:
|
|
76
|
+
value: '(unknown)',
|
|
69
77
|
},
|
|
70
78
|
};
|
|
71
79
|
}
|
|
72
80
|
|
|
73
|
-
const bundle = bundles.find(bundle => bundle.script.
|
|
81
|
+
const bundle = bundles.find(bundle => bundle.script.src === url);
|
|
74
82
|
return {
|
|
75
|
-
source: Audit.makeSourceLocation(
|
|
83
|
+
source: Audit.makeSourceLocation(url, listener.lineNumber, listener.columnNumber, bundle),
|
|
76
84
|
};
|
|
77
85
|
});
|
|
78
86
|
|
|
@@ -47,11 +47,10 @@ class PredictivePerf extends Audit {
|
|
|
47
47
|
const gatherContext = artifacts.GatherContext;
|
|
48
48
|
const trace = artifacts.traces[Audit.DEFAULT_PASS];
|
|
49
49
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
50
|
-
const URL = artifacts.URL;
|
|
51
50
|
/** @type {LH.Config.Settings} */
|
|
52
51
|
// @ts-expect-error - TODO(bckenny): allow optional `throttling` settings
|
|
53
52
|
const settings = {}; // Use default settings.
|
|
54
|
-
const computationData = {trace, devtoolsLog, gatherContext, settings
|
|
53
|
+
const computationData = {trace, devtoolsLog, gatherContext, settings};
|
|
55
54
|
const fcp = await LanternFcp.request(computationData, context);
|
|
56
55
|
const fmp = await LanternFmp.request(computationData, context);
|
|
57
56
|
const tti = await LanternInteractive.request(computationData, context);
|
|
@@ -17,8 +17,8 @@ const UIStrings = {
|
|
|
17
17
|
/** Title of a lighthouse audit that tells a user to preload an image in order to improve their LCP time. */
|
|
18
18
|
title: 'Preload Largest Contentful Paint image',
|
|
19
19
|
/** Description of a lighthouse audit that tells a user to preload an image in order to improve their LCP time. */
|
|
20
|
-
description: '
|
|
21
|
-
'
|
|
20
|
+
description: 'Preload the image used by ' +
|
|
21
|
+
'the LCP element in order to improve your LCP time. [Learn more](https://web.dev/optimize-lcp/#preload-important-resources).',
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
|
|
@@ -203,7 +203,7 @@ class PreloadLCPImageAudit extends Audit {
|
|
|
203
203
|
const trace = artifacts.traces[PreloadLCPImageAudit.DEFAULT_PASS];
|
|
204
204
|
const devtoolsLog = artifacts.devtoolsLogs[PreloadLCPImageAudit.DEFAULT_PASS];
|
|
205
205
|
const URL = artifacts.URL;
|
|
206
|
-
const metricData = {trace, devtoolsLog, gatherContext, settings: context.settings
|
|
206
|
+
const metricData = {trace, devtoolsLog, gatherContext, settings: context.settings};
|
|
207
207
|
const lcpElement = artifacts.TraceElements
|
|
208
208
|
.find(element => element.traceEventType === 'largest-contentful-paint');
|
|
209
209
|
|
|
@@ -93,7 +93,7 @@ class Redirects extends Audit {
|
|
|
93
93
|
const networkRecords = await NetworkRecords.request(devtoolsLog, context);
|
|
94
94
|
const mainResource = await MainResource.request({URL: artifacts.URL, devtoolsLog}, context);
|
|
95
95
|
|
|
96
|
-
const metricComputationData = {trace, devtoolsLog, gatherContext, settings
|
|
96
|
+
const metricComputationData = {trace, devtoolsLog, gatherContext, settings};
|
|
97
97
|
const metricResult = await LanternInteractive.request(metricComputationData, context);
|
|
98
98
|
|
|
99
99
|
/** @type {Map<string, LH.Gatherer.Simulation.NodeTiming>} */
|
|
@@ -19,7 +19,6 @@ const Audit = require('./audit.js');
|
|
|
19
19
|
const JsBundles = require('../computed/js-bundles.js');
|
|
20
20
|
const UnusedJavaScriptSummary = require('../computed/unused-javascript-summary.js');
|
|
21
21
|
const ModuleDuplication = require('../computed/module-duplication.js');
|
|
22
|
-
const {isInline} = require('../lib/script-helpers.js');
|
|
23
22
|
|
|
24
23
|
class ScriptTreemapDataAudit extends Audit {
|
|
25
24
|
/**
|
|
@@ -32,7 +31,7 @@ class ScriptTreemapDataAudit extends Audit {
|
|
|
32
31
|
title: 'Script Treemap Data',
|
|
33
32
|
description: 'Used for treemap app',
|
|
34
33
|
requiredArtifacts:
|
|
35
|
-
['traces', 'devtoolsLogs', 'SourceMaps', '
|
|
34
|
+
['traces', 'devtoolsLogs', 'SourceMaps', 'ScriptElements', 'JsUsage', 'URL'],
|
|
36
35
|
};
|
|
37
36
|
}
|
|
38
37
|
|
|
@@ -149,10 +148,10 @@ class ScriptTreemapDataAudit extends Audit {
|
|
|
149
148
|
* Returns nodes where the first level of nodes are URLs.
|
|
150
149
|
* Every external script has a node.
|
|
151
150
|
* All inline scripts are combined into a single node.
|
|
152
|
-
* If a script has a source map, that node will be
|
|
151
|
+
* If a script has a source map, that node will be set by makeNodeFromSourceMapData.
|
|
153
152
|
*
|
|
154
153
|
* Example return result:
|
|
155
|
-
- index.html (
|
|
154
|
+
- index.html (inlines scripts)
|
|
156
155
|
- main.js
|
|
157
156
|
- - webpack://
|
|
158
157
|
- - - react.js
|
|
@@ -166,22 +165,45 @@ class ScriptTreemapDataAudit extends Audit {
|
|
|
166
165
|
static async makeNodes(artifacts, context) {
|
|
167
166
|
/** @type {LH.Treemap.Node[]} */
|
|
168
167
|
const nodes = [];
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
|
|
169
|
+
let inlineScriptLength = 0;
|
|
170
|
+
for (const scriptElement of artifacts.ScriptElements) {
|
|
171
|
+
// No src means script is inline.
|
|
172
|
+
// Combine these ScriptElements so that inline scripts show up as a single root node.
|
|
173
|
+
if (!scriptElement.src) {
|
|
174
|
+
inlineScriptLength += (scriptElement.content || '').length;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (inlineScriptLength) {
|
|
178
|
+
const name = artifacts.URL.finalUrl;
|
|
179
|
+
nodes.push({
|
|
180
|
+
name,
|
|
181
|
+
resourceBytes: inlineScriptLength,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
171
185
|
const bundles = await JsBundles.request(artifacts, context);
|
|
172
186
|
const duplicationByPath = await ModuleDuplication.request(artifacts, context);
|
|
173
187
|
|
|
174
|
-
for (const
|
|
175
|
-
if (
|
|
188
|
+
for (const scriptElement of artifacts.ScriptElements) {
|
|
189
|
+
if (!scriptElement.src) continue;
|
|
190
|
+
|
|
191
|
+
const name = scriptElement.src;
|
|
192
|
+
const bundle = bundles.find(bundle => scriptElement.src === bundle.script.src);
|
|
193
|
+
const scriptCoverages = artifacts.JsUsage[scriptElement.src] || [];
|
|
194
|
+
if (!bundle && scriptCoverages.length === 0) {
|
|
195
|
+
// No bundle and no coverage information, so simply make a single node
|
|
196
|
+
// detailing how big the script is.
|
|
176
197
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
198
|
+
nodes.push({
|
|
199
|
+
name,
|
|
200
|
+
resourceBytes: scriptElement.content?.length || 0,
|
|
201
|
+
});
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const unusedJavascriptSummary = await UnusedJavaScriptSummary.request(
|
|
206
|
+
{url: scriptElement.src, scriptCoverages, bundle}, context);
|
|
185
207
|
|
|
186
208
|
/** @type {LH.Treemap.Node} */
|
|
187
209
|
let node;
|
|
@@ -196,7 +218,7 @@ class ScriptTreemapDataAudit extends Audit {
|
|
|
196
218
|
resourceBytes: bundle.sizes.files[source],
|
|
197
219
|
};
|
|
198
220
|
|
|
199
|
-
if (unusedJavascriptSummary
|
|
221
|
+
if (unusedJavascriptSummary.sourcesWastedBytes) {
|
|
200
222
|
sourceData.unusedBytes = unusedJavascriptSummary.sourcesWastedBytes[source];
|
|
201
223
|
}
|
|
202
224
|
|
|
@@ -219,46 +241,24 @@ class ScriptTreemapDataAudit extends Audit {
|
|
|
219
241
|
const sourceData = {
|
|
220
242
|
resourceBytes: bundle.sizes.unmappedBytes,
|
|
221
243
|
};
|
|
222
|
-
if (unusedJavascriptSummary
|
|
244
|
+
if (unusedJavascriptSummary.sourcesWastedBytes) {
|
|
223
245
|
sourceData.unusedBytes = unusedJavascriptSummary.sourcesWastedBytes['(unmapped)'];
|
|
224
246
|
}
|
|
225
247
|
sourcesData['(unmapped)'] = sourceData;
|
|
226
248
|
}
|
|
227
249
|
|
|
228
|
-
node = this.makeScriptNode(
|
|
250
|
+
node = this.makeScriptNode(scriptElement.src, bundle.rawMap.sourceRoot || '', sourcesData);
|
|
229
251
|
} else {
|
|
230
252
|
// No valid source map for this script, so we can only produce a single node.
|
|
253
|
+
|
|
231
254
|
node = {
|
|
232
255
|
name,
|
|
233
|
-
resourceBytes: unusedJavascriptSummary
|
|
234
|
-
unusedBytes: unusedJavascriptSummary
|
|
256
|
+
resourceBytes: unusedJavascriptSummary.totalBytes,
|
|
257
|
+
unusedBytes: unusedJavascriptSummary.wastedBytes,
|
|
235
258
|
};
|
|
236
259
|
}
|
|
237
260
|
|
|
238
|
-
|
|
239
|
-
// Also separate each iframe / the main page's inline scripts into their own top-level nodes.
|
|
240
|
-
if (isInline(script)) {
|
|
241
|
-
let htmlNode = htmlNodesByFrameId.get(script.executionContextAuxData.frameId);
|
|
242
|
-
if (!htmlNode) {
|
|
243
|
-
htmlNode = {
|
|
244
|
-
name,
|
|
245
|
-
resourceBytes: 0,
|
|
246
|
-
unusedBytes: undefined,
|
|
247
|
-
children: [],
|
|
248
|
-
};
|
|
249
|
-
htmlNodesByFrameId.set(script.executionContextAuxData.frameId, htmlNode);
|
|
250
|
-
nodes.push(htmlNode);
|
|
251
|
-
}
|
|
252
|
-
htmlNode.resourceBytes += node.resourceBytes;
|
|
253
|
-
if (node.unusedBytes) htmlNode.unusedBytes = (htmlNode.unusedBytes || 0) + node.unusedBytes;
|
|
254
|
-
node.name = script.content ?
|
|
255
|
-
'(inline) ' + script.content.trimStart().substring(0, 15) + '…' :
|
|
256
|
-
'(inline)';
|
|
257
|
-
htmlNode.children?.push(node);
|
|
258
|
-
} else {
|
|
259
|
-
// Non-inline scripts each have their own top-level node.
|
|
260
|
-
nodes.push(node);
|
|
261
|
-
}
|
|
261
|
+
nodes.push(node);
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
return nodes;
|
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const Audit = require('../audit.js');
|
|
9
|
+
const NetworkRecords = require('../../computed/network-records.js');
|
|
9
10
|
const HTTP_UNSUCCESSFUL_CODE_LOW = 400;
|
|
10
11
|
const HTTP_UNSUCCESSFUL_CODE_HIGH = 599;
|
|
11
12
|
const i18n = require('../../lib/i18n/i18n.js');
|
|
12
|
-
const
|
|
13
|
+
const NetworkAnalyzer = require('../../lib/dependency-graph/simulator/network-analyzer.js');
|
|
13
14
|
|
|
14
15
|
const UIStrings = {
|
|
15
16
|
/** Title of a Lighthouse audit that provides detail on the HTTP status code a page responds with. This descriptive title is shown when the page has responded with a valid HTTP status code. */
|
|
@@ -46,7 +47,8 @@ class HTTPStatusCode extends Audit {
|
|
|
46
47
|
static async audit(artifacts, context) {
|
|
47
48
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
48
49
|
const URL = artifacts.URL;
|
|
49
|
-
const
|
|
50
|
+
const networkRecords = await NetworkRecords.request(devtoolsLog, context);
|
|
51
|
+
const mainResource = NetworkAnalyzer.findMainDocument(networkRecords, URL.finalUrl);
|
|
50
52
|
|
|
51
53
|
const statusCode = mainResource.statusCode;
|
|
52
54
|
|
|
@@ -119,8 +119,6 @@ class LinkText extends Audit {
|
|
|
119
119
|
if (
|
|
120
120
|
href.startsWith('javascript:') ||
|
|
121
121
|
href.startsWith('mailto:') ||
|
|
122
|
-
// This line prevents the audit from flagging anchor links.
|
|
123
|
-
// In this case it is better to use `finalUrl` than `mainDocumentUrl`.
|
|
124
122
|
URL.equalWithExcludedFragments(link.href, artifacts.URL.finalUrl)
|
|
125
123
|
) {
|
|
126
124
|
return false;
|