Skip to content

Commit 6515360

Browse files
committed
Bug 1748930 - Add search selector engine properties to search settings metadata object. r=Standard8
Differential Revision: https://phabricator.services.mozilla.com/D135894
1 parent 51db0fd commit 6515360

File tree

2 files changed

+48
-12
lines changed

2 files changed

+48
-12
lines changed

toolkit/components/search/SearchService.jsm

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,23 +1041,26 @@ SearchService.prototype = {
10411041
},
10421042

10431043
async _fetchEngineSelectorEngines() {
1044-
let locale = Services.locale.appLocaleAsBCP47;
1045-
let region = Region.home || "default";
1044+
let searchEngineSelectorProperties = {
1045+
locale: Services.locale.appLocaleAsBCP47,
1046+
region: Region.home || "default",
1047+
channel: AppConstants.MOZ_APP_VERSION_DISPLAY.endsWith("esr")
1048+
? "esr"
1049+
: AppConstants.MOZ_UPDATE_CHANNEL,
1050+
experiment: NimbusFeatures.search.getVariable("experiment") ?? "",
1051+
distroID: SearchUtils.distroID ?? "",
1052+
};
10461053

1047-
let channel = AppConstants.MOZ_APP_VERSION_DISPLAY.endsWith("esr")
1048-
? "esr"
1049-
: AppConstants.MOZ_UPDATE_CHANNEL;
1054+
for (let [key, value] of Object.entries(searchEngineSelectorProperties)) {
1055+
this._settings.setAttribute(key, value);
1056+
}
10501057

10511058
let {
10521059
engines,
10531060
privateDefault,
1054-
} = await this._engineSelector.fetchEngineConfiguration({
1055-
locale,
1056-
region,
1057-
channel,
1058-
experiment: NimbusFeatures.search.getVariable("experiment"),
1059-
distroID: SearchUtils.distroID,
1060-
});
1061+
} = await this._engineSelector.fetchEngineConfiguration(
1062+
searchEngineSelectorProperties
1063+
);
10611064

10621065
for (let e of engines) {
10631066
if (!e.webExtension) {

toolkit/components/search/tests/xpcshell/test_settings.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,39 @@ add_task(async function test_current_setting_engine_properties() {
122122
await checkLoadSettingProperties("data/search.json", true, false);
123123
});
124124

125+
add_task(async function test_settings_metadata_properties() {
126+
info("init search service");
127+
await loadSettingsFile("data/search.json");
128+
129+
const settingsFileWritten = promiseAfterSettings();
130+
let ss = new SearchService();
131+
let result = await ss.init();
132+
133+
info("init'd search service");
134+
Assert.ok(Components.isSuccessCode(result));
135+
136+
await settingsFileWritten;
137+
138+
let metaDataProperties = [
139+
"locale",
140+
"region",
141+
"channel",
142+
"experiment",
143+
"distroID",
144+
];
145+
146+
for (let name of metaDataProperties) {
147+
Assert.notEqual(
148+
ss._settings.getAttribute(`${name}`),
149+
undefined,
150+
`Search settings should have ${name} property defined.`
151+
);
152+
}
153+
154+
removeSettingsFile();
155+
ss._removeObservers();
156+
});
157+
125158
/**
126159
* Test that the JSON settings written in the profile is correct.
127160
*/

0 commit comments

Comments
 (0)