From 7c21ecfee14211ff11bd5bfdc35e3859116396dd Mon Sep 17 00:00:00 2001 From: Blake Kaplan Date: Thu, 26 Jan 2012 12:54:34 +0100 Subject: [PATCH] Bug 720305 - Deal with odd getters and setters. r=jwalden --HG-- extra : rebase_source : b5df534b437a6c79ab95b16ebb081d961b08e87f --- js/src/jsproxy.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/js/src/jsproxy.cpp b/js/src/jsproxy.cpp index 1af029d0cafd..622de5b0ca52 100644 --- a/js/src/jsproxy.cpp +++ b/js/src/jsproxy.cpp @@ -180,7 +180,10 @@ ProxyHandler::set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, b if (desc.attrs & JSPROP_READONLY) return true; if (!desc.setter) { - desc.setter = JS_StrictPropertyStub; + // Be wary of the odd explicit undefined setter case possible through + // Object.defineProperty. + if (!(desc.attrs & JSPROP_SETTER)) + desc.setter = JS_StrictPropertyStub; } else if ((desc.attrs & JSPROP_SETTER) || desc.setter != JS_StrictPropertyStub) { if (!CallSetter(cx, receiver, id, desc.setter, desc.attrs, desc.shortid, strict, vp)) return false; @@ -189,8 +192,11 @@ ProxyHandler::set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, b if (desc.attrs & JSPROP_SHARED) return true; } - if (!desc.getter) - desc.getter = JS_PropertyStub; + if (!desc.getter) { + // Same as above for the null setter case. + if (!(desc.attrs & JSPROP_GETTER)) + desc.getter = JS_PropertyStub; + } desc.value = *vp; return defineProperty(cx, receiver, id, &desc); } @@ -200,7 +206,10 @@ ProxyHandler::set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, b if (desc.attrs & JSPROP_READONLY) return true; if (!desc.setter) { - desc.setter = JS_StrictPropertyStub; + // Be wary of the odd explicit undefined setter case possible through + // Object.defineProperty. + if (!(desc.attrs & JSPROP_SETTER)) + desc.setter = JS_StrictPropertyStub; } else if ((desc.attrs & JSPROP_SETTER) || desc.setter != JS_StrictPropertyStub) { if (!CallSetter(cx, receiver, id, desc.setter, desc.attrs, desc.shortid, strict, vp)) return false; @@ -209,8 +218,11 @@ ProxyHandler::set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, b if (desc.attrs & JSPROP_SHARED) return true; } - if (!desc.getter) - desc.getter = JS_PropertyStub; + if (!desc.getter) { + // Same as above for the null setter case. + if (!(desc.attrs & JSPROP_GETTER)) + desc.getter = JS_PropertyStub; + } return defineProperty(cx, receiver, id, &desc); }