I have problem with simple-prefs
module in my addon (simple-prefs documentation). I'm trying to use menulist
or radio
types. Problem is addon isn't loaded or started - function main
isn't called.
I don't have this problem when I use cfx run
command, which starts new, clear instace of Firefox - everything works correctly. I tried run this addon on two different computers, unfortunately with the same result.
Below I put code snippets:
main.js:
var prefs = require("simple-prefs").prefs;
...
exports.main = function (options, callbacks) {
console.log("Addon loaded: " + self.loadReason);
var modLogic = pageMod.PageMod({
include: "*",
contentScriptWhen: "start",
contentScriptFile: data.url("myContentScript.js"),
onAttach: function (worker) {
console.log("Page worker attached to: " + worker.tab.url);
// here I'm using prefs object: if(prefs.decision === "Y")
}
});
}
package.json:
{
"name": "myaddon",
...
"preferences" : [{
"name": "decision",
"title": "someTitle",
"type": "radio", // or menulist
"value": "D",
"options": [{
"value": "D",
"label": "Default"
},
{
"value": "Y",
"label": "Yes"
},
{
"value": "N",
"label": "No"
}
]
}]
}
I'm using addon-sdk 1.12 and Firefox 18.0. In my code snippets can be bugs - I've just written it here.
I'd created this example repo a while ago:
https://github.com/canuckistani/jp-prefs-example
All of the functionality works for me, see this screenshot:
https://dl.dropbox.com/u/44296964/Screen%20Shot%202013-01-18%20at%201.50.31%20PM.png
I'm also using Firefox 18 and SDK 1.12. In your example you have a comment in your JSON, that might be causing you problems.