Bug 1418266 - update preference behavior for DevTools onboarding experiment;r=ochameau draft
authorJulian Descottes <jdescottes@mozilla.com>
Thu, 16 Nov 2017 19:56:15 +0100
changeset 699634 6da6cc41f6388871cdfc66c04bef3b54ccfabcbf
parent 699096 a3f183201f7f183c263d554bfb15fbf0b0ed2ea4
child 740678 ee4fe4ab7903105fdf7cb15dec9f325799ecd058
push id89624
push userjdescottes@mozilla.com
push dateFri, 17 Nov 2017 11:25:43 +0000
reviewersochameau
bugs1418266
milestone59.0a1
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");