Bug 1451513 Part 3: Make loading the mochitest extension more robust r=kmag

A couple of changes to ensure that the mochitest harness doesn't try to
start executing changes before the mochitest extension is loaded:
1. Fix the marionette driver to wait for an installed extension to
   be started before returning from Addon:install
2. Wait for extension API onStartup() handlers to finish before
   considering a webextension started.

MozReview-Commit-ID: 8YEdNn6s5qh

--HG--
extra : rebase_source : 67e9abadcda82d55ac73c33367ec65cdbf7b823d
This commit is contained in:
Andrew Swan 2018-07-30 17:03:27 -07:00
Родитель 3493324938
Коммит ad31645d25
2 изменённых файлов: 9 добавлений и 32 удалений

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

@ -23,37 +23,12 @@ const ERRORS = {
async function installAddon(file) {
let install = await AddonManager.getInstallForFile(file);
return new Promise(resolve => {
if (install.error) {
throw new UnknownError(ERRORS[install.error]);
}
if (install.error) {
throw new UnknownError(ERRORS[install.error]);
}
let addonId = install.addon.id;
let success = install => {
if (install.addon.id === addonId) {
install.removeListener(listener);
resolve(install.addon);
}
};
let fail = install => {
if (install.addon.id === addonId) {
install.removeListener(listener);
throw new UnknownError(ERRORS[install.error]);
}
};
let listener = {
onDownloadCancelled: fail,
onDownloadFailed: fail,
onInstallCancelled: fail,
onInstallFailed: fail,
onInstallEnded: success,
};
install.addListener(listener);
install.install();
return install.install().catch(err => {
throw new UnknownError(ERRORS[install.error]);
});
}

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

@ -1778,9 +1778,11 @@ class Extension extends ExtensionData {
// and it is used to run code that needs to be executed before
// any of the "startup" listeners.
this.emit("startup", this);
Management.emit("startup", this);
await this.runManifest(this.manifest);
await Promise.all([
Management.emit("startup", this),
this.runManifest(this.manifest),
]);
Management.emit("ready", this);
this.emit("ready");