Skip to content

Commit

Permalink
incorporate #11876
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Dec 23, 2020
2 parents 599fa22 + e41bb6c commit b806ea9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lighthouse-core/report/html/renderer/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
clone.configSettings.formFactor = clone.configSettings.emulatedFormFactor;
}

for (const audit of Object.values(clone.audits)) {
// Turn 'not-applicable' (LHR <4.0) and 'not_applicable' (older proto versions)
Expand Down Expand Up @@ -424,10 +428,10 @@ class Util {
networkThrottling = Util.i18n.strings.runtimeUnknown;
}

let device = !settings.screenEmulation ? Util.i18n.strings.runtimeNoEmulation :
settings.formFactor === 'mobile'
? Util.i18n.strings.runtimeMobileEmulation
: Util.i18n.strings.runtimeDesktopEmulation;
let device = settings.screenEmulation ? {
mobile: Util.i18n.strings.runtimeMobileEmulation,
desktop: Util.i18n.strings.runtimeDesktopEmulation,
}[settings.formFactor] : Util.i18n.strings.runtimeNoEmulation;

if (settings.providedDeviceString) {
device = settings.providedDeviceString;
Expand Down
2 changes: 2 additions & 0 deletions lighthouse-core/test/report/html/renderer/util-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ describe('util helpers', () => {
assert.equal(get({screenEmulation: false, formFactor: 'mobile'}), 'No emulation');
assert.equal(get({screenEmulation: true, formFactor: 'mobile'}), 'Emulated Mobile');
assert.equal(get({screenEmulation: true, formFactor: 'desktop'}), 'Emulated Desktop');
// emulatedFormFactor=none mapped to formFactor thx to prepareReportUtil
assert.equal(get({formFactor: 'none'}), 'No emulation');
});

it('builds throttling strings when provided', () => {
Expand Down

0 comments on commit b806ea9

Please sign in to comment.