Bug 791944 - Use Object.defineProperty() instead of __defineGetter__ in XPCOMUtils.defineLazyGetter(). r=mak77
authorOHZEKI Tetsuharu <saneyuki.s.snyk@gmail.com>
Tue, 25 Sep 2012 11:04:25 -0400
changeset 108133 c89fff328c4c4051711207e0a6f2c6a9fdcf6b11
parent 108132 00141260d4e76c629136288861459c3b9aff476f
child 108134 768c8c6d3fe0652dad51124613ec94a57a8f6f7b
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersmak77
bugs791944
milestone18.0a1
Bug 791944 - Use Object.defineProperty() instead of __defineGetter__ in XPCOMUtils.defineLazyGetter(). r=mak77
js/xpconnect/loader/XPCOMUtils.jsm
--- a/js/xpconnect/loader/XPCOMUtils.jsm
+++ b/js/xpconnect/loader/XPCOMUtils.jsm
@@ -166,19 +166,23 @@ var XPCOMUtils = {
    * @param aName
    *        The name of the getter to define on aObject.
    * @param aLambda
    *        A function that returns what the getter should return.  This will
    *        only ever be called once.
    */
   defineLazyGetter: function XPCU_defineLazyGetter(aObject, aName, aLambda)
   {
-    aObject.__defineGetter__(aName, function() {
-      delete aObject[aName];
-      return aObject[aName] = aLambda.apply(aObject);
+    Object.defineProperty(aObject, aName, {
+      get: function () {
+        delete aObject[aName];
+        return aObject[aName] = aLambda.apply(aObject);
+      },
+      configurable: true,
+      enumerable: true
     });
   },
 
   /**
    * Defines a getter on a specified object for a service.  The service will not
    * be obtained until first use.
    *
    * @param aObject