Closed Bug 1036661 Opened 10 years ago Closed 10 years ago

Access to seenToS preference for the first time triggers an error message in the console

Categories

(Hello (Loop) :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla33

People

(Reporter: aoprea, Assigned: standard8)

References

Details

Attachments

(1 file, 1 obsolete file)

seenToS preference needs a default otherwise on first access it will log an error message in the console
This adds a default value option, so that we can specify a default value for those cases where we expect the preference to be missing.

Justin, if you can review the non-content parts, and Dan can review the content ones. Thanks.
Attachment #8453753 - Flags: review?(dolske)
Attachment #8453753 - Flags: review?(dmose)
Assignee: nobody → standard8
OS: Mac OS X → All
Hardware: x86 → All
Do we actually need this functionality?  If not, it seems like it would be less code and tests to maintain to just add a default line for loop.seenToS to firefox.js...
I'd rather not be adding default lines for every pref we want to store, just to avoid a warning. Whilst the ToS one could be defaulted in firefox.js, I don't think it would be reasonable to do the same for the default camera/microphone preferences that we're going to want real soon now.

Hence, whilst its nice to keep code to a minimum, I'm expecting that we're going to want this for multiple places.
Comment on attachment 8453753 [details] [diff] [review]
Avoid dumping a console error message for missing loop prefs when we expect them to be missing.

Review of attachment 8453753 [details] [diff] [review]:
-----------------------------------------------------------------

I would also have just added a default pref for this. :) That's generally encouraged as good-practice (as opposed to having hidden prefs for things), although for cases like this that isn't so relevant since you're really using this pref as a way to store some internal state.

But note that the way you've implemented this opens up a potential footgun -- if the pref has been set, but is the wrong type, the Services.pref.getCharPref() will throw and you'll get your API-specified default value instead. E.G. if someone (or somecode) sets loop.seenToS as a boolean true/false (which seems pretty natural, given it's used as such!), these calls will always return the default. And someone's going to be very confused when trying to debug what's happening. :)

I'd suggest making use of toolkit/modules/Preferences.jsm, or perhaps steal its error-checking for cases like this.
Attachment #8453753 - Flags: review?(dolske) → review-
Comment on attachment 8453753 [details] [diff] [review]
Avoid dumping a console error message for missing loop prefs when we expect them to be missing.

Review of attachment 8453753 [details] [diff] [review]:
-----------------------------------------------------------------

I'll wait for a new patch for review.

My recollection is that I tried to use Preferences.jsm originally but failed for some reason (I _think_ it was libxul-linkage related), and feel back to the bad old API.
Attachment #8453753 - Flags: review?(dmose)
I think we'll just go with defaulting the preference for now. We might change how some of this is saved in the future anyway (e.g. when we get indexeddb in our special panels we could move some of these prefs across to that), so I think this is fine for now.
Attachment #8456055 - Flags: review?(dolske)
Attachment #8453753 - Attachment is obsolete: true
Attachment #8456055 - Flags: review?(dolske) → review+
https://hg.mozilla.org/mozilla-central/rev/7271b1984ca3
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
I'm untracking this for QE verification. Please needinfo me to request manual testing.
Flags: qe-verify-
QA Contact: anthony.s.hughes
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: