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.
authorJason Orendorff <jorendorff@mozilla.com>
Mon, 16 Mar 2015 20:28:44 -0500
changeset 265462 3e8cc3750b9c64641afc78d374455be8cdc4a79d
parent 265461 c018aa2e76e6a30b51bede9bea5d175daa0af27e
child 265463 a25cc961aaf0c1400ff49514ca10aa7869798742
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [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)