Bug 1533519 hide private checkbox for non-extension addons r=rpl
authorShane Caraveo <scaraveo@mozilla.com>
Fri, 08 Mar 2019 13:51:52 +0000
changeset 521041 42193ad4cde7
parent 521040 c8a4f2586fc0
child 521042 8413368a95eb
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)
reviewersrpl
bugs1533519
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 1533519 hide private checkbox for non-extension addons r=rpl Differential Revision: https://phabricator.services.mozilla.com/D22591
browser/modules/ExtensionsUI.jsm
toolkit/mozapps/extensions/test/browser/browser_webapi_install.js
toolkit/mozapps/extensions/test/browser/browser_webapi_theme.js
toolkit/mozapps/extensions/test/browser/head.js
--- a/browser/modules/ExtensionsUI.jsm
+++ b/browser/modules/ExtensionsUI.jsm
@@ -438,17 +438,17 @@ var ExtensionsUI = {
     let bundle = window.gNavigatorBundle;
 
     let message = bundle.getFormattedString("addonPostInstall.message1",
                                             ["<>", appName]);
     return new Promise(resolve => {
       // Show or hide private permission ui based on the pref.
       let checkbox = window.document.getElementById("addon-incognito-checkbox");
       checkbox.checked = false;
-      checkbox.hidden = allowPrivateBrowsingByDefault;
+      checkbox.hidden = allowPrivateBrowsingByDefault || addon.type !== "extension";
 
       async function actionResolve() {
         if (checkbox.checked) {
           let perms = {permissions: ["internal:privateBrowsingAllowed"], origins: []};
           await ExtensionPermissions.add(addon.id, perms);
           AMTelemetry.recordActionEvent({
             addon,
             object: "doorhanger",
--- a/toolkit/mozapps/extensions/test/browser/browser_webapi_install.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_webapi_install.js
@@ -21,17 +21,18 @@ function waitForClear() {
 
     Services.mm.addMessageListener(MSG, listener, true);
   });
 }
 
 add_task(async function setup() {
   await SpecialPowers.pushPrefEnv({
     set: [["extensions.webapi.testing", true],
-          ["extensions.install.requireBuiltInCerts", false]],
+          ["extensions.install.requireBuiltInCerts", false],
+          ["extensions.allowPrivateBrowsingByDefault", false]],
   });
   info("added preferences");
 });
 
 // Wrapper around a common task to run in the content process to test
 // the mozAddonManager API.  Takes a URL for the XPI to install and an
 // array of steps, each of which can either be an action to take
 // (i.e., start or cancel the install) or an install event to wait for.
@@ -198,17 +199,17 @@ function makeRegularTest(options, what) 
       },
     ];
 
     let installPromptPromise =
       promisePopupNotificationShown("addon-webext-permissions").then(panel => {
         panel.button.click();
       });
 
-    let promptPromise = acceptAppMenuNotificationWhenShown("addon-installed");
+    let promptPromise = acceptAppMenuNotificationWhenShown("addon-installed", "extension");
 
     await testInstall(browser, options, steps, what);
 
     await installPromptPromise;
 
     await promptPromise;
 
     // Sanity check to ensure that the test in makeInstallTest() that
--- a/toolkit/mozapps/extensions/test/browser/browser_webapi_theme.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_webapi_theme.js
@@ -2,30 +2,31 @@
 "use strict";
 
 const TESTPAGE = `${SECURE_TESTROOT}webapi_checkavailable.html`;
 const URL = `${SECURE_TESTROOT}addons/browser_theme.xpi`;
 
 add_task(async function test_theme_install() {
   await SpecialPowers.pushPrefEnv({
     set: [["extensions.webapi.testing", true],
-          ["extensions.install.requireBuiltInCerts", false]],
+          ["extensions.install.requireBuiltInCerts", false],
+          ["extensions.allowPrivateBrowsingByDefault", false]],
   });
 
   await BrowserTestUtils.withNewTab(TESTPAGE, async (browser) => {
     let updates = [];
     function observer(subject, topic, data) {
       updates.push(data);
     }
     Services.obs.addObserver(observer, "lightweight-theme-styling-update");
     registerCleanupFunction(() => {
       Services.obs.removeObserver(observer, "lightweight-theme-styling-update");
     });
 
-    let promptPromise = acceptAppMenuNotificationWhenShown("addon-installed");
+    let promptPromise = acceptAppMenuNotificationWhenShown("addon-installed", "theme");
 
     let installPromise = ContentTask.spawn(browser, URL, async (url) => {
       let install = await content.navigator.mozAddonManager.createInstall({url});
       return install.install();
     });
 
     await promptPromise;
     await installPromise;
--- a/toolkit/mozapps/extensions/test/browser/head.js
+++ b/toolkit/mozapps/extensions/test/browser/head.js
@@ -1394,28 +1394,34 @@ function promisePopupNotificationShown(n
 
       PopupNotifications.panel.removeEventListener("popupshown", popupshown);
       resolve(PopupNotifications.panel.firstChild);
     }
     PopupNotifications.panel.addEventListener("popupshown", popupshown);
   });
 }
 
-function acceptAppMenuNotificationWhenShown(id) {
+function acceptAppMenuNotificationWhenShown(id, type) {
   const {AppMenuNotifications} = ChromeUtils.import("resource://gre/modules/AppMenuNotifications.jsm");
   return new Promise(resolve => {
     function popupshown() {
       let notification = AppMenuNotifications.activeNotification;
       if (!notification) { return; }
 
       is(notification.id, id, `${id} notification shown`);
       ok(PanelUI.isNotificationPanelOpen, "notification panel open");
 
       PanelUI.notificationPanel.removeEventListener("popupshown", popupshown);
 
+      if (id == "addon-installed" && type) {
+        let hidden = type !== "extension" ||
+                     Services.prefs.getBoolPref("extensions.allowPrivateBrowsingByDefault", true);
+        let checkbox = document.getElementById("addon-incognito-checkbox");
+        is(checkbox.hidden, hidden, "checkbox visibility is correct");
+      }
       let popupnotificationID = PanelUI._getPopupId(notification);
       let popupnotification = document.getElementById(popupnotificationID);
       popupnotification.button.click();
 
       resolve();
     }
     PanelUI.notificationPanel.addEventListener("popupshown", popupshown);
   });