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
parent 7024c06712
commit 15284e839e

View File

@ -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;
}
}