Bug 1643468 - Use a different pref for search engine configuration experiments. r=daleharvey

Differential Revision: https://phabricator.services.mozilla.com/D78366
This commit is contained in:
Mark Banner 2020-06-04 23:19:17 +00:00
parent 3083026d43
commit 0837dfa5be
4 changed files with 20 additions and 12 deletions

View File

@ -177,11 +177,14 @@ class SearchEngineSelector {
if (!this._configuration) {
await this.getEngineConfiguration();
}
let cohort = Services.prefs.getCharPref("browser.search.cohort", null);
let experiment = Services.prefs.getCharPref(
"browser.search.experiment",
null
);
let name = getAppInfo("name");
let version = getAppInfo("version");
logConsole.debug(
`fetchEngineConfiguration ${locale}:${region}:${channel}:${distroID}:${cohort}:${name}:${version}`
`fetchEngineConfiguration ${locale}:${region}:${channel}:${distroID}:${experiment}:${name}:${version}`
);
let engines = [];
const lcLocale = locale.toLowerCase();
@ -189,7 +192,7 @@ class SearchEngineSelector {
for (let config of this._configuration) {
const appliesTo = config.appliesTo || [];
const applies = appliesTo.filter(section => {
if ("cohort" in section && cohort != section.cohort) {
if ("experiment" in section && experiment != section.experiment) {
return false;
}
const distroExcluded =

View File

@ -334,11 +334,11 @@ Experiments
===========
We can run experiments by giving sections within ``appliesTo`` a
``cohort`` value, the Search Service can then optionally pass in a
matching ``cohort`` value to match those sections.
``experiment`` value, the Search Service can then optionally pass in a
matching ``experiment`` value to match those sections.
Sections which have a ``cohort`` will not be used unless a matching
``cohort`` has been passed in, for example:
Sections which have a ``experiment`` will not be used unless a matching
``experiment`` has been passed in, for example:
.. code-block:: js
@ -350,7 +350,7 @@ Sections which have a ``cohort`` will not be used unless a matching
"included": {
"everywhere": true
},
"cohort": "nov-16",
"experiment": "nov-16",
"webExtension": {
"id": "web-experimental@ext"
}

View File

@ -78,7 +78,7 @@
},
"excludedDistributions": {
"type": "array",
"title": "Exlucuded Distributions",
"title": "Excluded Distributions",
"description": "Which distributions this does not apply to.",
"items": {
"type": "string"
@ -377,6 +377,11 @@
},
"extraParams": {
"$ref": "#/definitions/extraParams"
},
"experiment": {
"type": "string",
"title": "Experiment",
"description": "The experiment this section is associated with, if blank it is associate with any configuration."
}
}
}

View File

@ -60,7 +60,7 @@ const TEST_CONFIG = [
},
{
included: { everywhere: true },
cohort: "acohortid",
experiment: "acohortid",
},
],
},
@ -106,7 +106,7 @@ add_task(async function() {
"The engines should be in the correct order"
);
Services.prefs.setCharPref("browser.search.cohort", "acohortid");
Services.prefs.setCharPref("browser.search.experiment", "acohortid");
({ engines, privateDefault } = await engineSelector.fetchEngineConfiguration(
"en-US",
"us",
@ -115,7 +115,7 @@ add_task(async function() {
Assert.deepEqual(
engines.map(obj => obj.engineName),
["lycos", "altavista", "aol", "excite"],
"Engines are in the correct order and include the cohort engine"
"Engines are in the correct order and include the experiment engine"
);
({ engines, privateDefault } = await engineSelector.fetchEngineConfiguration(