On 2014-03-20 5:03 PM, Neil wrote:
Irving Reid wrote:

For unknown reasons, internal bookkeeping prefs used by AddonManager
and XPIProvider are set to values of the wrong type on some Firefox
profiles, and are now stuck that way. I can write wrapper code on
these calls to catch the error and clear the broken preference, but I
wonder if it would be better to change set*Pref() to force the
preference to the intended type.

a) if the pref has a default in all.js then you don't want to be able to
change its type and in this case the prefs.js value should get ignored
if it is the wrong type.

Yes, this is what happens - if we've read a preference from any of the default files, like all.js, a value of the wrong type in the profile's prefs.js is discarded.

b) by the time you're calling setPref it's too late because you know the
type is wrong when your getPref failed so you might as well clear it as
part of fixing the problem.

Mostly yes - in one of my cases the code is setting the pref without reading it first.

An intermediate approach would be to check PREF_HAS_DEFAULT - if we have a default value for the preference, the type ought to be correct. If the pref doesn't have a default value, it's likely a record keeping pref created on the fly by our (or extension) code so it's probably OK for the setter to change the type.

 - irving -
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to