lighthouse 8.6.0-dev.20211105 → 8.6.0-dev.20211109

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.
@@ -175,7 +175,7 @@ async function potentiallyKillChrome(launchedChrome) {
175
175
  /** @type {NodeJS.Timeout} */
176
176
  let timeout;
177
177
  const timeoutPromise = new Promise((_, reject) => {
178
- timeout = setTimeout(() => reject(new Error('Timed out waiting to kill Chrome')), 5000);
178
+ timeout = setTimeout(reject, 5000, new Error('Timed out waiting to kill Chrome'));
179
179
  });
180
180
 
181
181
  return Promise.race([
@@ -11,6 +11,8 @@
11
11
  * that contain deprecated API warnings sent by Chrome.
12
12
  */
13
13
 
14
+ // TODO: when M97 is sufficiently old, drop support for console messages
15
+
14
16
  const Audit = require('./audit.js');
15
17
  const i18n = require('../lib/i18n/i18n.js');
16
18
 
@@ -45,7 +47,7 @@ class Deprecations extends Audit {
45
47
  title: str_(UIStrings.title),
46
48
  failureTitle: str_(UIStrings.failureTitle),
47
49
  description: str_(UIStrings.description),
48
- requiredArtifacts: ['ConsoleMessages'],
50
+ requiredArtifacts: ['ConsoleMessages', 'InspectorIssues'],
49
51
  };
50
52
  }
51
53
 
@@ -56,16 +58,36 @@ class Deprecations extends Audit {
56
58
  static audit(artifacts) {
57
59
  const entries = artifacts.ConsoleMessages;
58
60
 
59
- const deprecations = entries.filter(log => log.source === 'deprecation')
60
- // TODO(M91): Temporary ignore until Chrome M91 became stable version.
61
- // M91 doesn't throw deprecation on ::-webkit-details-marker.
62
- .filter(log => !log.text.includes('::-webkit-details-marker'))
63
- .map(log => {
64
- return {
65
- value: log.text,
66
- source: Audit.makeSourceLocationFromConsoleMessage(log),
67
- };
68
- });
61
+ let deprecations;
62
+
63
+ if (artifacts.InspectorIssues.deprecations.length) {
64
+ deprecations = artifacts.InspectorIssues.deprecations
65
+ .map(deprecation => {
66
+ return {
67
+ value: deprecation.message || '',
68
+ /** @type {LH.Audit.Details.SourceLocationValue} */
69
+ source: {
70
+ type: 'source-location',
71
+ url: deprecation.sourceCodeLocation.url,
72
+ urlProvider: 'network',
73
+ line: deprecation.sourceCodeLocation.lineNumber,
74
+ // Protocol.Audits.SourceCodeLocation.columnNumber is 1-indexed,
75
+ // but we use 0-indexed.
76
+ column: deprecation.sourceCodeLocation.columnNumber - 1,
77
+ },
78
+ };
79
+ });
80
+ } else {
81
+ // Backcompat for <M97.
82
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=1248484
83
+ deprecations = entries.filter(log => log.source === 'deprecation')
84
+ .map(log => {
85
+ return {
86
+ value: log.text,
87
+ source: Audit.makeSourceLocationFromConsoleMessage(log),
88
+ };
89
+ });
90
+ }
69
91
 
70
92
  /** @type {LH.Audit.Details.Table['headings']} */
71
93
  const headings = [
@@ -81,10 +81,9 @@ const screenEmulationMetrics = {
81
81
  desktop: DESKTOP_EMULATION_METRICS,
82
82
  };
83
83
 
84
- // eslint-disable-next-line max-len
85
- const MOTOG4_USERAGENT = 'Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4590.2 Mobile Safari/537.36 Chrome-Lighthouse';
86
- // eslint-disable-next-line max-len
87
- const DESKTOP_USERAGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4590.2 Safari/537.36 Chrome-Lighthouse';
84
+
85
+ const MOTOG4_USERAGENT = 'Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4695.0 Mobile Safari/537.36 Chrome-Lighthouse'; // eslint-disable-line max-len
86
+ const DESKTOP_USERAGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4695.0 Safari/537.36 Chrome-Lighthouse'; // eslint-disable-line max-len
88
87
 
89
88
  const userAgents = {
90
89
  mobile: MOTOG4_USERAGENT,
@@ -150,10 +150,9 @@ class ProtocolSession {
150
150
  const timeoutPromise = new Promise((resolve, reject) => {
151
151
  if (timeoutMs === Infinity) return;
152
152
 
153
- timeout = setTimeout((() => {
154
- const err = new LHError(LHError.errors.PROTOCOL_TIMEOUT, {protocolMethod: method});
155
- reject(err);
156
- }), timeoutMs);
153
+ timeout = setTimeout(reject, timeoutMs, new LHError(LHError.errors.PROTOCOL_TIMEOUT, {
154
+ protocolMethod: method,
155
+ }));
157
156
  });
158
157
 
159
158
  const resultPromise = this._session.send(method, ...params);
@@ -338,13 +338,9 @@ class Driver {
338
338
  let asyncTimeout;
339
339
  const timeoutPromise = new Promise((resolve, reject) => {
340
340
  if (timeout === Infinity) return;
341
- asyncTimeout = setTimeout((() => {
342
- const err = new LHError(
343
- LHError.errors.PROTOCOL_TIMEOUT,
344
- {protocolMethod: method}
345
- );
346
- reject(err);
347
- }), timeout);
341
+ asyncTimeout = setTimeout(reject, timeout, new LHError(LHError.errors.PROTOCOL_TIMEOUT, {
342
+ protocolMethod: method,
343
+ }));
348
344
  });
349
345
 
350
346
  return Promise.race([
@@ -195,9 +195,7 @@ class Fetcher {
195
195
  /** @type {NodeJS.Timeout} */
196
196
  let timeoutHandle;
197
197
  const timeoutPromise = new Promise((_, reject) => {
198
- timeoutHandle = setTimeout(() => {
199
- reject(new Error('Timed out fetching resource'));
200
- }, options.timeout);
198
+ timeoutHandle = setTimeout(reject, options.timeout, new Error('Timed out fetching resource'));
201
199
  });
202
200
 
203
201
  const responsePromise = this._loadNetworkResource(url);
@@ -283,17 +281,16 @@ class Fetcher {
283
281
  /* c8 ignore stop */
284
282
 
285
283
  /** @type {NodeJS.Timeout} */
286
- let timeoutHandle;
284
+ let asyncTimeout;
287
285
  /** @type {Promise<never>} */
288
286
  const timeoutPromise = new Promise((_, reject) => {
289
- const errorMessage = 'Timed out fetching resource.';
290
- timeoutHandle = setTimeout(() => reject(new Error(errorMessage)), options.timeout);
287
+ asyncTimeout = setTimeout(reject, options.timeout, new Error('Timed out fetching resource.'));
291
288
  });
292
289
 
293
290
  const racePromise = Promise.race([
294
291
  timeoutPromise,
295
292
  requestInterceptionPromise,
296
- ]).finally(() => clearTimeout(timeoutHandle));
293
+ ]).finally(() => clearTimeout(asyncTimeout));
297
294
 
298
295
  // Temporarily disable auto-attaching for this iframe.
299
296
  await this.session.sendCommand('Target.setAutoAttach', {
@@ -69,6 +69,8 @@ class InspectorIssues extends FRGatherer {
69
69
  heavyAds: [],
70
70
  /** @type {Array<LH.Crdp.Audits.ContentSecurityPolicyIssueDetails>} */
71
71
  contentSecurityPolicy: [],
72
+ /** @type {Array<LH.Crdp.Audits.DeprecationIssueDetails>} */
73
+ deprecations: [],
72
74
  };
73
75
 
74
76
  for (const issue of this._issues) {
@@ -105,6 +107,9 @@ class InspectorIssues extends FRGatherer {
105
107
  if (issue.details.contentSecurityPolicyIssueDetails) {
106
108
  artifact.contentSecurityPolicy.push(issue.details.contentSecurityPolicyIssueDetails);
107
109
  }
110
+ if (issue.details.deprecationIssueDetails) {
111
+ artifact.deprecations.push(issue.details.deprecationIssueDetails);
112
+ }
108
113
  }
109
114
 
110
115
  return artifact;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lighthouse",
3
- "version": "8.6.0-dev.20211105",
3
+ "version": "8.6.0-dev.20211109",
4
4
  "description": "Automated auditing, performance metrics, and best practices for the web.",
5
5
  "main": "./lighthouse-core/index.js",
6
6
  "bin": {
@@ -146,7 +146,7 @@
146
146
  "cpy": "^7.0.1",
147
147
  "cross-env": "^7.0.2",
148
148
  "csv-validator": "^0.0.3",
149
- "devtools-protocol": "0.0.901419",
149
+ "devtools-protocol": "0.0.939404",
150
150
  "es-main": "^1.0.2",
151
151
  "eslint": "^7.23.0",
152
152
  "eslint-config-google": "^0.9.1",
@@ -218,6 +218,9 @@
218
218
  "yargs": "^16.1.1",
219
219
  "yargs-parser": "^20.2.4"
220
220
  },
221
+ "resolutions": {
222
+ "puppeteer/**/devtools-protocol": "0.0.939404"
223
+ },
221
224
  "repository": "GoogleChrome/lighthouse",
222
225
  "keywords": [
223
226
  "google",
@@ -31,18 +31,26 @@ describe('issueAdded types', () => {
31
31
  .sort();
32
32
  });
33
33
 
34
- // TODO: https://github.com/GoogleChrome/lighthouse/issues/13147
35
- it.skip('should notify us if something changed', () => {
34
+ it('should notify us if something changed', () => {
36
35
  expect(inspectorIssueDetailsTypes).toMatchInlineSnapshot(`
37
- Array [
38
- "blockedByResponseIssueDetails",
39
- "contentSecurityPolicyIssueDetails",
40
- "heavyAdIssueDetails",
41
- "mixedContentIssueDetails",
42
- "sameSiteCookieIssueDetails",
43
- "sharedArrayBufferTransferIssueDetails",
44
- ]
45
- `);
36
+ Array [
37
+ "attributionReportingIssueDetails",
38
+ "blockedByResponseIssueDetails",
39
+ "contentSecurityPolicyIssueDetails",
40
+ "corsIssueDetails",
41
+ "deprecationIssueDetails",
42
+ "genericIssueDetails",
43
+ "heavyAdIssueDetails",
44
+ "lowTextContrastIssueDetails",
45
+ "mixedContentIssueDetails",
46
+ "navigatorUserAgentIssueDetails",
47
+ "quirksModeIssueDetails",
48
+ "sameSiteCookieIssueDetails",
49
+ "sharedArrayBufferIssueDetails",
50
+ "twaQualityEnforcementDetails",
51
+ "wasmCrossOriginModuleSharingIssue",
52
+ ]
53
+ `);
46
54
  });
47
55
 
48
56
  // TODO: https://github.com/GoogleChrome/lighthouse/issues/13147
@@ -558,6 +558,7 @@ declare module Artifacts {
558
558
  blockedByResponse: LH.Crdp.Audits.BlockedByResponseIssueDetails[];
559
559
  heavyAds: LH.Crdp.Audits.HeavyAdIssueDetails[];
560
560
  contentSecurityPolicy: LH.Crdp.Audits.ContentSecurityPolicyIssueDetails[];
561
+ deprecations: LH.Crdp.Audits.DeprecationIssueDetails[];
561
562
  }
562
563
 
563
564
  // Computed artifact types below.
@@ -263,6 +263,7 @@ declare module Details {
263
263
  urlProvider: 'network' | 'comment';
264
264
  /** Zero-indexed. */
265
265
  line: number;
266
+ /** Zero-indexed. */
266
267
  column: number;
267
268
  /** The original file location from the source map. */
268
269
  original?: {