lighthouse 9.5.0-dev.20220426 → 9.5.0-dev.20220427

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.
@@ -86,6 +86,55 @@ describe('DetailsRenderer', () => {
86
86
  '--thumbnail not set');
87
87
  });
88
88
 
89
+ it('renders with default granularity', () => {
90
+ const el = renderer.render({
91
+ type: 'table',
92
+ headings: [
93
+ {text: '', key: 'bytes', itemType: 'bytes'},
94
+ {text: '', key: 'numeric', itemType: 'numeric'},
95
+ {text: '', key: 'ms', itemType: 'ms'},
96
+ // Verify that 0 is ignored.
97
+ {text: '', key: 'ms', itemType: 'ms', granularity: 0},
98
+ ],
99
+ items: [
100
+ {
101
+ bytes: 1234.567,
102
+ numeric: 1234.567,
103
+ ms: 1234.567,
104
+ },
105
+ ],
106
+ });
107
+
108
+ assert.equal(el.querySelectorAll('td').length, 4, 'did not render table cells');
109
+ assert.equal(el.querySelectorAll('td')[0].textContent, '1.2\xa0KiB');
110
+ assert.equal(el.querySelectorAll('td')[1].textContent, '1,234.6');
111
+ assert.equal(el.querySelectorAll('td')[2].textContent, '1,230\xa0ms');
112
+ assert.equal(el.querySelectorAll('td')[3].textContent, '1,230\xa0ms');
113
+ });
114
+
115
+ it('renders with custom granularity', () => {
116
+ const el = renderer.render({
117
+ type: 'table',
118
+ headings: [
119
+ {text: '', key: 'bytes', itemType: 'bytes', granularity: 0.01},
120
+ {text: '', key: 'numeric', itemType: 'numeric', granularity: 100},
121
+ {text: '', key: 'ms', itemType: 'ms', granularity: 1},
122
+ ],
123
+ items: [
124
+ {
125
+ bytes: 1234.567,
126
+ numeric: 1234.567,
127
+ ms: 1234.567,
128
+ },
129
+ ],
130
+ });
131
+
132
+ assert.equal(el.querySelectorAll('td').length, 3, 'did not render table cells');
133
+ assert.equal(el.querySelectorAll('td')[0].textContent, '1.21\xa0KiB');
134
+ assert.equal(el.querySelectorAll('td')[1].textContent, '1,200');
135
+ assert.equal(el.querySelectorAll('td')[2].textContent, '1,235\xa0ms');
136
+ });
137
+
89
138
  it('renders critical request chains', () => {
90
139
  const details = {
91
140
  type: 'criticalrequestchain',
@@ -21,9 +21,27 @@ const NBSP = '\xa0';
21
21
  describe('util helpers', () => {
22
22
  it('formats a number', () => {
23
23
  const i18n = new I18n('en', {...Util.UIStrings});
24
- assert.strictEqual(i18n.formatNumber(10), '10.0');
25
- assert.strictEqual(i18n.formatNumber(100.01), '100.0');
26
- assert.strictEqual(i18n.formatNumber(13000.456), '13,000.5');
24
+ assert.strictEqual(i18n.formatNumber(10), '10');
25
+ assert.strictEqual(i18n.formatNumber(100.01), '100.01');
26
+ assert.strictEqual(i18n.formatNumber(13000.456), '13,000.456');
27
+ assert.strictEqual(i18n.formatNumber(13000.456444), '13,000.456');
28
+
29
+ assert.strictEqual(i18n.formatNumber(10, 0.1), '10.0');
30
+ assert.strictEqual(i18n.formatNumber(100.01, 0.1), '100.0');
31
+ assert.strictEqual(i18n.formatNumber(13000.456, 0.1), '13,000.5');
32
+
33
+ assert.strictEqual(i18n.formatNumber(0), '0');
34
+ assert.strictEqual(i18n.formatNumber(-0), '0');
35
+ assert.strictEqual(i18n.formatNumber(-0, 0.1), '0.0');
36
+ assert.strictEqual(i18n.formatNumber(0.000001), '0');
37
+ assert.strictEqual(i18n.formatNumber(-0.000001), '0');
38
+ assert.strictEqual(i18n.formatNumber(0.000001, 0.1), '0.0');
39
+ assert.strictEqual(i18n.formatNumber(-0.000001, 0.1), '0.0');
40
+
41
+ assert.strictEqual(i18n.formatNumber(10), '10');
42
+ assert.strictEqual(i18n.formatNumber(100.01), '100.01');
43
+ assert.strictEqual(i18n.formatNumber(13000.456, 0.1), '13,000.5');
44
+
27
45
  assert.strictEqual(i18n.formatInteger(10), '10');
28
46
  assert.strictEqual(i18n.formatInteger(100.01), '100');
29
47
  assert.strictEqual(i18n.formatInteger(13000.6), '13,001');
@@ -41,9 +59,10 @@ describe('util helpers', () => {
41
59
 
42
60
  it('formats bytes', () => {
43
61
  const i18n = new I18n('en', {...Util.UIStrings});
44
- assert.equal(i18n.formatBytesToKiB(100), `0.1${NBSP}KiB`);
45
- assert.equal(i18n.formatBytesToKiB(2000), `2.0${NBSP}KiB`);
46
- assert.equal(i18n.formatBytesToKiB(1014 * 1024), `1,014.0${NBSP}KiB`);
62
+ assert.equal(i18n.formatBytesToKiB(100), `0.098${NBSP}KiB`);
63
+ assert.equal(i18n.formatBytesToKiB(100, 0.1), `0.1${NBSP}KiB`);
64
+ assert.equal(i18n.formatBytesToKiB(2000, 0.1), `2.0${NBSP}KiB`);
65
+ assert.equal(i18n.formatBytesToKiB(1014 * 1024, 0.1), `1,014.0${NBSP}KiB`);
47
66
  });
48
67
 
49
68
  it('formats bytes with different granularities', () => {
@@ -59,11 +78,6 @@ describe('util helpers', () => {
59
78
  assert.strictEqual(i18n.formatBytes(15.12345, granularity), `15${NBSP}bytes`);
60
79
  assert.strictEqual(i18n.formatBytes(15.54321, granularity), `16${NBSP}bytes`);
61
80
 
62
- granularity = 0.5;
63
- assert.strictEqual(i18n.formatBytes(15.0, granularity), `15.0${NBSP}bytes`);
64
- assert.strictEqual(i18n.formatBytes(15.12345, granularity), `15.0${NBSP}bytes`);
65
- assert.strictEqual(i18n.formatBytes(15.54321, granularity), `15.5${NBSP}bytes`);
66
-
67
81
  granularity = 0.1;
68
82
  assert.strictEqual(i18n.formatBytes(15.0, granularity), `15.0${NBSP}bytes`);
69
83
  assert.strictEqual(i18n.formatBytes(15.12345, granularity), `15.1${NBSP}bytes`);
@@ -75,6 +89,21 @@ describe('util helpers', () => {
75
89
  assert.strictEqual(i18n.formatBytes(15.19999, granularity), `15.20${NBSP}bytes`);
76
90
  });
77
91
 
92
+ it('formats bytes with invalid granularity', () => {
93
+ const i18n = new I18n('en', {...Util.UIStrings});
94
+ const granularity = 0.5;
95
+ const originalWarn = console.warn;
96
+
97
+ try {
98
+ console.warn = () => {};
99
+ assert.strictEqual(i18n.formatBytes(15.0, granularity), `15${NBSP}bytes`);
100
+ assert.strictEqual(i18n.formatBytes(15.12345, granularity), `15${NBSP}bytes`);
101
+ assert.strictEqual(i18n.formatBytes(15.54321, granularity), `16${NBSP}bytes`);
102
+ } finally {
103
+ console.warn = originalWarn;
104
+ }
105
+ });
106
+
78
107
  it('formats kibibytes with different granularities', () => {
79
108
  const i18n = new I18n('en', {...Util.UIStrings});
80
109
 
@@ -95,7 +124,7 @@ describe('util helpers', () => {
95
124
 
96
125
  it('formats ms', () => {
97
126
  const i18n = new I18n('en', {...Util.UIStrings});
98
- assert.equal(i18n.formatMilliseconds(123), `120${NBSP}ms`);
127
+ assert.equal(i18n.formatMilliseconds(123, 10), `120${NBSP}ms`);
99
128
  assert.equal(i18n.formatMilliseconds(2456.5, 0.1), `2,456.5${NBSP}ms`);
100
129
  assert.equal(i18n.formatMilliseconds(0.000001), `0${NBSP}ms`);
101
130
  assert.equal(i18n.formatMilliseconds(-0.000001), `0${NBSP}ms`);
@@ -129,10 +158,10 @@ describe('util helpers', () => {
129
158
  const number = 12346.858558;
130
159
 
131
160
  const i18n = new I18n('de', {...Util.UIStrings});
132
- assert.strictEqual(i18n.formatNumber(number), '12.346,9');
133
- assert.strictEqual(i18n.formatBytesToKiB(number), `12,1${NBSP}KiB`);
134
- assert.strictEqual(i18n.formatMilliseconds(number), `12.350${NBSP}ms`);
135
- assert.strictEqual(i18n.formatSeconds(number), `12,3${NBSP}Sek.`);
161
+ assert.strictEqual(i18n.formatNumber(number), '12.346,859');
162
+ assert.strictEqual(i18n.formatBytesToKiB(number, 0.1), `12,1${NBSP}KiB`);
163
+ assert.strictEqual(i18n.formatMilliseconds(number, 10), `12.350${NBSP}ms`);
164
+ assert.strictEqual(i18n.formatSeconds(number), `12,347${NBSP}Sek.`);
136
165
  });
137
166
 
138
167
  it('uses decimal comma with en-XA test locale', () => {
@@ -140,10 +169,10 @@ describe('util helpers', () => {
140
169
  const number = 12346.858558;
141
170
 
142
171
  const i18n = new I18n('en-XA', {...Util.UIStrings});
143
- assert.strictEqual(i18n.formatNumber(number), '12.346,9');
144
- assert.strictEqual(i18n.formatBytesToKiB(number), `12,1${NBSP}KiB`);
145
- assert.strictEqual(i18n.formatMilliseconds(number), `12.350${NBSP}ms`);
146
- assert.strictEqual(i18n.formatSeconds(number), `12,3${NBSP}Sek.`);
172
+ assert.strictEqual(i18n.formatNumber(number), '12.346,859');
173
+ assert.strictEqual(i18n.formatBytesToKiB(number, 0.1), `12,1${NBSP}KiB`);
174
+ assert.strictEqual(i18n.formatMilliseconds(number, 100), `12.300${NBSP}ms`);
175
+ assert.strictEqual(i18n.formatSeconds(number, 1), `12${NBSP}Sek.`);
147
176
  });
148
177
 
149
178
  it('should not crash on unknown locales', () => {
@@ -1190,6 +1190,9 @@
1190
1190
  "lighthouse-core/audits/metrics/cumulative-layout-shift.js | description": {
1191
1191
  "message": "Cumulative Layout Shift measures the movement of visible elements within the viewport. [Learn more](https://web.dev/cls/)."
1192
1192
  },
1193
+ "lighthouse-core/audits/metrics/experimental-interaction-to-next-paint.js | description": {
1194
+ "message": "Interaction to Next Paint measures page responsiveness, how long it takes the page to visibly respond to user input. [Learn more](https://web.dev/inp/)."
1195
+ },
1193
1196
  "lighthouse-core/audits/metrics/first-contentful-paint.js | description": {
1194
1197
  "message": "First Contentful Paint marks the time at which the first text or image is painted. [Learn more](https://web.dev/first-contentful-paint/)."
1195
1198
  },
@@ -1961,6 +1964,9 @@
1961
1964
  "lighthouse-core/lib/i18n/i18n.js | imageResourceType": {
1962
1965
  "message": "Image"
1963
1966
  },
1967
+ "lighthouse-core/lib/i18n/i18n.js | interactionToNextPaint": {
1968
+ "message": "Interaction to Next Paint"
1969
+ },
1964
1970
  "lighthouse-core/lib/i18n/i18n.js | interactiveMetric": {
1965
1971
  "message": "Time to Interactive"
1966
1972
  },
@@ -1190,6 +1190,9 @@
1190
1190
  "lighthouse-core/audits/metrics/cumulative-layout-shift.js | description": {
1191
1191
  "message": "Ĉúm̂úl̂át̂ív̂é L̂áŷóût́ Ŝh́îf́t̂ ḿêáŝúr̂éŝ t́ĥé m̂óv̂ém̂én̂t́ ôf́ v̂íŝíb̂ĺê él̂ém̂én̂t́ŝ ẃît́ĥín̂ t́ĥé v̂íêẃp̂ór̂t́. [L̂éâŕn̂ ḿôŕê](https://web.dev/cls/)."
1192
1192
  },
1193
+ "lighthouse-core/audits/metrics/experimental-interaction-to-next-paint.js | description": {
1194
+ "message": "Îńt̂ér̂áĉt́îón̂ t́ô Ńêx́t̂ Ṕâín̂t́ m̂éâśûŕêś p̂áĝé r̂éŝṕôńŝív̂én̂éŝś, ĥóŵ ĺôńĝ ít̂ t́âḱêś t̂h́ê ṕâǵê t́ô v́îśîb́l̂ý r̂éŝṕôńd̂ t́ô úŝér̂ ín̂ṕût́. [L̂éâŕn̂ ḿôŕê](https://web.dev/inp/)."
1195
+ },
1193
1196
  "lighthouse-core/audits/metrics/first-contentful-paint.js | description": {
1194
1197
  "message": "F̂ír̂śt̂ Ćôńt̂én̂t́f̂úl̂ Ṕâín̂t́ m̂ár̂ḱŝ t́ĥé t̂ím̂é ât́ ŵh́îćĥ t́ĥé f̂ír̂śt̂ t́êx́t̂ ór̂ ím̂áĝé îś p̂áîńt̂éd̂. [Ĺêár̂ń m̂ór̂é](https://web.dev/first-contentful-paint/)."
1195
1198
  },
@@ -1961,6 +1964,9 @@
1961
1964
  "lighthouse-core/lib/i18n/i18n.js | imageResourceType": {
1962
1965
  "message": "Îḿâǵê"
1963
1966
  },
1967
+ "lighthouse-core/lib/i18n/i18n.js | interactionToNextPaint": {
1968
+ "message": "Îńt̂ér̂áĉt́îón̂ t́ô Ńêx́t̂ Ṕâín̂t́"
1969
+ },
1964
1970
  "lighthouse-core/lib/i18n/i18n.js | interactiveMetric": {
1965
1971
  "message": "T̂ím̂é t̂ó Îńt̂ér̂áĉt́îv́ê"
1966
1972
  },
@@ -5,7 +5,8 @@
5
5
  */
6
6
  'use strict';
7
7
 
8
- const {set: _set, get: _get} = require('lodash');
8
+ const _set = require('lodash/set.js');
9
+ const _get = require('lodash/get.js');
9
10
 
10
11
  const format = require('./format.js');
11
12
 
@@ -999,6 +999,9 @@ export interface TraceEvent {
999
999
  compositeFailed?: number;
1000
1000
  unsupportedProperties?: string[];
1001
1001
  size?: number;
1002
+ /** Responsiveness data. */
1003
+ interactionType?: 'drag'|'keyboard'|'tapOrClick';
1004
+ maxDuration?: number;
1002
1005
  };
1003
1006
  frame?: string;
1004
1007
  name?: string;