lighthouse 9.3.1 → 9.4.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 (58) hide show
  1. package/dist/report/bundle.esm.js +38 -24
  2. package/dist/report/flow.js +5 -5
  3. package/dist/report/standalone.js +9 -9
  4. package/flow-report/src/topbar.tsx +1 -1
  5. package/flow-report/src/wrappers/report.tsx +2 -1
  6. package/flow-report/test/topbar-test.tsx +1 -1
  7. package/lighthouse-cli/bin.js +1 -4
  8. package/lighthouse-cli/run.js +1 -1
  9. package/lighthouse-cli/test/smokehouse/core-tests.js +4 -5
  10. package/lighthouse-cli/test/smokehouse/readme.md +4 -0
  11. package/lighthouse-cli/test/smokehouse/report-assert.js +36 -0
  12. package/lighthouse-core/audits/autocomplete.js +34 -37
  13. package/lighthouse-core/audits/byte-efficiency/uses-long-cache-ttl.js +1 -0
  14. package/lighthouse-core/audits/seo/hreflang.js +2 -17
  15. package/lighthouse-core/config/default-config.js +2 -2
  16. package/lighthouse-core/fraggle-rock/config/default-config.js +3 -3
  17. package/lighthouse-core/fraggle-rock/gather/navigation-runner.js +50 -31
  18. package/lighthouse-core/fraggle-rock/gather/snapshot-runner.js +4 -5
  19. package/lighthouse-core/fraggle-rock/gather/timespan-runner.js +4 -5
  20. package/lighthouse-core/fraggle-rock/user-flow.js +8 -6
  21. package/lighthouse-core/gather/driver/navigation.js +29 -10
  22. package/lighthouse-core/gather/driver/network-monitor.js +8 -6
  23. package/lighthouse-core/gather/driver/prepare.js +13 -7
  24. package/lighthouse-core/gather/driver/wait-for-condition.js +11 -4
  25. package/lighthouse-core/gather/gather-runner.js +1 -1
  26. package/lighthouse-core/gather/gatherers/full-page-screenshot.js +35 -9
  27. package/lighthouse-core/gather/gatherers/inputs.js +113 -0
  28. package/lighthouse-core/index.js +3 -3
  29. package/lighthouse-core/lib/page-functions.js +11 -1
  30. package/lighthouse-core/lib/sentry.js +39 -24
  31. package/lighthouse-core/runner.js +79 -52
  32. package/lighthouse-core/util-commonjs.js +4 -0
  33. package/package.json +2 -3
  34. package/readme.md +1 -1
  35. package/report/assets/templates.html +2 -5
  36. package/report/renderer/components.js +3 -3
  37. package/report/renderer/dom.js +1 -3
  38. package/report/renderer/report-ui-features.js +25 -17
  39. package/report/renderer/topbar-features.js +5 -1
  40. package/report/renderer/util.js +4 -0
  41. package/report/test/renderer/__snapshots__/report-renderer-axe-test.js.snap +107 -0
  42. package/report/test/renderer/report-renderer-axe-test.js +38 -17
  43. package/report/test-assets/faux-psi.js +2 -1
  44. package/report/types/report-renderer.d.ts +21 -2
  45. package/shared/localization/locales/en-US.json +7 -1
  46. package/shared/localization/locales/en-XL.json +7 -1
  47. package/third-party/axe/LICENSE +362 -0
  48. package/third-party/axe/README.md +6 -0
  49. package/third-party/axe/valid-langs.js +110 -0
  50. package/third-party/snyk/snapshot.json +1 -0
  51. package/tsconfig.json +1 -0
  52. package/types/artifacts.d.ts +14 -14
  53. package/types/global-lh.d.ts +1 -0
  54. package/types/parse-cache-control/index.d.ts +1 -0
  55. package/types/smokehouse.d.ts +3 -0
  56. package/changelog.md +0 -5803
  57. package/lighthouse-core/gather/gatherers/form-elements.js +0 -113
  58. package/lighthouse-core/scripts/package.json +0 -4
@@ -626,6 +626,10 @@ const UIStrings = {
626
626
  thirdPartyResourcesLabel: 'Show 3rd-party resources',
627
627
  /** This label is for a button that opens a new tab to a webapp called "Treemap", which is a nested visual representation of a heierarchy of data related to the reports (script bytes and coverage, resource breakdown, etc.) */
628
628
  viewTreemapLabel: 'View Treemap',
629
+ /** This label is for a button that will show the user a trace of the page. */
630
+ viewTraceLabel: 'View Trace',
631
+ /** This label is for a button that will show the user a trace of the page. */
632
+ viewOriginalTraceLabel: 'View Original Trace',
629
633
 
630
634
  /** Option in a dropdown menu that opens a small, summary report in a print dialog. */
631
635
  dropdownPrintSummary: 'Print Summary',
@@ -1041,7 +1045,7 @@ function createGaugePwaComponent(dom) {
1041
1045
  function createHeadingComponent(dom) {
1042
1046
  const el0 = dom.createFragment();
1043
1047
  const el1 = dom.createElement('style');
1044
- el1.append('\n /* CSS Fireworks. Originally by Eddie Lin\n https://codepen.io/paulirish/pen/yEVMbP\n */\n .lh-pyro {\n display: none;\n z-index: 1;\n pointer-events: none;\n }\n .lh-score100 .lh-pyro {\n display: block;\n }\n .lh-score100 .lh-lighthouse stop:first-child {\n stop-color: hsla(200, 12%, 95%, 0);\n }\n .lh-score100 .lh-lighthouse stop:last-child {\n stop-color: hsla(65, 81%, 76%, 1);\n }\n\n .lh-pyro > .lh-pyro-before, .lh-pyro > .lh-pyro-after {\n position: absolute;\n width: 5px;\n height: 5px;\n border-radius: 2.5px;\n box-shadow: 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff;\n animation: 1s bang ease-out infinite backwards, 1s gravity ease-in infinite backwards, 5s position linear infinite backwards;\n animation-delay: 1s, 1s, 1s;\n }\n\n .lh-pyro > .lh-pyro-after {\n animation-delay: 2.25s, 2.25s, 2.25s;\n animation-duration: 1.25s, 1.25s, 6.25s;\n }\n .lh-fireworks-paused .lh-pyro > div {\n animation-play-state: paused;\n }\n\n @keyframes bang {\n to {\n box-shadow: -70px -115.67px #47ebbc, -28px -99.67px #eb47a4, 58px -31.67px #7eeb47, 13px -141.67px #eb47c5, -19px 6.33px #7347eb, -2px -74.67px #ebd247, 24px -151.67px #eb47e0, 57px -138.67px #b4eb47, -51px -104.67px #479eeb, 62px 8.33px #ebcf47, -93px 0.33px #d547eb, -16px -118.67px #47bfeb, 53px -84.67px #47eb83, 66px -57.67px #eb47bf, -93px -65.67px #91eb47, 30px -13.67px #86eb47, -2px -59.67px #83eb47, -44px 1.33px #eb47eb, 61px -58.67px #47eb73, 5px -22.67px #47e8eb, -66px -28.67px #ebe247, 42px -123.67px #eb5547, -75px 26.33px #7beb47, 15px -52.67px #a147eb, 36px -51.67px #eb8347, -38px -12.67px #eb5547, -46px -59.67px #47eb81, 78px -114.67px #eb47ba, 15px -156.67px #eb47bf, -36px 1.33px #eb4783, -72px -86.67px #eba147, 31px -46.67px #ebe247, -68px 29.33px #47e2eb, -55px 19.33px #ebe047, -56px 27.33px #4776eb, -13px -91.67px #eb5547, -47px -138.67px #47ebc7, -18px -96.67px #eb47ac, 11px -88.67px #4783eb, -67px -28.67px #47baeb, 53px 10.33px #ba47eb, 11px 19.33px #5247eb, -5px -11.67px #eb4791, -68px -4.67px #47eba7, 95px -37.67px #eb478b, -67px -162.67px #eb5d47, -54px -120.67px #eb6847, 49px -12.67px #ebe047, 88px 8.33px #47ebda, 97px 33.33px #eb8147, 6px -71.67px #ebbc47;\n }\n }\n @keyframes gravity {\n to {\n transform: translateY(80px);\n opacity: 0;\n }\n }\n @keyframes position {\n 0%, 19.9% {\n margin-top: 4%;\n margin-left: 47%;\n }\n 20%, 39.9% {\n margin-top: 7%;\n margin-left: 30%;\n }\n 40%, 59.9% {\n margin-top: 6%;\n margin-left: 70%;\n }\n 60%, 79.9% {\n margin-top: 3%;\n margin-left: 20%;\n }\n 80%, 99.9% {\n margin-top: 3%;\n margin-left: 80%;\n }\n }\n ');
1048
+ el1.append('\n /* CSS Fireworks. Originally by Eddie Lin\n https://codepen.io/paulirish/pen/yEVMbP\n */\n .lh-pyro {\n display: none;\n z-index: 1;\n pointer-events: none;\n }\n .lh-score100 .lh-pyro {\n display: block;\n }\n .lh-score100 .lh-lighthouse stop:first-child {\n stop-color: hsla(200, 12%, 95%, 0);\n }\n .lh-score100 .lh-lighthouse stop:last-child {\n stop-color: hsla(65, 81%, 76%, 1);\n }\n\n .lh-pyro > .lh-pyro-before, .lh-pyro > .lh-pyro-after {\n position: absolute;\n width: 5px;\n height: 5px;\n border-radius: 2.5px;\n box-shadow: 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff, 0 0 #fff;\n animation: 1s bang ease-out infinite backwards, 1s gravity ease-in infinite backwards, 5s position linear infinite backwards;\n animation-delay: 1s, 1s, 1s;\n }\n\n .lh-pyro > .lh-pyro-after {\n animation-delay: 2.25s, 2.25s, 2.25s;\n animation-duration: 1.25s, 1.25s, 6.25s;\n }\n\n @keyframes bang {\n to {\n box-shadow: -70px -115.67px #47ebbc, -28px -99.67px #eb47a4, 58px -31.67px #7eeb47, 13px -141.67px #eb47c5, -19px 6.33px #7347eb, -2px -74.67px #ebd247, 24px -151.67px #eb47e0, 57px -138.67px #b4eb47, -51px -104.67px #479eeb, 62px 8.33px #ebcf47, -93px 0.33px #d547eb, -16px -118.67px #47bfeb, 53px -84.67px #47eb83, 66px -57.67px #eb47bf, -93px -65.67px #91eb47, 30px -13.67px #86eb47, -2px -59.67px #83eb47, -44px 1.33px #eb47eb, 61px -58.67px #47eb73, 5px -22.67px #47e8eb, -66px -28.67px #ebe247, 42px -123.67px #eb5547, -75px 26.33px #7beb47, 15px -52.67px #a147eb, 36px -51.67px #eb8347, -38px -12.67px #eb5547, -46px -59.67px #47eb81, 78px -114.67px #eb47ba, 15px -156.67px #eb47bf, -36px 1.33px #eb4783, -72px -86.67px #eba147, 31px -46.67px #ebe247, -68px 29.33px #47e2eb, -55px 19.33px #ebe047, -56px 27.33px #4776eb, -13px -91.67px #eb5547, -47px -138.67px #47ebc7, -18px -96.67px #eb47ac, 11px -88.67px #4783eb, -67px -28.67px #47baeb, 53px 10.33px #ba47eb, 11px 19.33px #5247eb, -5px -11.67px #eb4791, -68px -4.67px #47eba7, 95px -37.67px #eb478b, -67px -162.67px #eb5d47, -54px -120.67px #eb6847, 49px -12.67px #ebe047, 88px 8.33px #47ebda, 97px 33.33px #eb8147, 6px -71.67px #ebbc47;\n }\n }\n @keyframes gravity {\n to {\n transform: translateY(80px);\n opacity: 0;\n }\n }\n @keyframes position {\n 0%, 19.9% {\n margin-top: 4%;\n margin-left: 47%;\n }\n 20%, 39.9% {\n margin-top: 7%;\n margin-left: 30%;\n }\n 40%, 59.9% {\n margin-top: 6%;\n margin-left: 70%;\n }\n 60%, 79.9% {\n margin-top: 3%;\n margin-left: 20%;\n }\n 80%, 99.9% {\n margin-top: 3%;\n margin-left: 80%;\n }\n }\n ');
1045
1049
  el0.append(el1);
1046
1050
  const el2 = dom.createElement('div', 'lh-header-container');
1047
1051
  const el3 = dom.createElement('div', 'lh-scores-wrapper-placeholder');
@@ -1142,8 +1146,8 @@ function createScoresWrapperComponent(dom) {
1142
1146
  const el2 = dom.createElement('div', 'lh-scores-wrapper');
1143
1147
  const el3 = dom.createElement('div', 'lh-scores-container');
1144
1148
  const el4 = dom.createElement('div', 'lh-pyro');
1145
- const el5 = dom.createElement('div', 'lh-before');
1146
- const el6 = dom.createElement('div', 'lh-after');
1149
+ const el5 = dom.createElement('div', 'lh-pyro-before');
1150
+ const el6 = dom.createElement('div', 'lh-pyro-after');
1147
1151
  el4.append(' ', el5, ' ', el6, ' ');
1148
1152
  el3.append(' ', el4, ' ');
1149
1153
  el2.append(' ', el3, ' ');
@@ -1772,10 +1776,8 @@ class DOM {
1772
1776
  * @param {string} filename
1773
1777
  */
1774
1778
  saveFile(blob, filename) {
1775
- const ext = blob.type.match('json') ? '.json' : '.html';
1776
-
1777
1779
  const a = this.createElement('a');
1778
- a.download = `${filename}${ext}`;
1780
+ a.download = filename;
1779
1781
  this.safelySetBlobHref(a, blob);
1780
1782
  this._document.body.appendChild(a); // Firefox requires anchor to be in the DOM.
1781
1783
  a.click();
@@ -5497,7 +5499,11 @@ class TopbarFeatures {
5497
5499
  }
5498
5500
 
5499
5501
  _print() {
5500
- self.print();
5502
+ if (this._reportUIFeatures._opts.onPrintOverride) {
5503
+ this._reportUIFeatures._opts.onPrintOverride(this._dom.rootEl);
5504
+ } else {
5505
+ self.print();
5506
+ }
5501
5507
  }
5502
5508
 
5503
5509
  /**
@@ -5725,12 +5731,13 @@ class ReportUIFeatures {
5725
5731
  this._setupThirdPartyFilter();
5726
5732
  this._setupElementScreenshotOverlay(this._dom.rootEl);
5727
5733
 
5728
- let turnOffTheLights = false;
5729
5734
  // Do not query the system preferences for DevTools - DevTools should only apply dark theme
5730
5735
  // if dark is selected in the settings panel.
5731
- const disableDarkMode = this._dom.isDevTools() || this._opts.disableAutoDarkModeAndFireworks;
5736
+ // TODO: set `disableDarkMode` in devtools and delete this special case.
5737
+ const disableDarkMode = this._dom.isDevTools() ||
5738
+ this._opts.disableDarkMode || this._opts.disableAutoDarkModeAndFireworks;
5732
5739
  if (!disableDarkMode && window.matchMedia('(prefers-color-scheme: dark)').matches) {
5733
- turnOffTheLights = true;
5740
+ toggleDarkTheme(this._dom, true);
5734
5741
  }
5735
5742
 
5736
5743
  // Fireworks!
@@ -5740,13 +5747,12 @@ class ReportUIFeatures {
5740
5747
  const cat = lhr.categories[id];
5741
5748
  return cat && cat.score === 1;
5742
5749
  });
5743
- if (scoresAll100 && !this._opts.disableAutoDarkModeAndFireworks) {
5744
- turnOffTheLights = true;
5750
+ const disableFireworks =
5751
+ this._opts.disableFireworks || this._opts.disableAutoDarkModeAndFireworks;
5752
+ if (scoresAll100 && !disableFireworks) {
5745
5753
  this._enableFireworks();
5746
- }
5747
-
5748
- if (turnOffTheLights) {
5749
- toggleDarkTheme(this._dom, true);
5754
+ // If dark mode is allowed, force it on because it looks so much better.
5755
+ if (!disableDarkMode) toggleDarkTheme(this._dom, true);
5750
5756
  }
5751
5757
 
5752
5758
  // Show the metric descriptions by default when there is an error.
@@ -5767,6 +5773,15 @@ class ReportUIFeatures {
5767
5773
  });
5768
5774
  }
5769
5775
 
5776
+ if (this._opts.onViewTrace) {
5777
+ this.addButton({
5778
+ text: lhr.configSettings.throttlingMethod === 'simulate' ?
5779
+ Util.i18n.strings.viewOriginalTraceLabel :
5780
+ Util.i18n.strings.viewTraceLabel,
5781
+ onClick: () => this._opts.onViewTrace?.(),
5782
+ });
5783
+ }
5784
+
5770
5785
  if (this._opts.getStandaloneReportHTML) {
5771
5786
  this._dom.find('a[data-action="save-html"]', this._dom.rootEl).classList.remove('lh-hidden');
5772
5787
  }
@@ -5835,9 +5850,6 @@ class ReportUIFeatures {
5835
5850
  _enableFireworks() {
5836
5851
  const scoresContainer = this._dom.find('.lh-scores-container', this._dom.rootEl);
5837
5852
  scoresContainer.classList.add('lh-score100');
5838
- scoresContainer.addEventListener('click', _ => {
5839
- scoresContainer.classList.toggle('lh-fireworks-paused');
5840
- });
5841
5853
  }
5842
5854
 
5843
5855
  _setupMediaQueryListeners() {
@@ -5994,14 +6006,16 @@ class ReportUIFeatures {
5994
6006
  }
5995
6007
 
5996
6008
  /**
5997
- * DevTools uses its own file manager to download files, so it redefines this function.
5998
- * Wrapper is necessary so DevTools can still override this function.
5999
- *
6000
6009
  * @param {Blob|File} blob
6001
6010
  */
6002
6011
  _saveFile(blob) {
6003
- const filename = fileNamer.getLhrFilenamePrefix(this.json);
6004
- this._dom.saveFile(blob, filename);
6012
+ const ext = blob.type.match('json') ? '.json' : '.html';
6013
+ const filename = fileNamer.getLhrFilenamePrefix(this.json) + ext;
6014
+ if (this._opts.onSaveFileOverride) {
6015
+ this._opts.onSaveFileOverride(blob, filename);
6016
+ } else {
6017
+ this._dom.saveFile(blob, filename);
6018
+ }
6005
6019
  }
6006
6020
  }
6007
6021