code review for #292

This commit is contained in:
gorhill 2015-06-04 16:50:46 -04:00
parent 987a8d2b64
commit 48264e1fd7
1 changed files with 10 additions and 5 deletions

View File

@ -116,20 +116,25 @@ vAPI.browserSettings = {
},
clear: function(branch, setting) {
var value = this.originalValues[branch + '.' + setting];
if (
value === undefined &&
this.originalValues.hasOwnProperty(branch + '.' + setting)
) {
var key = branch + '.' + setting;
// Value was not overriden -- nothing to restore
if ( this.originalValues.hasOwnProperty(key) === false ) {
return;
}
var value = this.originalValues[key];
// Original value was a default one
if ( value === undefined ) {
try {
Services.prefs.getBranch(branch + '.').clearUserPref(setting);
} catch (ex) {
}
return;
}
// Current value is same as original
if ( this.getBool(branch, setting) === value ) {
return;
}
// Reset to original value
try {
Services.prefs.getBranch(branch + '.').setBoolPref(setting, value);
} catch (ex) {