mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 23:05:42 +00:00
Bug 1268921 - Allow non-integer values to be specified for e10srollout cohort samples. r=mconley
MozReview-Commit-ID: 9pCaqWeapBl
This commit is contained in:
parent
c675959a63
commit
c5ab44cfcb
26
browser/extensions/e10srollout/bootstrap.js
vendored
26
browser/extensions/e10srollout/bootstrap.js
vendored
@ -9,10 +9,9 @@ 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, in %
|
||||
// The amount of people to be part of e10s
|
||||
const TEST_THRESHOLD = {
|
||||
"beta" : 50,
|
||||
"release" : 0,
|
||||
"beta" : 0.5, // 50%
|
||||
};
|
||||
|
||||
const PREF_COHORT_SAMPLE = "e10s.rollout.cohortSample";
|
||||
@ -79,14 +78,23 @@ function uninstall() {
|
||||
}
|
||||
|
||||
function getUserSample() {
|
||||
let existingVal = Preferences.get(PREF_COHORT_SAMPLE, undefined);
|
||||
if (typeof(existingVal) == "number") {
|
||||
return existingVal;
|
||||
let prefValue = Preferences.get(PREF_COHORT_SAMPLE, undefined);
|
||||
let value = 0.0;
|
||||
|
||||
if (typeof(prefValue) == "string") {
|
||||
value = parseFloat(prefValue, 10);
|
||||
return value;
|
||||
}
|
||||
|
||||
let val = Math.floor(Math.random() * 100);
|
||||
Preferences.set(PREF_COHORT_SAMPLE, val);
|
||||
return val;
|
||||
if (typeof(prefValue) == "number") {
|
||||
// convert old integer value
|
||||
value = prefValue / 100;
|
||||
} else {
|
||||
value = Math.random();
|
||||
}
|
||||
|
||||
Preferences.set(PREF_COHORT_SAMPLE, value.toString().substr(0, 8));
|
||||
return value;
|
||||
}
|
||||
|
||||
function setCohort(cohortName) {
|
||||
|
Loading…
Reference in New Issue
Block a user