From 5d7e6f9da2e4bfef3065b3c830fd76686417631d Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Tue, 22 Dec 2020 17:20:33 -0800 Subject: [PATCH] report: convert v6 emulatedFormFactor to v7 formFactor (#11876) --- lighthouse-core/report/html/renderer/util.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lighthouse-core/report/html/renderer/util.js b/lighthouse-core/report/html/renderer/util.js index 3be1e2b78323..ac81decb7175 100644 --- a/lighthouse-core/report/html/renderer/util.js +++ b/lighthouse-core/report/html/renderer/util.js @@ -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) @@ -425,9 +429,10 @@ class Util { } // TODO(paulirish): revise Runtime Settings strings: https://github.com/GoogleChrome/lighthouse/pull/11796 - const deviceEmulation = settings.formFactor === 'mobile' - ? Util.i18n.strings.runtimeMobileEmulation - : Util.i18n.strings.runtimeDesktopEmulation; + const deviceEmulation = { + mobile: Util.i18n.strings.runtimeMobileEmulation, + desktop: Util.i18n.strings.runtimeDesktopEmulation, + }[settings.formFactor] || Util.i18n.strings.runtimeNoEmulation; return { deviceEmulation,