Bug 1338336 Make sure to cleanup after test failures r=rhelmer

The issue here was a previous test failing to clean up after itself.
Add an extra cleanup check to the browser webextensions permissions
tests.  Given the small number of extensions used in these tests, the
manual approach seemed better than some very general solution.

MozReview-Commit-ID: 7AWx8nZK3L3

--HG--
extra : rebase_source : cce9a41bfed44017d887624b580d3ea1052077b7
This commit is contained in:
Andrew Swan 2017-02-10 14:57:58 -08:00
parent b56b27ec80
commit 7bf4c74cac
3 changed files with 27 additions and 7 deletions

View File

@ -13,6 +13,14 @@ const DEFAULT_EXTENSION_ICON = "chrome://browser/content/extension.svg";
Services.perms.add(makeURI("https://example.com/"), "install",
Services.perms.ALLOW_ACTION);
registerCleanupFunction(async function() {
let addon = await AddonManager.getAddonByID(ID);
if (addon) {
ok(false, `Addon ${ID} was still installed at the end of the test`);
addon.uninstall();
}
});
function promisePopupNotificationShown(name) {
return new Promise(resolve => {
function popupshown() {
@ -30,12 +38,6 @@ function promisePopupNotificationShown(name) {
});
}
function promiseGetAddonByID(id) {
return new Promise(resolve => {
AddonManager.getAddonByID(id, resolve);
});
}
function checkNotification(panel, filename) {
let icon = panel.getAttribute("icon");
@ -171,7 +173,7 @@ add_task(function* () {
}
let result = yield installPromise;
let addon = yield promiseGetAddonByID(ID);
let addon = yield AddonManager.getAddonByID(ID);
if (cancel) {
ok(!result, "Installation was cancelled");
is(addon, null, "Extension is not installed");

View File

@ -4,6 +4,16 @@ const URL_BASE = "https://example.com/browser/browser/base/content/test/general"
const ID = "update@tests.mozilla.org";
const ID_ICON = "update_icon@tests.mozilla.org";
registerCleanupFunction(async function() {
for (let id of [ID, ID_ICON]) {
let addon = await AddonManager.getAddonByID(id);
if (addon) {
ok(false, `Addon ${id} was still installed at the end of the test`);
addon.uninstall();
}
}
});
function promiseInstallAddon(url) {
return AddonManager.getInstallForURL(url, null, "application/x-xpinstall")
.then(install => {

View File

@ -3,6 +3,14 @@ const {AddonManagerPrivate} = Cu.import("resource://gre/modules/AddonManager.jsm
const URL_BASE = "https://example.com/browser/browser/base/content/test/general";
const ID = "update@tests.mozilla.org";
registerCleanupFunction(async function() {
let addon = await AddonManager.getAddonByID(ID);
if (addon) {
ok(false, `Addon ${ID} was still installed at the end of the test`);
addon.uninstall();
}
});
function promiseInstallAddon(url) {
return AddonManager.getInstallForURL(url, null, "application/x-xpinstall")
.then(install => {