Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc(proto): add ConfigSettings fields #15616

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cli/test/cli/run-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('CLI run', function() {
// eslint-disable-next-line max-len
const flags = getFlags([
'--output=json',
`--extra-headers '{"Cookie":"monster=blue"}'`,
`--output-path=${filename}`,
'--plugins=lighthouse-plugin-simple',
// Use sample artifacts to avoid gathering during a unit test.
Expand Down
25 changes: 0 additions & 25 deletions core/lib/proto-preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,6 @@ function processForProto(lhr) {
/** @type {LH.Result} */
const reportJson = JSON.parse(JSON.stringify(lhr));

// Clean up the configSettings
// Note: This is not strictly required for conversion if protobuf parsing is set to
// 'ignore unknown fields' in the language of conversion.
if (reportJson.configSettings) {
// The settings that are in both proto and LHR
const {
formFactor,
locale,
onlyCategories,
channel,
throttling,
screenEmulation,
throttlingMethod} = reportJson.configSettings;

// @ts-expect-error - intentionally only a subset of settings.
reportJson.configSettings = {
formFactor,
locale,
onlyCategories,
channel,
throttling,
screenEmulation,
throttlingMethod};
}

// Remove runtimeError if it is NO_ERROR
if (reportJson.runtimeError && reportJson.runtimeError.code === 'NO_ERROR') {
delete reportJson.runtimeError;
Expand Down
33 changes: 29 additions & 4 deletions core/test/lib/proto-preprocessor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,38 @@ describe('processing for proto', () => {
expect(output).toMatchObject(expectation);
expect(Object.keys(output.configSettings)).toMatchInlineSnapshot(`
Array [
"output",
"maxWaitForFcp",
"maxWaitForLoad",
"pauseAfterFcpMs",
"pauseAfterLoadMs",
"networkQuietThresholdMs",
"cpuQuietThresholdMs",
"formFactor",
"locale",
"onlyCategories",
"channel",
"throttling",
"screenEmulation",
"throttlingMethod",
"screenEmulation",
"emulatedUserAgent",
"auditMode",
"gatherMode",
"clearStorageTypes",
"disableStorageReset",
"debugNavigation",
"channel",
"usePassiveGathering",
"disableFullPageScreenshot",
"skipAboutBlank",
"blankPage",
"ignoreStatusCode",
"budgets",
"locale",
"blockedUrlPatterns",
"additionalTraceCategories",
"extraHeaders",
"precomputedLanternData",
"onlyAudits",
"onlyCategories",
"skipAudits",
]
`);
// This must be correctly populated for appropriate report metablock rendering
Expand Down
4 changes: 3 additions & 1 deletion core/test/results/artifacts/artifacts.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@
"locale": "en-US",
"blockedUrlPatterns": null,
"additionalTraceCategories": null,
"extraHeaders": null,
"extraHeaders": {
"Cookie": "monster=blue"
},
"precomputedLanternData": null,
"onlyAudits": null,
"onlyCategories": null,
Expand Down
3 changes: 3 additions & 0 deletions core/test/results/sample-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const budgetedConfig = {
extends: 'lighthouse:default',
settings: {
throttlingMethod: 'devtools',
extraHeaders: {
'Cookie': 'monster=blue',
},
budgets: [{
path: '/',
resourceCounts: [
Expand Down
4 changes: 3 additions & 1 deletion core/test/results/sample_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -5858,7 +5858,9 @@
"locale": "en-US",
"blockedUrlPatterns": null,
"additionalTraceCategories": null,
"extraHeaders": null,
"extraHeaders": {
"Cookie": "monster=blue"
},
"precomputedLanternData": null,
"onlyAudits": null,
"onlyCategories": null,
Expand Down
167 changes: 135 additions & 32 deletions proto/lighthouse-result.proto
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ message LighthouseResult {
map<string, CategoryGroup> category_groups = 11;

// Message containing the configuration settings for the LH run
// Next ID: 10
// Next ID: 35
message ConfigSettings {
// The possible form factors an audit can be run in.
// This enum served the emulated_form_factor field, but in v7, that field
Expand Down Expand Up @@ -189,20 +189,109 @@ message LighthouseResult {
string throttling_method = 8;

message ScreenEmulation {
// Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.
// 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.
// 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.
// 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.
// 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.
// 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 type(s) of report output to be produced.
// Can be a string of 'json' | 'html' | 'csv'
// Or an array of those strings
google.protobuf.Value output = 10;

// The maximum amount of time to wait for a page content render, in ms. If
// no content is rendered within this limit, the run is aborted with an
// error.
int32 max_wait_for_fcp = 11;
// The maximum amount of time to wait for a page to load, in ms.
int32 max_wait_for_load = 12;
// The number of milliseconds to wait after FCP until the page should be
// considered loaded.
int32 pause_after_fcp_ms = 13;
// The number of milliseconds to wait after the load event until the page
// should be considered loaded.
int32 pause_after_load_ms = 14;
// The number of milliseconds to wait between high priority network requests
// or 3 simultaneous requests before the page should be considered loaded.
int32 network_quiet_threshold_ms = 15;
// The number of milliseconds to wait between long tasks until the page
// should be considered loaded.
int32 cpu_quiet_threshold_ms = 16;

// User Agent string to apply, `false` to not change the host's UA string,
// or `true` to use Lighthouse's default UA string.
string emulated_user_agent = 17;
// Flag indicating the run should only audit.
bool audit_mode = 18;
// Flag indicating the run should only gather.
bool gather_mode = 19;
// Flag indicating that the browser storage should not be reset for the
// audit.
bool disable_storage_reset = 20;
// Flag indicating that Lighthouse should pause after page load to wait for
// the user's permission to continue the audit.
bool debug_navigation = 21;
// If set to true, gatherers should avoid any behavior that may be
// destructive to the page state. (e.g. extra navigations, resizing the
// viewport)
bool use_passive_gathering = 22;
// Disables collection of the full page screenshot, which can be rather
// large and possibly leave the page in an undesirable state.
bool disable_full_page_screenshot = 23;
// If set to true, will skip the initial navigation to about:blank.
bool skip_about_blank = 24;
// The URL to use for the "blank" neutral page in between navigations.
// Defaults to `about:blank`.
string blank_page = 25;

// List of URL patterns to block.
repeated string blocked_url_patterns = 26;

// Comma-delimited list of trace categories to include.
string additional_trace_categories = 27;

// If present, the run should only conduct this list of audits.
repeated string only_audits = 28;
// If present, the run should skip this list of audits.
repeated string skip_audits = 29;

// Flag indicating which kinds of browser storage should be reset for the audit.
// Cookies are not cleared by default, so the user isn't logged out.
// indexeddb, websql, and localstorage are not cleared by default to prevent
// loss of potentially important data.
// https://chromedevtools.github.io/debugger-protocol-viewer/tot/Storage/#type-StorageType
repeated string clear_storage_types = 30;

// Disables failing on 404 status code, and instead issues a warning
bool ignoreStatusCode = 31;

// List of extra HTTP Headers to include
map<string, string> extra_headers = 32;

// The budget.json object for LightWallet
repeated google.protobuf.Struct budgets = 33 [deprecated = true];

// Precomputed lantern estimates to use instead of observed analysis.
google.protobuf.Struct precomputed_lantern_data = 34;
}

// The settings that were used to run this audit
Expand Down Expand Up @@ -248,7 +337,8 @@ message LighthouseResult {
// URL displayed on the page after Lighthouse finishes.
string final_displayed_url = 18;

// Screenshot data of the full page, along with node rects relevant to the audit results.
// Screenshot data of the full page, along with node rects relevant to the
// audit results.
google.protobuf.Value full_page_screenshot = 19;

// Entity classification data.
Expand Down Expand Up @@ -281,7 +371,7 @@ message LhrCategory {
// This value is nullable, so is a `Value` type
google.protobuf.Value score = 4;

// An description for manual audits within this category.
// A description for manual audits within this category.
string manual_description = 5;

// A Category's reference to an AuditResult, with a weight for category
Expand Down Expand Up @@ -390,19 +480,24 @@ message AuditResult {

// Message containing the audit's MetricSavings.
message MetricSavings {
// Optional numeric value representing the audit's savings for the LCP metric.
// Optional numeric value representing the audit's savings for the LCP
// metric.
optional google.protobuf.DoubleValue LCP = 1;

// Optional numeric value representing the audit's savings for the FCP metric.
// Optional numeric value representing the audit's savings for the FCP
// metric.
optional google.protobuf.DoubleValue FCP = 2;

// Optional numeric value representing the audit's savings for the CLS metric.
// Optional numeric value representing the audit's savings for the CLS
// metric.
optional google.protobuf.DoubleValue CLS = 3;

// Optional numeric value representing the audit's savings for the TBT metric.
// Optional numeric value representing the audit's savings for the TBT
// metric.
optional google.protobuf.DoubleValue TBT = 4;

// Optional numeric value representing the audit's savings for the INP metric.
// Optional numeric value representing the audit's savings for the INP
// metric.
optional google.protobuf.DoubleValue INP = 5;
}

Expand Down Expand Up @@ -616,30 +711,34 @@ message I18n {
// of a browser, whereas field data often summarizes hundreds+ of page loads
string runtime_single_load_tooltip = 50;

// Descriptive label that this analysis only considers the initial load of the page,
// and no interaction beyond when the page had "fully loaded"
// Descriptive label that this analysis only considers the initial load of
// the page, and no interaction beyond when the page had "fully loaded"
string runtime_analysis_window = 51;

// Label for an interactive control that will reveal or hide a group of content.
// This control toggles between the text 'Show' and 'Hide'.
// Label for an interactive control that will reveal or hide a group of
// content. This control toggles between the text 'Show' and 'Hide'.
string show = 52;

// Label for an interactive control that will reveal or hide a group of content.
// This control toggles between the text 'Show' and 'Hide'.
// Label for an interactive control that will reveal or hide a group of
// content. This control toggles between the text 'Show' and 'Hide'.
string hide = 53;

// Label for an interactive control that will reveal or hide a group of content.
// This control toggles between the text 'Expand view' and 'Collapse view'.
// Label for an interactive control that will reveal or hide a group of
// content. This control toggles between the text 'Expand view' and
// 'Collapse view'.
string expand_view = 54;

// Label for an interactive control that will reveal or hide a group of content.
// This control toggles between the text 'Expand view' and 'Collapse view'.
// Label for an interactive control that will reveal or hide a group of
// content. This control toggles between the text 'Expand view' and
// 'Collapse view'.
string collapse_view = 55;

// Label indicating that Lighthouse throttled the page to emulate a slow 4G network connection.
// Label indicating that Lighthouse throttled the page to emulate a slow 4G
// network connection.
string runtime_slow_4g = 56;

// Label indicating that Lighthouse throttled the page using custom throttling settings.
// Label indicating that Lighthouse throttled the page using custom
// throttling settings.
string runtime_custom = 57;

// This label is for a button that will show the user a trace of the page.
Expand All @@ -654,28 +753,32 @@ message I18n {
// Label for a row decorative chip indiciating entity is first-party.
string first_party_chip_label = 61;

// Label for a link tooltip indicating that it will be opened in a new tab of the browser.
// Label for a link tooltip indicating that it will be opened in a new tab
// of the browser.
string open_in_a_new_tab_tooltip = 62;

// Label for a generic category for all resources that could not be attributed against a 1st or 3rd party entity.
// Label for a generic category for all resources that could not be
// attributed against a 1st or 3rd party entity.
string unattributable = 63;

// This label is for a button that will show the user a trace of the page.
string dropdown_view_unthrottled_trace = 64;

// Descriptive label that this analysis considers some arbitrary period of time containing user interactions
// Descriptive label that this analysis considers some arbitrary period of
// time containing user interactions
string runtime_analysis_window_timespan = 65;

// Descriptive label that this analysis considers a snapshot of the page at a single point in time
// Descriptive label that this analysis considers a snapshot of the page at
// a single point in time
string runtime_analysis_window_snapshot = 66;
}

// The message holding all formatted strings used in the renderer.
RendererFormattedStrings renderer_formatted_strings = 1;

// Holds all message paths used. The locale of the report has already be used to translated
// the strings in this LighthouseResult, but this field can be used to translate into another
// language.
// Holds all message paths used. The locale of the report has already be used
// to translated the strings in this LighthouseResult, but this field can be
// used to translate into another language.
map<string, google.protobuf.ListValue> icu_message_paths = 2;
}

Expand Down
2 changes: 1 addition & 1 deletion types/lhr/settings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export type ScreenEmulationSettings = {
pauseAfterFcpMs?: number;
/** The number of milliseconds to wait after the load event until the page should be considered loaded. */
pauseAfterLoadMs?: number;
/** The number of milliseconds to wait between high priority network requests or 3 simulataneous requests before the page should be considered loaded. */
/** The number of milliseconds to wait between high priority network requests or 3 simultaneous requests before the page should be considered loaded. */
networkQuietThresholdMs?: number;
/** The number of milliseconds to wait between long tasks until the page should be considered loaded. */
cpuQuietThresholdMs?: number;
Expand Down
Loading