Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 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() {

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
27 changes: 5 additions & 22 deletions core/lib/proto-preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,12 @@ 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.
// Drop these fields as we've omitted them from the proto for simplicity
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};
// @ts-expect-error Removing non-optional field.
delete reportJson.configSettings.auditMode;
// @ts-expect-error Removing non-optional field.
delete reportJson.configSettings.gatherMode;
}

// Remove runtimeError if it is NO_ERROR
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 @@ -458,7 +458,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 sampleConfig = {
extends: 'lighthouse:default',
settings: {
throttlingMethod: 'devtools',
extraHeaders: {
'Cookie': 'monster=blue',
},
},
};

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 @@ -7142,7 +7142,9 @@
"locale": "en-US",
"blockedUrlPatterns": null,
"additionalTraceCategories": null,
"extraHeaders": null,
"extraHeaders": {
"Cookie": "monster=blue"
},
"precomputedLanternData": null,
"onlyAudits": null,
"onlyCategories": null,
Expand Down
2 changes: 1 addition & 1 deletion proto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ You'll need to have **`v3.20+`** of protobuf.
Note that they [changed the versioning scheme](https://developers.google.com/protocol-buffers/docs/news/2022-05-06#versioning) and went from `3.20.1` to `4.21.0`. Making it more confusing, in `brew` and Github, `4.21.x` is shown as `v21.x`.


1. Install the proto compiler with `brew install protobuf`, or something [like this](https://github.com/GoogleChrome/lighthouse/blob/9fd45c5e2b92e3b1f10b642ea631dd5a9598f5ee/.github/workflows/unit.yml#L32-L45).
1. Install the proto compiler with `brew install protobuf`, or something [like this](https://github.com/GoogleChrome/lighthouse/blob/9fd45c5e2b92e3b1f10b642ea631dd5a9598f5ee/.github/workflows/unit.yml#L32-L45). You may also want to use miniconda to sandbox the python changes.
1. Run `yarn test-proto`

## Proto Resources
Expand Down
89 changes: 83 additions & 6 deletions proto/lighthouse-result.proto
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ message LighthouseResult {
map<string, CategoryGroup> category_groups = 11;

// Message containing the configuration settings for the LH run
// Next ID: 11
// Next ID: 33
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 @@ -193,11 +193,11 @@ 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;
Expand All @@ -217,8 +217,85 @@ message LighthouseResult {
// screen emulation.
ScreenEmulation screen_emulation = 9;


// Indicating whether Lighthouse should ignore status codes.
bool ignore_status_code = 10;

// 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 = 11;

// 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 = 12;
// The maximum amount of time to wait for a page to load, in ms.
int32 max_wait_for_load = 13;
// The number of milliseconds to wait after FCP until the page should be
// considered loaded.
int32 pause_after_fcp_ms = 14;
// The number of milliseconds to wait after the load event until the page
// should be considered loaded.
int32 pause_after_load_ms = 15;
// 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 = 16;
// The number of milliseconds to wait between long tasks until the page
// should be considered loaded.
int32 cpu_quiet_threshold_ms = 17;

// 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 = 18;

// audit_mode and gather_mode are excluded from the proto, as they are boolean/string and niche enough that we don't want to deal with them.

// Flag indicating that the browser storage should not be reset for the
// audit.
bool disable_storage_reset = 19;
// Flag indicating that Lighthouse should pause after page load to wait for
// the user's permission to continue the audit.
bool debug_navigation = 20;
// 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 = 21;
// 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 = 22;
// If set to true, will skip the initial navigation to about:blank.
bool skip_about_blank = 23;
// The URL to use for the "blank" neutral page in between navigations.
// Defaults to `about:blank`.
string blank_page = 24;

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

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

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

// 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 = 29;

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

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

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

// The settings that were used to run this audit
Expand Down Expand Up @@ -298,7 +375,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
2 changes: 1 addition & 1 deletion types/lhr/settings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,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