-
Notifications
You must be signed in to change notification settings - Fork 9.4k
/
Copy pathconstants.js
103 lines (89 loc) · 2.8 KB
/
constants.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/**
* @license
* Copyright 2018 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import * as Lantern from '../lib/lantern/lantern.js';
const throttling = Lantern.Simulation.Constants.throttling;
/**
* @type {Required<LH.SharedFlagsSettings['screenEmulation']>}
*/
const MOTOGPOWER_EMULATION_METRICS = {
mobile: true,
width: 412,
height: 823,
// This value has some interesting ramifications for image-size-responsive, see:
// /~https://github.com/GoogleChrome/lighthouse/issues/10741#issuecomment-626903508
deviceScaleFactor: 1.75,
disabled: false,
};
/**
* Desktop metrics adapted from emulated_devices/module.json
* @type {Required<LH.SharedFlagsSettings['screenEmulation']>}
*/
const DESKTOP_EMULATION_METRICS = {
mobile: false,
width: 1350,
height: 940,
deviceScaleFactor: 1,
disabled: false,
};
const screenEmulationMetrics = {
mobile: MOTOGPOWER_EMULATION_METRICS,
desktop: DESKTOP_EMULATION_METRICS,
};
const MOTOG4_USERAGENT = 'Mozilla/5.0 (Linux; Android 11; moto g power (2022)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.36'; // eslint-disable-line max-len
const DESKTOP_USERAGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36'; // eslint-disable-line max-len
const userAgents = {
mobile: MOTOG4_USERAGENT,
desktop: DESKTOP_USERAGENT,
};
/** @type {LH.Config.Settings} */
const defaultSettings = {
output: 'json',
maxWaitForFcp: 30 * 1000,
maxWaitForLoad: 45 * 1000,
pauseAfterFcpMs: 1000,
pauseAfterLoadMs: 1000,
networkQuietThresholdMs: 1000,
cpuQuietThresholdMs: 1000,
formFactor: 'mobile',
throttling: throttling.mobileSlow4G,
throttlingMethod: 'simulate',
screenEmulation: screenEmulationMetrics.mobile,
emulatedUserAgent: userAgents.mobile,
auditMode: false,
gatherMode: false,
clearStorageTypes: ['file_systems', 'shader_cache', 'service_workers', 'cache_storage'],
disableStorageReset: false,
debugNavigation: false,
channel: 'node',
usePassiveGathering: false,
disableFullPageScreenshot: false,
skipAboutBlank: false,
blankPage: 'about:blank',
ignoreStatusCode: false,
// the following settings have no defaults but we still want ensure that `key in settings`
// in config will work in a typechecked way
locale: 'en-US', // actual default determined by Config using lib/i18n
blockedUrlPatterns: null,
additionalTraceCategories: null,
extraHeaders: null,
precomputedLanternData: null,
onlyAudits: null,
onlyCategories: null,
skipAudits: null,
};
const nonSimulatedSettingsOverrides = {
pauseAfterFcpMs: 5250,
pauseAfterLoadMs: 5250,
networkQuietThresholdMs: 5250,
cpuQuietThresholdMs: 5250,
};
export {
throttling,
screenEmulationMetrics,
userAgents,
defaultSettings,
nonSimulatedSettingsOverrides,
};