mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 12:50:09 +00:00
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:
parent
b56b27ec80
commit
7bf4c74cac
@ -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");
|
||||
|
@ -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 => {
|
||||
|
@ -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 => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user