[lighthouse] Fix lighthouse web tests

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 <szuend@chromium.org>
Reviewed-by: Alex Rudenko <alexrudenko@chromium.org>
This commit is contained in:
Simon Zünd
2022-07-21 06:24:55 +00:00
committed by Devtools-frontend LUCI CQ
parent 5f35502b3c
commit eeaa7945ba
5 changed files with 13 additions and 9 deletions
@@ -309,6 +309,9 @@ export class LighthouseController extends Common.ObjectWrapper.ObjectWrapper<Eve
return '';
}
const usageData = await mainTarget.storageAgent().invoke_getUsageAndQuota({origin});
if (usageData.getError()) {
return '';
}
const locations = usageData.usageBreakdown.filter(usage => usage.usage)
.map(usage => STORAGE_TYPE_NAMES.get(usage.storageType))
.map(i18nStringFn => i18nStringFn ? i18nStringFn() : undefined)
@@ -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();
@@ -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,
@@ -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,
@@ -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,