Closed Bug 1142222 Opened 9 years ago Closed 9 years ago

boolForKey returns false for undefined keys

Categories

(Firefox for iOS :: General, defect)

All
iOS 8
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: bnicholson, Assigned: bnicholson)

References

Details

Attachments

(1 file)

47 bytes, text/x-github-pull-request
nalexander
: review+
Details | Review
Working on the search suggestions opt in, I found the following line was always false:

self.shouldShowSearchSuggestionsOptIn = prefs.boolForKey(ShowSearchSuggestionsOptIn) ?? true

Turns out userDefaults.boolForKey never returns nil when the pref isn't defined, returning false instead.

I then tried to add a simple nil assertion for undefined prefs, clearing prefs before each run in ProfilePrefsTests. That's where things got interesting since, for some reason, userDefaults.removePersistentDomainForName() simply has no effect for our app group. The workaround of manually removing each key works, but it's still unclear whether this is an iOS bug or our own.
Attached file Pull request
Attachment #8576205 - Flags: review?(nalexander)
Comment on attachment 8576205 [details] [review]
Pull request

Thanks.  I explicitly tried to avoid this kind of coercion bullshit, and still failed :(
Attachment #8576205 - Flags: review?(nalexander) → review+
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: