lighthouse 8.0.0-dev.20210709 → 8.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/docs/architecture.md +101 -0
- package/docs/authenticated-pages.md +44 -0
- package/docs/bug-labels.md +35 -0
- package/docs/configuration.md +213 -0
- package/docs/emulation.md +32 -0
- package/docs/error-reporting.md +42 -0
- package/docs/hacking-tips.md +55 -0
- package/docs/headless-chrome.md +119 -0
- package/docs/lantern.md +55 -0
- package/docs/new-audits.md +99 -0
- package/docs/performance-budgets.md +187 -0
- package/docs/plugins.md +374 -0
- package/docs/puppeteer.md +95 -0
- package/docs/readme.md +164 -0
- package/docs/recipes/auth/README.md +129 -0
- package/docs/recipes/auth/example-lh-auth.js +81 -0
- package/docs/recipes/auth/package.json +11 -0
- package/docs/recipes/auth/server/public/dashboard-unauthenticated.html +21 -0
- package/docs/recipes/auth/server/public/dashboard.html +25 -0
- package/docs/recipes/auth/server/public/home-unauthenticated.html +27 -0
- package/docs/recipes/auth/server/public/home.html +17 -0
- package/docs/recipes/auth/server/public/unauthenticated.html +22 -0
- package/docs/recipes/auth/server/server.js +85 -0
- package/docs/recipes/custom-audit/custom-config.js +36 -0
- package/docs/recipes/custom-audit/package.json +8 -0
- package/docs/recipes/custom-audit/readme.md +32 -0
- package/docs/recipes/custom-audit/searchable-audit.js +46 -0
- package/docs/recipes/custom-audit/searchable-gatherer.js +32 -0
- package/docs/recipes/custom-gatherer-puppeteer/custom-audit.js +34 -0
- package/{root.js → docs/recipes/custom-gatherer-puppeteer/custom-config.js} +23 -2
- package/docs/recipes/custom-gatherer-puppeteer/custom-gatherer.js +51 -0
- package/docs/recipes/custom-gatherer-puppeteer/package.json +13 -0
- package/docs/recipes/custom-gatherer-puppeteer/readme.md +7 -0
- package/docs/recipes/custom-gatherer-puppeteer/test.sh +9 -0
- package/docs/recipes/gulp/gulpfile.js +79 -0
- package/docs/recipes/gulp/package.json +12 -0
- package/docs/recipes/gulp/public/index.html +22 -0
- package/docs/recipes/gulp/readme.md +6 -0
- package/docs/recipes/integration-test/README.md +14 -0
- package/docs/recipes/integration-test/example-lh-auth.test.js +160 -0
- package/docs/recipes/integration-test/package.json +9 -0
- package/docs/recipes/lighthouse-plugin-example/audits/preload-as.js +46 -0
- package/docs/recipes/lighthouse-plugin-example/package.json +11 -0
- package/docs/recipes/lighthouse-plugin-example/plugin-recipe-screenshot.png +0 -0
- package/docs/recipes/lighthouse-plugin-example/plugin.js +24 -0
- package/docs/recipes/lighthouse-plugin-example/readme.md +53 -0
- package/docs/releasing.md +164 -0
- package/docs/scoring.md +79 -0
- package/docs/throttling.md +150 -0
- package/docs/understanding-results.md +209 -0
- package/docs/v8-perf-faq.md +244 -0
- package/docs/variability.md +150 -0
- package/jest.config.js +0 -3
- package/lighthouse-cli/bin.js +8 -6
- package/lighthouse-core/audits/accessibility/aria-command-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-tooltip-name.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-treeitem-name.js +1 -1
- package/lighthouse-core/audits/apple-touch-icon.js +0 -1
- package/lighthouse-core/audits/audit.js +3 -3
- package/lighthouse-core/audits/autocomplete.js +2 -2
- package/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js +14 -29
- package/lighthouse-core/audits/byte-efficiency/duplicated-javascript.js +2 -3
- package/lighthouse-core/audits/byte-efficiency/efficient-animated-content.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/legacy-javascript.js +2 -3
- package/lighthouse-core/audits/byte-efficiency/modern-image-formats.js +15 -55
- package/lighthouse-core/audits/byte-efficiency/offscreen-images.js +4 -8
- package/lighthouse-core/audits/byte-efficiency/render-blocking-resources.js +8 -15
- package/lighthouse-core/audits/byte-efficiency/total-byte-weight.js +9 -10
- package/lighthouse-core/audits/byte-efficiency/unminified-css.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/unminified-javascript.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/unused-css-rules.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/unused-javascript.js +1 -2
- package/lighthouse-core/audits/byte-efficiency/uses-long-cache-ttl.js +2 -2
- package/lighthouse-core/audits/byte-efficiency/uses-optimized-images.js +1 -2
- package/lighthouse-core/audits/byte-efficiency/uses-responsive-images.js +24 -46
- package/lighthouse-core/audits/byte-efficiency/uses-text-compression.js +1 -1
- package/lighthouse-core/audits/critical-request-chains.js +0 -1
- package/lighthouse-core/audits/csp-xss.js +1 -1
- package/lighthouse-core/audits/diagnostics.js +0 -1
- package/lighthouse-core/audits/dobetterweb/geolocation-on-start.js +0 -1
- package/lighthouse-core/audits/dobetterweb/inspector-issues.js +1 -1
- package/lighthouse-core/audits/dobetterweb/notification-on-start.js +0 -1
- package/lighthouse-core/audits/dobetterweb/uses-http2.js +0 -1
- package/lighthouse-core/audits/final-screenshot.js +4 -8
- package/lighthouse-core/audits/font-display.js +0 -1
- package/lighthouse-core/audits/installable-manifest.js +3 -4
- package/lighthouse-core/audits/largest-contentful-paint-element.js +0 -1
- package/lighthouse-core/audits/long-tasks.js +1 -1
- package/lighthouse-core/audits/maskable-icon.js +0 -1
- package/lighthouse-core/audits/metrics/first-contentful-paint-3g.js +2 -4
- package/lighthouse-core/audits/metrics/first-contentful-paint.js +2 -4
- package/lighthouse-core/audits/metrics/first-meaningful-paint.js +2 -4
- package/lighthouse-core/audits/metrics/interactive.js +2 -4
- package/lighthouse-core/audits/metrics/largest-contentful-paint.js +2 -4
- package/lighthouse-core/audits/metrics/max-potential-fid.js +2 -4
- package/lighthouse-core/audits/metrics/speed-index.js +2 -4
- package/lighthouse-core/audits/metrics/total-blocking-time.js +2 -10
- package/lighthouse-core/audits/metrics.js +2 -4
- package/lighthouse-core/audits/performance-budget.js +0 -1
- package/lighthouse-core/audits/predictive-perf.js +6 -9
- package/lighthouse-core/audits/preload-fonts.js +1 -11
- package/lighthouse-core/audits/preload-lcp-image.js +5 -18
- package/lighthouse-core/audits/redirects.js +8 -10
- package/lighthouse-core/audits/screenshot-thumbnails.js +13 -28
- package/lighthouse-core/audits/seo/canonical.js +1 -2
- package/lighthouse-core/audits/seo/font-size.js +4 -4
- package/lighthouse-core/audits/seo/hreflang.js +2 -3
- package/lighthouse-core/audits/seo/http-status-code.js +16 -21
- package/lighthouse-core/audits/seo/is-crawlable.js +3 -4
- package/lighthouse-core/audits/seo/robots-txt.js +2 -2
- package/lighthouse-core/audits/seo/tap-targets.js +5 -5
- package/lighthouse-core/audits/server-response-time.js +2 -20
- package/lighthouse-core/audits/splash-screen.js +0 -1
- package/lighthouse-core/audits/themed-omnibox.js +0 -1
- package/lighthouse-core/audits/third-party-facades.js +0 -1
- package/lighthouse-core/audits/third-party-summary.js +3 -1
- package/lighthouse-core/audits/timing-budget.js +2 -4
- package/lighthouse-core/audits/uses-rel-preconnect.js +9 -14
- package/lighthouse-core/audits/uses-rel-preload.js +2 -13
- package/lighthouse-core/computed/main-thread-tasks.js +2 -2
- package/lighthouse-core/computed/metrics/cumulative-layout-shift.js +3 -3
- package/lighthouse-core/computed/metrics/first-contentful-paint-all-frames.js +6 -6
- package/lighthouse-core/computed/metrics/first-contentful-paint.js +8 -9
- package/lighthouse-core/computed/metrics/first-meaningful-paint.js +9 -10
- package/lighthouse-core/computed/metrics/interactive.js +24 -25
- package/lighthouse-core/computed/metrics/lantern-first-contentful-paint.js +6 -6
- package/lighthouse-core/computed/metrics/lantern-first-meaningful-paint.js +6 -6
- package/lighthouse-core/computed/metrics/lantern-largest-contentful-paint.js +6 -6
- package/lighthouse-core/computed/metrics/lantern-metric.js +8 -16
- package/lighthouse-core/computed/metrics/largest-contentful-paint-all-frames.js +7 -7
- package/lighthouse-core/computed/metrics/largest-contentful-paint.js +9 -10
- package/lighthouse-core/computed/metrics/max-potential-fid.js +11 -8
- package/lighthouse-core/computed/metrics/metric.js +5 -32
- package/lighthouse-core/computed/metrics/speed-index.js +5 -6
- package/lighthouse-core/computed/metrics/timing-summary.js +45 -55
- package/lighthouse-core/computed/metrics/total-blocking-time.js +29 -36
- package/lighthouse-core/computed/page-dependency-graph.js +14 -14
- package/lighthouse-core/computed/resource-summary.js +7 -3
- package/lighthouse-core/computed/speedline.js +3 -3
- package/lighthouse-core/computed/trace-of-tab.js +86 -15
- package/lighthouse-core/computed/user-timings.js +5 -5
- package/lighthouse-core/config/default-config.js +0 -1
- package/lighthouse-core/fraggle-rock/config/config.js +7 -9
- package/lighthouse-core/fraggle-rock/config/default-config.js +2 -40
- package/lighthouse-core/fraggle-rock/config/filters.js +6 -39
- package/lighthouse-core/fraggle-rock/config/validation.js +4 -4
- package/lighthouse-core/fraggle-rock/gather/base-artifacts.js +19 -54
- package/lighthouse-core/fraggle-rock/gather/navigation-runner.js +10 -21
- package/lighthouse-core/fraggle-rock/gather/runner-helpers.js +2 -2
- package/lighthouse-core/fraggle-rock/gather/snapshot-runner.js +2 -2
- package/lighthouse-core/fraggle-rock/gather/timespan-runner.js +2 -2
- package/lighthouse-core/gather/driver/prepare.js +0 -3
- package/lighthouse-core/gather/fetcher.js +2 -0
- package/lighthouse-core/gather/gather-runner.js +14 -2
- package/lighthouse-core/gather/gatherers/image-elements.js +61 -24
- package/lighthouse-core/gather/gatherers/inspector-issues.js +2 -2
- package/lighthouse-core/gather/gatherers/script-elements.js +12 -45
- package/lighthouse-core/gather/gatherers/seo/font-size.js +5 -5
- package/lighthouse-core/gather/gatherers/seo/tap-targets.js +12 -64
- package/lighthouse-core/gather/gatherers/service-worker.js +3 -20
- package/lighthouse-core/gather/gatherers/trace-compat.js +1 -1
- package/lighthouse-core/gather/gatherers/trace-elements.js +3 -15
- package/lighthouse-core/gather/gatherers/trace.js +4 -13
- package/lighthouse-core/gather/gatherers/viewport-dimensions.js +1 -1
- package/lighthouse-core/lib/dependency-graph/simulator/network-analyzer.js +2 -13
- package/lighthouse-core/lib/emulation.js +2 -0
- package/lighthouse-core/lib/i18n/i18n.js +2 -2
- package/lighthouse-core/lib/i18n/locales/ar-XB.json +141 -141
- package/lighthouse-core/lib/i18n/locales/ar.json +143 -143
- package/lighthouse-core/lib/i18n/locales/bg.json +143 -143
- package/lighthouse-core/lib/i18n/locales/ca.json +141 -141
- package/lighthouse-core/lib/i18n/locales/cs.json +141 -141
- package/lighthouse-core/lib/i18n/locales/da.json +141 -141
- package/lighthouse-core/lib/i18n/locales/de.json +142 -142
- package/lighthouse-core/lib/i18n/locales/el.json +141 -141
- package/lighthouse-core/lib/i18n/locales/en-GB.json +141 -141
- package/lighthouse-core/lib/i18n/locales/en-US.ctc.json +6659 -0
- package/lighthouse-core/lib/i18n/locales/en-US.json +144 -150
- package/lighthouse-core/lib/i18n/locales/en-XA.json +141 -141
- package/lighthouse-core/lib/i18n/locales/en-XL.ctc.json +6628 -0
- package/lighthouse-core/lib/i18n/locales/en-XL.json +144 -150
- package/lighthouse-core/lib/i18n/locales/es-419.json +141 -141
- package/lighthouse-core/lib/i18n/locales/es.json +141 -141
- package/lighthouse-core/lib/i18n/locales/fi.json +143 -143
- package/lighthouse-core/lib/i18n/locales/fil.json +142 -142
- package/lighthouse-core/lib/i18n/locales/fr.json +141 -141
- package/lighthouse-core/lib/i18n/locales/he.json +142 -142
- package/lighthouse-core/lib/i18n/locales/hi.json +143 -143
- package/lighthouse-core/lib/i18n/locales/hr.json +141 -141
- package/lighthouse-core/lib/i18n/locales/hu.json +143 -143
- package/lighthouse-core/lib/i18n/locales/id.json +143 -143
- package/lighthouse-core/lib/i18n/locales/it.json +143 -143
- package/lighthouse-core/lib/i18n/locales/ja.json +143 -143
- package/lighthouse-core/lib/i18n/locales/ko.json +143 -143
- package/lighthouse-core/lib/i18n/locales/lt.json +143 -143
- package/lighthouse-core/lib/i18n/locales/lv.json +143 -143
- package/lighthouse-core/lib/i18n/locales/nl.json +141 -141
- package/lighthouse-core/lib/i18n/locales/no.json +141 -141
- package/lighthouse-core/lib/i18n/locales/pl.json +141 -141
- package/lighthouse-core/lib/i18n/locales/pt-PT.json +141 -141
- package/lighthouse-core/lib/i18n/locales/pt.json +141 -141
- package/lighthouse-core/lib/i18n/locales/ro.json +144 -144
- package/lighthouse-core/lib/i18n/locales/ru.json +143 -143
- package/lighthouse-core/lib/i18n/locales/sk.json +142 -142
- package/lighthouse-core/lib/i18n/locales/sl.json +141 -141
- package/lighthouse-core/lib/i18n/locales/sr-Latn.json +143 -143
- package/lighthouse-core/lib/i18n/locales/sr.json +143 -143
- package/lighthouse-core/lib/i18n/locales/sv.json +142 -142
- package/lighthouse-core/lib/i18n/locales/ta.json +141 -141
- package/lighthouse-core/lib/i18n/locales/te.json +143 -143
- package/lighthouse-core/lib/i18n/locales/th.json +143 -143
- package/lighthouse-core/lib/i18n/locales/tr.json +143 -143
- package/lighthouse-core/lib/i18n/locales/uk.json +141 -141
- package/lighthouse-core/lib/i18n/locales/vi.json +143 -143
- package/lighthouse-core/lib/i18n/locales/zh-HK.json +141 -141
- package/lighthouse-core/lib/i18n/locales/zh-TW.json +143 -143
- package/lighthouse-core/lib/i18n/locales/zh.json +143 -143
- package/lighthouse-core/lib/lh-error.js +2 -2
- package/lighthouse-core/lib/minify-trace.js +1 -1
- package/lighthouse-core/lib/network-request.js +1 -17
- package/lighthouse-core/lib/page-functions.js +5 -6
- package/lighthouse-core/lib/rect-helpers.js +3 -3
- package/lighthouse-core/lib/sd-validation/assets/jsonldcontext.json +7137 -0
- package/lighthouse-core/lib/sd-validation/assets/schema-tree.json +9900 -0
- package/{report/report-assets.js → lighthouse-core/lib/sd-validation/helpers/walk-object.js} +20 -12
- package/lighthouse-core/lib/sd-validation/json-expander.js +56 -0
- package/lighthouse-core/lib/sd-validation/json-linter.js +49 -0
- package/lighthouse-core/lib/sd-validation/jsonld-keyword-validator.js +50 -0
- package/lighthouse-core/lib/sd-validation/line-number-from-jsonld-path.js +60 -0
- package/lighthouse-core/lib/sd-validation/schema-validator.js +146 -0
- package/lighthouse-core/lib/sd-validation/scripts/download-jsonldcontext.js +30 -0
- package/lighthouse-core/lib/sd-validation/scripts/generate-schema-tree.js +97 -0
- package/lighthouse-core/lib/sd-validation/sd-validation.js +77 -0
- package/lighthouse-core/lib/tappable-rects.js +1 -1
- package/lighthouse-core/lib/tracehouse/trace-processor.js +42 -116
- package/lighthouse-core/lib/url-shim.js +2 -29
- package/lighthouse-core/report/html/html-report-assets.js +38 -0
- package/{report/README.md → lighthouse-core/report/html/readme.md} +11 -7
- package/{report → lighthouse-core/report/html}/renderer/category-renderer.js +0 -0
- package/{report → lighthouse-core/report/html}/renderer/crc-details-renderer.js +0 -0
- package/{report → lighthouse-core/report/html}/renderer/details-renderer.js +1 -1
- package/{report → lighthouse-core/report/html}/renderer/dom.js +0 -0
- package/{report → lighthouse-core/report/html}/renderer/element-screenshot-renderer.js +0 -0
- package/{report → lighthouse-core/report/html}/renderer/i18n.js +1 -1
- package/{report → lighthouse-core/report/html}/renderer/logger.js +0 -0
- package/{report → lighthouse-core/report/html}/renderer/performance-category-renderer.js +0 -0
- package/{report → lighthouse-core/report/html}/renderer/psi.js +0 -0
- package/{report → lighthouse-core/report/html}/renderer/pwa-category-renderer.js +0 -0
- package/{report → lighthouse-core/report/html}/renderer/report-renderer.js +0 -0
- package/{report → lighthouse-core/report/html}/renderer/report-ui-features.js +3 -3
- package/{report → lighthouse-core/report/html}/renderer/snippet-renderer.js +0 -0
- package/{report → lighthouse-core/report/html}/renderer/text-encoding.js +0 -0
- package/{report → lighthouse-core/report/html}/renderer/util.js +4 -7
- package/{report/assets/styles.css → lighthouse-core/report/html/report-styles.css} +0 -0
- package/{report/assets/standalone-template.html → lighthouse-core/report/html/report-template.html} +41 -1
- package/{report/assets → lighthouse-core/report/html}/templates.html +0 -0
- package/{report → lighthouse-core/report}/report-generator.js +1 -1
- package/lighthouse-core/runner.js +1 -1
- package/package.json +12 -13
- package/readme.md +2 -2
- package/third-party/chromium-synchronization/inspector-issueAdded-types-test.js +2 -3
- package/third-party/chromium-synchronization/installability-errors-test.js +2 -2
- package/third-party/download-content-shell/download-content-shell.js +1 -2
- package/third-party/snyk/snapshot.json +1 -1
- package/tsconfig.json +1 -0
- package/types/artifacts.d.ts +21 -41
- package/types/audit.d.ts +0 -2
- package/types/config.d.ts +2 -16
- package/types/externs.d.ts +0 -1
- package/types/gatherer.d.ts +13 -13
- package/types/html-renderer.d.ts +14 -14
- package/types/i18n.d.ts +1 -1
- package/lighthouse-core/audits/byte-efficiency/uses-responsive-images-snapshot.js +0 -94
- package/lighthouse-core/computed/image-records.js +0 -62
- package/lighthouse-core/computed/metrics/navigation-metric.js +0 -46
- package/lighthouse-core/computed/processed-navigation.js +0 -21
- package/lighthouse-core/computed/processed-trace.js +0 -21
- package/lighthouse-core/gather/gatherers/gather-context.js +0 -25
- package/lighthouse-core/gather/gatherers/host-form-factor.js +0 -31
- package/lighthouse-core/gather/gatherers/host-user-agent.js +0 -29
- package/lighthouse-core/lib/lh-trace-processor.js +0 -46
- package/report/clients/standalone.js +0 -52
- package/report/test/renderer/category-renderer-test.js +0 -488
- package/report/test/renderer/crc-details-renderer-test.js +0 -115
- package/report/test/renderer/details-renderer-test.js +0 -843
- package/report/test/renderer/dom-test.js +0 -157
- package/report/test/renderer/element-screenshot-renderer-test.js +0 -189
- package/report/test/renderer/i18n-test.js +0 -146
- package/report/test/renderer/performance-category-renderer-test.js +0 -332
- package/report/test/renderer/psi-test.js +0 -152
- package/report/test/renderer/pwa-category-renderer-test.js +0 -303
- package/report/test/renderer/report-renderer-test.js +0 -325
- package/report/test/renderer/report-ui-features-test.js +0 -572
- package/report/test/renderer/snippet-renderer-test.js +0 -291
- package/report/test/renderer/text-encoding-test.js +0 -41
- package/report/test/renderer/util-test.js +0 -388
- package/report/test/report-generator-test.js +0 -145
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const Audit = require('../audit.js');
|
|
9
|
-
const
|
|
9
|
+
const MainResource = require('../../computed/main-resource.js');
|
|
10
10
|
const HTTP_UNSUCCESSFUL_CODE_LOW = 400;
|
|
11
11
|
const HTTP_UNSUCCESSFUL_CODE_HIGH = 599;
|
|
12
12
|
const i18n = require('../../lib/i18n/i18n.js');
|
|
13
|
-
const NetworkAnalyzer = require('../../lib/dependency-graph/simulator/network-analyzer.js');
|
|
14
13
|
|
|
15
14
|
const UIStrings = {
|
|
16
15
|
/** 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. */
|
|
@@ -34,7 +33,7 @@ class HTTPStatusCode extends Audit {
|
|
|
34
33
|
title: str_(UIStrings.title),
|
|
35
34
|
failureTitle: str_(UIStrings.failureTitle),
|
|
36
35
|
description: str_(UIStrings.description),
|
|
37
|
-
requiredArtifacts: ['devtoolsLogs', 'URL'
|
|
36
|
+
requiredArtifacts: ['devtoolsLogs', 'URL'],
|
|
38
37
|
};
|
|
39
38
|
}
|
|
40
39
|
|
|
@@ -43,30 +42,26 @@ class HTTPStatusCode extends Audit {
|
|
|
43
42
|
* @param {LH.Audit.Context} context
|
|
44
43
|
* @return {Promise<LH.Audit.Product>}
|
|
45
44
|
*/
|
|
46
|
-
static
|
|
45
|
+
static audit(artifacts, context) {
|
|
47
46
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
48
47
|
const URL = artifacts.URL;
|
|
49
|
-
const networkRecords = await NetworkRecords.request(devtoolsLog, context);
|
|
50
|
-
const mainResource = NetworkAnalyzer.findOptionalMainDocument(networkRecords, URL.finalUrl);
|
|
51
48
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
49
|
+
return MainResource.request({devtoolsLog, URL}, context)
|
|
50
|
+
.then(mainResource => {
|
|
51
|
+
const statusCode = mainResource.statusCode;
|
|
56
52
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (statusCode >= HTTP_UNSUCCESSFUL_CODE_LOW &&
|
|
53
|
+
if (statusCode >= HTTP_UNSUCCESSFUL_CODE_LOW &&
|
|
60
54
|
statusCode <= HTTP_UNSUCCESSFUL_CODE_HIGH) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
return {
|
|
56
|
+
score: 0,
|
|
57
|
+
displayValue: `${statusCode}`,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
66
60
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
61
|
+
return {
|
|
62
|
+
score: 1,
|
|
63
|
+
};
|
|
64
|
+
});
|
|
70
65
|
}
|
|
71
66
|
}
|
|
72
67
|
|
|
@@ -32,7 +32,7 @@ const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
|
|
|
32
32
|
/**
|
|
33
33
|
* Checks if given directive is a valid unavailable_after directive with a date in the past
|
|
34
34
|
* @param {string} directive
|
|
35
|
-
* @
|
|
35
|
+
* @returns {boolean}
|
|
36
36
|
*/
|
|
37
37
|
function isUnavailable(directive) {
|
|
38
38
|
const parts = directive.split(':');
|
|
@@ -49,7 +49,7 @@ function isUnavailable(directive) {
|
|
|
49
49
|
/**
|
|
50
50
|
* Returns true if any of provided directives blocks page from being indexed
|
|
51
51
|
* @param {string} directives
|
|
52
|
-
* @
|
|
52
|
+
* @returns {boolean}
|
|
53
53
|
*/
|
|
54
54
|
function hasBlockingDirective(directives) {
|
|
55
55
|
return directives.split(',')
|
|
@@ -60,7 +60,7 @@ function hasBlockingDirective(directives) {
|
|
|
60
60
|
/**
|
|
61
61
|
* Returns true if robots header specifies user agent (e.g. `googlebot: noindex`)
|
|
62
62
|
* @param {string} directives
|
|
63
|
-
* @
|
|
63
|
+
* @returns {boolean}
|
|
64
64
|
*/
|
|
65
65
|
function hasUserAgent(directives) {
|
|
66
66
|
const parts = directives.match(/^([^,:]+):/);
|
|
@@ -80,7 +80,6 @@ class IsCrawlable extends Audit {
|
|
|
80
80
|
title: str_(UIStrings.title),
|
|
81
81
|
failureTitle: str_(UIStrings.failureTitle),
|
|
82
82
|
description: str_(UIStrings.description),
|
|
83
|
-
supportedModes: ['navigation'],
|
|
84
83
|
requiredArtifacts: ['MetaElements', 'RobotsTxt', 'URL', 'devtoolsLogs'],
|
|
85
84
|
};
|
|
86
85
|
}
|
|
@@ -101,7 +101,7 @@ function verifyDirective(directiveName, directiveValue) {
|
|
|
101
101
|
/**
|
|
102
102
|
* @param {string} line single line from a robots.txt file
|
|
103
103
|
* @throws will throw an exception if given line has errors
|
|
104
|
-
* @
|
|
104
|
+
* @returns {{directive: string, value: string}|null}
|
|
105
105
|
*/
|
|
106
106
|
function parseLine(line) {
|
|
107
107
|
const hashIndex = line.indexOf('#');
|
|
@@ -135,7 +135,7 @@ function parseLine(line) {
|
|
|
135
135
|
|
|
136
136
|
/**
|
|
137
137
|
* @param {string} content
|
|
138
|
-
* @
|
|
138
|
+
* @returns {Array<{index: string, line: string, message: string}>}
|
|
139
139
|
*/
|
|
140
140
|
function validateRobots(content) {
|
|
141
141
|
/**
|
|
@@ -72,7 +72,7 @@ function clientRectBelowMinimumSize(cr) {
|
|
|
72
72
|
/**
|
|
73
73
|
* A target is "too small" if none of its clientRects are at least the size of a finger.
|
|
74
74
|
* @param {BoundedTapTarget[]} targets
|
|
75
|
-
* @
|
|
75
|
+
* @returns {BoundedTapTarget[]}
|
|
76
76
|
*/
|
|
77
77
|
function getTooSmallTargets(targets) {
|
|
78
78
|
return targets.filter(target => {
|
|
@@ -83,7 +83,7 @@ function getTooSmallTargets(targets) {
|
|
|
83
83
|
/**
|
|
84
84
|
* @param {BoundedTapTarget[]} tooSmallTargets
|
|
85
85
|
* @param {BoundedTapTarget[]} allTargets
|
|
86
|
-
* @
|
|
86
|
+
* @returns {TapTargetOverlapFailure[]}
|
|
87
87
|
*/
|
|
88
88
|
function getAllOverlapFailures(tooSmallTargets, allTargets) {
|
|
89
89
|
/** @type {TapTargetOverlapFailure[]} */
|
|
@@ -138,7 +138,7 @@ function getAllOverlapFailures(tooSmallTargets, allTargets) {
|
|
|
138
138
|
/**
|
|
139
139
|
* @param {LH.Artifacts.Rect[]} tappableRects
|
|
140
140
|
* @param {LH.Artifacts.Rect[]} maybeOverlappingRects
|
|
141
|
-
* @
|
|
141
|
+
* @returns {ClientRectOverlapFailure | null}
|
|
142
142
|
*/
|
|
143
143
|
function getOverlapFailureForTargetPair(tappableRects, maybeOverlappingRects) {
|
|
144
144
|
/** @type ClientRectOverlapFailure | null */
|
|
@@ -176,7 +176,7 @@ function getOverlapFailureForTargetPair(tappableRects, maybeOverlappingRects) {
|
|
|
176
176
|
/**
|
|
177
177
|
* Only report one failure if two targets overlap each other
|
|
178
178
|
* @param {TapTargetOverlapFailure[]} overlapFailures
|
|
179
|
-
* @
|
|
179
|
+
* @returns {TapTargetOverlapFailure[]}
|
|
180
180
|
*/
|
|
181
181
|
function mergeSymmetricFailures(overlapFailures) {
|
|
182
182
|
/** @type TapTargetOverlapFailure[] */
|
|
@@ -212,7 +212,7 @@ function mergeSymmetricFailures(overlapFailures) {
|
|
|
212
212
|
|
|
213
213
|
/**
|
|
214
214
|
* @param {TapTargetOverlapFailure[]} overlapFailures
|
|
215
|
-
* @
|
|
215
|
+
* @returns {TapTargetTableItem[]}
|
|
216
216
|
*/
|
|
217
217
|
function getTableItems(overlapFailures) {
|
|
218
218
|
const tableItems = overlapFailures.map(failure => {
|
|
@@ -8,8 +8,6 @@
|
|
|
8
8
|
const Audit = require('./audit.js');
|
|
9
9
|
const i18n = require('../lib/i18n/i18n.js');
|
|
10
10
|
const MainResource = require('../computed/main-resource.js');
|
|
11
|
-
const NetworkRecords = require('../computed/network-records.js');
|
|
12
|
-
const NetworkAnalyzer = require('../lib/dependency-graph/simulator/network-analyzer.js');
|
|
13
11
|
|
|
14
12
|
const UIStrings = {
|
|
15
13
|
/** Title of a diagnostic audit that provides detail on how long it took from starting a request to when the server started responding. This descriptive title is shown to users when the amount is acceptable and no user action is required. */
|
|
@@ -39,8 +37,7 @@ class ServerResponseTime extends Audit {
|
|
|
39
37
|
title: str_(UIStrings.title),
|
|
40
38
|
failureTitle: str_(UIStrings.failureTitle),
|
|
41
39
|
description: str_(UIStrings.description),
|
|
42
|
-
|
|
43
|
-
requiredArtifacts: ['devtoolsLogs', 'URL', 'GatherContext'],
|
|
40
|
+
requiredArtifacts: ['devtoolsLogs', 'URL'],
|
|
44
41
|
};
|
|
45
42
|
}
|
|
46
43
|
|
|
@@ -59,22 +56,7 @@ class ServerResponseTime extends Audit {
|
|
|
59
56
|
*/
|
|
60
57
|
static async audit(artifacts, context) {
|
|
61
58
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
62
|
-
|
|
63
|
-
/** @type {LH.Artifacts.NetworkRequest} */
|
|
64
|
-
let mainResource;
|
|
65
|
-
if (artifacts.GatherContext.gatherMode === 'timespan') {
|
|
66
|
-
const networkRecords = await NetworkRecords.request(devtoolsLog, context);
|
|
67
|
-
const optionalMainResource = NetworkAnalyzer.findOptionalMainDocument(
|
|
68
|
-
networkRecords,
|
|
69
|
-
artifacts.URL.finalUrl
|
|
70
|
-
);
|
|
71
|
-
if (!optionalMainResource) {
|
|
72
|
-
return {score: null, notApplicable: true};
|
|
73
|
-
}
|
|
74
|
-
mainResource = optionalMainResource;
|
|
75
|
-
} else {
|
|
76
|
-
mainResource = await MainResource.request({devtoolsLog, URL: artifacts.URL}, context);
|
|
77
|
-
}
|
|
59
|
+
const mainResource = await MainResource.request({devtoolsLog, URL: artifacts.URL}, context);
|
|
78
60
|
|
|
79
61
|
const responseTime = ServerResponseTime.calculateResponseTime(mainResource);
|
|
80
62
|
const passed = responseTime < TOO_SLOW_THRESHOLD_MS;
|
|
@@ -45,7 +45,6 @@ class SplashScreen extends MultiCheckAudit {
|
|
|
45
45
|
title: str_(UIStrings.title),
|
|
46
46
|
failureTitle: str_(UIStrings.failureTitle),
|
|
47
47
|
description: str_(UIStrings.description),
|
|
48
|
-
supportedModes: ['navigation'],
|
|
49
48
|
requiredArtifacts: ['WebAppManifest', 'InstallabilityErrors'],
|
|
50
49
|
};
|
|
51
50
|
}
|
|
@@ -42,7 +42,6 @@ class ThemedOmnibox extends MultiCheckAudit {
|
|
|
42
42
|
title: str_(UIStrings.title),
|
|
43
43
|
failureTitle: str_(UIStrings.failureTitle),
|
|
44
44
|
description: str_(UIStrings.description),
|
|
45
|
-
supportedModes: ['navigation'],
|
|
46
45
|
requiredArtifacts: ['WebAppManifest', 'InstallabilityErrors', 'MetaElements'],
|
|
47
46
|
};
|
|
48
47
|
}
|
|
@@ -85,7 +85,6 @@ class ThirdPartyFacades extends Audit {
|
|
|
85
85
|
title: str_(UIStrings.title),
|
|
86
86
|
failureTitle: str_(UIStrings.failureTitle),
|
|
87
87
|
description: str_(UIStrings.description),
|
|
88
|
-
supportedModes: ['navigation'],
|
|
89
88
|
requiredArtifacts: ['traces', 'devtoolsLogs', 'URL'],
|
|
90
89
|
};
|
|
91
90
|
}
|
|
@@ -10,6 +10,7 @@ const BootupTime = require('./bootup-time.js');
|
|
|
10
10
|
const i18n = require('../lib/i18n/i18n.js');
|
|
11
11
|
const thirdPartyWeb = require('../lib/third-party-web.js');
|
|
12
12
|
const NetworkRecords = require('../computed/network-records.js');
|
|
13
|
+
const MainResource = require('../computed/main-resource.js');
|
|
13
14
|
const MainThreadTasks = require('../computed/main-thread-tasks.js');
|
|
14
15
|
|
|
15
16
|
const UIStrings = {
|
|
@@ -197,7 +198,8 @@ class ThirdPartySummary extends Audit {
|
|
|
197
198
|
const trace = artifacts.traces[Audit.DEFAULT_PASS];
|
|
198
199
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
199
200
|
const networkRecords = await NetworkRecords.request(devtoolsLog, context);
|
|
200
|
-
const
|
|
201
|
+
const mainResource = await MainResource.request({devtoolsLog, URL: artifacts.URL}, context);
|
|
202
|
+
const mainEntity = thirdPartyWeb.getEntity(mainResource.url);
|
|
201
203
|
const tasks = await MainThreadTasks.request(trace, context);
|
|
202
204
|
const multiplier = settings.throttlingMethod === 'simulate' ?
|
|
203
205
|
settings.throttling.cpuSlowdownMultiplier : 1;
|
|
@@ -36,8 +36,7 @@ class TimingBudget extends Audit {
|
|
|
36
36
|
title: str_(UIStrings.title),
|
|
37
37
|
description: str_(UIStrings.description),
|
|
38
38
|
scoreDisplayMode: Audit.SCORING_MODES.INFORMATIVE,
|
|
39
|
-
|
|
40
|
-
requiredArtifacts: ['devtoolsLogs', 'traces', 'URL', 'GatherContext'],
|
|
39
|
+
requiredArtifacts: ['devtoolsLogs', 'traces', 'URL'],
|
|
41
40
|
};
|
|
42
41
|
}
|
|
43
42
|
|
|
@@ -137,11 +136,10 @@ class TimingBudget extends Audit {
|
|
|
137
136
|
* @return {Promise<LH.Audit.Product>}
|
|
138
137
|
*/
|
|
139
138
|
static async audit(artifacts, context) {
|
|
140
|
-
const gatherContext = artifacts.GatherContext;
|
|
141
139
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
142
140
|
const trace = artifacts.traces[Audit.DEFAULT_PASS];
|
|
143
141
|
const mainResource = await MainResource.request({URL: artifacts.URL, devtoolsLog}, context);
|
|
144
|
-
const data = {trace, devtoolsLog,
|
|
142
|
+
const data = {trace, devtoolsLog, settings: context.settings};
|
|
145
143
|
const summary = (await TimingSummary.request(data, context)).metrics;
|
|
146
144
|
const budget = Budget.getMatchingBudget(context.settings.budgets, mainResource.url);
|
|
147
145
|
|
|
@@ -13,8 +13,7 @@ const i18n = require('../lib/i18n/i18n.js');
|
|
|
13
13
|
const NetworkRecords = require('../computed/network-records.js');
|
|
14
14
|
const MainResource = require('../computed/main-resource.js');
|
|
15
15
|
const LoadSimulator = require('../computed/load-simulator.js');
|
|
16
|
-
const
|
|
17
|
-
const ProcessedNavigation = require('../computed/processed-navigation.js');
|
|
16
|
+
const TraceOfTab = require('../computed/trace-of-tab.js');
|
|
18
17
|
const PageDependencyGraph = require('../computed/page-dependency-graph.js');
|
|
19
18
|
const LanternLCP = require('../computed/metrics/lantern-largest-contentful-paint.js');
|
|
20
19
|
|
|
@@ -63,7 +62,6 @@ class UsesRelPreconnectAudit extends Audit {
|
|
|
63
62
|
id: 'uses-rel-preconnect',
|
|
64
63
|
title: str_(UIStrings.title),
|
|
65
64
|
description: str_(UIStrings.description),
|
|
66
|
-
supportedModes: ['navigation'],
|
|
67
65
|
requiredArtifacts: ['traces', 'devtoolsLogs', 'URL', 'LinkElements'],
|
|
68
66
|
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
|
|
69
67
|
};
|
|
@@ -115,19 +113,16 @@ class UsesRelPreconnectAudit extends Audit {
|
|
|
115
113
|
/** @type {Array<LH.IcuMessage>} */
|
|
116
114
|
const warnings = [];
|
|
117
115
|
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
ProcessedNavigation.request(processedTrace, context),
|
|
126
|
-
PageDependencyGraph.request({trace, devtoolsLog}, context),
|
|
127
|
-
]);
|
|
116
|
+
const [networkRecords, mainResource, loadSimulator, traceOfTab, pageGraph] = await Promise.all([
|
|
117
|
+
NetworkRecords.request(devtoolsLog, context),
|
|
118
|
+
MainResource.request({devtoolsLog, URL: artifacts.URL}, context),
|
|
119
|
+
LoadSimulator.request({devtoolsLog, settings}, context),
|
|
120
|
+
TraceOfTab.request(trace, context),
|
|
121
|
+
PageDependencyGraph.request({trace, devtoolsLog}, context),
|
|
122
|
+
]);
|
|
128
123
|
|
|
129
124
|
const {rtt, additionalRttByOrigin} = loadSimulator.getOptions();
|
|
130
|
-
const lcpGraph = await LanternLCP.getPessimisticGraph(pageGraph,
|
|
125
|
+
const lcpGraph = await LanternLCP.getPessimisticGraph(pageGraph, traceOfTab);
|
|
131
126
|
/** @type {Set<string>} */
|
|
132
127
|
const lcpGraphURLs = new Set();
|
|
133
128
|
lcpGraph.traverse(node => {
|
|
@@ -42,7 +42,6 @@ class UsesRelPreloadAudit extends Audit {
|
|
|
42
42
|
id: 'uses-rel-preload',
|
|
43
43
|
title: str_(UIStrings.title),
|
|
44
44
|
description: str_(UIStrings.description),
|
|
45
|
-
supportedModes: ['navigation'],
|
|
46
45
|
requiredArtifacts: ['devtoolsLogs', 'traces', 'URL'],
|
|
47
46
|
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
|
|
48
47
|
};
|
|
@@ -209,11 +208,11 @@ class UsesRelPreloadAudit extends Audit {
|
|
|
209
208
|
* @param {LH.Audit.Context} context
|
|
210
209
|
* @return {Promise<LH.Audit.Product>}
|
|
211
210
|
*/
|
|
212
|
-
static async
|
|
211
|
+
static async audit(artifacts, context) {
|
|
213
212
|
const trace = artifacts.traces[UsesRelPreloadAudit.DEFAULT_PASS];
|
|
214
213
|
const devtoolsLog = artifacts.devtoolsLogs[UsesRelPreloadAudit.DEFAULT_PASS];
|
|
215
214
|
const URL = artifacts.URL;
|
|
216
|
-
const simulatorOptions = {devtoolsLog, settings: context.settings};
|
|
215
|
+
const simulatorOptions = {trace, devtoolsLog, settings: context.settings};
|
|
217
216
|
|
|
218
217
|
const [mainResource, graph, simulator] = await Promise.all([
|
|
219
218
|
MainResource.request({devtoolsLog, URL}, context),
|
|
@@ -252,16 +251,6 @@ class UsesRelPreloadAudit extends Audit {
|
|
|
252
251
|
warnings,
|
|
253
252
|
};
|
|
254
253
|
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* @return {Promise<LH.Audit.Product>}
|
|
258
|
-
*/
|
|
259
|
-
static async audit() {
|
|
260
|
-
// Preload advice is dangerous until https://bugs.chromium.org/p/chromium/issues/detail?id=788757
|
|
261
|
-
// has been fixed and validated. All preload audits are on hold until then.
|
|
262
|
-
// See https://github.com/GoogleChrome/lighthouse/issues/11960 for more discussion.
|
|
263
|
-
return {score: 1, notApplicable: true, details: Audit.makeOpportunityDetails([], [], 0)};
|
|
264
|
-
}
|
|
265
254
|
}
|
|
266
255
|
|
|
267
256
|
module.exports = UsesRelPreloadAudit;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
const makeComputedArtifact = require('./computed-artifact.js');
|
|
9
9
|
const MainThreadTasks_ = require('../lib/tracehouse/main-thread-tasks.js');
|
|
10
|
-
const
|
|
10
|
+
const TraceOfTab = require('./trace-of-tab.js');
|
|
11
11
|
|
|
12
12
|
class MainThreadTasks {
|
|
13
13
|
/**
|
|
@@ -16,7 +16,7 @@ class MainThreadTasks {
|
|
|
16
16
|
* @return {Promise<Array<LH.Artifacts.TaskNode>>}
|
|
17
17
|
*/
|
|
18
18
|
static async compute_(trace, context) {
|
|
19
|
-
const {mainThreadEvents, frames, timestamps} = await
|
|
19
|
+
const {mainThreadEvents, frames, timestamps} = await TraceOfTab.request(trace, context);
|
|
20
20
|
return MainThreadTasks_.getMainThreadTasks(mainThreadEvents, frames, timestamps.traceEnd);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const makeComputedArtifact = require('../computed-artifact.js');
|
|
9
|
-
const
|
|
9
|
+
const TraceOfTab = require('../trace-of-tab.js');
|
|
10
10
|
const LHError = require('../../lib/lh-error.js');
|
|
11
11
|
|
|
12
12
|
/** @typedef {{ts: number, isMainFrame: boolean, weightedScore: number}} LayoutShiftEvent */
|
|
@@ -108,10 +108,10 @@ class CumulativeLayoutShift {
|
|
|
108
108
|
* @return {Promise<{cumulativeLayoutShift: number, cumulativeLayoutShiftMainFrame: number, totalCumulativeLayoutShift: number}>}
|
|
109
109
|
*/
|
|
110
110
|
static async compute_(trace, context) {
|
|
111
|
-
const
|
|
111
|
+
const traceOfTab = await TraceOfTab.request(trace, context);
|
|
112
112
|
|
|
113
113
|
const allFrameShiftEvents =
|
|
114
|
-
CumulativeLayoutShift.getLayoutShiftEvents(
|
|
114
|
+
CumulativeLayoutShift.getLayoutShiftEvents(traceOfTab.frameTreeEvents);
|
|
115
115
|
const mainFrameShiftEvents = allFrameShiftEvents.filter(e => e.isMainFrame);
|
|
116
116
|
|
|
117
117
|
// The original Cumulative Layout Shift metric, the sum of all main-frame shift events.
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const makeComputedArtifact = require('../computed-artifact.js');
|
|
9
|
-
const
|
|
9
|
+
const ComputedMetric = require('./metric.js');
|
|
10
10
|
|
|
11
|
-
class FirstContentfulPaintAllFrames extends
|
|
11
|
+
class FirstContentfulPaintAllFrames extends ComputedMetric {
|
|
12
12
|
/**
|
|
13
13
|
* @return {Promise<LH.Artifacts.LanternMetric>}
|
|
14
14
|
*/
|
|
@@ -18,15 +18,15 @@ class FirstContentfulPaintAllFrames extends NavigationMetric {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* @param {LH.Artifacts.
|
|
21
|
+
* @param {LH.Artifacts.MetricComputationData} data
|
|
22
22
|
* @return {Promise<LH.Artifacts.Metric>}
|
|
23
23
|
*/
|
|
24
24
|
static async computeObservedMetric(data) {
|
|
25
|
-
const {
|
|
25
|
+
const {traceOfTab} = data;
|
|
26
26
|
|
|
27
27
|
return {
|
|
28
|
-
timing:
|
|
29
|
-
timestamp:
|
|
28
|
+
timing: traceOfTab.timings.firstContentfulPaintAllFrames,
|
|
29
|
+
timestamp: traceOfTab.timestamps.firstContentfulPaintAllFrames,
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -6,30 +6,29 @@
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const makeComputedArtifact = require('../computed-artifact.js');
|
|
9
|
-
const
|
|
9
|
+
const ComputedMetric = require('./metric.js');
|
|
10
10
|
const LanternFirstContentfulPaint = require('./lantern-first-contentful-paint.js');
|
|
11
11
|
|
|
12
|
-
class FirstContentfulPaint extends
|
|
12
|
+
class FirstContentfulPaint extends ComputedMetric {
|
|
13
13
|
/**
|
|
14
|
-
* @param {LH.Artifacts.
|
|
14
|
+
* @param {LH.Artifacts.MetricComputationData} data
|
|
15
15
|
* @param {LH.Artifacts.ComputedContext} context
|
|
16
16
|
* @return {Promise<LH.Artifacts.LanternMetric>}
|
|
17
17
|
*/
|
|
18
18
|
static computeSimulatedMetric(data, context) {
|
|
19
|
-
|
|
20
|
-
return LanternFirstContentfulPaint.request(metricData, context);
|
|
19
|
+
return LanternFirstContentfulPaint.request(data, context);
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
/**
|
|
24
|
-
* @param {LH.Artifacts.
|
|
23
|
+
* @param {LH.Artifacts.MetricComputationData} data
|
|
25
24
|
* @return {Promise<LH.Artifacts.Metric>}
|
|
26
25
|
*/
|
|
27
26
|
static async computeObservedMetric(data) {
|
|
28
|
-
const {
|
|
27
|
+
const {traceOfTab} = data;
|
|
29
28
|
|
|
30
29
|
return {
|
|
31
|
-
timing:
|
|
32
|
-
timestamp:
|
|
30
|
+
timing: traceOfTab.timings.firstContentfulPaint,
|
|
31
|
+
timestamp: traceOfTab.timestamps.firstContentfulPaint,
|
|
33
32
|
};
|
|
34
33
|
}
|
|
35
34
|
}
|
|
@@ -6,34 +6,33 @@
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const makeComputedArtifact = require('../computed-artifact.js');
|
|
9
|
-
const
|
|
9
|
+
const ComputedMetric = require('./metric.js');
|
|
10
10
|
const LHError = require('../../lib/lh-error.js');
|
|
11
11
|
const LanternFirstMeaningfulPaint = require('./lantern-first-meaningful-paint.js');
|
|
12
12
|
|
|
13
|
-
class FirstMeaningfulPaint extends
|
|
13
|
+
class FirstMeaningfulPaint extends ComputedMetric {
|
|
14
14
|
/**
|
|
15
|
-
* @param {LH.Artifacts.
|
|
15
|
+
* @param {LH.Artifacts.MetricComputationData} data
|
|
16
16
|
* @param {LH.Artifacts.ComputedContext} context
|
|
17
17
|
* @return {Promise<LH.Artifacts.LanternMetric>}
|
|
18
18
|
*/
|
|
19
19
|
static computeSimulatedMetric(data, context) {
|
|
20
|
-
|
|
21
|
-
return LanternFirstMeaningfulPaint.request(metricData, context);
|
|
20
|
+
return LanternFirstMeaningfulPaint.request(data, context);
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
/**
|
|
25
|
-
* @param {LH.Artifacts.
|
|
24
|
+
* @param {LH.Artifacts.MetricComputationData} data
|
|
26
25
|
* @return {Promise<LH.Artifacts.Metric>}
|
|
27
26
|
*/
|
|
28
27
|
static async computeObservedMetric(data) {
|
|
29
|
-
const {
|
|
30
|
-
if (
|
|
28
|
+
const {traceOfTab} = data;
|
|
29
|
+
if (traceOfTab.timings.firstMeaningfulPaint === undefined) {
|
|
31
30
|
throw new LHError(LHError.errors.NO_FMP);
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
return {
|
|
35
|
-
timing:
|
|
36
|
-
timestamp:
|
|
34
|
+
timing: traceOfTab.timings.firstMeaningfulPaint,
|
|
35
|
+
timestamp: traceOfTab.timestamps.firstMeaningfulPaint,
|
|
37
36
|
};
|
|
38
37
|
}
|
|
39
38
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const makeComputedArtifact = require('../computed-artifact.js');
|
|
9
|
-
const
|
|
9
|
+
const ComputedMetric = require('./metric.js');
|
|
10
10
|
const LanternInteractive = require('./lantern-interactive.js');
|
|
11
11
|
|
|
12
12
|
const NetworkMonitor = require('../../gather/driver/network-monitor.js');
|
|
@@ -21,16 +21,16 @@ const ALLOWED_CONCURRENT_REQUESTS = 2;
|
|
|
21
21
|
* resources and is mostly idle.
|
|
22
22
|
* @see https://docs.google.com/document/d/1yE4YWsusi5wVXrnwhR61j-QyjK9tzENIzfxrCjA1NAk/edit#heading=h.yozfsuqcgpc4
|
|
23
23
|
*/
|
|
24
|
-
class Interactive extends
|
|
24
|
+
class Interactive extends ComputedMetric {
|
|
25
25
|
/**
|
|
26
26
|
* Finds all time periods where the number of inflight requests is less than or equal to the
|
|
27
27
|
* number of allowed concurrent requests (2).
|
|
28
28
|
* @param {Array<LH.Artifacts.NetworkRequest>} networkRecords
|
|
29
|
-
* @param {{timestamps: {traceEnd: number}}}
|
|
29
|
+
* @param {{timestamps: {traceEnd: number}}} traceOfTab
|
|
30
30
|
* @return {Array<TimePeriod>}
|
|
31
31
|
*/
|
|
32
|
-
static _findNetworkQuietPeriods(networkRecords,
|
|
33
|
-
const traceEndTsInMs =
|
|
32
|
+
static _findNetworkQuietPeriods(networkRecords, traceOfTab) {
|
|
33
|
+
const traceEndTsInMs = traceOfTab.timestamps.traceEnd / 1000;
|
|
34
34
|
// Ignore records that failed, never finished, or were POST/PUT/etc.
|
|
35
35
|
const filteredNetworkRecords = networkRecords.filter(record => {
|
|
36
36
|
return record.finished && record.requestMethod === 'GET' && !record.failed &&
|
|
@@ -44,12 +44,12 @@ class Interactive extends NavigationMetric {
|
|
|
44
44
|
/**
|
|
45
45
|
* Finds all time periods where there are no long tasks.
|
|
46
46
|
* @param {Array<TimePeriod>} longTasks
|
|
47
|
-
* @param {{timestamps: {timeOrigin: number, traceEnd: number}}}
|
|
47
|
+
* @param {{timestamps: {timeOrigin: number, traceEnd: number}}} traceOfTab
|
|
48
48
|
* @return {Array<TimePeriod>}
|
|
49
49
|
*/
|
|
50
|
-
static _findCPUQuietPeriods(longTasks,
|
|
51
|
-
const timeOriginTsInMs =
|
|
52
|
-
const traceEndTsInMs =
|
|
50
|
+
static _findCPUQuietPeriods(longTasks, traceOfTab) {
|
|
51
|
+
const timeOriginTsInMs = traceOfTab.timestamps.timeOrigin / 1000;
|
|
52
|
+
const traceEndTsInMs = traceOfTab.timestamps.traceEnd / 1000;
|
|
53
53
|
if (longTasks.length === 0) {
|
|
54
54
|
return [{start: 0, end: traceEndTsInMs}];
|
|
55
55
|
}
|
|
@@ -84,19 +84,19 @@ class Interactive extends NavigationMetric {
|
|
|
84
84
|
* Finds the first time period where a network quiet period and a CPU quiet period overlap.
|
|
85
85
|
* @param {Array<TimePeriod>} longTasks
|
|
86
86
|
* @param {Array<LH.Artifacts.NetworkRequest>} networkRecords
|
|
87
|
-
* @param {LH.Artifacts.
|
|
87
|
+
* @param {LH.Artifacts.TraceOfTab} traceOfTab
|
|
88
88
|
* @return {{cpuQuietPeriod: TimePeriod, networkQuietPeriod: TimePeriod, cpuQuietPeriods: Array<TimePeriod>, networkQuietPeriods: Array<TimePeriod>}}
|
|
89
89
|
*/
|
|
90
|
-
static findOverlappingQuietPeriods(longTasks, networkRecords,
|
|
91
|
-
const FcpTsInMs =
|
|
90
|
+
static findOverlappingQuietPeriods(longTasks, networkRecords, traceOfTab) {
|
|
91
|
+
const FcpTsInMs = traceOfTab.timestamps.firstContentfulPaint / 1000;
|
|
92
92
|
|
|
93
93
|
/** @type {function(TimePeriod):boolean} */
|
|
94
94
|
const isLongEnoughQuietPeriod = period =>
|
|
95
95
|
period.end > FcpTsInMs + REQUIRED_QUIET_WINDOW &&
|
|
96
96
|
period.end - period.start >= REQUIRED_QUIET_WINDOW;
|
|
97
|
-
const networkQuietPeriods = this._findNetworkQuietPeriods(networkRecords,
|
|
97
|
+
const networkQuietPeriods = this._findNetworkQuietPeriods(networkRecords, traceOfTab)
|
|
98
98
|
.filter(isLongEnoughQuietPeriod);
|
|
99
|
-
const cpuQuietPeriods = this._findCPUQuietPeriods(longTasks,
|
|
99
|
+
const cpuQuietPeriods = this._findCPUQuietPeriods(longTasks, traceOfTab)
|
|
100
100
|
.filter(isLongEnoughQuietPeriod);
|
|
101
101
|
|
|
102
102
|
const cpuQueue = cpuQuietPeriods.slice();
|
|
@@ -141,42 +141,41 @@ class Interactive extends NavigationMetric {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
|
-
* @param {LH.Artifacts.
|
|
144
|
+
* @param {LH.Artifacts.MetricComputationData} data
|
|
145
145
|
* @param {LH.Artifacts.ComputedContext} context
|
|
146
146
|
* @return {Promise<LH.Artifacts.LanternMetric>}
|
|
147
147
|
*/
|
|
148
148
|
static computeSimulatedMetric(data, context) {
|
|
149
|
-
|
|
150
|
-
return LanternInteractive.request(metricData, context);
|
|
149
|
+
return LanternInteractive.request(data, context);
|
|
151
150
|
}
|
|
152
151
|
|
|
153
152
|
/**
|
|
154
|
-
* @param {LH.Artifacts.
|
|
153
|
+
* @param {LH.Artifacts.MetricComputationData} data
|
|
155
154
|
* @return {Promise<LH.Artifacts.Metric>}
|
|
156
155
|
*/
|
|
157
156
|
static computeObservedMetric(data) {
|
|
158
|
-
const {
|
|
157
|
+
const {traceOfTab, networkRecords} = data;
|
|
159
158
|
|
|
160
|
-
if (!
|
|
159
|
+
if (!traceOfTab.timestamps.domContentLoaded) {
|
|
161
160
|
throw new LHError(LHError.errors.NO_DCL);
|
|
162
161
|
}
|
|
163
162
|
|
|
164
|
-
const longTasks = TracingProcessor.getMainThreadTopLevelEvents(
|
|
163
|
+
const longTasks = TracingProcessor.getMainThreadTopLevelEvents(traceOfTab)
|
|
165
164
|
.filter(event => event.duration >= 50);
|
|
166
165
|
const quietPeriodInfo = Interactive.findOverlappingQuietPeriods(
|
|
167
166
|
longTasks,
|
|
168
167
|
networkRecords,
|
|
169
|
-
|
|
168
|
+
traceOfTab
|
|
170
169
|
);
|
|
171
170
|
|
|
172
171
|
const cpuQuietPeriod = quietPeriodInfo.cpuQuietPeriod;
|
|
173
172
|
|
|
174
173
|
const timestamp = Math.max(
|
|
175
174
|
cpuQuietPeriod.start,
|
|
176
|
-
|
|
177
|
-
|
|
175
|
+
traceOfTab.timestamps.firstContentfulPaint / 1000,
|
|
176
|
+
traceOfTab.timestamps.domContentLoaded / 1000
|
|
178
177
|
) * 1000;
|
|
179
|
-
const timing = (timestamp -
|
|
178
|
+
const timing = (timestamp - traceOfTab.timestamps.timeOrigin) / 1000;
|
|
180
179
|
return Promise.resolve({timing, timestamp});
|
|
181
180
|
}
|
|
182
181
|
}
|