Bug 1556424 - Dont await init() on init() installed engines. r=Standard8

Differential Revision: https://phabricator.services.mozilla.com/D33577

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dale Harvey 2019-06-04 16:44:29 +00:00
Родитель ae2ef98e40
Коммит bd3dac3bc5
1 изменённых файлов: 9 добавлений и 5 удалений

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

@ -916,7 +916,7 @@ SearchService.prototype = {
SearchUtils.log("_loadEngines: loading " +
this._startupExtensions.size + " engines reported by AddonManager startup");
for (let extension of this._startupExtensions) {
await this._installExtensionEngine(extension, [DEFAULT_TAG]);
await this._installExtensionEngine(extension, [DEFAULT_TAG], true);
}
}
@ -1109,6 +1109,7 @@ SearchService.prototype = {
*/
reset() {
gInitialized = false;
this._initObservers = PromiseUtils.defer();
this._initStarted = this.__sortedEngines =
this._currentEngine = this._searchDefault = null;
this._startupExtensions = new Set();
@ -1846,7 +1847,7 @@ SearchService.prototype = {
// We install search extensions during the init phase, both built in
// web extensions freshly installed (via addEnginesFromExtension) or
// user installed extensions being reenabled calling this directly.
if (!gInitialized && !isBuiltin) {
if (!gInitialized && !isBuiltin && !params.initEngine) {
await this.init(true);
}
if (!name)
@ -1898,13 +1899,13 @@ SearchService.prototype = {
return this._installExtensionEngine(extension, [DEFAULT_TAG]);
},
async _installExtensionEngine(extension, locales) {
async _installExtensionEngine(extension, locales, initEngine) {
SearchUtils.log("installExtensionEngine: " + extension.id);
let installLocale = async (locale) => {
let manifest = (locale === DEFAULT_TAG) ? extension.manifest :
(await extension.getLocalizedManifest(locale));
return this._addEngineForManifest(extension, manifest, locale);
return this._addEngineForManifest(extension, manifest, locale, initEngine);
};
let engines = [];
@ -1916,7 +1917,9 @@ SearchService.prototype = {
return engines;
},
async _addEngineForManifest(extension, manifest, locale = DEFAULT_TAG) {
async _addEngineForManifest(extension, manifest,
locale = DEFAULT_TAG,
initEngine = false) {
let {IconDetails} = ExtensionParent;
// General set of icons for an engine.
@ -1966,6 +1969,7 @@ SearchService.prototype = {
suggestGetParams: searchProvider.suggest_url_get_params,
queryCharset: searchProvider.encoding || "UTF-8",
mozParams: searchProvider.params,
initEngine,
};
return this.addEngineWithDetails(params.name, params);