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.
Files changed (299) hide show
  1. package/docs/architecture.md +101 -0
  2. package/docs/authenticated-pages.md +44 -0
  3. package/docs/bug-labels.md +35 -0
  4. package/docs/configuration.md +213 -0
  5. package/docs/emulation.md +32 -0
  6. package/docs/error-reporting.md +42 -0
  7. package/docs/hacking-tips.md +55 -0
  8. package/docs/headless-chrome.md +119 -0
  9. package/docs/lantern.md +55 -0
  10. package/docs/new-audits.md +99 -0
  11. package/docs/performance-budgets.md +187 -0
  12. package/docs/plugins.md +374 -0
  13. package/docs/puppeteer.md +95 -0
  14. package/docs/readme.md +164 -0
  15. package/docs/recipes/auth/README.md +129 -0
  16. package/docs/recipes/auth/example-lh-auth.js +81 -0
  17. package/docs/recipes/auth/package.json +11 -0
  18. package/docs/recipes/auth/server/public/dashboard-unauthenticated.html +21 -0
  19. package/docs/recipes/auth/server/public/dashboard.html +25 -0
  20. package/docs/recipes/auth/server/public/home-unauthenticated.html +27 -0
  21. package/docs/recipes/auth/server/public/home.html +17 -0
  22. package/docs/recipes/auth/server/public/unauthenticated.html +22 -0
  23. package/docs/recipes/auth/server/server.js +85 -0
  24. package/docs/recipes/custom-audit/custom-config.js +36 -0
  25. package/docs/recipes/custom-audit/package.json +8 -0
  26. package/docs/recipes/custom-audit/readme.md +32 -0
  27. package/docs/recipes/custom-audit/searchable-audit.js +46 -0
  28. package/docs/recipes/custom-audit/searchable-gatherer.js +32 -0
  29. package/docs/recipes/custom-gatherer-puppeteer/custom-audit.js +34 -0
  30. package/{root.js → docs/recipes/custom-gatherer-puppeteer/custom-config.js} +23 -2
  31. package/docs/recipes/custom-gatherer-puppeteer/custom-gatherer.js +51 -0
  32. package/docs/recipes/custom-gatherer-puppeteer/package.json +13 -0
  33. package/docs/recipes/custom-gatherer-puppeteer/readme.md +7 -0
  34. package/docs/recipes/custom-gatherer-puppeteer/test.sh +9 -0
  35. package/docs/recipes/gulp/gulpfile.js +79 -0
  36. package/docs/recipes/gulp/package.json +12 -0
  37. package/docs/recipes/gulp/public/index.html +22 -0
  38. package/docs/recipes/gulp/readme.md +6 -0
  39. package/docs/recipes/integration-test/README.md +14 -0
  40. package/docs/recipes/integration-test/example-lh-auth.test.js +160 -0
  41. package/docs/recipes/integration-test/package.json +9 -0
  42. package/docs/recipes/lighthouse-plugin-example/audits/preload-as.js +46 -0
  43. package/docs/recipes/lighthouse-plugin-example/package.json +11 -0
  44. package/docs/recipes/lighthouse-plugin-example/plugin-recipe-screenshot.png +0 -0
  45. package/docs/recipes/lighthouse-plugin-example/plugin.js +24 -0
  46. package/docs/recipes/lighthouse-plugin-example/readme.md +53 -0
  47. package/docs/releasing.md +164 -0
  48. package/docs/scoring.md +79 -0
  49. package/docs/throttling.md +150 -0
  50. package/docs/understanding-results.md +209 -0
  51. package/docs/v8-perf-faq.md +244 -0
  52. package/docs/variability.md +150 -0
  53. package/jest.config.js +0 -3
  54. package/lighthouse-cli/bin.js +8 -6
  55. package/lighthouse-core/audits/accessibility/aria-command-name.js +1 -1
  56. package/lighthouse-core/audits/accessibility/aria-meter-name.js +1 -1
  57. package/lighthouse-core/audits/accessibility/aria-progressbar-name.js +1 -1
  58. package/lighthouse-core/audits/accessibility/aria-tooltip-name.js +1 -1
  59. package/lighthouse-core/audits/accessibility/aria-treeitem-name.js +1 -1
  60. package/lighthouse-core/audits/apple-touch-icon.js +0 -1
  61. package/lighthouse-core/audits/audit.js +3 -3
  62. package/lighthouse-core/audits/autocomplete.js +2 -2
  63. package/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js +14 -29
  64. package/lighthouse-core/audits/byte-efficiency/duplicated-javascript.js +2 -3
  65. package/lighthouse-core/audits/byte-efficiency/efficient-animated-content.js +1 -1
  66. package/lighthouse-core/audits/byte-efficiency/legacy-javascript.js +2 -3
  67. package/lighthouse-core/audits/byte-efficiency/modern-image-formats.js +15 -55
  68. package/lighthouse-core/audits/byte-efficiency/offscreen-images.js +4 -8
  69. package/lighthouse-core/audits/byte-efficiency/render-blocking-resources.js +8 -15
  70. package/lighthouse-core/audits/byte-efficiency/total-byte-weight.js +9 -10
  71. package/lighthouse-core/audits/byte-efficiency/unminified-css.js +1 -1
  72. package/lighthouse-core/audits/byte-efficiency/unminified-javascript.js +1 -1
  73. package/lighthouse-core/audits/byte-efficiency/unused-css-rules.js +1 -1
  74. package/lighthouse-core/audits/byte-efficiency/unused-javascript.js +1 -2
  75. package/lighthouse-core/audits/byte-efficiency/uses-long-cache-ttl.js +2 -2
  76. package/lighthouse-core/audits/byte-efficiency/uses-optimized-images.js +1 -2
  77. package/lighthouse-core/audits/byte-efficiency/uses-responsive-images.js +24 -46
  78. package/lighthouse-core/audits/byte-efficiency/uses-text-compression.js +1 -1
  79. package/lighthouse-core/audits/critical-request-chains.js +0 -1
  80. package/lighthouse-core/audits/csp-xss.js +1 -1
  81. package/lighthouse-core/audits/diagnostics.js +0 -1
  82. package/lighthouse-core/audits/dobetterweb/geolocation-on-start.js +0 -1
  83. package/lighthouse-core/audits/dobetterweb/inspector-issues.js +1 -1
  84. package/lighthouse-core/audits/dobetterweb/notification-on-start.js +0 -1
  85. package/lighthouse-core/audits/dobetterweb/uses-http2.js +0 -1
  86. package/lighthouse-core/audits/final-screenshot.js +4 -8
  87. package/lighthouse-core/audits/font-display.js +0 -1
  88. package/lighthouse-core/audits/installable-manifest.js +3 -4
  89. package/lighthouse-core/audits/largest-contentful-paint-element.js +0 -1
  90. package/lighthouse-core/audits/long-tasks.js +1 -1
  91. package/lighthouse-core/audits/maskable-icon.js +0 -1
  92. package/lighthouse-core/audits/metrics/first-contentful-paint-3g.js +2 -4
  93. package/lighthouse-core/audits/metrics/first-contentful-paint.js +2 -4
  94. package/lighthouse-core/audits/metrics/first-meaningful-paint.js +2 -4
  95. package/lighthouse-core/audits/metrics/interactive.js +2 -4
  96. package/lighthouse-core/audits/metrics/largest-contentful-paint.js +2 -4
  97. package/lighthouse-core/audits/metrics/max-potential-fid.js +2 -4
  98. package/lighthouse-core/audits/metrics/speed-index.js +2 -4
  99. package/lighthouse-core/audits/metrics/total-blocking-time.js +2 -10
  100. package/lighthouse-core/audits/metrics.js +2 -4
  101. package/lighthouse-core/audits/performance-budget.js +0 -1
  102. package/lighthouse-core/audits/predictive-perf.js +6 -9
  103. package/lighthouse-core/audits/preload-fonts.js +1 -11
  104. package/lighthouse-core/audits/preload-lcp-image.js +5 -18
  105. package/lighthouse-core/audits/redirects.js +8 -10
  106. package/lighthouse-core/audits/screenshot-thumbnails.js +13 -28
  107. package/lighthouse-core/audits/seo/canonical.js +1 -2
  108. package/lighthouse-core/audits/seo/font-size.js +4 -4
  109. package/lighthouse-core/audits/seo/hreflang.js +2 -3
  110. package/lighthouse-core/audits/seo/http-status-code.js +16 -21
  111. package/lighthouse-core/audits/seo/is-crawlable.js +3 -4
  112. package/lighthouse-core/audits/seo/robots-txt.js +2 -2
  113. package/lighthouse-core/audits/seo/tap-targets.js +5 -5
  114. package/lighthouse-core/audits/server-response-time.js +2 -20
  115. package/lighthouse-core/audits/splash-screen.js +0 -1
  116. package/lighthouse-core/audits/themed-omnibox.js +0 -1
  117. package/lighthouse-core/audits/third-party-facades.js +0 -1
  118. package/lighthouse-core/audits/third-party-summary.js +3 -1
  119. package/lighthouse-core/audits/timing-budget.js +2 -4
  120. package/lighthouse-core/audits/uses-rel-preconnect.js +9 -14
  121. package/lighthouse-core/audits/uses-rel-preload.js +2 -13
  122. package/lighthouse-core/computed/main-thread-tasks.js +2 -2
  123. package/lighthouse-core/computed/metrics/cumulative-layout-shift.js +3 -3
  124. package/lighthouse-core/computed/metrics/first-contentful-paint-all-frames.js +6 -6
  125. package/lighthouse-core/computed/metrics/first-contentful-paint.js +8 -9
  126. package/lighthouse-core/computed/metrics/first-meaningful-paint.js +9 -10
  127. package/lighthouse-core/computed/metrics/interactive.js +24 -25
  128. package/lighthouse-core/computed/metrics/lantern-first-contentful-paint.js +6 -6
  129. package/lighthouse-core/computed/metrics/lantern-first-meaningful-paint.js +6 -6
  130. package/lighthouse-core/computed/metrics/lantern-largest-contentful-paint.js +6 -6
  131. package/lighthouse-core/computed/metrics/lantern-metric.js +8 -16
  132. package/lighthouse-core/computed/metrics/largest-contentful-paint-all-frames.js +7 -7
  133. package/lighthouse-core/computed/metrics/largest-contentful-paint.js +9 -10
  134. package/lighthouse-core/computed/metrics/max-potential-fid.js +11 -8
  135. package/lighthouse-core/computed/metrics/metric.js +5 -32
  136. package/lighthouse-core/computed/metrics/speed-index.js +5 -6
  137. package/lighthouse-core/computed/metrics/timing-summary.js +45 -55
  138. package/lighthouse-core/computed/metrics/total-blocking-time.js +29 -36
  139. package/lighthouse-core/computed/page-dependency-graph.js +14 -14
  140. package/lighthouse-core/computed/resource-summary.js +7 -3
  141. package/lighthouse-core/computed/speedline.js +3 -3
  142. package/lighthouse-core/computed/trace-of-tab.js +86 -15
  143. package/lighthouse-core/computed/user-timings.js +5 -5
  144. package/lighthouse-core/config/default-config.js +0 -1
  145. package/lighthouse-core/fraggle-rock/config/config.js +7 -9
  146. package/lighthouse-core/fraggle-rock/config/default-config.js +2 -40
  147. package/lighthouse-core/fraggle-rock/config/filters.js +6 -39
  148. package/lighthouse-core/fraggle-rock/config/validation.js +4 -4
  149. package/lighthouse-core/fraggle-rock/gather/base-artifacts.js +19 -54
  150. package/lighthouse-core/fraggle-rock/gather/navigation-runner.js +10 -21
  151. package/lighthouse-core/fraggle-rock/gather/runner-helpers.js +2 -2
  152. package/lighthouse-core/fraggle-rock/gather/snapshot-runner.js +2 -2
  153. package/lighthouse-core/fraggle-rock/gather/timespan-runner.js +2 -2
  154. package/lighthouse-core/gather/driver/prepare.js +0 -3
  155. package/lighthouse-core/gather/fetcher.js +2 -0
  156. package/lighthouse-core/gather/gather-runner.js +14 -2
  157. package/lighthouse-core/gather/gatherers/image-elements.js +61 -24
  158. package/lighthouse-core/gather/gatherers/inspector-issues.js +2 -2
  159. package/lighthouse-core/gather/gatherers/script-elements.js +12 -45
  160. package/lighthouse-core/gather/gatherers/seo/font-size.js +5 -5
  161. package/lighthouse-core/gather/gatherers/seo/tap-targets.js +12 -64
  162. package/lighthouse-core/gather/gatherers/service-worker.js +3 -20
  163. package/lighthouse-core/gather/gatherers/trace-compat.js +1 -1
  164. package/lighthouse-core/gather/gatherers/trace-elements.js +3 -15
  165. package/lighthouse-core/gather/gatherers/trace.js +4 -13
  166. package/lighthouse-core/gather/gatherers/viewport-dimensions.js +1 -1
  167. package/lighthouse-core/lib/dependency-graph/simulator/network-analyzer.js +2 -13
  168. package/lighthouse-core/lib/emulation.js +2 -0
  169. package/lighthouse-core/lib/i18n/i18n.js +2 -2
  170. package/lighthouse-core/lib/i18n/locales/ar-XB.json +141 -141
  171. package/lighthouse-core/lib/i18n/locales/ar.json +143 -143
  172. package/lighthouse-core/lib/i18n/locales/bg.json +143 -143
  173. package/lighthouse-core/lib/i18n/locales/ca.json +141 -141
  174. package/lighthouse-core/lib/i18n/locales/cs.json +141 -141
  175. package/lighthouse-core/lib/i18n/locales/da.json +141 -141
  176. package/lighthouse-core/lib/i18n/locales/de.json +142 -142
  177. package/lighthouse-core/lib/i18n/locales/el.json +141 -141
  178. package/lighthouse-core/lib/i18n/locales/en-GB.json +141 -141
  179. package/lighthouse-core/lib/i18n/locales/en-US.ctc.json +6659 -0
  180. package/lighthouse-core/lib/i18n/locales/en-US.json +144 -150
  181. package/lighthouse-core/lib/i18n/locales/en-XA.json +141 -141
  182. package/lighthouse-core/lib/i18n/locales/en-XL.ctc.json +6628 -0
  183. package/lighthouse-core/lib/i18n/locales/en-XL.json +144 -150
  184. package/lighthouse-core/lib/i18n/locales/es-419.json +141 -141
  185. package/lighthouse-core/lib/i18n/locales/es.json +141 -141
  186. package/lighthouse-core/lib/i18n/locales/fi.json +143 -143
  187. package/lighthouse-core/lib/i18n/locales/fil.json +142 -142
  188. package/lighthouse-core/lib/i18n/locales/fr.json +141 -141
  189. package/lighthouse-core/lib/i18n/locales/he.json +142 -142
  190. package/lighthouse-core/lib/i18n/locales/hi.json +143 -143
  191. package/lighthouse-core/lib/i18n/locales/hr.json +141 -141
  192. package/lighthouse-core/lib/i18n/locales/hu.json +143 -143
  193. package/lighthouse-core/lib/i18n/locales/id.json +143 -143
  194. package/lighthouse-core/lib/i18n/locales/it.json +143 -143
  195. package/lighthouse-core/lib/i18n/locales/ja.json +143 -143
  196. package/lighthouse-core/lib/i18n/locales/ko.json +143 -143
  197. package/lighthouse-core/lib/i18n/locales/lt.json +143 -143
  198. package/lighthouse-core/lib/i18n/locales/lv.json +143 -143
  199. package/lighthouse-core/lib/i18n/locales/nl.json +141 -141
  200. package/lighthouse-core/lib/i18n/locales/no.json +141 -141
  201. package/lighthouse-core/lib/i18n/locales/pl.json +141 -141
  202. package/lighthouse-core/lib/i18n/locales/pt-PT.json +141 -141
  203. package/lighthouse-core/lib/i18n/locales/pt.json +141 -141
  204. package/lighthouse-core/lib/i18n/locales/ro.json +144 -144
  205. package/lighthouse-core/lib/i18n/locales/ru.json +143 -143
  206. package/lighthouse-core/lib/i18n/locales/sk.json +142 -142
  207. package/lighthouse-core/lib/i18n/locales/sl.json +141 -141
  208. package/lighthouse-core/lib/i18n/locales/sr-Latn.json +143 -143
  209. package/lighthouse-core/lib/i18n/locales/sr.json +143 -143
  210. package/lighthouse-core/lib/i18n/locales/sv.json +142 -142
  211. package/lighthouse-core/lib/i18n/locales/ta.json +141 -141
  212. package/lighthouse-core/lib/i18n/locales/te.json +143 -143
  213. package/lighthouse-core/lib/i18n/locales/th.json +143 -143
  214. package/lighthouse-core/lib/i18n/locales/tr.json +143 -143
  215. package/lighthouse-core/lib/i18n/locales/uk.json +141 -141
  216. package/lighthouse-core/lib/i18n/locales/vi.json +143 -143
  217. package/lighthouse-core/lib/i18n/locales/zh-HK.json +141 -141
  218. package/lighthouse-core/lib/i18n/locales/zh-TW.json +143 -143
  219. package/lighthouse-core/lib/i18n/locales/zh.json +143 -143
  220. package/lighthouse-core/lib/lh-error.js +2 -2
  221. package/lighthouse-core/lib/minify-trace.js +1 -1
  222. package/lighthouse-core/lib/network-request.js +1 -17
  223. package/lighthouse-core/lib/page-functions.js +5 -6
  224. package/lighthouse-core/lib/rect-helpers.js +3 -3
  225. package/lighthouse-core/lib/sd-validation/assets/jsonldcontext.json +7137 -0
  226. package/lighthouse-core/lib/sd-validation/assets/schema-tree.json +9900 -0
  227. package/{report/report-assets.js → lighthouse-core/lib/sd-validation/helpers/walk-object.js} +20 -12
  228. package/lighthouse-core/lib/sd-validation/json-expander.js +56 -0
  229. package/lighthouse-core/lib/sd-validation/json-linter.js +49 -0
  230. package/lighthouse-core/lib/sd-validation/jsonld-keyword-validator.js +50 -0
  231. package/lighthouse-core/lib/sd-validation/line-number-from-jsonld-path.js +60 -0
  232. package/lighthouse-core/lib/sd-validation/schema-validator.js +146 -0
  233. package/lighthouse-core/lib/sd-validation/scripts/download-jsonldcontext.js +30 -0
  234. package/lighthouse-core/lib/sd-validation/scripts/generate-schema-tree.js +97 -0
  235. package/lighthouse-core/lib/sd-validation/sd-validation.js +77 -0
  236. package/lighthouse-core/lib/tappable-rects.js +1 -1
  237. package/lighthouse-core/lib/tracehouse/trace-processor.js +42 -116
  238. package/lighthouse-core/lib/url-shim.js +2 -29
  239. package/lighthouse-core/report/html/html-report-assets.js +38 -0
  240. package/{report/README.md → lighthouse-core/report/html/readme.md} +11 -7
  241. package/{report → lighthouse-core/report/html}/renderer/category-renderer.js +0 -0
  242. package/{report → lighthouse-core/report/html}/renderer/crc-details-renderer.js +0 -0
  243. package/{report → lighthouse-core/report/html}/renderer/details-renderer.js +1 -1
  244. package/{report → lighthouse-core/report/html}/renderer/dom.js +0 -0
  245. package/{report → lighthouse-core/report/html}/renderer/element-screenshot-renderer.js +0 -0
  246. package/{report → lighthouse-core/report/html}/renderer/i18n.js +1 -1
  247. package/{report → lighthouse-core/report/html}/renderer/logger.js +0 -0
  248. package/{report → lighthouse-core/report/html}/renderer/performance-category-renderer.js +0 -0
  249. package/{report → lighthouse-core/report/html}/renderer/psi.js +0 -0
  250. package/{report → lighthouse-core/report/html}/renderer/pwa-category-renderer.js +0 -0
  251. package/{report → lighthouse-core/report/html}/renderer/report-renderer.js +0 -0
  252. package/{report → lighthouse-core/report/html}/renderer/report-ui-features.js +3 -3
  253. package/{report → lighthouse-core/report/html}/renderer/snippet-renderer.js +0 -0
  254. package/{report → lighthouse-core/report/html}/renderer/text-encoding.js +0 -0
  255. package/{report → lighthouse-core/report/html}/renderer/util.js +4 -7
  256. package/{report/assets/styles.css → lighthouse-core/report/html/report-styles.css} +0 -0
  257. package/{report/assets/standalone-template.html → lighthouse-core/report/html/report-template.html} +41 -1
  258. package/{report/assets → lighthouse-core/report/html}/templates.html +0 -0
  259. package/{report → lighthouse-core/report}/report-generator.js +1 -1
  260. package/lighthouse-core/runner.js +1 -1
  261. package/package.json +12 -13
  262. package/readme.md +2 -2
  263. package/third-party/chromium-synchronization/inspector-issueAdded-types-test.js +2 -3
  264. package/third-party/chromium-synchronization/installability-errors-test.js +2 -2
  265. package/third-party/download-content-shell/download-content-shell.js +1 -2
  266. package/third-party/snyk/snapshot.json +1 -1
  267. package/tsconfig.json +1 -0
  268. package/types/artifacts.d.ts +21 -41
  269. package/types/audit.d.ts +0 -2
  270. package/types/config.d.ts +2 -16
  271. package/types/externs.d.ts +0 -1
  272. package/types/gatherer.d.ts +13 -13
  273. package/types/html-renderer.d.ts +14 -14
  274. package/types/i18n.d.ts +1 -1
  275. package/lighthouse-core/audits/byte-efficiency/uses-responsive-images-snapshot.js +0 -94
  276. package/lighthouse-core/computed/image-records.js +0 -62
  277. package/lighthouse-core/computed/metrics/navigation-metric.js +0 -46
  278. package/lighthouse-core/computed/processed-navigation.js +0 -21
  279. package/lighthouse-core/computed/processed-trace.js +0 -21
  280. package/lighthouse-core/gather/gatherers/gather-context.js +0 -25
  281. package/lighthouse-core/gather/gatherers/host-form-factor.js +0 -31
  282. package/lighthouse-core/gather/gatherers/host-user-agent.js +0 -29
  283. package/lighthouse-core/lib/lh-trace-processor.js +0 -46
  284. package/report/clients/standalone.js +0 -52
  285. package/report/test/renderer/category-renderer-test.js +0 -488
  286. package/report/test/renderer/crc-details-renderer-test.js +0 -115
  287. package/report/test/renderer/details-renderer-test.js +0 -843
  288. package/report/test/renderer/dom-test.js +0 -157
  289. package/report/test/renderer/element-screenshot-renderer-test.js +0 -189
  290. package/report/test/renderer/i18n-test.js +0 -146
  291. package/report/test/renderer/performance-category-renderer-test.js +0 -332
  292. package/report/test/renderer/psi-test.js +0 -152
  293. package/report/test/renderer/pwa-category-renderer-test.js +0 -303
  294. package/report/test/renderer/report-renderer-test.js +0 -325
  295. package/report/test/renderer/report-ui-features-test.js +0 -572
  296. package/report/test/renderer/snippet-renderer-test.js +0 -291
  297. package/report/test/renderer/text-encoding-test.js +0 -41
  298. package/report/test/renderer/util-test.js +0 -388
  299. 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 NetworkRecords = require('../../computed/network-records.js');
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', 'GatherContext'],
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 async audit(artifacts, context) {
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
- if (!mainResource) {
53
- if (artifacts.GatherContext.gatherMode === 'timespan') return {notApplicable: true, score: 1};
54
- throw new Error(`Unable to locate main resource`);
55
- }
49
+ return MainResource.request({devtoolsLog, URL}, context)
50
+ .then(mainResource => {
51
+ const statusCode = mainResource.statusCode;
56
52
 
57
- const statusCode = mainResource.statusCode;
58
-
59
- if (statusCode >= HTTP_UNSUCCESSFUL_CODE_LOW &&
53
+ if (statusCode >= HTTP_UNSUCCESSFUL_CODE_LOW &&
60
54
  statusCode <= HTTP_UNSUCCESSFUL_CODE_HIGH) {
61
- return {
62
- score: 0,
63
- displayValue: `${statusCode}`,
64
- };
65
- }
55
+ return {
56
+ score: 0,
57
+ displayValue: `${statusCode}`,
58
+ };
59
+ }
66
60
 
67
- return {
68
- score: 1,
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
- * @return {boolean}
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
- * @return {boolean}
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
- * @return {boolean}
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
- * @return {{directive: string, value: string}|null}
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
- * @return {Array<{index: string, line: string, message: string}>}
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
- * @return {BoundedTapTarget[]}
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
- * @return {TapTargetOverlapFailure[]}
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
- * @return {ClientRectOverlapFailure | null}
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
- * @return {TapTargetOverlapFailure[]}
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
- * @return {TapTargetTableItem[]}
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
- supportedModes: ['timespan', 'navigation'],
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 mainEntity = thirdPartyWeb.getEntity(artifacts.URL.finalUrl);
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
- supportedModes: ['navigation'],
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, gatherContext, settings: context.settings};
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 ProcessedTrace = require('../computed/processed-trace.js');
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 processedTrace = await ProcessedTrace.request(trace, context);
119
-
120
- const [networkRecords, mainResource, loadSimulator, processedNavigation, pageGraph] =
121
- await Promise.all([
122
- NetworkRecords.request(devtoolsLog, context),
123
- MainResource.request({devtoolsLog, URL: artifacts.URL}, context),
124
- LoadSimulator.request({devtoolsLog, settings}, context),
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, processedNavigation);
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 audit_(artifacts, context) {
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 ProcessedTrace = require('./processed-trace.js');
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 ProcessedTrace.request(trace, context);
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 ProcessedTrace = require('../processed-trace.js');
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 processedTrace = await ProcessedTrace.request(trace, context);
111
+ const traceOfTab = await TraceOfTab.request(trace, context);
112
112
 
113
113
  const allFrameShiftEvents =
114
- CumulativeLayoutShift.getLayoutShiftEvents(processedTrace.frameTreeEvents);
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 NavigationMetric = require('./navigation-metric.js');
9
+ const ComputedMetric = require('./metric.js');
10
10
 
11
- class FirstContentfulPaintAllFrames extends NavigationMetric {
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.NavigationMetricComputationData} data
21
+ * @param {LH.Artifacts.MetricComputationData} data
22
22
  * @return {Promise<LH.Artifacts.Metric>}
23
23
  */
24
24
  static async computeObservedMetric(data) {
25
- const {processedNavigation} = data;
25
+ const {traceOfTab} = data;
26
26
 
27
27
  return {
28
- timing: processedNavigation.timings.firstContentfulPaintAllFrames,
29
- timestamp: processedNavigation.timestamps.firstContentfulPaintAllFrames,
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 NavigationMetric = require('./navigation-metric.js');
9
+ const ComputedMetric = require('./metric.js');
10
10
  const LanternFirstContentfulPaint = require('./lantern-first-contentful-paint.js');
11
11
 
12
- class FirstContentfulPaint extends NavigationMetric {
12
+ class FirstContentfulPaint extends ComputedMetric {
13
13
  /**
14
- * @param {LH.Artifacts.NavigationMetricComputationData} data
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
- const metricData = NavigationMetric.getMetricComputationInput(data);
20
- return LanternFirstContentfulPaint.request(metricData, context);
19
+ return LanternFirstContentfulPaint.request(data, context);
21
20
  }
22
21
 
23
22
  /**
24
- * @param {LH.Artifacts.NavigationMetricComputationData} data
23
+ * @param {LH.Artifacts.MetricComputationData} data
25
24
  * @return {Promise<LH.Artifacts.Metric>}
26
25
  */
27
26
  static async computeObservedMetric(data) {
28
- const {processedNavigation} = data;
27
+ const {traceOfTab} = data;
29
28
 
30
29
  return {
31
- timing: processedNavigation.timings.firstContentfulPaint,
32
- timestamp: processedNavigation.timestamps.firstContentfulPaint,
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 NavigationMetric = require('./navigation-metric.js');
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 NavigationMetric {
13
+ class FirstMeaningfulPaint extends ComputedMetric {
14
14
  /**
15
- * @param {LH.Artifacts.NavigationMetricComputationData} data
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
- const metricData = NavigationMetric.getMetricComputationInput(data);
21
- return LanternFirstMeaningfulPaint.request(metricData, context);
20
+ return LanternFirstMeaningfulPaint.request(data, context);
22
21
  }
23
22
 
24
23
  /**
25
- * @param {LH.Artifacts.NavigationMetricComputationData} data
24
+ * @param {LH.Artifacts.MetricComputationData} data
26
25
  * @return {Promise<LH.Artifacts.Metric>}
27
26
  */
28
27
  static async computeObservedMetric(data) {
29
- const {processedNavigation} = data;
30
- if (processedNavigation.timings.firstMeaningfulPaint === undefined) {
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: processedNavigation.timings.firstMeaningfulPaint,
36
- timestamp: processedNavigation.timestamps.firstMeaningfulPaint,
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 NavigationMetric = require('./navigation-metric.js');
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 NavigationMetric {
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}}} processedNavigation
29
+ * @param {{timestamps: {traceEnd: number}}} traceOfTab
30
30
  * @return {Array<TimePeriod>}
31
31
  */
32
- static _findNetworkQuietPeriods(networkRecords, processedNavigation) {
33
- const traceEndTsInMs = processedNavigation.timestamps.traceEnd / 1000;
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}}} processedNavigation
47
+ * @param {{timestamps: {timeOrigin: number, traceEnd: number}}} traceOfTab
48
48
  * @return {Array<TimePeriod>}
49
49
  */
50
- static _findCPUQuietPeriods(longTasks, processedNavigation) {
51
- const timeOriginTsInMs = processedNavigation.timestamps.timeOrigin / 1000;
52
- const traceEndTsInMs = processedNavigation.timestamps.traceEnd / 1000;
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.ProcessedNavigation} processedNavigation
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, processedNavigation) {
91
- const FcpTsInMs = processedNavigation.timestamps.firstContentfulPaint / 1000;
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, processedNavigation)
97
+ const networkQuietPeriods = this._findNetworkQuietPeriods(networkRecords, traceOfTab)
98
98
  .filter(isLongEnoughQuietPeriod);
99
- const cpuQuietPeriods = this._findCPUQuietPeriods(longTasks, processedNavigation)
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.NavigationMetricComputationData} data
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
- const metricData = NavigationMetric.getMetricComputationInput(data);
150
- return LanternInteractive.request(metricData, context);
149
+ return LanternInteractive.request(data, context);
151
150
  }
152
151
 
153
152
  /**
154
- * @param {LH.Artifacts.NavigationMetricComputationData} data
153
+ * @param {LH.Artifacts.MetricComputationData} data
155
154
  * @return {Promise<LH.Artifacts.Metric>}
156
155
  */
157
156
  static computeObservedMetric(data) {
158
- const {processedTrace, processedNavigation, networkRecords} = data;
157
+ const {traceOfTab, networkRecords} = data;
159
158
 
160
- if (!processedNavigation.timestamps.domContentLoaded) {
159
+ if (!traceOfTab.timestamps.domContentLoaded) {
161
160
  throw new LHError(LHError.errors.NO_DCL);
162
161
  }
163
162
 
164
- const longTasks = TracingProcessor.getMainThreadTopLevelEvents(processedTrace)
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
- processedNavigation
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
- processedNavigation.timestamps.firstContentfulPaint / 1000,
177
- processedNavigation.timestamps.domContentLoaded / 1000
175
+ traceOfTab.timestamps.firstContentfulPaint / 1000,
176
+ traceOfTab.timestamps.domContentLoaded / 1000
178
177
  ) * 1000;
179
- const timing = (timestamp - processedNavigation.timestamps.timeOrigin) / 1000;
178
+ const timing = (timestamp - traceOfTab.timestamps.timeOrigin) / 1000;
180
179
  return Promise.resolve({timing, timestamp});
181
180
  }
182
181
  }