fune/browser/base/content/test/webextensions/browser_permissions_dismiss.js
Kris Maglione 94e3b0bd8d Bug 1596918: Part 3a - Scripted rewrite of most ContentTask.spawn calls to SpecialPowers.spawn calls. r=mccr8,remote-protocol-reviewers,ato
This is generally pretty straightforward, and rewrites nearly all calls. It
skips the ones that it can detect using frame script globals like
`sendAsyncMessage`, though.

Differential Revision: https://phabricator.services.mozilla.com/D53740

--HG--
extra : moz-landing-system : lando
2019-12-13 20:36:16 +00:00

61 lines
1.8 KiB
JavaScript

"use strict";
const INSTALL_PAGE = `${BASE}/file_install_extensions.html`;
const INSTALL_XPI = `${BASE}/browser_webext_permissions.xpi`;
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["extensions.webapi.testing", true],
["extensions.install.requireBuiltInCerts", false],
],
});
registerCleanupFunction(async () => {
await SpecialPowers.popPrefEnv();
});
});
add_task(async function test_tab_switch_dismiss() {
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, INSTALL_PAGE);
let installCanceled = new Promise(resolve => {
let listener = {
onInstallCancelled() {
AddonManager.removeInstallListener(listener);
resolve();
},
};
AddonManager.addInstallListener(listener);
});
SpecialPowers.spawn(gBrowser.selectedBrowser, [INSTALL_XPI], function(url) {
content.wrappedJSObject.installMozAM(url);
});
await promisePopupNotificationShown("addon-webext-permissions");
let permsUL = document.getElementById("addon-webext-perm-list");
is(permsUL.childElementCount, 5, `Permissions list has 5 entries`);
let permsLearnMore = document.getElementById("addon-webext-perm-info");
ok(
BrowserTestUtils.is_visible(permsLearnMore),
"Learn more link is shown on Permission popup"
);
is(
permsLearnMore.href,
Services.urlFormatter.formatURLPref("app.support.baseURL") +
"extension-permissions",
"Learn more link has desired URL"
);
// Switching tabs dismisses the notification and cancels the install.
let switchTo = await BrowserTestUtils.openNewForegroundTab(gBrowser);
BrowserTestUtils.removeTab(switchTo);
await installCanceled;
let addon = await AddonManager.getAddonByID("permissions@test.mozilla.org");
is(addon, null, "Extension is not installed");
BrowserTestUtils.removeTab(tab);
});