lighthouse 8.6.0-dev.20211031 → 8.6.0-dev.20211101

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 (44) hide show
  1. package/dist/report/flow.js +7 -7
  2. package/dist/report/standalone.js +7 -7
  3. package/flow-report/src/app.tsx +10 -11
  4. package/flow-report/src/common.tsx +11 -5
  5. package/flow-report/src/header.tsx +3 -3
  6. package/flow-report/src/sidebar/flow.tsx +3 -3
  7. package/flow-report/src/sidebar/sidebar.tsx +3 -3
  8. package/flow-report/src/summary/category.tsx +2 -2
  9. package/flow-report/src/util.ts +12 -12
  10. package/flow-report/src/wrappers/report.tsx +11 -6
  11. package/flow-report/test/common-test.tsx +25 -10
  12. package/flow-report/test/header-test.tsx +6 -6
  13. package/flow-report/test/summary/category-test.tsx +5 -5
  14. package/flow-report/test/util-test.tsx +32 -11
  15. package/lighthouse-cli/test/smokehouse/lighthouse-runners/bundle.js +4 -2
  16. package/lighthouse-cli/test/smokehouse/smokehouse.js +1 -1
  17. package/lighthouse-core/computed/metrics/lantern-total-blocking-time.js +3 -4
  18. package/lighthouse-core/computed/metrics/tbt-utils.js +57 -0
  19. package/lighthouse-core/computed/metrics/total-blocking-time.js +3 -53
  20. package/lighthouse-core/config/config-helpers.js +20 -10
  21. package/lighthouse-core/config/default-config.js +59 -53
  22. package/lighthouse-core/fraggle-rock/config/default-config.js +1 -1
  23. package/lighthouse-core/fraggle-rock/gather/base-gatherer.js +6 -1
  24. package/lighthouse-core/gather/gatherers/dobetterweb/response-compression.js +1 -0
  25. package/lighthouse-core/lib/asset-saver.js +4 -1
  26. package/lighthouse-core/lib/lh-env.js +2 -0
  27. package/lighthouse-core/lib/tappable-rects.js +8 -15
  28. package/lighthouse-core/runner.js +1 -1
  29. package/lighthouse-core/util-commonjs.js +1 -2
  30. package/package.json +9 -6
  31. package/report/clients/standalone.js +0 -2
  32. package/report/renderer/element-screenshot-renderer.js +2 -2
  33. package/report/renderer/performance-category-renderer.js +20 -5
  34. package/report/renderer/util.js +1 -2
  35. package/report/test/renderer/performance-category-renderer-test.js +34 -8
  36. package/report/test/renderer/report-renderer-test.js +1 -1
  37. package/report/test/renderer/report-ui-features-test.js +3 -0
  38. package/report/test/renderer/util-test.js +13 -31
  39. package/shared/localization/format.js +9 -4
  40. package/shared/localization/locales/en-US.json +1 -1
  41. package/shared/localization/locales/en-XL.json +1 -1
  42. package/third-party/chromium-synchronization/installability-errors-test.js +2 -0
  43. package/types/lhr/flow.d.ts +3 -2
  44. package/types/rollup-plugin-postprocess.d.ts +10 -0
@@ -96,11 +96,23 @@ describe('PerfCategoryRenderer', () => {
96
96
  assert.strictEqual(new URL(calcLink.href).hostname, 'googlechrome.github.io');
97
97
  });
98
98
 
99
+ it('ignores hidden audits', () => {
100
+ const categoryDOM = renderer.render(category, sampleResults.categoryGroups);
101
+
102
+ const hiddenAudits = category.auditRefs.filter(audit => audit.group === 'hidden');
103
+ const auditElements = [...categoryDOM.querySelectorAll('.lh-audit')];
104
+ const matchingElements = auditElements
105
+ .filter(el => hiddenAudits.some(audit => audit.id === el.id));
106
+ expect(matchingElements).toHaveLength(0);
107
+ });
108
+
99
109
  it('renders the failing performance opportunities', () => {
100
110
  const categoryDOM = renderer.render(category, sampleResults.categoryGroups);
101
111
 
102
- const oppAudits = category.auditRefs.filter(audit => audit.group === 'load-opportunities' &&
103
- !Util.showAsPassed(audit.result));
112
+ const oppAudits = category.auditRefs.filter(audit =>
113
+ audit.result.details &&
114
+ audit.result.details.type === 'opportunity' &&
115
+ !Util.showAsPassed(audit.result));
104
116
  const oppElements = [...categoryDOM.querySelectorAll('.lh-audit--load-opportunity')];
105
117
  expect(oppElements.map(e => e.id).sort()).toEqual(oppAudits.map(a => a.id).sort());
106
118
  expect(oppElements.length).toBeGreaterThan(0);
@@ -120,10 +132,14 @@ describe('PerfCategoryRenderer', () => {
120
132
  it('renders performance opportunities with an errorMessage', () => {
121
133
  const auditWithError = {
122
134
  score: 0,
123
- group: 'load-opportunities',
124
135
  result: {
125
136
  score: null, scoreDisplayMode: 'error', errorMessage: 'Yikes!!', title: 'Bug #2',
126
137
  description: '',
138
+ details: {
139
+ overallSavingsMs: 0,
140
+ items: [],
141
+ type: 'opportunity',
142
+ },
127
143
  },
128
144
  };
129
145
 
@@ -137,10 +153,14 @@ describe('PerfCategoryRenderer', () => {
137
153
  it('renders performance opportunities\' explanation', () => {
138
154
  const auditWithExplanation = {
139
155
  score: 0,
140
- group: 'load-opportunities',
141
156
  result: {
142
157
  score: 0, scoreDisplayMode: 'numeric',
143
158
  numericValue: 100, explanation: 'Yikes!!', title: 'Bug #2', description: '',
159
+ details: {
160
+ overallSavingsMs: 0,
161
+ items: [],
162
+ type: 'opportunity',
163
+ },
144
164
  },
145
165
  };
146
166
 
@@ -159,7 +179,9 @@ describe('PerfCategoryRenderer', () => {
159
179
  '.lh-category > .lh-audit-group.lh-audit-group--diagnostics');
160
180
 
161
181
  const diagnosticAuditIds = category.auditRefs.filter(audit => {
162
- return audit.group === 'diagnostics' && !Util.showAsPassed(audit.result);
182
+ return !audit.group &&
183
+ !(audit.result.details && audit.result.details.type === 'opportunity') &&
184
+ !Util.showAsPassed(audit.result);
163
185
  }).map(audit => audit.id).sort();
164
186
  assert.ok(diagnosticAuditIds.length > 0);
165
187
 
@@ -173,8 +195,8 @@ describe('PerfCategoryRenderer', () => {
173
195
  const passedSection = categoryDOM.querySelector('.lh-category > .lh-clump--passed');
174
196
 
175
197
  const passedAudits = category.auditRefs.filter(audit =>
176
- audit.group && audit.group !== 'metrics' && audit.id !== 'performance-budget'
177
- && Util.showAsPassed(audit.result));
198
+ !audit.group &&
199
+ Util.showAsPassed(audit.result));
178
200
  const passedElements = passedSection.querySelectorAll('.lh-audit');
179
201
  assert.equal(passedElements.length, passedAudits.length);
180
202
  });
@@ -187,10 +209,14 @@ describe('PerfCategoryRenderer', () => {
187
209
  it('handles erroring opportunities', () => {
188
210
  const auditWithDebug = {
189
211
  score: 0,
190
- group: 'load-opportunities',
191
212
  result: {
192
213
  error: true, score: 0,
193
214
  numericValue: 100, explanation: 'Yikes!!', title: 'Bug #2',
215
+ details: {
216
+ overallSavingsMs: 0,
217
+ items: [],
218
+ type: 'opportunity',
219
+ },
194
220
  },
195
221
  };
196
222
  const wastedMs = renderer._getWastedMs(auditWithDebug);
@@ -90,7 +90,7 @@ describe('ReportRenderer', () => {
90
90
  const output = renderer.renderReport(sampleResultsCopy, container);
91
91
 
92
92
  function isPWAGauge(el) {
93
- return el.querySelector('.lh-gauge__label').textContent === 'Progressive Web App';
93
+ return el.querySelector('.lh-gauge__label').textContent === 'PWA';
94
94
  }
95
95
  function isPluginGauge(el) {
96
96
  return el.querySelector('.lh-gauge__label').textContent === 'Some Plugin';
@@ -515,6 +515,9 @@ describe('ReportUIFeatures', () => {
515
515
  expect(render(lhr).querySelector('.lh-button.lh-report-icon--treemap')).toBeTruthy();
516
516
 
517
517
  delete lhr.audits['script-treemap-data'];
518
+ const newAuditRefs = lhr.categories['performance'].auditRefs
519
+ .filter(a => a.id !== 'script-treemap-data');
520
+ lhr.categories['performance'].auditRefs = newAuditRefs;
518
521
  expect(render(lhr).querySelector('.lh-button.lh-report-icon--treemap')).toBeNull();
519
522
  });
520
523
  });
@@ -401,10 +401,10 @@ describe('util helpers', () => {
401
401
  const category = {
402
402
  id: 'performance',
403
403
  auditRefs: [
404
- {weight: 3, result: {score: 1, scoreDisplayMode: 'binary'}, group: 'diagnostics'},
405
- {weight: 2, result: {score: 1, scoreDisplayMode: 'binary'}, group: 'diagnostics'},
406
- {weight: 0, result: {score: 1, scoreDisplayMode: 'binary'}, group: 'diagnostics'},
407
- {weight: 1, result: {score: 0, scoreDisplayMode: 'binary'}, group: 'diagnostics'},
404
+ {weight: 3, result: {score: 1, scoreDisplayMode: 'binary'}, group: 'metrics'},
405
+ {weight: 2, result: {score: 1, scoreDisplayMode: 'binary'}, group: 'metrics'},
406
+ {weight: 0, result: {score: 1, scoreDisplayMode: 'binary'}, group: 'metrics'},
407
+ {weight: 1, result: {score: 0, scoreDisplayMode: 'binary'}, group: 'metrics'},
408
408
  ],
409
409
  };
410
410
  const fraction = Util.calculateCategoryFraction(category);
@@ -416,14 +416,14 @@ describe('util helpers', () => {
416
416
  });
417
417
  });
418
418
 
419
- it('ignores manual audits, N/A audits, and performance audits with no group', () => {
419
+ it('ignores manual audits, N/A audits, and hidden audits', () => {
420
420
  const category = {
421
421
  id: 'performance',
422
422
  auditRefs: [
423
- {weight: 1, result: {score: 1, scoreDisplayMode: 'binary'}, group: 'diagnostics'},
424
- {weight: 1, result: {score: 1, scoreDisplayMode: 'binary'}},
425
- {weight: 1, result: {score: 0, scoreDisplayMode: 'manual'}, group: 'diagnostics'},
426
- {weight: 1, result: {score: 0, scoreDisplayMode: 'notApplicable'}, group: 'diagnostics'},
423
+ {weight: 1, result: {score: 1, scoreDisplayMode: 'binary'}, group: 'metrics'},
424
+ {weight: 1, result: {score: 1, scoreDisplayMode: 'binary'}, group: 'hidden'},
425
+ {weight: 1, result: {score: 0, scoreDisplayMode: 'manual'}, group: 'metrics'},
426
+ {weight: 1, result: {score: 0, scoreDisplayMode: 'notApplicable'}, group: 'metrics'},
427
427
  ],
428
428
  };
429
429
  const fraction = Util.calculateCategoryFraction(category);
@@ -435,32 +435,14 @@ describe('util helpers', () => {
435
435
  });
436
436
  });
437
437
 
438
- it('does not ignore audits with no group in non-performance category', () => {
439
- const category = {
440
- id: 'seo',
441
- auditRefs: [
442
- {weight: 1, result: {score: 1, scoreDisplayMode: 'binary'}, group: 'diagnostics'},
443
- {weight: 1, result: {score: 1, scoreDisplayMode: 'binary'}},
444
- {weight: 1, result: {score: 0, scoreDisplayMode: 'manual'}, group: 'diagnostics'},
445
- ],
446
- };
447
- const fraction = Util.calculateCategoryFraction(category);
448
- expect(fraction).toEqual({
449
- numPassableAudits: 2,
450
- numPassed: 2,
451
- numInformative: 0,
452
- totalWeight: 2,
453
- });
454
- });
455
-
456
438
  it('tracks informative audits separately', () => {
457
439
  const category = {
458
440
  id: 'performance',
459
441
  auditRefs: [
460
- {weight: 1, result: {score: 1, scoreDisplayMode: 'binary'}, group: 'diagnostics'},
461
- {weight: 1, result: {score: 1, scoreDisplayMode: 'binary'}, group: 'diagnostics'},
462
- {weight: 0, result: {score: 1, scoreDisplayMode: 'informative'}, group: 'diagnostics'},
463
- {weight: 1, result: {score: 0, scoreDisplayMode: 'informative'}, group: 'diagnostics'},
442
+ {weight: 1, result: {score: 1, scoreDisplayMode: 'binary'}, group: 'metrics'},
443
+ {weight: 1, result: {score: 1, scoreDisplayMode: 'binary'}, group: 'metrics'},
444
+ {weight: 0, result: {score: 1, scoreDisplayMode: 'informative'}, group: 'metrics'},
445
+ {weight: 1, result: {score: 0, scoreDisplayMode: 'informative'}, group: 'metrics'},
464
446
  ],
465
447
  };
466
448
  const fraction = Util.calculateCategoryFraction(category);
@@ -7,11 +7,13 @@
7
7
 
8
8
  const fs = require('fs');
9
9
 
10
- const MessageFormat = require('intl-messageformat').default;
10
+ const MessageFormat = require('intl-messageformat');
11
11
  const {isObjectOfUnknownValues, isObjectOrArrayOfUnknownValues} = require('../type-verifiers.js');
12
12
 
13
13
  /** Contains available locales with messages. May be an empty object if bundled. */
14
- const LOCALE_MESSAGES = require('./locales.js');
14
+ /** @type {import('./locales')} */
15
+ // @ts-expect-error TODO(esmodules): remove when file is es modules.
16
+ const LOCALE_MESSAGES = require('./locales.js').default || require('./locales.js');
15
17
 
16
18
  const DEFAULT_LOCALE = 'en-US';
17
19
 
@@ -93,7 +95,7 @@ function collectAllCustomElementsFromICU(icuElements, seenElementsById = new Map
93
95
  * Returns a copy of the `values` object, with the values formatted based on how
94
96
  * they will be used in their icuMessage, e.g. KB or milliseconds. The original
95
97
  * object is unchanged.
96
- * @param {MessageFormat} messageFormatter
98
+ * @param {MessageFormat.IntlMessageFormat} messageFormatter
97
99
  * @param {Readonly<Record<string, string | number>>} values
98
100
  * @param {string} lhlMessage Used for clear error logging.
99
101
  * @return {Record<string, string | number>}
@@ -171,7 +173,10 @@ function formatMessage(message, values = {}, locale) {
171
173
  // When using accented english, force the use of a different locale for number formatting.
172
174
  const localeForMessageFormat = (locale === 'en-XA' || locale === 'en-XL') ? 'de-DE' : locale;
173
175
 
174
- const formatter = new MessageFormat(message, localeForMessageFormat, formats);
176
+ // This package is not correctly bundled by Rollup.
177
+ /** @type {typeof MessageFormat.IntlMessageFormat} */
178
+ const MessageFormatCtor = MessageFormat.IntlMessageFormat || MessageFormat;
179
+ const formatter = new MessageFormatCtor(message, localeForMessageFormat, formats);
175
180
 
176
181
  // Preformat values for the message format like KB and milliseconds.
177
182
  const valuesForMessageFormat = _preformatValues(formatter, values, message);
@@ -1776,7 +1776,7 @@
1776
1776
  "message": "These checks are required by the baseline [PWA Checklist](https://developers.google.com/web/progressive-web-apps/checklist) but are not automatically checked by Lighthouse. They do not affect your score but it's important that you verify them manually."
1777
1777
  },
1778
1778
  "lighthouse-core/config/default-config.js | pwaCategoryTitle": {
1779
- "message": "Progressive Web App"
1779
+ "message": "PWA"
1780
1780
  },
1781
1781
  "lighthouse-core/config/default-config.js | pwaInstallableGroupTitle": {
1782
1782
  "message": "Installable"
@@ -1776,7 +1776,7 @@
1776
1776
  "message": "T̂h́êśê ćĥéĉḱŝ ár̂é r̂éq̂úîŕêd́ b̂ý t̂h́ê b́âśêĺîńê [ṔŴÁ Ĉh́êćk̂ĺîśt̂](https://developers.google.com/web/progressive-web-apps/checklist) b́ût́ âŕê ńôt́ âút̂óm̂át̂íĉál̂ĺŷ ćĥéĉḱêd́ b̂ý L̂íĝh́t̂h́ôúŝé. T̂h́êý d̂ó n̂ót̂ áf̂f́êćt̂ ýôúr̂ śĉór̂é b̂út̂ ít̂'ś îḿp̂ór̂t́âńt̂ t́ĥát̂ ýôú v̂ér̂íf̂ý t̂h́êḿ m̂án̂úâĺl̂ý."
1777
1777
  },
1778
1778
  "lighthouse-core/config/default-config.js | pwaCategoryTitle": {
1779
- "message": "P̂ŕôǵr̂éŝśîv́ê Ẃêb́ Âṕp̂"
1779
+ "message": "P̂ẂÂ"
1780
1780
  },
1781
1781
  "lighthouse-core/config/default-config.js | pwaInstallableGroupTitle": {
1782
1782
  "message": "Îńŝt́âĺl̂áb̂ĺê"
@@ -11,6 +11,8 @@ const InstallableManifestAudit = require('../../lighthouse-core/audits/installab
11
11
 
12
12
  /* eslint-env jest */
13
13
 
14
+ jest.setTimeout(20_000);
15
+
14
16
  describe('installabilityErrors', () => {
15
17
  let chromiumErrorIds;
16
18
 
@@ -12,9 +12,10 @@ declare module FlowResult {
12
12
  name: string;
13
13
  }
14
14
 
15
- interface LhrRef {
16
- value: Result;
15
+ interface HashState {
16
+ currentLhr: Result;
17
17
  index: number;
18
+ anchor: string|null;
18
19
  }
19
20
  }
20
21
 
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
3
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
4
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
5
+ */
6
+
7
+ declare module '@stadtlandnetz/rollup-plugin-postprocess' {
8
+ function postprocess(args: Array<[RegExp, string]>): void;
9
+ export = postprocess;
10
+ }