npmiconsfirefox-addon-sdkmenuitemjpm

Firefox Addon-SDK jpm menuitem module: image not showing on Tools menubar


Possibly related to, but distinct from:

firefox addon icon not showing and firefox extension not showing icons.

Whereas those questions revolved around the API-user's need to use self.data.url( './icon-16.png' ) and put images in './data/' directory from root of plugin, I have done this, so it may be a bug in the API-coder's menuitem module (it looks ok to me), or the API iteself, or some other misuse (on my part or others) or conflict.

I have gotten the menuitem text label to display, and associated onCommand handler to work. I have used ActionButton to load icons using self.data.url(), so I know the icons can be found. These same images and functions fail in menuitem module code. I have tried adding items under Files and Tools menus on the menubar. I have tried modifying menuitem module's index.js file.

In my addon's index.js, I have tried various options:

// for reference, all shown at once, but tried individually
image: self.data.url( "./icon-16.png" ),
image: self.data.url( "icon-16.png" ),
image: "./icon-16.png",
image: "icon-16.png",

In menuitem's index.js, I have tried:

// using self.data.url in my index.js, despite example not showing this
menuitem.style.listStyleImage = "url('" + options.image + "')";
menuitem.setAttribute('image', options.image );

Are the icons for the menubar's menuitems just simply forbidden by the browser with no warning in the console, per some Mozilla security policy? Is there a browser setting or override? Does it even work with XUL Overlays anymore?

I was simply trying to use the menuitem addons directly from various code examples (modified to remove other options).

require("menuitem").Menuitem({
    id: "clickme",
    //menuid: "menu_FilePopup",
    //insertbefore: "menu_FileQuitItem",
    menuid: "menu_ToolsPopup",
    insertbefore: "menu_pageInfo"
    label: "Click to visit Mozilla!",
    image: self.data.url( "./icon-16.png" ),
    onCommand: handleClick,
});

using jpm run -b (absolute path to browser binary) for testing results, which creates a new, default, empty profile each time.


Solution

  • The menuitem module is working correctly in other contexts. Apparently there are just no icons allowed on the menubar menuitems other than bookmarks (maybe).