Preferences
From PlainOldWebserver
Preferences can be read at the address, 'about:config'. These will not show there, because clearUserPref() is called right after reading.
<?sjs
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
prefs.setBoolPref("my_extension.trash_bool", true);
if(prefs.getPrefType("my_extension.trash_bool") == prefs.PREF_BOOL) {
var b = prefs.getBoolPref("my_extension.trash_bool");
document.writeln("b is "+b);
prefs.clearUserPref("my_extension.trash_bool");
}
prefs.setIntPref("my_extension.trash_int", 5);
if(prefs.getPrefType("my_extension.trash_int") == prefs.PREF_INT) {
var i = prefs.getIntPref("my_extension.trash_int");
document.writeln("i is "+i);
prefs.clearUserPref("my_extension.trash_int");
}
prefs.setCharPref("my_extension.trash_char", "hello prefs!");
if(prefs.getPrefType("my_extension.trash_char") == prefs.PREF_STRING) {
var c = prefs.getCharPref("my_extension.trash_char");
document.writeln("c is "+c);
prefs.clearUserPref("my_extension.trash_char");
}
?>
Result:
b is true i is 5 c is hello prefs!
