Bug 1342896 Don't show prompts for interactive webextension updates with no new permissions r=rhelmer

MozReview-Commit-ID: 50SP3eL79Qm

--HG--
rename : browser/base/content/test/webextensions/browser_extension_update_interactive.js => browser/base/content/test/webextensions/browser_update_interactive.js
rename : browser/base/content/test/webextensions/browser_extension_update_interactive.js => browser/base/content/test/webextensions/browser_update_interactive_noprompt.js
extra : rebase_source : fdddf8a3ae3957bdaf63cc2a1e39c5a29550cf3a
This commit is contained in:
Andrew Swan 2017-03-03 11:05:35 -08:00
Родитель 60a995f719
Коммит 90597f90e1
4 изменённых файлов: 70 добавлений и 42 удалений

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

@ -17,8 +17,9 @@ support-files =
[browser_extension_sideloading.js]
[browser_extension_update_background.js]
[browser_extension_update_interactive.js]
[browser_permissions_addons_search.js]
[browser_permissions_installTrigger.js]
[browser_permissions_local_file.js]
[browser_permissions_mozAddonManager.js]
[browser_update_interactive.js]
[browser_update_interactive_noprompt.js]

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

@ -1,7 +1,6 @@
const {AddonManagerPrivate} = Cu.import("resource://gre/modules/AddonManager.jsm", {});
const ID = "update2@tests.mozilla.org";
const ID_LEGACY = "legacy_update@tests.mozilla.org";
// Set some prefs that apply to all the tests in this file
add_task(function* setup() {
@ -134,43 +133,3 @@ function checkOne(win, addon) {
// Test "Find Updates" with both auto-update settings
add_task(() => interactiveUpdateTest(true, checkOne));
add_task(() => interactiveUpdateTest(false, checkOne));
// Check that an update from a legacy extension to a webextensino
// does not display a prompt
add_task(async function() {
await SpecialPowers.pushPrefEnv({set: [
// Point updates to the local mochitest server
["extensions.update.url", `${BASE}/browser_webext_update.json`],
]});
// Navigate away to ensure that BrowserOpenAddonMgr() opens a new tab
gBrowser.selectedBrowser.loadURI("about:robots");
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
// Install initial version of the test extension
let addon = await promiseInstallAddon(`${BASE}/browser_legacy.xpi`);
ok(addon, "Addon was installed");
is(addon.version, "1.1", "Version 1 of the addon is installed");
// Go to Extensions in about:addons
let win = await BrowserOpenAddonsMgr("addons://list/extension");
let sawPopup = false;
PopupNotifications.panel.addEventListener("popupshown",
() => sawPopup = true,
{once: true});
// Trigger an update check, we should see the update get applied
let updatePromise = promiseInstallEvent(addon, "onInstallEnded");
win.gViewController.doCommand("cmd_findAllUpdates");
await updatePromise;
addon = await AddonManager.getAddonByID(ID_LEGACY);
is(addon.version, "2.0", "Should have upgraded");
ok(!sawPopup, "Should not have seen a permission notification");
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
addon.uninstall();
await SpecialPowers.popPrefEnv();
});

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

@ -0,0 +1,62 @@
// Set some prefs that apply to all the tests in this file
add_task(function* setup() {
yield SpecialPowers.pushPrefEnv({set: [
// We don't have pre-pinned certificates for the local mochitest server
["extensions.install.requireBuiltInCerts", false],
["extensions.update.requireBuiltInCerts", false],
// Point updates to the local mochitest server
["extensions.update.url", `${BASE}/browser_webext_update.json`],
// XXX remove this when prompts are enabled by default
["extensions.webextPermissionPrompts", true],
]});
});
// Helper to test that an update of a given extension does not
// generate any permission prompts.
async function testUpdateNoPrompt(filename, id,
initialVersion = "1.0", updateVersion = "2.0") {
// Navigate away to ensure that BrowserOpenAddonMgr() opens a new tab
gBrowser.selectedBrowser.loadURI("about:robots");
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
// Install initial version of the test extension
let addon = await promiseInstallAddon(`${BASE}/${filename}`);
ok(addon, "Addon was installed");
is(addon.version, initialVersion, "Version 1 of the addon is installed");
// Go to Extensions in about:addons
let win = await BrowserOpenAddonsMgr("addons://list/extension");
let sawPopup = false;
function popupListener() {
sawPopup = true;
}
PopupNotifications.panel.addEventListener("popupshown", popupListener);
// Trigger an update check, we should see the update get applied
let updatePromise = promiseInstallEvent(addon, "onInstallEnded");
win.gViewController.doCommand("cmd_findAllUpdates");
await updatePromise;
addon = await AddonManager.getAddonByID(id);
is(addon.version, updateVersion, "Should have upgraded");
ok(!sawPopup, "Should not have seen a permission notification");
PopupNotifications.panel.removeEventListener("popupshown", popupListener);
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
addon.uninstall();
}
// Test that we don't see a prompt when updating from a legacy
// extension to a webextension.
add_task(() => testUpdateNoPrompt("browser_legacy.xpi",
"legacy_update@tests.mozilla.org", "1.1"));
// Test that we don't see a prompt when no new promptable permissions
// are added.
add_task(() => testUpdateNoPrompt("browser_webext_update_perms1.xpi",
"update_perms@tests.mozilla.org"));

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

@ -141,6 +141,12 @@ this.ExtensionsUI = {
}
let strings = this._buildStrings(info);
// If this is an update with no promptable permissions, just apply it
if (info.type == "update" && strings.msgs.length == 0) {
info.resolve();
return;
}
this.showPermissionsPrompt(target, strings, info.icon).then(answer => {
if (answer) {
info.resolve();