Bug 1304164 - Allow the e10srollout system add-on to control temporary disqualifications. r=mconley
MozReview-Commit-ID: EpW3klQguiq
--- a/browser/extensions/e10srollout/bootstrap.js
+++ b/browser/extensions/e10srollout/bootstrap.js
@@ -71,28 +71,40 @@ function defineCohort() {
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 temporaryDisqualification = getTemporaryDisqualification();
let cohortPrefix = "";
if (disqualified) {
cohortPrefix = "disqualified-";
} else if (hasNonExemptAddon) {
cohortPrefix = `addons-set${addonPolicy}-`;
}
if (userOptedOut) {
setCohort("optedOut");
} else if (userOptedIn) {
setCohort("optedIn");
+ } else if (temporaryDisqualification != "") {
+ // Users who are disqualified by the backend (from multiprocessBlockPolicy)
+ // can be put into either the test or control groups, because e10s will
+ // still be denied by the backend, which is useful so that the E10S_STATUS
+ // telemetry probe can be correctly set.
+
+ // For these volatile disqualification reasons, however, we must not try
+ // to activate e10s because the backend doesn't know about it. E10S_STATUS
+ // here will be accumulated as "2 - Disabled", which is fine too.
+ setCohort(`temp-disqualified-${temporaryDisqualification}`);
+ Preferences.reset(PREF_TOGGLE_E10S);
} else if (testGroup) {
setCohort(`${cohortPrefix}test`);
Preferences.set(PREF_TOGGLE_E10S, true);
} else {
setCohort(`${cohortPrefix}control`);
Preferences.reset(PREF_TOGGLE_E10S);
}
}
@@ -140,8 +152,18 @@ function optedIn() {
function optedOut() {
// Users can also opt-out by toggling back the pref to false.
// If they reset the pref instead they might be re-enabled if
// they are still part of the threshold.
return Preferences.get(PREF_E10S_FORCE_DISABLED, false) ||
(Preferences.isSet(PREF_TOGGLE_E10S) &&
Preferences.get(PREF_TOGGLE_E10S) == false);
}
+
+/* If this function returns a non-empty string, it
+ * means that this particular user should be temporarily
+ * disqualified due to some particular reason.
+ * If a user shouldn't be disqualified, then an empty
+ * string must be returned.
+ */
+function getTemporaryDisqualification() {
+ return "";
+}