Bug 1407234 - Don't show getCachedClientID error on new profiles. r?chutten draft
authorAlessio Placitelli <alessio.placitelli@gmail.com>
Wed, 11 Oct 2017 16:10:29 +0200
changeset 678489 bd51b82284bbc25eb4d1ce0b44fa379e11394c13
parent 678484 2c17b581bc180e9200840031527f92d0ea21c464
child 735345 bb08166e705904709455cd4c10b3bcc9353ff306
push id83941
push useralessio.placitelli@gmail.com
push dateWed, 11 Oct 2017 14:11:15 +0000
reviewerschutten
bugs1407234
milestone58.0a1
Bug 1407234 - Don't show getCachedClientID error on new profiles. r?chutten This patch changes ClientID.jsm to only check for the pref validity if the cached client id pref was set. MozReview-Commit-ID: KI3YHaMozl6
toolkit/modules/ClientID.jsm
--- a/toolkit/modules/ClientID.jsm
+++ b/toolkit/modules/ClientID.jsm
@@ -172,22 +172,27 @@ var ClientIDImpl = {
    *  - null otherwise
    */
   getCachedClientID() {
     if (this._clientID) {
       // Already loaded the client id from disk.
       return this._clientID;
     }
 
-    // Not yet loaded, return the cached client id if we have one.
-    if (Services.prefs.getPrefType(PREF_CACHED_CLIENTID) != Ci.nsIPrefBranch.PREF_STRING) {
+    // If the client id cache contains a value of the wrong type,
+    // reset the pref. We need to do this before |getStringPref| since
+    // it will just return |null| in that case and we won't be able
+    // to distinguish between the missing pref and wrong type cases.
+    if (Services.prefs.prefHasUserValue(PREF_CACHED_CLIENTID) &&
+        Services.prefs.getPrefType(PREF_CACHED_CLIENTID) != Ci.nsIPrefBranch.PREF_STRING) {
       this._log.error("getCachedClientID - invalid client id type in preferences, resetting");
       Services.prefs.clearUserPref(PREF_CACHED_CLIENTID);
     }
 
+    // Not yet loaded, return the cached client id if we have one.
     let id = Services.prefs.getStringPref(PREF_CACHED_CLIENTID, null);
     if (id === null) {
       return null;
     }
     if (!isValidClientID(id)) {
       this._log.error("getCachedClientID - invalid client id in preferences, resetting", id);
       Services.prefs.clearUserPref(PREF_CACHED_CLIENTID);
       return null;