I would like to sync prefs of my Firefox addon using require(‘sdk/preferences/service’).
Here my non-working trial:
lib/main.js:
const
addonid = require(‘sdk/self’).id,
simprefs = require(‘sdk/simple-prefs’)
service = require(‘sdk/preferences/service’)
;
service.set(‘services.sync.prefs.sync.extensions.’ + addonid + ‘.syncy’, true);
simprefs.on('1', function() {
simprefs.prefs["syncy"] = simprefs.prefs["1"];
});
package.json:
{
“title”: “Test”,
“name”: “test”,
“author”: “devname”,
“version”: “1.0.0”,
“main”: “lib/main.js”,
“engines”: {“firefox”: “>=38.0a1”,“fennec”: “>=38.0a1”},
“license”: “MPL-2.0”,
“id”: "test@devname.org",
“permissions”: {“private-browsing”: true},
“dependencies”: [“addon-kit”],
“preferences”: [{
“title”: “Color 1”,
“type”: “color”,
“value”: “#000000”,
“name”: “1”
}]}
So, when in the Addon-Manager I set pref 1 to color #777777 then pref
syncy will get the same value (visible on the about:config page).
When I use 2 Firefox profiles and register with Mozilla for syncing and
install this add-on on each of them I expect that changing this value on
one profile will change it on the other (so the setting on about:config
-> extensions.test@devname.org.syncy) - but it doesn’t.
What do I do wrong?