Bug 1144819 - Change JS_DefineProperty APIs to treat getter=nullptr and setter=nullptr as indicating class getter/setter ops only for data properties. r=Waldo.
☠☠ backed out by c3638d994edd ☠ ☠
authorJason Orendorff <jorendorff@mozilla.com>
Mon, 16 Mar 2015 20:28:44 -0500
changeset 263829 7ebc76a450c31ef5b8c53482f3a9ad830bc96ee8
parent 263828 92adb459d519c7d0c6fd08e234dafd3f6f660a14
child 263830 26fd5567784152b092a241061771552eb8c0004a
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs1144819
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1144819 - Change JS_DefineProperty APIs to treat getter=nullptr and setter=nullptr as indicating class getter/setter ops only for data properties. r=Waldo.
js/src/jsapi.cpp
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -2200,20 +2200,22 @@ DefinePropertyById(JSContext *cx, Handle
                           ? JS_FUNC_TO_DATA_PTR(JSObject *, setter)
                           : nullptr);
 
     // In most places throughout the engine, a property with null getter and
     // not JSPROP_GETTER/SETTER/SHARED has no getter, and the same for setters:
     // it's just a plain old data property. However the JS_Define* APIs use
     // null getter and setter to mean "default to the Class getProperty and
     // setProperty ops".
-    if (!getter)
-        getter = obj->getClass()->getProperty;
-    if (!setter)
-        setter = obj->getClass()->setProperty;
+    if (!(attrs & (JSPROP_GETTER | JSPROP_SETTER))) {
+        if (!getter)
+            getter = obj->getClass()->getProperty;
+        if (!setter)
+            setter = obj->getClass()->setProperty;
+    }
     if (getter == JS_PropertyStub)
         getter = nullptr;
     if (setter == JS_StrictPropertyStub)
         setter = nullptr;
     return DefineProperty(cx, obj, id, value, getter, setter, attrs);
 }
 
 JS_PUBLIC_API(bool)