Open Bug 1250615 Opened 8 years ago Updated 2 years ago

getComplexValue fails for empty strings

Categories

(Firefox :: Settings UI, defect)

45 Branch
defect

Tracking

()

People

(Reporter: mkaply, Unassigned)

Details

I'm working on distribution code trying to unset a complex preference and I've discovered that if you set a complex preference to an empty value, getting the value fails with

Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIPrefBranch.getComplexValue]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"

It should just return an empty string. You can see the problem with this code in a browser scratchpad:

var defaults = Services.prefs.getDefaultBranch(null);
var localizedStr = Cc["@mozilla.org/pref-localizedstring;1"].createInstance(Ci.nsIPrefLocalizedString);
var key = "foo";
var value = "";
localizedStr.data = "data:text/plain," + key + "=" + value;
defaults.setComplexValue(key, Ci.nsIPrefLocalizedString, localizedStr);
defaults.getComplexValue(key, Ci.nsIPrefLocalizedString).data;

Changing value to something other than an empty string works fine.

and the value in preferences is correct - it shows:

data:text/plain,foo=
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.