File tree Expand file tree Collapse file tree 2 files changed +48
-12
lines changed
toolkit/components/search Expand file tree Collapse file tree 2 files changed +48
-12
lines changed Original file line number Diff line number Diff line change @@ -1041,23 +1041,26 @@ SearchService.prototype = {
1041
1041
} ,
1042
1042
1043
1043
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
+ } ;
1046
1053
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
+ }
1050
1057
1051
1058
let {
1052
1059
engines,
1053
1060
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
+ ) ;
1061
1064
1062
1065
for ( let e of engines ) {
1063
1066
if ( ! e . webExtension ) {
Original file line number Diff line number Diff line change @@ -122,6 +122,39 @@ add_task(async function test_current_setting_engine_properties() {
122
122
await checkLoadSettingProperties ( "data/search.json" , true , false ) ;
123
123
} ) ;
124
124
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
+
125
158
/**
126
159
* Test that the JSON settings written in the profile is correct.
127
160
*/
You can’t perform that action at this time.
0 commit comments