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.
This commit is contained in:
Bobby Holley 2014-06-05 22:32:38 -07:00
parent eb617d939d
commit 71a3504f8c

View File

@ -2065,10 +2065,16 @@ XrayWrapper<Base, Traits>::defineProperty(JSContext *cx, HandleObject wrapper,
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;