From a02a18c1e531c86528a82fcb69bdeaa5922a496a Mon Sep 17 00:00:00 2001 From: Andrew Swan Date: Mon, 10 Apr 2017 19:12:23 -0700 Subject: [PATCH] Bug 1352152 Fix several issues with optional webextension permissions r=kmag 1. Use the right strings in permission dialogs 2. Don't show permissions dialogs for non-promptable permissions 3. Enable dialogs by default MozReview-Commit-ID: JJdxxcP7IeU --HG-- extra : rebase_source : b5525cbae3822f3e2727788fd63580e6d5bd8293 --- browser/app/profile/firefox.js | 1 + browser/modules/ExtensionsUI.jsm | 14 ++++++++++++++ .../mochitest/test_chrome_ext_permissions.html | 7 +++++++ 3 files changed, 22 insertions(+) diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index c89e45e23099..e5cc8c6fbad9 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -39,6 +39,7 @@ pref("extensions.checkCompatibility.temporaryThemeOverride_minAppVersion", "29.0 pref("xpinstall.customConfirmationUI", true); pref("extensions.webextPermissionPrompts", true); +pref("extensions.webextOptionalPermissionPrompts", true); // Preferences for AMO integration pref("extensions.getAddons.cache.enabled", true); diff --git a/browser/modules/ExtensionsUI.jsm b/browser/modules/ExtensionsUI.jsm index ce08cde2225b..9f78fa4ba40e 100644 --- a/browser/modules/ExtensionsUI.jsm +++ b/browser/modules/ExtensionsUI.jsm @@ -211,6 +211,13 @@ this.ExtensionsUI = { addon: {name}, permissions, }); + + // If we don't have any promptable permissions, just proceed + if (strings.msgs.length == 0) { + resolve(); + return; + } + resolve(this.showPermissionsPrompt(browser, strings, icon)); } }, @@ -334,6 +341,13 @@ this.ExtensionsUI = { result.text = bundle.formatStringFromName("webextPerms.updateText", [addonName], 1); result.acceptText = bundle.GetStringFromName("webextPerms.updateAccept.label"); result.acceptKey = bundle.GetStringFromName("webextPerms.updateAccept.accessKey"); + } else if (info.type == "optional") { + result.header = bundle.formatStringFromName("webextPerms.optionalPermsHeader", [addonName], 1); + result.text = ""; + result.listIntro = bundle.GetStringFromName("webextPerms.optionalPermsListIntro"); + result.acceptText = bundle.GetStringFromName("webextPerms.optionalPermsAllow.label"); + result.acceptKey = bundle.GetStringFromName("webextPerms.optionalPermsAllow.accessKey"); + result.cancelText = bundle.GetStringFromName("webextPerms.optionalPermsDeny.label"); } return result; diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_permissions.html b/toolkit/components/extensions/test/mochitest/test_chrome_ext_permissions.html index 188c862c9741..7753ad601364 100644 --- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_permissions.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_permissions.html @@ -154,6 +154,13 @@ function makeTest(manifestPermissions, optionalPermissions, checkFetch = true) { }; } +add_task(function setup() { + // Don't bother with prompts in this test. + return SpecialPowers.pushPrefEnv({ + set: [["extensions.webextOptionalPermissionPrompts", false]], + }); +}); + const ORIGIN = "*://example.com/"; add_task(makeTest([], { permissions: ["cookies"],