Bug 1552799 - Hide report action on system and builtin addons. r=mstriemer a=jcristau
authorLuca Greco <lgreco@mozilla.com>
Fri, 07 Jun 2019 08:55:48 +0000
changeset 536826 d512a17f5a554e8b19e21d6ed5055797273d742c
parent 536825 8a4c14d86baa1ab9a8b42cecc0675316de6b9abc
child 536827 52554b40948e17eb3b72a8c742c907fb225a47d7
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstriemer, jcristau
bugs1552799
milestone68.0
Bug 1552799 - Hide report action on system and builtin addons. r=mstriemer a=jcristau Differential Revision: https://phabricator.services.mozilla.com/D32625
toolkit/mozapps/extensions/content/aboutaddons.js
toolkit/mozapps/extensions/test/browser/browser_html_abuse_report.js
--- a/toolkit/mozapps/extensions/content/aboutaddons.js
+++ b/toolkit/mozapps/extensions/content/aboutaddons.js
@@ -575,17 +575,17 @@ class AddonOptions extends HTMLElement {
   }
 
   setElementState(el, card, addon, updateInstall) {
     switch (el.getAttribute("action")) {
       case "remove":
         el.hidden = !hasPermission(addon, "uninstall");
         break;
       case "report":
-        el.hidden = !ABUSE_REPORT_ENABLED;
+        el.hidden = !ABUSE_REPORT_ENABLED || addon.isBuiltin || addon.isSystem;
         break;
       case "toggle-disabled":
         let toggleDisabledAction = addon.userDisabled ? "enable" : "disable";
         document.l10n.setAttributes(
           el, `${toggleDisabledAction}-addon-button`);
         el.hidden = !hasPermission(addon, toggleDisabledAction);
         break;
       case "install-update":
--- a/toolkit/mozapps/extensions/test/browser/browser_html_abuse_report.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_html_abuse_report.js
@@ -21,17 +21,19 @@ const BASE_TEST_MANIFEST = {
   name: "Fake extension to report",
   author: "Fake author",
   homepage_url: "https://fake.extension.url/",
   applications: {gecko: {id: ADDON_ID}},
   icons: {
     32: "test-icon.png",
   },
 };
+const DEFAULT_BUILTIN_THEME_ID = "default-theme@mozilla.org";
 const EXT_WITH_PRIVILEGED_URL_ID = "ext-with-privileged-url@mochi.test";
+const EXT_SYSTEM_ADDON_ID = "test-system-addon@mochi.test";
 const THEME_NO_UNINSTALL_ID = "theme-without-perm-can-uninstall@mochi.test";
 
 let gProvider;
 let gHtmlAboutAddonsWindow;
 let gManagerWindow;
 let apiRequestHandler;
 
 AddonTestUtils.initMochitest(this);
@@ -75,16 +77,29 @@ async function openAboutAddons(type = "e
 async function closeAboutAddons() {
   if (gHtmlAboutAddonsWindow) {
     await closeView(gHtmlAboutAddonsWindow);
     gHtmlAboutAddonsWindow = null;
     gManagerWindow = null;
   }
 }
 
+async function assertReportActionHidden(gManagerWindow, extId) {
+  await gManagerWindow.htmlBrowserLoaded;
+  const {contentDocument: doc} = gManagerWindow.getHtmlBrowser();
+
+  let addonCard = doc.querySelector(
+    `addon-list addon-card[addon-id="${extId}"]`);
+  ok(addonCard, `Got the addon-card for the ${extId} test extension`);
+
+  let reportButton = addonCard.querySelector("[action=report]");
+  ok(reportButton, `Got the report action for ${extId}`);
+  ok(reportButton.hidden, `${extId} report action should be hidden`);
+}
+
 async function installTestExtension(
   id = ADDON_ID, type = "extension", manifest = {}
 ) {
   const additionalProps = type === "theme" ? {
     theme: {
       colors: {
         frame: "#a14040",
         tab_background_text: "#fac96e",
@@ -227,16 +242,23 @@ add_task(async function setup() {
     type: "theme",
     permissions: 0,
   }, {
     id: EXT_WITH_PRIVILEGED_URL_ID,
     name: "This extension has an unexpected privileged creator URL",
     version: "1.1",
     creator: {name: "creator", url: "about:config"},
     type: "extension",
+  }, {
+    id: EXT_SYSTEM_ADDON_ID,
+    name: "This is a system addon",
+    version: "1.1",
+    creator: {name: "creator", url: "http://example.com/creator"},
+    type: "extension",
+    isSystem: true,
   }]);
 });
 
 // This test case verifies that:
 // - the about:addons XUL page contains the addon-abuse-report-xulframe element,
 //   and that
 //   it is part of a XUL stack alongside with the rest of a about:addons
 //   XUL page
@@ -1062,8 +1084,20 @@ add_task(async function test_abuse_repor
      "Got about:blank loaded in the new tab");
 
   SimpleTest.endMonitorConsole();
   await waitForConsole;
 
   BrowserTestUtils.removeTab(gBrowser.selectedTab);
   await closeAboutAddons();
 });
+
+add_task(async function test_report_action_hidden_on_builtin_addons() {
+  await openAboutAddons("theme");
+  await assertReportActionHidden(gManagerWindow, DEFAULT_BUILTIN_THEME_ID);
+  await closeAboutAddons();
+});
+
+add_task(async function test_report_action_hidden_on_system_addons() {
+  await openAboutAddons("extension");
+  await assertReportActionHidden(gManagerWindow, EXT_SYSTEM_ADDON_ID);
+  await closeAboutAddons();
+});