Bug 1370224 - Fallback to extension icon for browser/page action r=mstriemer,mixedpuppy
authorNicklas Boman <smurfd@gmail.com>
Sun, 04 Nov 2018 20:03:15 +0100
changeset 503331 8ab318a0ae56110d72fac3dd73ba2ce617943049
parent 503330 c7a9ceb9becbccaf75f65eec47a98f0a72fafb02
child 503332 2e250aa206d11319cfaab13e9d57c1095940668c
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstriemer, mixedpuppy
bugs1370224
milestone65.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 1370224 - Fallback to extension icon for browser/page action r=mstriemer,mixedpuppy
browser/components/extensions/parent/ext-browserAction.js
browser/components/extensions/test/browser/browser_ext_browserAction_simple.js
--- a/browser/components/extensions/parent/ext-browserAction.js
+++ b/browser/components/extensions/parent/ext-browserAction.js
@@ -78,17 +78,17 @@ this.browserAction = class extends Exten
 
     this.browserStyle = options.browser_style;
 
     browserActionMap.set(extension, this);
 
     this.defaults.icon = await StartupCache.get(
       extension, ["browserAction", "default_icon"],
       () => IconDetails.normalize({
-        path: options.default_icon,
+        path: options.default_icon || extension.manifest.icons,
         iconType: "browserAction",
         themeIcons: options.theme_icons,
       }, extension));
 
     this.iconData.set(
       this.defaults.icon,
       await StartupCache.get(
         extension, ["browserAction", "default_icon_data"],
--- a/browser/components/extensions/test/browser/browser_ext_browserAction_simple.js
+++ b/browser/components/extensions/test/browser/browser_ext_browserAction_simple.js
@@ -4,31 +4,33 @@
 
 add_task(async function() {
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "browser_action": {
         "default_popup": "popup.html",
         "unrecognized_property": "with-a-random-value",
       },
+      icons: {32: "icon.png"},
     },
 
     files: {
       "popup.html": `
       <!DOCTYPE html>
       <html><body>
       <script src="popup.js"></script>
       </body></html>
       `,
 
       "popup.js": function() {
         window.onload = () => {
           browser.runtime.sendMessage("from-popup");
         };
       },
+      "icon.png": imageBuffer,
     },
 
     background: function() {
       browser.runtime.onMessage.addListener(msg => {
         browser.test.assertEq(msg, "from-popup", "correct message received");
         browser.test.sendMessage("popup");
       });
     },
@@ -42,16 +44,20 @@ add_task(async function() {
   });
 
   await extension.startup();
 
   // Do this a few times to make sure the pop-up is reloaded each time.
   for (let i = 0; i < 3; i++) {
     clickBrowserAction(extension);
 
+    let widget = getBrowserActionWidget(extension).forWindow(window);
+    let image = getComputedStyle(widget.node).listStyleImage;
+
+    ok(image.includes("/icon.png"), "The extension's icon is used");
     await extension.awaitMessage("popup");
 
     closeBrowserAction(extension);
   }
 
   await extension.unload();
 
   SimpleTest.endMonitorConsole();