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

Conversation

paulirish
Copy link
Member

fixes #11873

restored the handling for the report's "Device" string for v6.

image

I redid the conditionals using ternaries, but that bit has the same logic.

@paulirish paulirish requested a review from a team as a code owner December 22, 2020 22:36
@paulirish paulirish requested review from patrickhulce and removed request for a team December 22, 2020 22:36
@google-cla google-cla bot added the cla: yes label Dec 22, 2020
@@ -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.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

@brendankenny
Copy link
Member

can we upgrade the LHR to the expected format in prepareReportResult like we do for configSettings.locale and friends so the rest of the code can assume the genuine form (and keep all the @ts-expect-errors in one place)?

Copy link
Member Author

@paulirish paulirish left a comment

Choose a reason for hiding this comment

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

can we upgrade the LHR to the expected format in prepareReportResult like we do for configSettings.locale and friends so the rest of the code can assume the genuine form (and keep all the @ts-expect-errors in one place)?

love it

@connorjclark connorjclark changed the title report: support v6 settings report: convert v6 emulatedFormFactor to v7 formFactor Dec 22, 2020
paulirish added a commit that referenced this pull request Dec 23, 2020
@paulirish paulirish merged commit 0d25b6b into master Dec 23, 2020
@paulirish paulirish deleted the reportdevicestringfallback branch December 23, 2020 01:20
@@ -66,6 +66,10 @@ class Util {
if (!clone.configSettings.locale) {
clone.configSettings.locale = 'en';
}
if (!clone.configSettings.formFactor) {
// @ts-expect-error fallback handling for emulatedFormFactor
Copy link
Member

Choose a reason for hiding this comment

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

can you add a version comment like on the other comments? Someday we won't remember when this change happened :)

const deviceEmulation = settings.formFactor === 'mobile'
? Util.i18n.strings.runtimeMobileEmulation
: Util.i18n.strings.runtimeDesktopEmulation;
const deviceEmulation = {
Copy link
Member

Choose a reason for hiding this comment

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

The fallback case shouldn't ever happen for the 'mobile'|'desktop' type it is today, so probably worth adding a comment about why there's a fallback to runtimeNoEmulation

@brendankenny
Copy link
Member

brendankenny commented Dec 23, 2020

Well, you were too fast, but maybe in the arbitrary strings PR :)


edit from paul since github isn't automatically crosslinking...... yup i addressed in #11796 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lighthouse Chrome plugin emulates desktop in mobile tests
5 participants