From 98d5cb6bb7fe7c73ad75ee3f44e47a5f8fbe891e Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Thu, 16 Nov 2023 10:36:40 -0800 Subject: [PATCH 1/8] proto: add ConfigSettings fields. thx #15193 --- proto/lighthouse-result.proto | 151 +++++++++++++++++++++++++++------- types/lhr/settings.d.ts | 2 +- 2 files changed, 120 insertions(+), 33 deletions(-) diff --git a/proto/lighthouse-result.proto b/proto/lighthouse-result.proto index 8126d66d6598..c82bd3a848d0 100644 --- a/proto/lighthouse-result.proto +++ b/proto/lighthouse-result.proto @@ -128,7 +128,7 @@ message LighthouseResult { map category_groups = 11; // Message containing the configuration settings for the LH run - // Next ID: 10 + // Next ID: 30 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 @@ -189,20 +189,93 @@ 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: 'json' | 'html' | 'csv' + string 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. + int64 max_wait_for_fcp = 11; + // The maximum amount of time to wait for a page to load, in ms. + int64 max_wait_for_load = 12; + // The number of milliseconds to wait after FCP until the page should be + // considered loaded. + int64 pause_after_fcp_ms = 13; + // The number of milliseconds to wait after the load event until the page + // should be considered loaded. + int64 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. + int64 network_quiet_threshold_ms = 15; + // The number of milliseconds to wait between long tasks until the page + // should be considered loaded. + int64 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; + + // Additional fields we haven't explicitly typed for proto: + // budgets + // extra_headers + // precomputed_lantern_data } // The settings that were used to run this audit @@ -248,7 +321,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. @@ -281,7 +355,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 @@ -390,19 +464,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; } @@ -616,30 +695,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. @@ -654,28 +737,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 icu_message_paths = 2; } diff --git a/types/lhr/settings.d.ts b/types/lhr/settings.d.ts index 3baf6eb87803..74dfebe7ce34 100644 --- a/types/lhr/settings.d.ts +++ b/types/lhr/settings.d.ts @@ -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; From 8b8d7efad9f632aab5fba197e24840b7ad4519c5 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Thu, 16 Nov 2023 10:37:51 -0800 Subject: [PATCH 2/8] ci hax --- .github/workflows/unit.yml | 79 +++++++++++++++++----------------- core/lib/proto-preprocessor.js | 48 ++++++++++----------- 2 files changed, 63 insertions(+), 64 deletions(-) diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index 80a45b24926d..24104732b546 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -2,7 +2,6 @@ name: unit on: push: - branches: [main] pull_request: # run on all PRs, not just PRs to a particular branch env: @@ -61,28 +60,28 @@ jobs: - run: yarn test-proto # Run before unit-core because the roundtrip json is needed for proto tests. - - run: sudo apt-get install xvfb - - - name: yarn unit - if: ${{ matrix.node != env.LATEST_NODE }} - run: xvfb-run --auto-servernum yarn unit:ci - - # Only gather coverage on latest node, where c8 is the most accurate. - - name: yarn unit:cicoverage - if: ${{ matrix.node == env.LATEST_NODE }} - run: | - xvfb-run --auto-servernum yarn unit:cicoverage - yarn c8 report --reporter text-lcov > unit-coverage.lcov - - name: Upload test coverage to Codecov - if: ${{ matrix.node == env.LATEST_NODE }} - uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d - with: - flags: unit - file: ./unit-coverage.lcov - - # Runs here because it needs the roundtrip proto. - - name: yarn test-viewer - run: yarn build-viewer && xvfb-run --auto-servernum bash $GITHUB_WORKSPACE/.github/scripts/test-retry.sh yarn test-viewer + # - run: sudo apt-get install xvfb + + # - name: yarn unit + # if: ${{ matrix.node != env.LATEST_NODE }} + # run: xvfb-run --auto-servernum yarn unit:ci + + # # Only gather coverage on latest node, where c8 is the most accurate. + # - name: yarn unit:cicoverage + # if: ${{ matrix.node == env.LATEST_NODE }} + # run: | + # xvfb-run --auto-servernum yarn unit:cicoverage + # yarn c8 report --reporter text-lcov > unit-coverage.lcov + # - name: Upload test coverage to Codecov + # if: ${{ matrix.node == env.LATEST_NODE }} + # uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d + # with: + # flags: unit + # file: ./unit-coverage.lcov + + # # Runs here because it needs the roundtrip proto. + # - name: yarn test-viewer + # run: yarn build-viewer && xvfb-run --auto-servernum bash $GITHUB_WORKSPACE/.github/scripts/test-retry.sh yarn test-viewer - name: Upload failures if: failure() @@ -91,25 +90,25 @@ jobs: name: Unit (ubuntu; node ${{ matrix.node }}) path: .tmp/unit-failures/ - # For windows, just test the potentially platform-specific code. - unit-windows: - runs-on: windows-latest - name: Windows unit + # # For windows, just test the potentially platform-specific code. + # unit-windows: + # runs-on: windows-latest + # name: Windows unit - steps: - - name: git clone - uses: actions/checkout@v3 + # steps: + # - name: git clone + # uses: actions/checkout@v3 - - name: Use Node.js 18.x - uses: actions/setup-node@v3 - with: - node-version: 18.x + # - name: Use Node.js 18.x + # uses: actions/setup-node@v3 + # with: + # node-version: 18.x - - run: yarn install --frozen-lockfile --network-timeout 1000000 - - run: yarn build-report + # - run: yarn install --frozen-lockfile --network-timeout 1000000 + # - run: yarn build-report - - run: yarn unit-cli - - run: yarn diff:sample-json + # - run: yarn unit-cli + # - run: yarn diff:sample-json - # Fail if any changes were written to any source files or generated untracked files (ex, from -GA). - - run: git add -A && git diff --cached --exit-code + # # Fail if any changes were written to any source files or generated untracked files (ex, from -GA). + # - run: git add -A && git diff --cached --exit-code diff --git a/core/lib/proto-preprocessor.js b/core/lib/proto-preprocessor.js index fbe561cc325d..dfc5bf46479f 100644 --- a/core/lib/proto-preprocessor.js +++ b/core/lib/proto-preprocessor.js @@ -24,30 +24,30 @@ 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}; - } + // // 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') { From 864607ebcd696734c5a219c161311811ea24c5f9 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Thu, 16 Nov 2023 10:55:07 -0800 Subject: [PATCH 3/8] drop optional? --- proto/lighthouse-result.proto | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/proto/lighthouse-result.proto b/proto/lighthouse-result.proto index c82bd3a848d0..bb85ac523f62 100644 --- a/proto/lighthouse-result.proto +++ b/proto/lighthouse-result.proto @@ -466,23 +466,23 @@ message AuditResult { message MetricSavings { // Optional numeric value representing the audit's savings for the LCP // metric. - optional google.protobuf.DoubleValue LCP = 1; + google.protobuf.DoubleValue LCP = 1; // Optional numeric value representing the audit's savings for the FCP // metric. - optional google.protobuf.DoubleValue FCP = 2; + google.protobuf.DoubleValue FCP = 2; // Optional numeric value representing the audit's savings for the CLS // metric. - optional google.protobuf.DoubleValue CLS = 3; + google.protobuf.DoubleValue CLS = 3; // Optional numeric value representing the audit's savings for the TBT // metric. - optional google.protobuf.DoubleValue TBT = 4; + google.protobuf.DoubleValue TBT = 4; // Optional numeric value representing the audit's savings for the INP // metric. - optional google.protobuf.DoubleValue INP = 5; + google.protobuf.DoubleValue INP = 5; } // The audit's MetricSavings. @@ -787,16 +787,16 @@ message LhrEntity { string name = 1; // An optional homepage URL of the entity. - optional string homepage = 2; + string homepage = 2; // An optional category name for the entity. - optional string category = 3; + string category = 3; // An optional flag indicating if the entity is the first party. - optional bool is_first_party = 4; + bool is_first_party = 4; // An optional flag indicating if the entity is not recognized. - optional bool is_unrecognized = 5; + bool is_unrecognized = 5; // A list of URL origin strings that belong to this entity. repeated string origins = 6; From 5d54cdb986b7be83f5308e46f82c4a7f7c90579d Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Thu, 16 Nov 2023 11:42:40 -0800 Subject: [PATCH 4/8] finish typing the rest. the json roundtrip is happy too --- core/lib/proto-preprocessor.js | 25 -------------- core/test/lib/proto-preprocessor-test.js | 33 ++++++++++++++++--- core/test/results/sample_v2.json | 14 ++++++-- proto/lighthouse-result.proto | 42 ++++++++++++++++-------- 4 files changed, 70 insertions(+), 44 deletions(-) diff --git a/core/lib/proto-preprocessor.js b/core/lib/proto-preprocessor.js index dfc5bf46479f..e3d8fa6c3f33 100644 --- a/core/lib/proto-preprocessor.js +++ b/core/lib/proto-preprocessor.js @@ -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; diff --git a/core/test/lib/proto-preprocessor-test.js b/core/test/lib/proto-preprocessor-test.js index 6047c878d388..fbf8fa8df589 100644 --- a/core/test/lib/proto-preprocessor-test.js +++ b/core/test/lib/proto-preprocessor-test.js @@ -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 diff --git a/core/test/results/sample_v2.json b/core/test/results/sample_v2.json index ed08b43588a6..e6acc5eba743 100644 --- a/core/test/results/sample_v2.json +++ b/core/test/results/sample_v2.json @@ -5858,8 +5858,18 @@ "locale": "en-US", "blockedUrlPatterns": null, "additionalTraceCategories": null, - "extraHeaders": null, - "precomputedLanternData": null, + "extraHeaders": { + "Cookie": "monster=blue", + "x-men": "wolverine" + }, + "precomputedLanternData": { + "additionalRttByOrigin": { + "http://localhost:10200'": 500 + }, + "serverResponseTimeByOrigin": { + "'http://localhost:10200'": 1000 + } + }, "onlyAudits": null, "onlyCategories": null, "skipAudits": null diff --git a/proto/lighthouse-result.proto b/proto/lighthouse-result.proto index bb85ac523f62..9861fa5325a6 100644 --- a/proto/lighthouse-result.proto +++ b/proto/lighthouse-result.proto @@ -128,7 +128,7 @@ message LighthouseResult { map category_groups = 11; // Message containing the configuration settings for the LH run - // Next ID: 30 + // 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 @@ -213,27 +213,29 @@ message LighthouseResult { // screen emulation. ScreenEmulation screen_emulation = 9; - // The type(s) of report output to be produced: 'json' | 'html' | 'csv' - string output = 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 = 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. - int64 max_wait_for_fcp = 11; + int32 max_wait_for_fcp = 11; // The maximum amount of time to wait for a page to load, in ms. - int64 max_wait_for_load = 12; + int32 max_wait_for_load = 12; // The number of milliseconds to wait after FCP until the page should be // considered loaded. - int64 pause_after_fcp_ms = 13; + int32 pause_after_fcp_ms = 13; // The number of milliseconds to wait after the load event until the page // should be considered loaded. - int64 pause_after_load_ms = 14; + 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. - int64 network_quiet_threshold_ms = 15; + int32 network_quiet_threshold_ms = 15; // The number of milliseconds to wait between long tasks until the page // should be considered loaded. - int64 cpu_quiet_threshold_ms = 16; + 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. @@ -272,10 +274,24 @@ message LighthouseResult { // If present, the run should skip this list of audits. repeated string skip_audits = 29; - // Additional fields we haven't explicitly typed for proto: - // budgets - // extra_headers - // precomputed_lantern_data + // 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 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 From 19f6faaabb447e9506740b2d1af6c808daf311e4 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Thu, 16 Nov 2023 11:48:42 -0800 Subject: [PATCH 5/8] bake extraheaders into samplejson for testing purposes --- core/test/results/artifacts/artifacts.json | 4 +++- core/test/results/sample-config.js | 3 +++ core/test/results/sample_v2.json | 12 ++---------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/core/test/results/artifacts/artifacts.json b/core/test/results/artifacts/artifacts.json index fd6277ab1b8c..279a0e029231 100644 --- a/core/test/results/artifacts/artifacts.json +++ b/core/test/results/artifacts/artifacts.json @@ -175,7 +175,9 @@ "locale": "en-US", "blockedUrlPatterns": null, "additionalTraceCategories": null, - "extraHeaders": null, + "extraHeaders": { + "Cookie": "monster=blue" + }, "precomputedLanternData": null, "onlyAudits": null, "onlyCategories": null, diff --git a/core/test/results/sample-config.js b/core/test/results/sample-config.js index 82dbfa7e0bc8..f6d722cf9d67 100644 --- a/core/test/results/sample-config.js +++ b/core/test/results/sample-config.js @@ -13,6 +13,9 @@ const budgetedConfig = { extends: 'lighthouse:default', settings: { throttlingMethod: 'devtools', + extraHeaders: { + 'Cookie': 'monster=blue', + }, budgets: [{ path: '/', resourceCounts: [ diff --git a/core/test/results/sample_v2.json b/core/test/results/sample_v2.json index e6acc5eba743..7d154a6da6a9 100644 --- a/core/test/results/sample_v2.json +++ b/core/test/results/sample_v2.json @@ -5859,17 +5859,9 @@ "blockedUrlPatterns": null, "additionalTraceCategories": null, "extraHeaders": { - "Cookie": "monster=blue", - "x-men": "wolverine" - }, - "precomputedLanternData": { - "additionalRttByOrigin": { - "http://localhost:10200'": 500 - }, - "serverResponseTimeByOrigin": { - "'http://localhost:10200'": 1000 - } + "Cookie": "monster=blue" }, + "precomputedLanternData": null, "onlyAudits": null, "onlyCategories": null, "skipAudits": null From 6414aad2abdf12d316b8e79b383f975916850acb Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Thu, 16 Nov 2023 11:49:02 -0800 Subject: [PATCH 6/8] Revert "drop optional?" This reverts commit 864607ebcd696734c5a219c161311811ea24c5f9. --- proto/lighthouse-result.proto | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/proto/lighthouse-result.proto b/proto/lighthouse-result.proto index 9861fa5325a6..6b42c18c9f98 100644 --- a/proto/lighthouse-result.proto +++ b/proto/lighthouse-result.proto @@ -482,23 +482,23 @@ message AuditResult { message MetricSavings { // Optional numeric value representing the audit's savings for the LCP // metric. - google.protobuf.DoubleValue LCP = 1; + optional google.protobuf.DoubleValue LCP = 1; // Optional numeric value representing the audit's savings for the FCP // metric. - google.protobuf.DoubleValue FCP = 2; + optional google.protobuf.DoubleValue FCP = 2; // Optional numeric value representing the audit's savings for the CLS // metric. - google.protobuf.DoubleValue CLS = 3; + optional google.protobuf.DoubleValue CLS = 3; // Optional numeric value representing the audit's savings for the TBT // metric. - google.protobuf.DoubleValue TBT = 4; + optional google.protobuf.DoubleValue TBT = 4; // Optional numeric value representing the audit's savings for the INP // metric. - google.protobuf.DoubleValue INP = 5; + optional google.protobuf.DoubleValue INP = 5; } // The audit's MetricSavings. @@ -803,16 +803,16 @@ message LhrEntity { string name = 1; // An optional homepage URL of the entity. - string homepage = 2; + optional string homepage = 2; // An optional category name for the entity. - string category = 3; + optional string category = 3; // An optional flag indicating if the entity is the first party. - bool is_first_party = 4; + optional bool is_first_party = 4; // An optional flag indicating if the entity is not recognized. - bool is_unrecognized = 5; + optional bool is_unrecognized = 5; // A list of URL origin strings that belong to this entity. repeated string origins = 6; From 2a78fb1d1e744f0965b1e46607aab9fe4dc3fee1 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Thu, 16 Nov 2023 12:00:04 -0800 Subject: [PATCH 7/8] Revert "ci hax" This reverts commit 8b8d7efad9f632aab5fba197e24840b7ad4519c5. --- .github/workflows/unit.yml | 79 +++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index 24104732b546..80a45b24926d 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -2,6 +2,7 @@ name: unit on: push: + branches: [main] pull_request: # run on all PRs, not just PRs to a particular branch env: @@ -60,28 +61,28 @@ jobs: - run: yarn test-proto # Run before unit-core because the roundtrip json is needed for proto tests. - # - run: sudo apt-get install xvfb - - # - name: yarn unit - # if: ${{ matrix.node != env.LATEST_NODE }} - # run: xvfb-run --auto-servernum yarn unit:ci - - # # Only gather coverage on latest node, where c8 is the most accurate. - # - name: yarn unit:cicoverage - # if: ${{ matrix.node == env.LATEST_NODE }} - # run: | - # xvfb-run --auto-servernum yarn unit:cicoverage - # yarn c8 report --reporter text-lcov > unit-coverage.lcov - # - name: Upload test coverage to Codecov - # if: ${{ matrix.node == env.LATEST_NODE }} - # uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d - # with: - # flags: unit - # file: ./unit-coverage.lcov - - # # Runs here because it needs the roundtrip proto. - # - name: yarn test-viewer - # run: yarn build-viewer && xvfb-run --auto-servernum bash $GITHUB_WORKSPACE/.github/scripts/test-retry.sh yarn test-viewer + - run: sudo apt-get install xvfb + + - name: yarn unit + if: ${{ matrix.node != env.LATEST_NODE }} + run: xvfb-run --auto-servernum yarn unit:ci + + # Only gather coverage on latest node, where c8 is the most accurate. + - name: yarn unit:cicoverage + if: ${{ matrix.node == env.LATEST_NODE }} + run: | + xvfb-run --auto-servernum yarn unit:cicoverage + yarn c8 report --reporter text-lcov > unit-coverage.lcov + - name: Upload test coverage to Codecov + if: ${{ matrix.node == env.LATEST_NODE }} + uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d + with: + flags: unit + file: ./unit-coverage.lcov + + # Runs here because it needs the roundtrip proto. + - name: yarn test-viewer + run: yarn build-viewer && xvfb-run --auto-servernum bash $GITHUB_WORKSPACE/.github/scripts/test-retry.sh yarn test-viewer - name: Upload failures if: failure() @@ -90,25 +91,25 @@ jobs: name: Unit (ubuntu; node ${{ matrix.node }}) path: .tmp/unit-failures/ - # # For windows, just test the potentially platform-specific code. - # unit-windows: - # runs-on: windows-latest - # name: Windows unit + # For windows, just test the potentially platform-specific code. + unit-windows: + runs-on: windows-latest + name: Windows unit - # steps: - # - name: git clone - # uses: actions/checkout@v3 + steps: + - name: git clone + uses: actions/checkout@v3 - # - name: Use Node.js 18.x - # uses: actions/setup-node@v3 - # with: - # node-version: 18.x + - name: Use Node.js 18.x + uses: actions/setup-node@v3 + with: + node-version: 18.x - # - run: yarn install --frozen-lockfile --network-timeout 1000000 - # - run: yarn build-report + - run: yarn install --frozen-lockfile --network-timeout 1000000 + - run: yarn build-report - # - run: yarn unit-cli - # - run: yarn diff:sample-json + - run: yarn unit-cli + - run: yarn diff:sample-json - # # Fail if any changes were written to any source files or generated untracked files (ex, from -GA). - # - run: git add -A && git diff --cached --exit-code + # Fail if any changes were written to any source files or generated untracked files (ex, from -GA). + - run: git add -A && git diff --cached --exit-code From 3271004fb394e677383011bbcfe98952c4e9d9c7 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Thu, 16 Nov 2023 12:24:46 -0800 Subject: [PATCH 8/8] add extraheaders to cli run test --- cli/test/cli/run-test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/test/cli/run-test.js b/cli/test/cli/run-test.js index 4b42ec3f70ee..da1fc2d3cb05 100644 --- a/cli/test/cli/run-test.js +++ b/cli/test/cli/run-test.js @@ -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.