Bug 1645511 - Improve the provider manager's provider.updateBehavior calls. r=mak

I considered wrapping `provider.tryMethod("updateBehavior", queryContext)` in a
promise in case there are implementations that aren't async or don't return a
promise. But there's only one implementation of `updateBehavior`, it's async,
and we probably won't end up with any more implementations, so for simplicity I
didn't.

Differential Revision: https://phabricator.services.mozilla.com/D79559
This commit is contained in:
Drew Willcoxon 2020-06-16 01:09:26 +00:00
Родитель 7024c06712
Коммит 15284e839e
1 изменённых файлов: 10 добавлений и 1 удалений

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

@ -206,12 +206,21 @@ class ProvidersManager {
}
// Update the behavior of extension providers.
let updateBehaviorPromises = [];
for (let provider of this.providers) {
if (
provider.type == UrlbarUtils.PROVIDER_TYPE.EXTENSION &&
provider.name != "Omnibox"
) {
await provider.tryMethod("updateBehavior", queryContext);
updateBehaviorPromises.push(
provider.tryMethod("updateBehavior", queryContext)
);
}
}
if (updateBehaviorPromises.length) {
await Promise.all(updateBehaviorPromises);
if (query.canceled) {
return;
}
}