From 1c15092dfea717f332d6bb2979171bb7f48ea67e Mon Sep 17 00:00:00 2001 From: Greg Tatum Date: Tue, 28 Jan 2020 11:38:19 +0000 Subject: [PATCH] Bug 1611815 - Fix thrown error about presetName om the performance-new devtools panel; r=canaltinova The reducer errors in the implementation of the DevTools panel, as the presetName was not being fetched from the preferences in the debuggee. This fixes that. TypeScript caught this, but I guess I forgot to check it. Differential Revision: https://phabricator.services.mozilla.com/D61128 --HG-- extra : moz-landing-system : lando --- devtools/client/performance-new/browser.js | 33 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/devtools/client/performance-new/browser.js b/devtools/client/performance-new/browser.js index cbbfb392436a..362fd5da74b3 100644 --- a/devtools/client/performance-new/browser.js +++ b/devtools/client/performance-new/browser.js @@ -63,7 +63,8 @@ const INTERVAL_PREF = "devtools.performance.recording.interval"; const FEATURES_PREF = "devtools.performance.recording.features"; /** @type {PerformancePref["Threads"]} */ const THREADS_PREF = "devtools.performance.recording.threads"; - +/** @type {PerformancePref["Preset"]} */ +const PRESET_PREF = "devtools.performance.recording.preset"; /** @type {PerformancePref["ObjDirs"]} */ const OBJDIRS_PREF = "devtools.performance.recording.objdirs"; /** @type {PerformancePref["UIBaseUrl"]} */ @@ -230,6 +231,23 @@ async function _getIntPref(preferenceFront, prefName, defaultValue) { } } +/** + * Attempt to get a char preference value from the debuggee. + * + * @param {PreferenceFront} preferenceFront + * @param {string} prefName + * @param {string} defaultValue Default value of the preference. We don't need + * this value since Firefox 72, but we keep it to support older Firefox versions. + * @returns Promise + */ +async function _getCharPref(preferenceFront, prefName, defaultValue) { + try { + return await preferenceFront.getCharPref(prefName); + } catch (error) { + return defaultValue; + } +} + /** * Get the recording settings from the preferences. These settings are stored once * for local debug targets, and another set of settings for remote targets. This @@ -240,12 +258,21 @@ async function _getIntPref(preferenceFront, prefName, defaultValue) { * @param {RecordingStateFromPreferences} defaultPrefs Default preference values. * We don't need this value since Firefox 72, but we keep it to support older * Firefox versions. + * @returns {Promise} */ async function getRecordingPreferencesFromDebuggee( preferenceFront, defaultPrefs ) { - const [entries, interval, features, threads, objdirs] = await Promise.all([ + const [ + presetName, + entries, + interval, + features, + threads, + objdirs, + ] = await Promise.all([ + _getCharPref(preferenceFront, PRESET_PREF, defaultPrefs.presetName), _getIntPref(preferenceFront, ENTRIES_PREF, defaultPrefs.entries), _getIntPref(preferenceFront, INTERVAL_PREF, defaultPrefs.interval), _getArrayOfStringsPref( @@ -257,7 +284,7 @@ async function getRecordingPreferencesFromDebuggee( _getArrayOfStringsHostPref(OBJDIRS_PREF, defaultPrefs.objdirs), ]); - return { entries, interval, features, threads, objdirs }; + return { presetName, entries, interval, features, threads, objdirs }; } /**