Bug 1527660 - Adding learn more link to permissions popup r=mstriemer,johannh
authorTrishul <trishul.goel@gmail.com>
Thu, 21 Feb 2019 10:36:33 +0000
changeset 519096 da6f15f3a5232c102dda02f3efb13c1f64ceb894
parent 519095 1dcb31a1d5be037dd32d9f9f46ccc79b7329f741
child 519097 bc51c190590a057206eb960e3eca6ac7461c36a3
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstriemer, johannh
bugs1527660
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1527660 - Adding learn more link to permissions popup r=mstriemer,johannh Adding learn more link to permissions popup Differential Revision: https://phabricator.services.mozilla.com/D19711
browser/base/content/popup-notifications.inc
browser/base/content/test/webextensions/browser_permissions_dismiss.js
browser/base/content/test/webextensions/head.js
browser/locales/en-US/chrome/browser/browser.properties
browser/modules/ExtensionsUI.jsm
browser/themes/shared/browser.inc.css
--- a/browser/base/content/popup-notifications.inc
+++ b/browser/base/content/popup-notifications.inc
@@ -72,16 +72,19 @@
       <popupnotificationcontent id="addon-install-confirmation-content" orient="vertical"/>
     </popupnotification>
 
     <popupnotification id="addon-webext-permissions-notification" hidden="true">
       <popupnotificationcontent class="addon-webext-perm-notification-content" orient="vertical">
         <description id="addon-webext-perm-text" class="addon-webext-perm-text"/>
         <label id="addon-webext-perm-intro" class="addon-webext-perm-text"/>
         <html:ul id="addon-webext-perm-list" class="addon-webext-perm-list"/>
+        <hbox>
+          <label id="addon-webext-perm-info" is="text-link" class="popup-notification-learnmore-link"/>
+        </hbox>
       </popupnotificationcontent>
     </popupnotification>
 
     <popupnotification id="contextual-feature-recommendation-notification" hidden="true">
       <popupnotificationheader id="cfr-notification-header">
         <stack id="cfr-notification-header-stack">
           <description id="cfr-notification-header-label"></description>
           <label id="cfr-notification-header-link" is="text-link">
--- a/browser/base/content/test/webextensions/browser_permissions_dismiss.js
+++ b/browser/base/content/test/webextensions/browser_permissions_dismiss.js
@@ -30,16 +30,23 @@ add_task(async function test_tab_switch_
   ContentTask.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");
 
--- a/browser/base/content/test/webextensions/head.js
+++ b/browser/base/content/test/webextensions/head.js
@@ -206,30 +206,33 @@ function checkPermissionString(string, k
  *        in this array is itself a 2-element array with the string key
  *        for the item (e.g., "webextPerms.description.foo") and an
  *        optional formatting parameter.
  */
 function checkNotification(panel, checkIcon, permissions) {
   let icon = panel.getAttribute("icon");
   let ul = document.getElementById("addon-webext-perm-list");
   let header = document.getElementById("addon-webext-perm-intro");
+  let learnMoreLink = document.getElementById("addon-webext-perm-info");
 
   if (checkIcon instanceof RegExp) {
     ok(checkIcon.test(icon), `Notification icon is correct ${JSON.stringify(icon)} ~= ${checkIcon}`);
   } else if (typeof checkIcon == "function") {
     ok(checkIcon(icon), "Notification icon is correct");
   } else {
     is(icon, checkIcon, "Notification icon is correct");
   }
 
   is(ul.childElementCount, permissions.length, `Permissions list has ${permissions.length} entries`);
   if (permissions.length == 0) {
     is(header.getAttribute("hidden"), "true", "Permissions header is hidden");
+    is(learnMoreLink.getAttribute("hidden"), "true", "Permissions learn more is hidden");
   } else {
     is(header.getAttribute("hidden"), "", "Permissions header is visible");
+    is(learnMoreLink.getAttribute("hidden"), "", "Permissions learn more is visible");
   }
 
   for (let i in permissions) {
     let [key, param] = permissions[i];
     checkPermissionString(ul.children[i].textContent, key, param,
                           `Permission number ${i + 1} is correct`);
   }
 }
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -42,16 +42,17 @@ xpinstallDisabledButton.accesskey=n
 webextPerms.header=Add %S?
 
 webextPerms.unsignedWarning=Caution: This add-on is unverified. Malicious add-ons can steal your private information or compromise your computer. Only install this add-on if you trust the source.
 
 # LOCALIZATION NOTE (webextPerms.listIntro)
 # This string will be followed by a list of permissions requested
 # by the webextension.
 webextPerms.listIntro=It requires your permission to:
+webextPerms.learnMore=Learn more about permissions
 webextPerms.add.label=Add
 webextPerms.add.accessKey=A
 webextPerms.cancel.label=Cancel
 webextPerms.cancel.accessKey=C
 
 # LOCALIZATION NOTE (webextPerms.sideloadMenuItem)
 # %1$S will be replaced with the localized name of the sideloaded add-on.
 # %2$S will be replace with the name of the application (e.g., Firefox, Nightly)
--- a/browser/modules/ExtensionsUI.jsm
+++ b/browser/modules/ExtensionsUI.jsm
@@ -287,16 +287,17 @@ var ExtensionsUI = {
   _buildStrings(info) {
     let bundle = Services.strings.createBundle(BROWSER_PROPERTIES);
     let brandBundle = Services.strings.createBundle(BRAND_PROPERTIES);
     let appName = brandBundle.GetStringFromName("brandShortName");
     let info2 = Object.assign({appName}, info);
 
     let strings = ExtensionData.formatPermissionStrings(info2, bundle);
     strings.addonName = info.addon.name;
+    strings.learnMore = bundle.GetStringFromName("webextPerms.learnMore");
     return strings;
   },
 
   async showPermissionsPrompt(target, strings, icon, histkey) {
     let {browser, window} = getTabBrowser(target);
 
     // Wait for any pending prompts in this window to complete before
     // showing the next one.
@@ -312,16 +313,21 @@ var ExtensionsUI = {
           let textEl = doc.getElementById("addon-webext-perm-text");
           textEl.textContent = strings.text;
           textEl.hidden = !strings.text;
 
           let listIntroEl = doc.getElementById("addon-webext-perm-intro");
           listIntroEl.textContent = strings.listIntro;
           listIntroEl.hidden = (strings.msgs.length == 0);
 
+          let listInfoEl = doc.getElementById("addon-webext-perm-info");
+          listInfoEl.textContent = strings.learnMore;
+          listInfoEl.href = Services.urlFormatter.formatURLPref("app.support.baseURL") + "extension-permissions";
+          listInfoEl.hidden = (strings.msgs.length == 0);
+
           let list = doc.getElementById("addon-webext-perm-list");
           while (list.firstChild) {
             list.firstChild.remove();
           }
 
           for (let msg of strings.msgs) {
             let item = doc.createElementNS(HTML_NS, "li");
             item.textContent = msg;
--- a/browser/themes/shared/browser.inc.css
+++ b/browser/themes/shared/browser.inc.css
@@ -167,16 +167,21 @@
 #widget-overflow .webextension-popup-browser {
   background: #fff;
 }
 
 #addon-progress-notification-progressmeter {
   margin: 2px 4px;
 }
 
+/* Permissions popup learn more link. */
+#addon-webext-perm-info {
+  margin-inline-start: 0;
+}
+
 /* Contextual Feature Recommendation popup-notification */
 
 #cfr-notification-header {
   width: 100%;
   text-align: center;
   box-shadow: 0px 1px 0px rgba(0, 0, 0, 0.2);
 }