forked from GoogleChrome/lighthouse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
installability-errors.js
56 lines (47 loc) · 1.37 KB
/
installability-errors.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import log from 'lighthouse-logger';
import BaseGatherer from '../base-gatherer.js';
class InstallabilityErrors extends BaseGatherer {
/** @type {LH.Gatherer.GathererMeta} */
meta = {
supportedModes: ['snapshot', 'navigation'],
};
/**
* Creates an Artifacts.InstallabilityErrors, tranforming data from the protocol
* for old versions of Chrome.
* @param {LH.Gatherer.ProtocolSession} session
* @return {Promise<LH.Artifacts['InstallabilityErrors']>}
*/
static async getInstallabilityErrors(session) {
const status = {
msg: 'Get webapp installability errors',
id: 'lh:gather:getInstallabilityErrors',
};
log.time(status);
const response = await session.sendCommand('Page.getInstallabilityErrors');
const errors = response.installabilityErrors;
log.timeEnd(status);
return {errors};
}
/**
* @param {LH.Gatherer.Context} context
* @return {Promise<LH.Artifacts['InstallabilityErrors']>}
*/
async getArtifact(context) {
const driver = context.driver;
try {
return await InstallabilityErrors.getInstallabilityErrors(driver.defaultSession);
} catch {
return {
errors: [
{errorId: 'protocol-timeout', errorArguments: []},
],
};
}
}
}
export default InstallabilityErrors;