From eeaa7945ba085c321cd511deef1fe1d8e3ac358c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Z=C3=BCnd?= Date: Tue, 19 Jul 2022 09:25:44 +0200 Subject: [PATCH] [lighthouse] Fix lighthouse web tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL fixes the lighthouse web tests sitting in the DevTools repo. The `GetStorageAndQuota` CDP method can fail now due to storage partitioning, so we have to account for that error. Another bug seems to be that changing the throttling drop down does not affect the underlying setting, so we change the test to massage the settings directly instead of poking the UI. Bug: None Change-Id: Ib7f4e3845722bde7dd1fd86b99896a8339414d87 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3769874 Commit-Queue: Simon Zünd Reviewed-by: Alex Rudenko --- front_end/panels/lighthouse/LighthouseController.ts | 3 +++ .../devtools/lighthouse/lighthouse-flags-run.js | 13 +++++++------ .../lighthouse/lighthouse-emulate-run-expected.txt | 2 +- .../lighthouse-successful-navigation-expected.txt | 2 +- .../lighthouse-successful-run-expected.txt | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/front_end/panels/lighthouse/LighthouseController.ts b/front_end/panels/lighthouse/LighthouseController.ts index 5ced4b51b9..88e3fcd96e 100644 --- a/front_end/panels/lighthouse/LighthouseController.ts +++ b/front_end/panels/lighthouse/LighthouseController.ts @@ -309,6 +309,9 @@ export class LighthouseController extends Common.ObjectWrapper.ObjectWrapper usage.usage) .map(usage => STORAGE_TYPE_NAMES.get(usage.storageType)) .map(i18nStringFn => i18nStringFn ? i18nStringFn() : undefined) diff --git a/test/webtests/http/tests/devtools/lighthouse/lighthouse-flags-run.js b/test/webtests/http/tests/devtools/lighthouse/lighthouse-flags-run.js index 48d11c7740..d6c3c8e475 100644 --- a/test/webtests/http/tests/devtools/lighthouse/lighthouse-flags-run.js +++ b/test/webtests/http/tests/devtools/lighthouse/lighthouse-flags-run.js @@ -9,12 +9,13 @@ await TestRunner.loadTestModule('lighthouse_test_runner'); await TestRunner.showPanel('lighthouse'); - const dialogElement = LighthouseTestRunner.getContainerElement(); - dialogElement.querySelector('input[name="lighthouse.device_type"][value="desktop"]').click(); - // Turn off simulated throttling. - dialogElement.querySelector('.lighthouse-settings-pane .toolbar') - .shadowRoot.querySelector('option[value="devtools"]') - .selected = true; + // Turn off simulated throttling and use mobile. + const throttlingSetting = + self.Common.Settings.instance().createSetting('lighthouse.throttling', 'simulate', 'Synced'); + throttlingSetting.set('devtools'); + + const deviceSetting = self.Common.Settings.instance().createSetting('lighthouse.device_type', 'mobile', 'Synced'); + deviceSetting.set('desktop'); LighthouseTestRunner.dumpStartAuditState(); LighthouseTestRunner.getRunButton().click(); diff --git a/test/webtests/platform/generic/http/tests/devtools/lighthouse/lighthouse-emulate-run-expected.txt b/test/webtests/platform/generic/http/tests/devtools/lighthouse/lighthouse-emulate-run-expected.txt index 4bb2d9beb8..142018c89f 100644 --- a/test/webtests/platform/generic/http/tests/devtools/lighthouse/lighthouse-emulate-run-expected.txt +++ b/test/webtests/platform/generic/http/tests/devtools/lighthouse/lighthouse-emulate-run-expected.txt @@ -15,7 +15,7 @@ Analyze page load: enabled visible =============== Lighthouse Results =============== URL: http://127.0.0.1:8000/devtools/lighthouse/resources/lighthouse-emulate-pass.html -Version: 9.6.1 +Version: 9.6.2 formFactor: mobile screenEmulation: { "mobile": true, diff --git a/test/webtests/platform/generic/http/tests/devtools/lighthouse/lighthouse-successful-navigation-expected.txt b/test/webtests/platform/generic/http/tests/devtools/lighthouse/lighthouse-successful-navigation-expected.txt index 064f438784..3d982a9080 100644 --- a/test/webtests/platform/generic/http/tests/devtools/lighthouse/lighthouse-successful-navigation-expected.txt +++ b/test/webtests/platform/generic/http/tests/devtools/lighthouse/lighthouse-successful-navigation-expected.txt @@ -262,7 +262,7 @@ Generating results... =============== Lighthouse Results =============== URL: http://127.0.0.1:8000/devtools/lighthouse/resources/lighthouse-basic.html -Version: 9.6.1 +Version: 9.6.2 ViewportDimensions: { "innerWidth": 980, "innerHeight": 1743, diff --git a/test/webtests/platform/generic/http/tests/devtools/lighthouse/lighthouse-successful-run-expected.txt b/test/webtests/platform/generic/http/tests/devtools/lighthouse/lighthouse-successful-run-expected.txt index ee4926a0fa..1ebde799d7 100644 --- a/test/webtests/platform/generic/http/tests/devtools/lighthouse/lighthouse-successful-run-expected.txt +++ b/test/webtests/platform/generic/http/tests/devtools/lighthouse/lighthouse-successful-run-expected.txt @@ -373,7 +373,7 @@ Generating results... =============== Lighthouse Results =============== URL: http://127.0.0.1:8000/devtools/lighthouse/resources/lighthouse-basic.html -Version: 9.6.1 +Version: 9.6.2 ViewportDimensions: { "innerWidth": 980, "innerHeight": 1743,