Bug 1634493 - Wait for extension policy to be ready. r=aklotz

When exporting the addon object, the extension policy sometimes is not ready
yet (very common when `list()` is called at startup), so we need to wait until
it's ready or the values in it will not be correct.

Differential Revision: https://phabricator.services.mozilla.com/D73770
This commit is contained in:
Agi Sferro 2020-05-05 18:07:40 +00:00
Родитель 7b6639a92d
Коммит 69074e75ca
1 изменённых файлов: 7 добавлений и 7 удалений

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

@ -252,6 +252,11 @@ async function filterPromptPermissions(aPermissions) {
}
async function exportExtension(aAddon, aPermissions, aSourceURI) {
// First, let's make sure the policy is ready if present
const policy = WebExtensionPolicy.getByID(aAddon.id);
if (policy) {
await policy.readyPromise;
}
const {
creator,
description,
@ -288,13 +293,8 @@ async function exportExtension(aAddon, aPermissions, aSourceURI) {
if (embedderDisabled) {
disabledFlags.push("appDisabled");
}
let baseURL = "";
let privateBrowsingAllowed = false;
const policy = WebExtensionPolicy.getByID(id);
if (policy) {
baseURL = policy.getURL();
privateBrowsingAllowed = policy.privateBrowsingAllowed;
}
const baseURL = policy ? policy.getURL() : "";
const privateBrowsingAllowed = policy ? policy.privateBrowsingAllowed : false;
const promptPermissions = aPermissions
? await filterPromptPermissions(aPermissions.permissions)
: [];