Bug 987111 - Fill out existing_desc with all properties, not just |own| ones. r=gabor
authorBobby Holley <bobbyholley@gmail.com>
Thu, 05 Jun 2014 22:32:38 -0700
changeset 207329 3a1f67c7f2236d21592f107a1ff65e9077589564
parent 207328 c4d288e2a0a6fb25c2af66bcc4c5f35e55eb445b
child 207330 3d93bce9a4563e6d8b38e3bdfab1b9a6bf9a6404
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor
bugs987111
milestone32.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 987111 - Fill out existing_desc with all properties, not just |own| ones. r=gabor This gives us strictly more information than we had before, which turns out to be useful. We can still get the old behavior by testing the identity of desc.object(), which I've done in one of the two existing uses for existing_desc. The other (in DOMXrayTraits::defineProperty) is actually more correct with the full (non-own) lookup.
js/xpconnect/wrappers/XrayWrapper.cpp
--- a/js/xpconnect/wrappers/XrayWrapper.cpp
+++ b/js/xpconnect/wrappers/XrayWrapper.cpp
@@ -2060,20 +2060,26 @@ RecreateLostWaivers(JSContext *cx, JSPro
 template <typename Base, typename Traits>
 bool
 XrayWrapper<Base, Traits>::defineProperty(JSContext *cx, HandleObject wrapper,
                                           HandleId id, MutableHandle<JSPropertyDescriptor> desc)
 {
     assertEnteredPolicy(cx, wrapper, id, BaseProxyHandler::SET);
 
     Rooted<JSPropertyDescriptor> existing_desc(cx);
-    if (!getOwnPropertyDescriptor(cx, wrapper, id, &existing_desc))
+    if (!JS_GetPropertyDescriptorById(cx, wrapper, id, &existing_desc))
         return false;
 
-    if (existing_desc.object() && existing_desc.isPermanent())
+    // Note that the check here is intended to differentiate between own and
+    // non-own properties, since the above lookup is not limited to own
+    // properties. At present, this may not always do the right thing because
+    // we often lie (sloppily) about where we found properties and set
+    // desc.object() to |wrapper|. Once we fully fix our Xray prototype semantics,
+    // this should work as intended.
+    if (existing_desc.object() == wrapper && existing_desc.isPermanent())
         return true; // silently ignore attempt to overwrite native property
 
     bool defined = false;
     if (!Traits::defineProperty(cx, wrapper, id, desc, existing_desc, &defined))
         return false;
     if (defined)
         return true;