Two issues here:
- There was some inconsistency in how we handled domains with multiple dots at the end. Instead of making this consistent, I just did the easier thing and return an error if a domain ends with more than one dot, because I don't think there's a realistic use case for it.
- Also, places that we called `Preferences::UnregisterCallback()` assumed that it succeeded and would always release the last reference to the `PrefCallback`, so if it didn't succeed a `PrefCallback` would get freed but would still be in `mObservers`. So now we check if `UnregisterCallback()` fails and if so, add the `PrefCallback` back to `mObservers`. (I decided to do it this way since `UnregisterCallback()` failing should be very rare so I didn't want to incur a lookup followed by a remove in the normal case)
(technically we only need to fix one of these to close the hole, but fixing both made sense)
Differential Revision: https://phabricator.services.mozilla.com/D323047