Bug 1247497 - Let the system add-on control the add-ons rollout policy, and properly tag the cohort based on it. r=mconley
authorFelipe Gomes <felipc@gmail.com>
Wed, 27 Jul 2016 13:33:01 -0300
changeset 346951 a2a83524584936b5fb4ff6c6584f1b8407b25e48
parent 346950 62f0ff98f9c14336a68b130eb9d43045ec3f643a
child 346952 5ef9e319b525b64c35e35fe640a08455b89fdac1
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1247497
milestone50.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 1247497 - Let the system add-on control the add-ons rollout policy, and properly tag the cohort based on it. r=mconley MozReview-Commit-ID: F46qxiTXCMn
browser/extensions/e10srollout/bootstrap.js
--- a/browser/extensions/e10srollout/bootstrap.js
+++ b/browser/extensions/e10srollout/bootstrap.js
@@ -1,31 +1,37 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
 
 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 Cu.import("resource://gre/modules/Preferences.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/UpdateUtils.jsm");
 
  // The amount of people to be part of e10s
 const TEST_THRESHOLD = {
   "beta"    : 0.5,  // 50%
 };
 
+const ADDON_ROLLOUT_POLICY = {
+  // per-channel policies go here
+};
+
 const PREF_COHORT_SAMPLE       = "e10s.rollout.cohortSample";
 const PREF_COHORT_NAME         = "e10s.rollout.cohort";
 const PREF_E10S_OPTED_IN       = "browser.tabs.remote.autostart";
 const PREF_E10S_FORCE_ENABLED  = "browser.tabs.remote.force-enable";
 const PREF_E10S_FORCE_DISABLED = "browser.tabs.remote.force-disable";
 const PREF_TOGGLE_E10S         = "browser.tabs.remote.autostart.2";
-
+const PREF_E10S_ADDON_POLICY   = "extensions.e10s.rollout.policy";
+const PREF_E10S_HAS_NONEXEMPT_ADDON = "extensions.e10s.rollout.hasAddon";
 
 function startup() {
   // In theory we only need to run this once (on install()), but
   // it's better to also run it on every startup. If the user has
   // made manual changes to the prefs, this will keep the data
   // reported more accurate.
   // It's also fine (and preferred) to just do it here on startup
   // (instead of observing prefs), because e10s takes a restart
@@ -48,30 +54,48 @@ function defineCohort() {
   cohortDefinedOnThisSession = true;
 
   let updateChannel = UpdateUtils.getUpdateChannel(false);
   if (!(updateChannel in TEST_THRESHOLD)) {
     setCohort("unsupportedChannel");
     return;
   }
 
+  let addonPolicy = "unknown";
+  if (updateChannel in ADDON_ROLLOUT_POLICY) {
+    addonPolicy = ADDON_ROLLOUT_POLICY[updateChannel];
+    Preferences.set(PREF_E10S_ADDON_POLICY, ADDON_ROLLOUT_POLICY[updateChannel]);
+    // This is also the proper place to set the blocklist pref
+    // in case it is necessary.
+  } else {
+    Preferences.reset(PREF_E10S_ADDON_POLICY);
+  }
+
   let userOptedOut = optedOut();
   let userOptedIn = optedIn();
   let disqualified = (Services.appinfo.multiprocessBlockPolicy != 0);
   let testGroup = (getUserSample() < TEST_THRESHOLD[updateChannel]);
+  let hasNonExemptAddon = Preferences.get(PREF_E10S_HAS_NONEXEMPT_ADDON, false);
+
+  let cohortPrefix = "";
+  if (disqualified) {
+    cohortPrefix = "disqualified-";
+  } else if (hasNonExemptAddon) {
+    cohortPrefix = `addons-set${addonPolicy}-`;
+  }
 
   if (userOptedOut) {
     setCohort("optedOut");
   } else if (userOptedIn) {
     setCohort("optedIn");
   } else if (testGroup) {
-    setCohort(disqualified ? "disqualified-test" : "test");
+    setCohort(`${cohortPrefix}test`);
     Preferences.set(PREF_TOGGLE_E10S, true);
   } else {
-    setCohort(disqualified ? "disqualified-control" : "control");
+    setCohort(`${cohortPrefix}control`);
     Preferences.reset(PREF_TOGGLE_E10S);
   }
 }
 
 function shutdown(data, reason) {
 }
 
 function uninstall() {