This is the preference I'm trying to set:
{
"name": "datestamp",
"title": "Date stamp?",
"type": "bool",
"value": true
}
Heres the addon code,
preference.js
var preference = require("simple-prefs");
exports.set = function(preferenceTemp, value){
console.log(value);
preference.prefs[preferenceTemp] = value;
}
main.js
Preference = require("./Preference")
Preference.set('datestamp', true);
Error on console when trying to execute:
console.error: addon:
Message: [Exception... "Component returned failure code: 0x8000ffff
(NS_ERROR_UNEXPECTED) [nsIPrefBranch.setComplexValue]" nsresult: "0x8000ffff
(NS_ERROR_UNEXPECTED)" location: "JS frame :: resource://gre/modules/XPIProvider.jsm
-> jar:file:///tmp/tmpuc82Vi.mozrunner/extensions
/[email protected]!/bootstrap.js -> resource://gre/modules/commonjs/toolkit
/loader.js -> resource://gre/modules/commonjs/sdk/preferences/service.js :: set ::
line 92" data: no]
Problem was, I was passing in a string from elsewhere in my code that was not set as a boolean.
This did the trick:
Preference.set('datestamp', 'true' === "true");