core: add emulatedFormFactor setting#6098
Conversation
| const DESKTOP_EMULATION_METRICS = { | ||
| mobile: false, | ||
| screenWidth: 1366, | ||
| screenHeight: 768, |
There was a problem hiding this comment.
@paulirish it's not 100% clear to me what of these are necessary to zero-out any potential previous emulation 🤔
There was a problem hiding this comment.
you can just trim it down to these:
const DESKTOP_EMULATION_METRICS = {
mobile: false,
width: 1366,
height: 768,
deviceScaleFactor: 1,
};the rest are reset on the call.
| gatherMode?: boolean | string; | ||
| disableStorageReset?: boolean; | ||
| disableDeviceEmulation?: boolean; | ||
| emulatedFormFactor?: 'mobile'|'desktop'|'none'; |
There was a problem hiding this comment.
makes me want to add a 'none' to throttlingMethod that's just an alias of 'provided' 😆
There was a problem hiding this comment.
makes me want to add a
'none'to throttlingMethod that's just an alias of'provided'
yes pls :D
There was a problem hiding this comment.
I think we need to as it would be confusing if this one has a none but throttling does not.
Maybe add an alias provided here too? 🙄
brendankenny
left a comment
There was a problem hiding this comment.
LGTM!
We should probably bikeshed for at least a minute on emulated-form-factor and if it's obvious enough just from the flag name, but I have no strong opinion on it (yet :).
| const get = opts => Util.getEmulationDescriptions(opts).deviceEmulation; | ||
| assert.equal(get({disableDeviceEmulation: true}), 'No emulation'); | ||
| assert.equal(get({disableDeviceEmulation: false}), 'Emulated Nexus 5X'); | ||
| assert.equal(get({emulatedFormFactor: 'none'}), 'No emulation'); |
There was a problem hiding this comment.
Should this include the disableDeviceEmulation: false -> 'No emulation' case as well (since no emulatedFormFactor)? Admittedly Config won't let you get into this situation due to the emulatedFormFactor default, but it feels weird to leave out when testing just this file :)
| 'Disable clearing the browser cache and other storage APIs before a run', | ||
| 'disable-device-emulation': 'Disable Nexus 5X emulation', | ||
| 'disable-device-emulation': 'Disable all device form factor emulation', | ||
| 'emulated-form-factor': 'Controls the emulated device form factor (mobile vs. desktop)', |
There was a problem hiding this comment.
Should we also mention the flag precedence here, like "Controls the emulated device form factor (mobile vs. desktop) if emulation not disabled" or something. It gets weird that none also disables it, but it isn't too confusing...
(could also add something about Deprecated: use '--emulated-form-factor none'. to the disable-device-emulation description)
There was a problem hiding this comment.
should also update the readme with new --help output
There was a problem hiding this comment.
yeah good call, done
| const DESKTOP_EMULATION_METRICS = { | ||
| mobile: false, | ||
| screenWidth: 1366, | ||
| screenHeight: 768, |
There was a problem hiding this comment.
you can just trim it down to these:
const DESKTOP_EMULATION_METRICS = {
mobile: false,
width: 1366,
height: 768,
deviceScaleFactor: 1,
};the rest are reset on the call.
| const NEXUS5X_USERAGENT = { | ||
| userAgent: 'Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36' + | ||
| '(KHTML, like Gecko) Chrome/66.0.3359.30 Mobile Safari/537.36', | ||
| '(KHTML, like Gecko) Chrome/69.0.3497.100 Mobile Safari/537.36', |
There was a problem hiding this comment.
i usually bump to canary. 71.0.3559.0
here and below.
| @@ -992,7 +992,11 @@ class Driver { | |||
| */ | |||
| async beginEmulation(settings) { | |||
| if (!settings.disableDeviceEmulation) { | |||
There was a problem hiding this comment.
add TODO somewhere to remove this flag in a breaking version?
| 'list-trace-categories', 'view', 'verbose', 'quiet', 'help', | ||
| ]) | ||
| .choices('output', printer.getValidOutputOptions()) | ||
| .choices('emulated-form-factor', ['mobile', 'desktop', 'none']) |
There was a problem hiding this comment.
let's set the default to mobile here in the CLI too?
Summary
Introduces a new
emulatedFormFactorenum to settings to eventually replacedisableDeviceEmulationwhich is still respected.emulatedFormFactordefaults tomobilebut can be one ofmobile,desktop, ornone.noneis equivalent to settingdisableDeviceEmulationtotrue.Related Issues/PRs
closes #6092