зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1597727 - Preference based MozParams should be able to have a localised preference name. r=mixedpuppy,mikedeboer
Differential Revision: https://phabricator.services.mozilla.com/D54112 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
fa730a61a7
Коммит
d0a29268be
|
@ -149,7 +149,8 @@
|
|||
"pref": {
|
||||
"type": "string",
|
||||
"optional": true,
|
||||
"description": "The preference to retreive the value from."
|
||||
"description": "The preference to retrieve the value from.",
|
||||
"preprocess": "localize"
|
||||
},
|
||||
"purpose": {
|
||||
"type": "string",
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
{
|
||||
"name": "channel",
|
||||
"condition": "pref",
|
||||
"pref": "__MSG_channel_pref__"
|
||||
"pref": "__MSG_channelPref__"
|
||||
}
|
||||
],
|
||||
"search_url_get_params": "__MSG_searchUrlGetParams__"
|
||||
|
|
|
@ -71,3 +71,57 @@ add_task(async function test_searchConfig_google() {
|
|||
await test.run(false);
|
||||
await test.run(true);
|
||||
});
|
||||
|
||||
add_task(async function test_searchConfig_google_with_mozparam() {
|
||||
// Test a couple of configurations with a MozParam set up.
|
||||
const TEST_DATA = [
|
||||
{
|
||||
locale: "en-US",
|
||||
region: "US",
|
||||
pref: "google_channel_us",
|
||||
expected: "us_param",
|
||||
},
|
||||
{
|
||||
locale: "en-US",
|
||||
region: "GB",
|
||||
pref: "google_channel_row",
|
||||
expected: "row_param",
|
||||
},
|
||||
];
|
||||
|
||||
const defaultBranch = Services.prefs.getDefaultBranch(
|
||||
SearchUtils.BROWSER_SEARCH_PREF
|
||||
);
|
||||
for (const testData of TEST_DATA) {
|
||||
defaultBranch.setCharPref("param." + testData.pref, testData.expected);
|
||||
}
|
||||
|
||||
// TODO: Bug 1598270 will add the true option here, to test for the selector,
|
||||
// aka modern configuration.
|
||||
for (const useSelector of [false]) {
|
||||
info("Using " + (useSelector ? "Selector" : "Legacy Configuration"));
|
||||
for (const testData of TEST_DATA) {
|
||||
info(`Checking region ${testData.region}, locale ${testData.locale}`);
|
||||
await test._reinit(testData.region, testData.locale);
|
||||
const engines = await test._getEngines(
|
||||
useSelector,
|
||||
testData.region,
|
||||
testData.locale
|
||||
);
|
||||
|
||||
Assert.ok(
|
||||
engines[0].identifier.startsWith("google"),
|
||||
"Should have the correct engine"
|
||||
);
|
||||
console.log(engines[0]);
|
||||
|
||||
const submission = engines[0].getSubmission("test", URLTYPE_SEARCH_HTML);
|
||||
Assert.ok(
|
||||
submission.uri.query
|
||||
.split("&")
|
||||
.includes("channel=" + testData.expected),
|
||||
"Should be including the correct MozParam parameter for the engine"
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче