Bug 720305 - Deal with odd getters and setters. r=jwalden

--HG--
extra : rebase_source : b5df534b437a6c79ab95b16ebb081d961b08e87f
This commit is contained in:
Blake Kaplan 2012-01-26 12:54:34 +01:00
parent 2dcf64b0c3
commit 7c21ecfee1

View File

@ -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);
}