firefox addon sdk - Set preferences in the user branch and unset them on uninstall -
i created firefox add-on following lib/main.js:
const {cc,ci} = require("chrome"); var pref = cc["@mozilla.org/preferences-service;1"].getservice(ci.nsiprefbranch); pref.setintpref("network.http.response.timeout", 3600*24); it wasn't accepted following reason:
add-ons change critical settings must revert changes when disabled or uninstalled. should make changes in default, rather user, branch.
you need call
getdefaultbranch("")on preferences service, , call preference methods on returned object rather on preference service directly.
to revert preference default, set setintpref(), found out have this on uninstall:
pref.clearuserpref("network.http.response.timeout") this command works fine if call in test-addon. have find out how implement command, executed when firefox-addon uninstalled?
so how have understand these comments? how set preferences in "user branch"?
i solved the second part (uninstall) this, in main.js added code @ end:
exports.onunload = function(reason) { //called when add-on // uninstalled // disabled // shutdown // upgraded // downgraded pref.clearuserpref("network.http.response.timeout"); }; that worked on disabling , uninstalling add-on.
Comments
Post a Comment