Bug 1558823 - Show generic icon for extensions without icon. r=mstriemer,mixedpuppy
authorOriol Brufau <oriol-bugzilla@hotmail.com>
Wed, 10 Jul 2019 19:48:31 +0000
changeset 482268 278205a39cd87fae34b84827c4188147d8ee2b1e
parent 482267 118cd41584b5f4a66eda0d4bf491b749f2e5ca71
child 482269 dc058b3425f758eadb09e6c18d872d8635b4a23d
push id89663
push usermstriemer@mozilla.com
push dateWed, 10 Jul 2019 20:00:35 +0000
treeherderautoland@278205a39cd8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstriemer, mixedpuppy
bugs1558823
milestone70.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 1558823 - Show generic icon for extensions without icon. r=mstriemer,mixedpuppy Differential Revision: https://phabricator.services.mozilla.com/D36730
toolkit/mozapps/extensions/content/aboutaddons.js
toolkit/mozapps/extensions/test/browser/browser_html_list_view.js
--- a/toolkit/mozapps/extensions/content/aboutaddons.js
+++ b/toolkit/mozapps/extensions/content/aboutaddons.js
@@ -69,16 +69,18 @@ XPCOMUtils.defineLazyPreferenceGetter(
 XPCOMUtils.defineLazyPreferenceGetter(
   this,
   "LIST_RECOMMENDATIONS_ENABLED",
   "extensions.htmlaboutaddons.recommendations.enabled",
   false
 );
 
 const PLUGIN_ICON_URL = "chrome://global/skin/plugins/pluginGeneric.svg";
+const EXTENSION_ICON_URL =
+  "chrome://mozapps/skin/extensions/extensionGeneric.svg";
 const PERMISSION_MASKS = {
   "ask-to-activate": AddonManager.PERM_CAN_ASK_TO_ACTIVATE,
   enable: AddonManager.PERM_CAN_ENABLE,
   "always-activate": AddonManager.PERM_CAN_ENABLE,
   disable: AddonManager.PERM_CAN_DISABLE,
   "never-activate": AddonManager.PERM_CAN_DISABLE,
   uninstall: AddonManager.PERM_CAN_UNINSTALL,
   upgrade: AddonManager.PERM_CAN_UPGRADE,
@@ -1814,17 +1816,19 @@ class AddonCard extends HTMLElement {
   update() {
     let { addon, card } = this;
 
     // Update the icon.
     let icon;
     if (addon.type == "plugin") {
       icon = PLUGIN_ICON_URL;
     } else {
-      icon = AddonManager.getPreferredIconURL(addon, 32, window);
+      icon =
+        AddonManager.getPreferredIconURL(addon, 32, window) ||
+        EXTENSION_ICON_URL;
     }
     card.querySelector(".addon-icon").src = icon;
 
     // Update the theme preview.
     let preview = card.querySelector(".card-heading-image");
     preview.hidden = true;
     if (addon.type == "theme") {
       let screenshotUrl = getScreenshotUrlForAddon(addon);
--- a/toolkit/mozapps/extensions/test/browser/browser_html_list_view.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_html_list_view.js
@@ -727,8 +727,33 @@ add_task(async function testPluginIcons(
   ok(icons.length > 0, "There are some plugins listed");
 
   for (let icon of icons) {
     is(icon.src, pluginIconUrl, "Plugins use the plugin icon");
   }
 
   await closeView(win);
 });
+
+add_task(async function testExtensionGenericIcon() {
+  const extensionIconUrl =
+    "chrome://mozapps/skin/extensions/extensionGeneric.svg";
+
+  let id = "test@mochi.test";
+  let extension = ExtensionTestUtils.loadExtension({
+    manifest: {
+      name: "Test extension",
+      applications: { gecko: { id } },
+    },
+    useAddonManager: "temporary",
+  });
+  await extension.startup();
+
+  let win = await loadInitialView("extension");
+  let doc = win.document;
+
+  let card = getCardByAddonId(doc, id);
+  let icon = card.querySelector(".addon-icon");
+  is(icon.src, extensionIconUrl, "Extensions without icon use the generic one");
+
+  await extension.unload();
+  await closeView(win);
+});