misc(proto): add screenEmulation to configSettings (#14809)

This commit is contained in:
Paul Irish 2023-02-21 08:56:49 -08:00 коммит произвёл GitHub
Родитель c958468921
Коммит 0386b9b9fd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 43 добавлений и 26 удалений

Просмотреть файл

@ -35,6 +35,7 @@ function processForProto(lhr) {
onlyCategories,
channel,
throttling,
screenEmulation,
throttlingMethod} = reportJson.configSettings;
// @ts-expect-error - intentionally only a subset of settings.
@ -44,6 +45,7 @@ function processForProto(lhr) {
onlyCategories,
channel,
throttling,
screenEmulation,
throttlingMethod};
}

Просмотреть файл

@ -20,32 +20,10 @@ describe('processing for proto', () => {
});
it('keeps only necessary configSettings', () => {
const samplejson = JSON.parse(JSON.stringify(sampleJson));
const {configSettings} = samplejson;
const input = {
'configSettings': {
'output': [
'json',
],
'maxWaitForLoad': 45000,
'throttlingMethod': 'devtools',
'throttling': {
'rttMs': 150,
'throughputKbps': 1638.4,
'requestLatencyMs': 562.5,
'downloadThroughputKbps': 1474.5600000000002,
'uploadThroughputKbps': 675,
'cpuSlowdownMultiplier': 4,
},
'gatherMode': false,
'disableStorageReset': false,
'formFactor': 'mobile',
'locale': 'en-US',
'blockedUrlPatterns': null,
'additionalTraceCategories': null,
'extraHeaders': null,
'onlyAudits': null,
'onlyCategories': null,
'skipAudits': null,
},
configSettings,
};
const expectation = {
'configSettings': {
@ -57,6 +35,27 @@ describe('processing for proto', () => {
const output = processForProto(input);
expect(output).toMatchObject(expectation);
expect(Object.keys(output.configSettings)).toMatchInlineSnapshot(`
Array [
"formFactor",
"locale",
"onlyCategories",
"channel",
"throttling",
"screenEmulation",
"throttlingMethod",
]
`);
// This must be correctly populated for appropriate report metablock rendering
expect(output.configSettings.screenEmulation).toMatchInlineSnapshot(`
Object {
"deviceScaleFactor": 1.75,
"disabled": false,
"height": 823,
"mobile": true,
"width": 412,
}
`);
});
it('cleans up default runtimeErrors', () => {

Просмотреть файл

@ -185,6 +185,22 @@ message LighthouseResult {
// The method used to throttle the network.
string throttling_method = 8;
message ScreenEmulation {
// Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.
double width = 1;
// Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override.
double height = 2;
// Overriding device scale factor value. 0 disables the override.
double deviceScaleFactor = 3;
// Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more.
bool mobile = 4;
// Whether screen emulation is disabled. If true, the other emulation settings are ignored.
bool disabled = 5;
}
// Screen emulation properties (width, height, dpr, mobile viewport) to apply or an object of `{disabled: true}` if Lighthouse should avoid applying screen emulation. If either emulation is applied outside of Lighthouse, or it's being run on a mobile device, it typically should be set to disabled. For desktop, we recommend applying consistent desktop screen emulation.
ScreenEmulation screen_emulation = 9;
}
// The settings that were used to run this audit
@ -633,4 +649,4 @@ message LhrEntity {
// A list of URL origin strings that belong to this entity.
repeated string origins = 6;
}
}