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 207648 f2258c53e599823361e40bc45110360b262663da
parent 207647 6e86551176168b654593abc16b5576e8304ddd0c
child 207649 b46397f84e13021fb3a2b7dc3ee6bf0f4442182a
push id27564
push userryanvm@gmail.com
push dateMon, 29 Sep 2014 18:57:04 +0000
treeherdermozilla-central@ce9a0b34225e [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)