Bug 1299254 - avoid recursion in Services.prefs shim initialization; r?bgrins draft
authorTom Tromey <tom@tromey.com>
Tue, 30 Aug 2016 08:03:56 -0600
changeset 407665 3349962c3ea3bd4e6f02c9e4b0f299a2b1cbfa1c
parent 407496 b18c8bcdc116eef8799880b7c50317bf54218474
child 529912 eb2805d7a2bfc03d4d27b63cd90775652501be3d
push id28004
push userbmo:ttromey@mozilla.com
push dateTue, 30 Aug 2016 18:48:26 +0000
reviewersbgrins
bugs1299254
milestone51.0a1
Bug 1299254 - avoid recursion in Services.prefs shim initialization; r?bgrins MozReview-Commit-ID: CuLgSaEtpgi
devtools/client/shared/shim/Services.js
--- a/devtools/client/shared/shim/Services.js
+++ b/devtools/client/shared/shim/Services.js
@@ -36,20 +36,16 @@ function PrefBranch(parent, name, fullNa
   this._observers = {};
   this._children = {};
 
   // Properties used when this branch has a value as well.
   this._defaultValue = null;
   this._hasUserValue = false;
   this._userValue = null;
   this._type = PREF_INVALID;
-
-  if (!parent) {
-    this._initializeRoot();
-  }
 }
 
 PrefBranch.prototype = {
   PREF_INVALID: PREF_INVALID,
   PREF_STRING: PREF_STRING,
   PREF_INT: PREF_INT,
   PREF_BOOL: PREF_BOOL,
 
@@ -464,16 +460,17 @@ const Services = {
    * storage.  Only the subset of nsIPrefService that is actually used
    * by devtools is implemented here.  This is lazily instantiated so
    * that the tests have a chance to disable the loading of default
    * prefs.
    */
   get prefs() {
     if (!this._prefs) {
       this._prefs = new PrefBranch(null, "", "");
+      this._prefs._initializeRoot();
     }
     return this._prefs;
   },
 
   /**
    * An implementation of Services.appinfo that holds just the
    * properties needed by devtools.
    */