From 13b081a62d3f3e3e3120f95564529257b0bf451c Mon Sep 17 00:00:00 2001 From: Greg Tatum Date: Wed, 4 Mar 2020 16:39:17 +0000 Subject: [PATCH] Bug 1619578 - Make the profiler WebChannel work on beta; r=canaltinova The WebChannels were not being initialized on beta due to being initialized after the feature pref was checked. This patch changes it so that profiler.firefox.com will still have the WebChannel registered, and then if the menu button is enabled via the WebChannel, the feature flag is flipped. I did not include a test on this, as this is a temporary measure until we flip on the mechanism for all users. Differential Revision: https://phabricator.services.mozilla.com/D65199 --HG-- extra : moz-landing-system : lando --- devtools/client/performance-new/@types/perf.d.ts | 6 ++++++ devtools/client/performance-new/popup/background.jsm.js | 7 +++++++ devtools/startup/DevToolsStartup.jsm | 9 +++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/devtools/client/performance-new/@types/perf.d.ts b/devtools/client/performance-new/@types/perf.d.ts index eb8d081dc57f..be48433fa74d 100644 --- a/devtools/client/performance-new/@types/perf.d.ts +++ b/devtools/client/performance-new/@types/perf.d.ts @@ -372,6 +372,12 @@ export interface PerformancePref { * time that you open it. After that, it is not displayed by default. */ PopupIntroDisplayed: "devtools.performance.popup.intro-displayed"; + /** + * This preference is used outside of the performance-new type system + * (in DevToolsStartup). It toggles the availability of the menu item + * "Tools -> Web Developer -> Enable Profiler Toolbar Icon". + */ + PopupFeatureFlag: "devtools.performance.popup.feature-flag"; } /** diff --git a/devtools/client/performance-new/popup/background.jsm.js b/devtools/client/performance-new/popup/background.jsm.js index 8cba8405d501..f97ba9032d3d 100644 --- a/devtools/client/performance-new/popup/background.jsm.js +++ b/devtools/client/performance-new/popup/background.jsm.js @@ -44,6 +44,8 @@ const OBJDIRS_PREF = "devtools.performance.recording.objdirs"; const DURATION_PREF = "devtools.performance.recording.duration"; /** @type {PerformancePref["Preset"]} */ const PRESET_PREF = "devtools.performance.recording.preset"; +/** @type {PerformancePref["PopupFeatureFlag"]} */ +const POPUP_FEATURE_FLAG_PREF = "devtools.performance.popup.feature-flag"; // The following utilities are lazily loaded as they are not needed when controlling the // global state of the profiler, and only are used during specific funcationality like @@ -394,6 +396,7 @@ function revertRecordingPreferences() { Services.prefs.clearUserPref(THREADS_PREF); Services.prefs.clearUserPref(OBJDIRS_PREF); Services.prefs.clearUserPref(DURATION_PREF); + Services.prefs.clearUserPref(POPUP_FEATURE_FLAG_PREF); } /** @@ -499,6 +502,10 @@ function handleWebChannelMessage(channel, id, message, target) { "the profiler menu button" ); } + // The menu button toggle is only enabled on Nightly by default. Once the profiler + // is turned on once, make sure that the menu button is also available. + Services.prefs.setBoolPref(POPUP_FEATURE_FLAG_PREF, true); + ProfilerMenuButton.toggle(ownerDocument); } diff --git a/devtools/startup/DevToolsStartup.jsm b/devtools/startup/DevToolsStartup.jsm index f33ddb3107b5..015a42cc3aba 100644 --- a/devtools/startup/DevToolsStartup.jsm +++ b/devtools/startup/DevToolsStartup.jsm @@ -628,6 +628,11 @@ DevToolsStartup.prototype = { AppConstants.NIGHTLY_BUILD ); + // Listen for messages from the front-end. This needs to happen even if the + // button isn't enabled yet. This will allow the front-end to turn on the + // popup for our users, regardless of if the feature is enabled by default. + this.initializeProfilerWebChannel(); + if (!isPopupFeatureFlagEnabled) { // The profiler's popup is experimental. The plan is to eventually turn it on // everywhere, but while it's under active development we don't want everyone @@ -637,10 +642,6 @@ DevToolsStartup.prototype = { return; } - // Listen for messages from the front-end. This needs to happen even if the - // button isn't enabled yet. - this.initializeProfilerWebChannel(); - if (isProfilerButtonEnabled()) { ProfilerMenuButton.initialize(); }