Bug 1460190 - Handle search regions with default but no enginelist. r=adw

MozReview-Commit-ID: FJM1Q9DLXWR

--HG--
extra : rebase_source : 7b22a5e40982280a858f7147edd00fc83c0fe52b
This commit is contained in:
Michael Kaply 2018-05-09 23:29:34 -07:00
Родитель b11f8e3794
Коммит 02a451dc6e
1 изменённых файлов: 8 добавлений и 5 удалений

Просмотреть файл

@ -3500,13 +3500,15 @@ SearchService.prototype = {
if (Services.prefs.prefHasUserValue("browser.search.region")) { if (Services.prefs.prefHasUserValue("browser.search.region")) {
searchRegion = Services.prefs.getCharPref("browser.search.region"); searchRegion = Services.prefs.getCharPref("browser.search.region");
} }
if (!searchRegion || !(searchRegion in searchSettings)) {
searchRegion = "default";
}
// Fallback to building a list based on the regions in the JSON // Fallback to building a list based on the regions in the JSON
if (!engineNames || !engineNames.length) { if (!engineNames || !engineNames.length) {
engineNames = searchSettings[searchRegion].visibleDefaultEngines; if (searchRegion && searchRegion in searchSettings &&
"visibleDefaultEngines" in searchSettings[searchRegion]) {
engineNames = searchSettings[searchRegion].visibleDefaultEngines;
} else {
engineNames = searchSettings.default.visibleDefaultEngines;
}
} }
// Remove any engine names that are supposed to be ignored. // Remove any engine names that are supposed to be ignored.
@ -3530,7 +3532,8 @@ SearchService.prototype = {
// Store this so that it can be used while writing the cache file. // Store this so that it can be used while writing the cache file.
this._visibleDefaultEngines = engineNames; this._visibleDefaultEngines = engineNames;
if ("searchDefault" in searchSettings[searchRegion]) { if (searchRegion && searchRegion in searchSettings &&
"searchDefault" in searchSettings[searchRegion]) {
this._searchDefault = searchSettings[searchRegion].searchDefault; this._searchDefault = searchSettings[searchRegion].searchDefault;
} else { } else {
this._searchDefault = searchSettings.default.searchDefault; this._searchDefault = searchSettings.default.searchDefault;