Bug 628041 refresh the install blocked panel text r=flod,aswan
authorShane Caraveo <scaraveo@mozilla.com>
Thu, 11 Apr 2019 18:56:47 +0000
changeset 469073 e56cd039fd9461b9946ac166a6c2a0a12664adb3
parent 469072 186322f1d1f212f92a5a925814a5869e9c78d19b
child 469074 7befb6bf6b3b2441d1659579e0edf7226aff8781
push id35856
push usercsabou@mozilla.com
push dateFri, 12 Apr 2019 03:19:48 +0000
treeherdermozilla-central@940684cd1065 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflod, aswan
bugs628041
milestone68.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 628041 refresh the install blocked panel text r=flod,aswan Differential Revision: https://phabricator.services.mozilla.com/D25881
browser/base/content/browser-addons.js
browser/base/content/popup-notifications.inc
browser/locales/en-US/chrome/browser/browser.properties
toolkit/mozapps/extensions/test/xpinstall/browser_doorhanger_installs.js
--- a/browser/base/content/browser-addons.js
+++ b/browser/base/content/browser-addons.js
@@ -409,23 +409,47 @@ var gXPInstallObserver = {
       let secHistogram = Services.telemetry.getHistogramById("SECURITY_UI");
       secHistogram.add(Ci.nsISecurityUITelemetry.WARNING_ADDON_ASKING_PREVENTED);
       let popup = PopupNotifications.show(browser, notificationID,
                                           messageString, anchorID,
                                           null, null, options);
       removeNotificationOnEnd(popup, installInfo.installs);
       break; }
     case "addon-install-blocked": {
-      messageString = gNavigatorBundle.getFormattedString("xpinstallPromptMessage",
-                        [brandShortName]);
+      messageString = gNavigatorBundle.getFormattedString("xpinstallPromptMessage.header", ["<>"]);
+      let unknown = gNavigatorBundle.getString("xpinstallPromptMessage.unknown");
+      options.name = options.displayURI && options.displayURI.displayHost || unknown;
+      // displayURI becomes it's own label, so we unset it for this panel. It will become part of the
+      // messageString above.
+      options.displayURI = undefined;
+
+      options.eventCallback = (topic) => {
+        if (topic !== "showing") {
+          return;
+        }
+        let doc = browser.ownerDocument;
+        let message = doc.getElementById("addon-install-blocked-message");
+        // We must remove any prior use of this panel message in this window.
+        while (message.firstChild) {
+          message.firstChild.remove();
+        }
+        let text = gNavigatorBundle.getString("xpinstallPromptMessage.message");
+        let b = doc.createElementNS("http://www.w3.org/1999/xhtml", "b");
+        b.textContent = options.name;
+        let fragment = BrowserUtils.getLocalizedFragment(doc, text, b);
+        message.appendChild(fragment);
+        let learnMore = doc.getElementById("addon-install-blocked-info");
+        learnMore.textContent = gNavigatorBundle.getString("xpinstallPromptMessage.learnMore");
+        learnMore.setAttribute("href", Services.urlFormatter.formatURLPref("app.support.baseURL") + "unlisted-extensions-risks");
+      };
 
       let secHistogram = Services.telemetry.getHistogramById("SECURITY_UI");
       action = {
-        label: gNavigatorBundle.getString("xpinstallPromptAllowButton"),
-        accessKey: gNavigatorBundle.getString("xpinstallPromptAllowButton.accesskey"),
+        label: gNavigatorBundle.getString("xpinstallPromptMessage.install"),
+        accessKey: gNavigatorBundle.getString("xpinstallPromptMessage.install.accesskey"),
         callback() {
           secHistogram.add(Ci.nsISecurityUITelemetry.WARNING_ADDON_ASKING_PREVENTED_CLICK_THROUGH);
           installInfo.install();
         },
       };
       let secondaryAction = {
         label: gNavigatorBundle.getString("xpinstallPromptMessage.dontAllow"),
         accessKey: gNavigatorBundle.getString("xpinstallPromptMessage.dontAllow.accesskey"),
--- a/browser/base/content/popup-notifications.inc
+++ b/browser/base/content/popup-notifications.inc
@@ -78,16 +78,25 @@
         <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="addon-install-blocked-notification" hidden="true">
+      <popupnotificationcontent id="addon-install-blocked-content" orient="vertical">
+        <description id="addon-install-blocked-message" class="popup-notification-description"></description>
+        <hbox>
+          <label id="addon-install-blocked-info" class="popup-notification-learnmore-link" is="text-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">
             <xul:image id="cfr-notification-header-image"/>
           </label>
         </stack>
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -16,23 +16,33 @@ droponhomemsgMultiple=Do you want these 
 contextMenuSearch=Search %1$S for “%2$S”
 contextMenuSearch.accesskey=S
 
 # bookmark dialog strings
 
 bookmarkAllTabsDefault=[Folder Name]
 
 xpinstallPromptMessage=%S prevented this site from asking you to install software on your computer.
+# LOCALIZATION NOTE (xpinstallPromptMessage.header)
+# The string contains the hostname of the site the add-on is being installed from.
+xpinstallPromptMessage.header=Allow %S to install an add-on?
+xpinstallPromptMessage.message=You are attempting to install an add-on from %S. Make sure you trust this site before continuing.
+# LOCALIZATION NOTE (xpinstallPromptMessage.unknown)
+# This string is used in xpinstallPromptMessage.header and xpinstallPromptMessage.message when the domain is not available,
+# for example in case of local installs with drag and drop.
+xpinstallPromptMessage.unknown=an unknown site
+xpinstallPromptMessage.learnMore=Learn more about installing add-ons safely
 xpinstallPromptMessage.dontAllow=Don’t Allow
 xpinstallPromptMessage.dontAllow.accesskey=D
-xpinstallPromptAllowButton=Allow
 # Accessibility Note:
 # Be sure you do not choose an accesskey that is used elsewhere in the active context (e.g. main menu bar, submenu of the warning popup button)
-# See http://www.mozilla.org/access/keyboard/accesskey for details
-xpinstallPromptAllowButton.accesskey=A
+# See https://website-archive.mozilla.org/www.mozilla.org/access/access/keyboard/ for details
+xpinstallPromptMessage.install=Continue to Installation
+xpinstallPromptMessage.install.accesskey=C
+
 xpinstallDisabledMessageLocked=Software installation has been disabled by your system administrator.
 xpinstallDisabledMessage=Software installation is currently disabled. Click Enable and try again.
 xpinstallDisabledButton=Enable
 xpinstallDisabledButton.accesskey=n
 
 # LOCALIZATION NOTE (webextPerms.header)
 # This string is used as a header in the webextension permissions dialog,
 # %S is replaced with the localized name of the extension being installed.
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_doorhanger_installs.js
+++ b/toolkit/mozapps/extensions/test/xpinstall/browser_doorhanger_installs.js
@@ -4,18 +4,16 @@
 
 const {AddonTestUtils} = ChromeUtils.import("resource://testing-common/AddonTestUtils.jsm");
 
 const SECUREROOT = "https://example.com/browser/toolkit/mozapps/extensions/test/xpinstall/";
 const PROGRESS_NOTIFICATION = "addon-progress";
 
 const CHROMEROOT = extractChromeRoot(gTestPath);
 
-var gApp = document.getElementById("bundle_brand").getString("brandShortName");
-
 AddonTestUtils.initMochitest(this);
 AddonTestUtils.hookAMTelemetryEvents();
 
 // Assert on the expected "addonsManager.action" telemetry events (and optional filter events to verify
 // by using a given actionType).
 function assertActionAMTelemetryEvent(expectedActionEvents, assertMessage, {actionType} = {}) {
   const events = AddonTestUtils.getAMTelemetryEvents().filter(({method, extra}) => {
     return method === "action" && (!actionType ? true : extra && extra.action === actionType);
@@ -269,21 +267,20 @@ async function test_blockedInstall() {
   let notificationPromise = waitForNotification("addon-install-blocked");
   let triggers = encodeURIComponent(JSON.stringify({
     "XPI": "amosigned.xpi",
   }));
   BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "installtrigger.html?" + triggers);
   let panel = await notificationPromise;
 
   let notification = panel.childNodes[0];
-  is(notification.button.label, "Allow", "Should have seen the right button");
-  is(notification.getAttribute("origin"), "example.com",
-     "Should have seen the right origin host");
-  is(notification.getAttribute("label"),
-     gApp + " prevented this site from asking you to install software on your computer.",
+  is(notification.button.label, "Continue to Installation", "Should have seen the right button");
+  let message = panel.ownerDocument.getElementById("addon-install-blocked-message");
+  is(message.textContent,
+     "You are attempting to install an add-on from example.com. Make sure you trust this site before continuing.",
      "Should have seen the right message");
 
   let dialogPromise = waitForInstallDialog();
   // Click on Allow
   EventUtils.synthesizeMouse(notification.button, 20, 10, {});
   // Notification should have changed to progress notification
   ok(PopupNotifications.isPanelOpen, "Notification should still be open");
   notification = panel.childNodes[0];