Bug 1461145: Follow-up: Fix more racy tests. r=bustage CLOSED TREE

MozReview-Commit-ID: 7uep5FCvVwC

--HG--
extra : rebase_source : 22e6c32288fe6dfd72625eabdebb1bb5c4637069
This commit is contained in:
Kris Maglione 2018-05-27 17:53:01 -07:00
parent 61aeafad6a
commit f72f5fc596
3 changed files with 12 additions and 8 deletions

View File

@ -640,11 +640,9 @@ SpecialPowersObserverAPI.prototype = {
let id = aMessage.data.id;
let extension = this._extensions.get(id);
this._extensions.delete(id);
let {setTimeout} = ChromeUtils.import("resource://gre/modules/Timer.jsm", null);
let done = () => {
setTimeout(() => {
this._sendReply(aMessage, "SPExtensionMessage", {id, type: "extensionUnloaded", args: []});
}, 0);
let done = async () => {
await extension._uninstallPromise;
this._sendReply(aMessage, "SPExtensionMessage", {id, type: "extensionUnloaded", args: []});
};
extension.shutdown().then(done, done);
return undefined;

View File

@ -1155,7 +1155,9 @@ class BootstrapScope {
uninstall(data, reason) {
AsyncShutdown.profileChangeTeardown.addBlocker(
`Uninstalling add-on: ${data.id}`,
Management.emit("uninstall", {id: data.id}));
Management.emit("uninstall", {id: data.id}).then(() => {
Management.emit("uninstall-complete", {id: data.id});
}));
}
update(data, reason) {

View File

@ -56,9 +56,10 @@ XPCOMUtils.defineLazyGetter(this, "console", ExtensionUtils.getConsole);
* @param {nsIFile} file
* @param {nsIURI} rootURI
* @param {string} installType
* @param {boolean} [embedded = false]
*/
class MockExtension {
constructor(file, rootURI, installType) {
constructor(file, rootURI, installType, embedded) {
this.id = null;
this.file = file;
this.rootURI = rootURI;
@ -84,6 +85,9 @@ class MockExtension {
this._extension = null;
this._extensionPromise = promiseEvent("startup");
this._readyPromise = promiseEvent("ready");
if (!embedded) {
this._uninstallPromise = promiseEvent("uninstall-complete");
}
}
maybeSetID(uri, id) {
@ -374,7 +378,7 @@ var ExtensionTestCommon = class ExtensionTestCommon {
// This may be "temporary" or "permanent".
if (data.useAddonManager) {
return new MockExtension(file, jarURI, data.useAddonManager);
return new MockExtension(file, jarURI, data.useAddonManager, data.embedded);
}
let id;