Bug 1418266 - update preference behavior for DevTools onboarding experiment;r=ochameau
authorJulian Descottes <jdescottes@mozilla.com>
Thu, 16 Nov 2017 19:56:15 +0100
changeset 392937 4a35428990925d014a83d267fd1fdab696eb0aea
parent 392936 356b50c5becf41a2839ecb895e7c2219223f55b5
child 392938 d27b88d59fb3a580b6213e5fb0e229ea8ca7453a
push id55772
push userjdescottes@mozilla.com
push dateTue, 21 Nov 2017 16:48:55 +0000
treeherderautoland@4a3542899092 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1418266
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1418266 - update preference behavior for DevTools onboarding experiment;r=ochameau The devtools.onboarding.experiment pref now supports 3 states: - off (default) - on - force When set to "on" or "force" the preference will flip devtools enabled to false. When set to "force" the devtools.enabled pref can no longer be flipped to true by looking at devtools.selfxss.count, users have to go through the onboarding flow. To make sure the devtools.enabled pref is only flipped once, we use a supporting pref devtools.onboarding.experiment.flipped MozReview-Commit-ID: B5fPKuGxPW2
devtools/shim/devtools-startup-prefs.js
devtools/shim/devtools-startup.js
--- a/devtools/shim/devtools-startup-prefs.js
+++ b/devtools/shim/devtools-startup-prefs.js
@@ -16,14 +16,22 @@ pref("devtools.jsonview.enabled", true);
 sticky_pref("devtools.theme", "dark");
 #else
 sticky_pref("devtools.theme", "light");
 #endif
 
 // Should the devtools toolbar be opened on startup
 pref("devtools.toolbar.visible", false);
 
-// Flag to drive the devtools onboarding flow experiment. Forces devtools.enabled to true
-// when false.
-pref("devtools.onboarding.experiment", false);
+// Pref to drive the devtools onboarding flow experiment. States:
+// - off: forces devtools.enabled to true
+// - on: devtools.enabled is not forced to true.
+// - force: devtools.enabled is not forced to true and cannot be set to true by checking
+//   devtools.selfxss.count. User will have to go through onboarding to use DevTools.
+pref("devtools.onboarding.experiment", "off");
+
+// If devtools.onboarding.experiment is set to "on" or "force", we will flip the
+// devtools.enabled preference to false once. The flag is used to make sure it is only
+// flipped once.
+pref("devtools.onboarding.experiment.flipped", false);
 
 // Flag to check if we already logged the devtools onboarding related probe.
 pref("devtools.onboarding.telemetry.logged", false);
--- a/devtools/shim/devtools-startup.js
+++ b/devtools/shim/devtools-startup.js
@@ -468,30 +468,45 @@ DevToolsStartup.prototype = {
   /**
    * Depending on some runtime parameters (command line arguments as well as existing
    * preferences), the DEVTOOLS_ENABLED_PREF might be forced to true.
    *
    * @param {Boolean} hasDevToolsFlag
    *        true if any DevTools command line argument was passed when starting Firefox.
    */
   setupEnabledPref(hasDevToolsFlag) {
+    // Read the current experiment state.
+    let experimentState = Services.prefs.getCharPref("devtools.onboarding.experiment");
+    let isRegularExperiment = experimentState == "on";
+    let isForcedExperiment = experimentState == "force";
+    let isInExperiment = isRegularExperiment || isForcedExperiment;
+
+    // Force devtools.enabled to true for users that are not part of the experiment.
+    if (!isInExperiment) {
+      Services.prefs.setBoolPref(DEVTOOLS_ENABLED_PREF, true);
+      return;
+    }
+
+    // Force devtools.enabled to false once for each experiment user.
+    if (!Services.prefs.getBoolPref("devtools.onboarding.experiment.flipped")) {
+      Services.prefs.setBoolPref(DEVTOOLS_ENABLED_PREF, false);
+      Services.prefs.setBoolPref("devtools.onboarding.experiment.flipped", true);
+    }
+
     if (Services.prefs.getBoolPref(DEVTOOLS_ENABLED_PREF)) {
       // Nothing to do if DevTools are already enabled.
       return;
     }
 
-    if (!Services.prefs.getBoolPref("devtools.onboarding.experiment")) {
-      // Force devtools.enabled to true for users that are not part of the experiment.
-      Services.prefs.setBoolPref(DEVTOOLS_ENABLED_PREF, true);
-      return;
-    }
+    // We only consider checking the actual isDevToolsUser() if the user is in the
+    // "regular" experiment group.
+    let isDevToolsUser = isRegularExperiment && this.isDevToolsUser();
 
     let hasToolbarPref = Services.prefs.getBoolPref(TOOLBAR_VISIBLE_PREF, false);
-
-    if (hasDevToolsFlag || hasToolbarPref || this.isDevToolsUser()) {
+    if (hasDevToolsFlag || hasToolbarPref || isDevToolsUser) {
       Services.prefs.setBoolPref(DEVTOOLS_ENABLED_PREF, true);
     }
   },
 
   hookKeyShortcuts(window) {
     let doc = window.document;
     let keyset = doc.createElement("keyset");
     keyset.setAttribute("id", "devtoolsKeyset");