Bug 787070 - Expandos on the xray of DOM prototypes should have effect on xrays of DOM nodes, make Proxy::set throw for read-only properties. r=efaust.
authorPeter Van der Beken <peterv@propagandism.org>
Thu, 14 Aug 2014 15:12:19 +0200
changeset 207607 f2258c53e599
parent 207606 6e8655117616
child 207608 b46397f84e13
push id49735
push userpvanderbeken@mozilla.com
push dateMon, 29 Sep 2014 07:58:28 +0000
treeherdermozilla-inbound@090b62fdfd21 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersefaust
bugs787070
milestone35.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 787070 - Expandos on the xray of DOM prototypes should have effect on xrays of DOM nodes, make Proxy::set throw for read-only properties. r=efaust.
js/src/proxy/Proxy.cpp
--- a/js/src/proxy/Proxy.cpp
+++ b/js/src/proxy/Proxy.cpp
@@ -316,16 +316,20 @@ Proxy::set(JSContext *cx, HandleObject p
     // If we have an existing (own or non-own) property with a setter, we want
     // to invoke that.
     Rooted<PropertyDescriptor> desc(cx);
     if (!Proxy::getPropertyDescriptor(cx, proxy, id, &desc))
         return false;
     if (desc.object() && desc.setter() && desc.setter() != JS_StrictPropertyStub)
         return CallSetter(cx, receiver, id, desc.setter(), desc.attributes(), strict, vp);
 
+    if (desc.isReadonly()) {
+        return strict ? Throw(cx, id, JSMSG_READ_ONLY) : true;
+    }
+
     // Ok. Either there was no pre-existing property, or it was a value prop
     // that we're going to shadow. Make a property descriptor and define it.
     //
     // Note that for pre-existing own value properties, we inherit the existing
     // attributes, since we're really just changing the value and not trying to
     // reconfigure the property.
     Rooted<PropertyDescriptor> newDesc(cx);
     if (desc.object() == proxy)