Commit a96d4c75 authored by Paul Irish's avatar Paul Irish Committed by Commit Bot

Audits: Fix viewport emulation invisibility bugs

Bug: 979126, 816849, 984743
Change-Id: I454cee9d75c24b4b703b8dd71cb83be4eff0fb11
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1699018
Commit-Queue: Paul Irish <paulirish@chromium.org>
Auto-Submit: Paul Irish <paulirish@chromium.org>
Reviewed-by: default avatarErik Luo <luoe@chromium.org>
Cr-Commit-Position: refs/heads/master@{#678036}
parent b6d9932f
...@@ -237,7 +237,9 @@ Audits.RuntimeSettings = [ ...@@ -237,7 +237,9 @@ Audits.RuntimeSettings = [
setting: Common.settings.createSetting('audits.device_type', 'mobile'), setting: Common.settings.createSetting('audits.device_type', 'mobile'),
description: ls`Apply mobile emulation during auditing`, description: ls`Apply mobile emulation during auditing`,
setFlags: (flags, value) => { setFlags: (flags, value) => {
flags.emulatedFormFactor = value; flags._devtoolsEmulationType = value;
// See Audits.AuditsPanel._setupEmulationAndProtocolConnection()
flags.emulatedFormFactor = 'none';
}, },
options: [ options: [
{label: ls`Mobile`, value: 'mobile'}, {label: ls`Mobile`, value: 'mobile'},
......
...@@ -244,6 +244,12 @@ Audits.AuditsPanel = class extends UI.Panel { ...@@ -244,6 +244,12 @@ Audits.AuditsPanel = class extends UI.Panel {
this._renderStartView(); this._renderStartView();
} }
/**
* We set the device emulation on the DevTools-side for two reasons:
* 1. To workaround some odd device metrics emulation bugs like occuluding viewports
* 2. To get the attractive device outline
* flags.emulatedFormFactor is always set to none, so Lighthouse doesn't apply its own emulation.
*/
async _setupEmulationAndProtocolConnection() { async _setupEmulationAndProtocolConnection() {
const flags = this._controller.getFlags(); const flags = this._controller.getFlags();
...@@ -252,11 +258,10 @@ Audits.AuditsPanel = class extends UI.Panel { ...@@ -252,11 +258,10 @@ Audits.AuditsPanel = class extends UI.Panel {
this._emulationOutlineEnabledBefore = emulationModel.deviceOutlineSetting().get(); this._emulationOutlineEnabledBefore = emulationModel.deviceOutlineSetting().get();
emulationModel.toolbarControlsEnabledSetting().set(false); emulationModel.toolbarControlsEnabledSetting().set(false);
if (flags.emulatedFormFactor === 'desktop') { if (flags._devtoolsEmulationType === 'desktop') {
emulationModel.enabledSetting().set(false); emulationModel.enabledSetting().set(false);
emulationModel.deviceOutlineSetting().set(false);
emulationModel.emulate(Emulation.DeviceModeModel.Type.None, null, null); emulationModel.emulate(Emulation.DeviceModeModel.Type.None, null, null);
} else { } else if (flags._devtoolsEmulationType === 'mobile') {
emulationModel.enabledSetting().set(true); emulationModel.enabledSetting().set(true);
emulationModel.deviceOutlineSetting().set(true); emulationModel.deviceOutlineSetting().set(true);
......
...@@ -11,7 +11,7 @@ Tests that audits panel passes flags. ...@@ -11,7 +11,7 @@ Tests that audits panel passes flags.
Run audits: enabled visible Run audits: enabled visible
=============== Lighthouse Results =============== =============== Lighthouse Results ===============
emulatedFormFactor: desktop emulatedFormFactor: none
disableStorageReset: false disableStorageReset: false
throttlingMethod: provided throttlingMethod: provided
...@@ -298,7 +298,7 @@ button-name: notApplicable ...@@ -298,7 +298,7 @@ button-name: notApplicable
bypass: notApplicable bypass: notApplicable
canonical: notApplicable canonical: notApplicable
color-contrast: notApplicable color-contrast: notApplicable
content-width: fail content-width: notApplicable
critical-request-chains: notApplicable critical-request-chains: notApplicable
custom-controls-labels: manual custom-controls-labels: manual
custom-controls-roles: manual custom-controls-roles: manual
...@@ -321,7 +321,7 @@ first-meaningful-paint: flaky ...@@ -321,7 +321,7 @@ first-meaningful-paint: flaky
focus-traps: manual focus-traps: manual
focusable-controls: manual focusable-controls: manual
font-display: pass font-display: pass
font-size: fail font-size: notApplicable
frame-title: notApplicable frame-title: notApplicable
geolocation-on-start: pass geolocation-on-start: pass
heading-levels: manual heading-levels: manual
...@@ -381,7 +381,7 @@ speed-index: flaky ...@@ -381,7 +381,7 @@ speed-index: flaky
splash-screen: fail splash-screen: fail
structured-data: manual structured-data: manual
tabindex: notApplicable tabindex: notApplicable
tap-targets: fail tap-targets: notApplicable
td-headers-attr: notApplicable td-headers-attr: notApplicable
th-has-data-cells: notApplicable th-has-data-cells: notApplicable
themed-omnibox: fail themed-omnibox: fail
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment