4
votes

I am using the mozilla-addon-sdk and the cfx tool to build a firefox extension.

The extension is only showing a toggle button, which usually appear in the toolbar menu.

Everything is working well when I launch the extension with this command:

$ cfx run

But if I generate an xpi file like this:

$ cfx xpi

and try to install my extension manually from this file, even if firefox tells me the installation is ok, I cannot see it in any toolbar/menu. However, the extension is reported in the firefox modules list.

I published it on the store, and the issue persists, no way to access to it from any menu.

I'm thinking of something going wrong in the xpi generation, but I can't find what.

I also thought maybe I should add some code to automatically put the toggle button somewhere in the toolbar, but I couldn't find anything solving my issue. And even if I the extension should put itself in the toolbar with some extra code, why is it working when running from cfx then ?

Any idea ?

[update] here is the code I use.

manifest.json :

{
  "name": "firefox-extension",
  "title": "...",
  "id": "...",
  "description": "...",
  "icon": "data/my-icon.png",
  "author": "...",
  "license": "MPL 2.0",
  "version": "0.1"
}

main.js:

var { ToggleButton } = require('sdk/ui/button/toggle');
var panels = require("sdk/panel");
var self = require("sdk/self");
var tabs = require("sdk/tabs");

var button = ToggleButton({
 id: "extension-button",
 label: "extension",
 icon: {
   "48": "./my-icon.png"
 },
 onChange: handleChange
});

function handleChange(state) {
 if (state.checked) {
   var panel = panels.Panel({
     contentURL: self.data.url("http://my_url"),
     onHide: handleHide,
     width: 600,
     height: 600
   });

   panel.show({
     position: button
   });
 }
}

function handleHide() {
 button.state('window', {checked: false});
}
1
Without code, this question may be off-topic: Questions seeking debugging help ("why isn't this code working the way I want?") must include: •the desired behavior, •a specific problem or error and •the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example, What topics can I ask about here?, and How to Ask. - Makyen
Agree with @Makyen, provide some code so we can help you. - dgil
Please add some code as @Makyen said - matagus

1 Answers

4
votes

You need to specify the icon sizes 16 and 32 for your button :

  icon: {
    "16": "./icon-16.png",
    "32": "./icon-32.png",
    "48": "./icon-48.png"
  },

Enjoy !