Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

report: convert v6 emulatedFormFactor to v7 formFactor #11876

Merged
merged 4 commits into from
Dec 23, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions lighthouse-core/report/html/renderer/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,24 @@ class Util {
networkThrottling = Util.i18n.strings.runtimeUnknown;
}

// TODO(paulirish): revise Runtime Settings strings: https://github.com/GoogleChrome/lighthouse/pull/11796
const deviceEmulation = settings.formFactor === 'mobile'

This comment was marked as resolved.

? Util.i18n.strings.runtimeMobileEmulation
: Util.i18n.strings.runtimeDesktopEmulation;

let deviceEmulation;
// COMPAT: remove this fallback handling at Lighthouse v8
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove in v8? Don't we want to keep the renderer backwards-compat indefinitely?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right, there's three possibilities for the old way...

Copy link
Collaborator

@connorjclark connorjclark Dec 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deviceEmulation = {
  mobile: Util.i18n.strings.runtimeMobileEmulation,
  desktop: Util.i18n.strings.runtimeDesktopEmulation,
  none: Util.i18n.strings.runtimeNoEmulation,
}[settings.formFactor || settings.emulatedFormFactor || 'none']

maybe?

or

deviceEmulation = {
  mobile: Util.i18n.strings.runtimeMobileEmulation,
  desktop: Util.i18n.strings.runtimeDesktopEmulation,
}[settings.formFactor || settings.emulatedFormFactor] || Util.i18n.strings.runtimeNoEmulation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

// @ts-expect-error fallback handling for emulatedFormFactor
if (settings.emulatedFormFactor) {
// @ts-expect-error removed setting
deviceEmulation = settings.emulatedFormFactor === 'mobile'
? Util.i18n.strings.runtimeMobileEmulation
// @ts-expect-error removed setting
: settings.emulatedFormFactor === 'desktop'
? Util.i18n.strings.runtimeDesktopEmulation
: Util.i18n.strings.runtimeNoEmulation;
} else {
// TODO(paulirish): revise Runtime Settings strings: https://github.com/GoogleChrome/lighthouse/pull/11796
deviceEmulation = settings.formFactor === 'mobile'
? Util.i18n.strings.runtimeMobileEmulation
: Util.i18n.strings.runtimeDesktopEmulation;
}

return {
deviceEmulation,
Expand Down