Search code examples
firefoxfirefox-addonfirefox-addon-sdktor

An addon's ToggleButton icon is not displayed when used in Tor browser


I have a question about a strange behaviour of an addon used in Firefox (40) and Tor browser 5.0.1 (Firefox 38.2.0). The goal would be to have a working addon for both environments.

This simple example was created with jpm init and slightly adapted to highlight the ToggleButton problems. While the ToggleButton and its icon is displayed nicely in Firefox via jpm run, Tor seems to have problems finding the icon files and displays nothing. For importing the addon in Tor I've used jpm xpiand installed the addon via the addon-manager.

My current directory layout has the following structure:

├── README.md
├── data
│   ├── skull-16.png
│   ├── skull-32.png
│   ├── skull-48.png
│   └── skull-64.png
├── icon.png
├── index.js
├── package.json
└── test
    └── test-index.js

And this is the content of the index.jsfile:

const self = require('sdk/self');
const { ToggleButton } = require("sdk/ui/button/toggle");

// a dummy function, to show how tests work.
// to see how to test this function, look at test/test-index.js
function dummy(text, callback) {
    callback(text);
}

let button = ToggleButton({
    id: "skull-link",
    label: "Skull Master",
    icon: {
        "16": "./skull-16.png",
        "32": "./skull-32.png",
        "48": "./skull-48.png",
        "64": "./skull-64.png"
    },
    onChange: function() {
        console.log("toggle")
    },
    bagde: 0
});

exports.dummy = dummy;

Nothing special, I have just added the ToggleButton part. I haven't found any clashes between the API in Firefox 38 and 40, so I'm clueless what might trigger this behavior. Thank you all for your help.

You can find the example in as zip-file here: sample addon


Solution

  • It was actually a simple one but took me very long to figure out. I found the answer in the post ndm13's answer. If you have problems with addons working in Firefox but not Tor, append

    "permissions": {"private-browsing": true}

    to your package.json. Tor browser is always in private browsing mode.