mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-01 13:57:32 +00:00
Bug 596031 - 'this' is wrong in getters and setters when a proxy object is on the prototype chain. r=brendan
This commit is contained in:
parent
87258e96ce
commit
0b4a0f77a0
@ -688,7 +688,7 @@ js_GetDenseArrayElementValue(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||
}
|
||||
|
||||
static JSBool
|
||||
array_getProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||
array_getProperty(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp)
|
||||
{
|
||||
uint32 i;
|
||||
|
||||
@ -754,7 +754,8 @@ array_typeOf(JSContext *cx, JSObject *obj)
|
||||
}
|
||||
|
||||
static JSBool
|
||||
array_setProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict)
|
||||
array_setProperty(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp,
|
||||
JSBool strict)
|
||||
{
|
||||
uint32 i;
|
||||
|
||||
@ -781,7 +782,8 @@ array_setProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool stric
|
||||
}
|
||||
|
||||
static JSBool
|
||||
slowarray_setProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict)
|
||||
slowarray_setProperty(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp,
|
||||
JSBool strict)
|
||||
{
|
||||
JS_ASSERT(obj->isSlowArray());
|
||||
|
||||
@ -849,7 +851,7 @@ array_defineProperty(JSContext *cx, JSObject *obj, jsid id, const Value *value,
|
||||
}
|
||||
|
||||
Value tmp = *value;
|
||||
return array_setProperty(cx, obj, id, &tmp, false);
|
||||
return array_setProperty(cx, obj, obj, id, &tmp, false);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
|
@ -4422,7 +4422,7 @@ BEGIN_CASE(JSOP_SETMETHOD)
|
||||
defineHow = JSDNP_CACHE_RESULT | JSDNP_UNQUALIFIED;
|
||||
else
|
||||
defineHow = JSDNP_CACHE_RESULT;
|
||||
if (!js_SetPropertyHelper(cx, obj, id, defineHow, &rval, script->strictModeCode))
|
||||
if (!js_SetPropertyHelper(cx, obj, obj, id, defineHow, &rval, script->strictModeCode))
|
||||
goto error;
|
||||
} else {
|
||||
if (!obj->setProperty(cx, id, &rval, script->strictModeCode))
|
||||
@ -5980,7 +5980,7 @@ BEGIN_CASE(JSOP_INITMETHOD)
|
||||
? JSDNP_CACHE_RESULT | JSDNP_SET_METHOD
|
||||
: JSDNP_CACHE_RESULT;
|
||||
if (!(JS_UNLIKELY(atom == cx->runtime->atomState.protoAtom)
|
||||
? js_SetPropertyHelper(cx, obj, id, defineHow, &rval, script->strictModeCode)
|
||||
? js_SetPropertyHelper(cx, obj, obj, id, defineHow, &rval, script->strictModeCode)
|
||||
: js_DefineNativeProperty(cx, obj, id, rval, NULL, NULL,
|
||||
JSPROP_ENUMERATE, 0, 0, NULL,
|
||||
defineHow))) {
|
||||
|
@ -3021,13 +3021,14 @@ with_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
|
||||
}
|
||||
|
||||
static JSBool
|
||||
with_GetProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||
with_GetProperty(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp)
|
||||
{
|
||||
return obj->getProto()->getProperty(cx, id, vp);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
with_SetProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict)
|
||||
with_SetProperty(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp,
|
||||
JSBool strict)
|
||||
{
|
||||
return obj->getProto()->setProperty(cx, id, vp, strict);
|
||||
}
|
||||
@ -4931,7 +4932,7 @@ js_NativeSet(JSContext *cx, JSObject *obj, const Shape *shape, bool added, Value
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE bool
|
||||
js_GetPropertyHelperWithShapeInline(JSContext *cx, JSObject *obj, jsid id,
|
||||
js_GetPropertyHelperWithShapeInline(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id,
|
||||
uintN getHow, Value *vp,
|
||||
const Shape **shapeOut, JSObject **holderOut)
|
||||
{
|
||||
@ -5017,8 +5018,11 @@ js_GetPropertyHelperWithShapeInline(JSContext *cx, JSObject *obj, jsid id,
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (!obj2->isNative())
|
||||
return obj2->getProperty(cx, id, vp);
|
||||
if (!obj2->isNative()) {
|
||||
return obj2->isProxy()
|
||||
? JSProxy::get(cx, obj2, receiver, id, vp)
|
||||
: obj2->getProperty(cx, id, vp);
|
||||
}
|
||||
|
||||
shape = (Shape *) prop;
|
||||
*shapeOut = shape;
|
||||
@ -5029,39 +5033,41 @@ js_GetPropertyHelperWithShapeInline(JSContext *cx, JSObject *obj, jsid id,
|
||||
}
|
||||
|
||||
/* This call site is hot -- use the always-inlined variant of js_NativeGet(). */
|
||||
if (!js_NativeGetInline(cx, obj, obj2, shape, getHow, vp))
|
||||
if (!js_NativeGetInline(cx, receiver, obj2, shape, getHow, vp))
|
||||
return JS_FALSE;
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
extern bool
|
||||
js_GetPropertyHelperWithShape(JSContext *cx, JSObject *obj, jsid id,
|
||||
bool
|
||||
js_GetPropertyHelperWithShape(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id,
|
||||
uint32 getHow, Value *vp,
|
||||
const Shape **shapeOut, JSObject **holderOut)
|
||||
{
|
||||
return js_GetPropertyHelperWithShapeInline(cx, obj, id, getHow, vp, shapeOut, holderOut);
|
||||
return js_GetPropertyHelperWithShapeInline(cx, obj, receiver, id, getHow, vp,
|
||||
shapeOut, holderOut);
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
js_GetPropertyHelperInline(JSContext *cx, JSObject *obj, jsid id, uint32 getHow, Value *vp)
|
||||
js_GetPropertyHelperInline(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id,
|
||||
uint32 getHow, Value *vp)
|
||||
{
|
||||
const Shape *shape;
|
||||
JSObject *holder;
|
||||
return js_GetPropertyHelperWithShapeInline(cx, obj, id, getHow, vp, &shape, &holder);
|
||||
}
|
||||
|
||||
extern JSBool
|
||||
js_GetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, uint32 getHow, Value *vp)
|
||||
{
|
||||
return js_GetPropertyHelperInline(cx, obj, id, getHow, vp);
|
||||
return js_GetPropertyHelperWithShapeInline(cx, obj, receiver, id, getHow, vp, &shape, &holder);
|
||||
}
|
||||
|
||||
JSBool
|
||||
js_GetProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||
js_GetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, uint32 getHow, Value *vp)
|
||||
{
|
||||
return js_GetPropertyHelperInline(cx, obj, obj, id, getHow, vp);
|
||||
}
|
||||
|
||||
JSBool
|
||||
js_GetProperty(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp)
|
||||
{
|
||||
/* This call site is hot -- use the always-inlined variant of js_GetPropertyHelper(). */
|
||||
return js_GetPropertyHelperInline(cx, obj, id, JSGET_METHOD_BARRIER, vp);
|
||||
return js_GetPropertyHelperInline(cx, obj, receiver, id, JSGET_METHOD_BARRIER, vp);
|
||||
}
|
||||
|
||||
JSBool
|
||||
@ -5097,7 +5103,7 @@ js_GetMethod(JSContext *cx, JSObject *obj, jsid id, uintN getHow, Value *vp)
|
||||
if (obj->isXML())
|
||||
return js_GetXMLMethod(cx, obj, id, vp);
|
||||
#endif
|
||||
return op(cx, obj, id, vp);
|
||||
return op(cx, obj, obj, id, vp);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
@ -5152,7 +5158,7 @@ JSObject::reportNotExtensible(JSContext *cx, uintN report)
|
||||
* (defineHow & JSDNP_CACHE_RESULT).
|
||||
*/
|
||||
JSBool
|
||||
js_SetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, uintN defineHow,
|
||||
js_SetPropertyHelper(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, uintN defineHow,
|
||||
Value *vp, JSBool strict)
|
||||
{
|
||||
int protoIndex;
|
||||
@ -5178,8 +5184,11 @@ js_SetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, uintN defineHow,
|
||||
if (protoIndex < 0)
|
||||
return JS_FALSE;
|
||||
if (prop) {
|
||||
if (!pobj->isNative())
|
||||
if (!pobj->isNative()) {
|
||||
if (pobj->isProxy())
|
||||
return JSProxy::set(cx, pobj, receiver, id, vp);
|
||||
prop = NULL;
|
||||
}
|
||||
} else {
|
||||
/* We should never add properties to lexical blocks. */
|
||||
JS_ASSERT(!obj->isBlock());
|
||||
@ -5236,7 +5245,7 @@ js_SetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, uintN defineHow,
|
||||
}
|
||||
|
||||
attrs = shape->attributes();
|
||||
if (pobj != obj) {
|
||||
if (pobj != receiver) {
|
||||
/*
|
||||
* We found id in a prototype object: prepare to share or shadow.
|
||||
*
|
||||
@ -5255,7 +5264,7 @@ js_SetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, uintN defineHow,
|
||||
if (shape->hasDefaultSetter() && !shape->hasGetterValue())
|
||||
return JS_TRUE;
|
||||
|
||||
return shape->set(cx, obj, vp);
|
||||
return shape->set(cx, receiver, vp);
|
||||
}
|
||||
|
||||
/* Restore attrs to the ECMA default for new properties. */
|
||||
@ -5377,9 +5386,9 @@ js_SetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, uintN defineHow,
|
||||
}
|
||||
|
||||
JSBool
|
||||
js_SetProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict)
|
||||
js_SetProperty(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp, JSBool strict)
|
||||
{
|
||||
return js_SetPropertyHelper(cx, obj, id, 0, vp, strict);
|
||||
return js_SetPropertyHelper(cx, obj, receiver, id, 0, vp, strict);
|
||||
}
|
||||
|
||||
JSBool
|
||||
|
@ -209,7 +209,13 @@ js_DefineProperty(JSContext *cx, JSObject *obj, jsid id, const js::Value *value,
|
||||
js::PropertyOp getter, js::PropertyOp setter, uintN attrs);
|
||||
|
||||
extern JSBool
|
||||
js_GetProperty(JSContext *cx, JSObject *obj, jsid id, js::Value *vp);
|
||||
js_GetProperty(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, js::Value *vp);
|
||||
|
||||
inline JSBool
|
||||
js_GetProperty(JSContext *cx, JSObject *obj, jsid id, js::Value *vp)
|
||||
{
|
||||
return js_GetProperty(cx, obj, obj, id, vp);
|
||||
}
|
||||
|
||||
namespace js {
|
||||
|
||||
@ -219,7 +225,14 @@ GetPropertyDefault(JSContext *cx, JSObject *obj, jsid id, Value def, Value *vp);
|
||||
} /* namespace js */
|
||||
|
||||
extern JSBool
|
||||
js_SetProperty(JSContext *cx, JSObject *obj, jsid id, js::Value *vp, JSBool strict);
|
||||
js_SetProperty(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, js::Value *vp,
|
||||
JSBool strict);
|
||||
|
||||
inline JSBool
|
||||
js_SetProperty(JSContext *cx, JSObject *obj, jsid id, js::Value *vp, JSBool strict)
|
||||
{
|
||||
return js_SetProperty(cx, obj, obj, id, vp, strict);
|
||||
}
|
||||
|
||||
extern JSBool
|
||||
js_GetAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp);
|
||||
@ -1064,14 +1077,23 @@ struct JSObject : js::gc::Cell {
|
||||
return (op ? op : js_DefineProperty)(cx, this, id, &value, getter, setter, attrs);
|
||||
}
|
||||
|
||||
JSBool getProperty(JSContext *cx, jsid id, js::Value *vp) {
|
||||
JSBool getProperty(JSContext *cx, JSObject *receiver, jsid id, js::Value *vp) {
|
||||
js::PropertyIdOp op = getOps()->getProperty;
|
||||
return (op ? op : js_GetProperty)(cx, this, id, vp);
|
||||
return (op ? op : (js::PropertyIdOp)js_GetProperty)(cx, this, receiver, id, vp);
|
||||
}
|
||||
|
||||
JSBool getProperty(JSContext *cx, jsid id, js::Value *vp) {
|
||||
return getProperty(cx, this, id, vp);
|
||||
}
|
||||
|
||||
JSBool setProperty(JSContext *cx, JSObject *receiver, jsid id, js::Value *vp, JSBool strict) {
|
||||
js::StrictPropertyIdOp op = getOps()->setProperty;
|
||||
return (op ? op : (js::StrictPropertyIdOp)js_SetProperty)(cx, this, receiver, id,
|
||||
vp, strict);
|
||||
}
|
||||
|
||||
JSBool setProperty(JSContext *cx, jsid id, js::Value *vp, JSBool strict) {
|
||||
js::StrictPropertyIdOp op = getOps()->setProperty;
|
||||
return (op ? op : js_SetProperty)(cx, this, id, vp, strict);
|
||||
return setProperty(cx, this, id, vp, strict);
|
||||
}
|
||||
|
||||
JSBool getAttributes(JSContext *cx, jsid id, uintN *attrsp) {
|
||||
@ -1085,7 +1107,7 @@ struct JSObject : js::gc::Cell {
|
||||
}
|
||||
|
||||
JSBool deleteProperty(JSContext *cx, jsid id, js::Value *rval, JSBool strict) {
|
||||
js::StrictPropertyIdOp op = getOps()->deleteProperty;
|
||||
js::DeleteIdOp op = getOps()->deleteProperty;
|
||||
return (op ? op : js_DeleteProperty)(cx, this, id, rval, strict);
|
||||
}
|
||||
|
||||
@ -1569,8 +1591,9 @@ extern JSBool
|
||||
js_GetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, uint32 getHow, js::Value *vp);
|
||||
|
||||
extern bool
|
||||
js_GetPropertyHelperWithShape(JSContext *cx, JSObject *obj, jsid id, uint32 getHow,
|
||||
js::Value *vp, const js::Shape **shapeOut, JSObject **holderOut);
|
||||
js_GetPropertyHelperWithShape(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id,
|
||||
uint32 getHow, js::Value *vp,
|
||||
const js::Shape **shapeOut, JSObject **holderOut);
|
||||
|
||||
extern JSBool
|
||||
js_GetOwnPropertyDescriptor(JSContext *cx, JSObject *obj, jsid id, js::Value *vp);
|
||||
@ -1588,7 +1611,7 @@ extern JS_FRIEND_API(bool)
|
||||
js_CheckUndeclaredVarAssignment(JSContext *cx, JSString *propname);
|
||||
|
||||
extern JSBool
|
||||
js_SetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, uintN defineHow,
|
||||
js_SetPropertyHelper(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, uintN defineHow,
|
||||
js::Value *vp, JSBool strict);
|
||||
|
||||
/*
|
||||
|
@ -153,7 +153,7 @@ JSObject::methodReadBarrier(JSContext *cx, const js::Shape &shape, js::Value *vp
|
||||
funobj->setMethodObj(*this);
|
||||
|
||||
vp->setObject(*funobj);
|
||||
if (!js_SetPropertyHelper(cx, this, shape.id, 0, vp, false))
|
||||
if (!js_SetPropertyHelper(cx, this, this, shape.id, 0, vp, false))
|
||||
return false;
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -127,7 +127,7 @@ JSProxyHandler::get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id,
|
||||
return true;
|
||||
}
|
||||
if (desc.attrs & JSPROP_GETTER) {
|
||||
return ExternalGetOrSet(cx, proxy, id, CastAsObjectJsval(desc.getter),
|
||||
return ExternalGetOrSet(cx, receiver, id, CastAsObjectJsval(desc.getter),
|
||||
JSACC_READ, 0, NULL, vp);
|
||||
}
|
||||
if (!(desc.attrs & JSPROP_SHARED))
|
||||
@ -136,7 +136,7 @@ JSProxyHandler::get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id,
|
||||
vp->setUndefined();
|
||||
if (desc.attrs & JSPROP_SHORTID)
|
||||
id = INT_TO_JSID(desc.shortid);
|
||||
return CallJSPropertyOp(cx, desc.getter, proxy, id, vp);
|
||||
return CallJSPropertyOp(cx, desc.getter, receiver, id, vp);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -150,12 +150,12 @@ JSProxyHandler::set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id,
|
||||
if (desc.obj) {
|
||||
if (desc.setter && ((desc.attrs & JSPROP_SETTER) || desc.setter != PropertyStub)) {
|
||||
if (desc.attrs & JSPROP_SETTER) {
|
||||
return ExternalGetOrSet(cx, proxy, id, CastAsObjectJsval(desc.setter),
|
||||
return ExternalGetOrSet(cx, receiver, id, CastAsObjectJsval(desc.setter),
|
||||
JSACC_WRITE, 1, vp, vp);
|
||||
}
|
||||
if (desc.attrs & JSPROP_SHORTID)
|
||||
id = INT_TO_JSID(desc.shortid);
|
||||
return CallJSPropertyOpSetter(cx, desc.setter, proxy, id, vp);
|
||||
return CallJSPropertyOpSetter(cx, desc.setter, receiver, id, vp);
|
||||
}
|
||||
if (desc.attrs & JSPROP_READONLY)
|
||||
return true;
|
||||
@ -167,12 +167,12 @@ JSProxyHandler::set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id,
|
||||
if (desc.obj) {
|
||||
if (desc.setter && ((desc.attrs & JSPROP_SETTER) || desc.setter != PropertyStub)) {
|
||||
if (desc.attrs & JSPROP_SETTER) {
|
||||
return ExternalGetOrSet(cx, proxy, id, CastAsObjectJsval(desc.setter),
|
||||
return ExternalGetOrSet(cx, receiver, id, CastAsObjectJsval(desc.setter),
|
||||
JSACC_WRITE, 1, vp, vp);
|
||||
}
|
||||
if (desc.attrs & JSPROP_SHORTID)
|
||||
id = INT_TO_JSID(desc.shortid);
|
||||
return CallJSPropertyOpSetter(cx, desc.setter, proxy, id, vp);
|
||||
return CallJSPropertyOpSetter(cx, desc.setter, receiver, id, vp);
|
||||
}
|
||||
if (desc.attrs & JSPROP_READONLY)
|
||||
return true;
|
||||
@ -862,16 +862,17 @@ proxy_DefineProperty(JSContext *cx, JSObject *obj, jsid id, const Value *value,
|
||||
}
|
||||
|
||||
static JSBool
|
||||
proxy_GetProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||
proxy_GetProperty(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp)
|
||||
{
|
||||
return JSProxy::get(cx, obj, obj, id, vp);
|
||||
return JSProxy::get(cx, obj, receiver, id, vp);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
proxy_SetProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict)
|
||||
proxy_SetProperty(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp,
|
||||
JSBool strict)
|
||||
{
|
||||
// TODO: throwing away strict
|
||||
return JSProxy::set(cx, obj, obj, id, vp);
|
||||
// FIXME (bug 596351): throwing away strict.
|
||||
return JSProxy::set(cx, obj, receiver, id, vp);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
|
@ -12032,7 +12032,7 @@ GetPropertyByName(JSContext* cx, JSObject* obj, JSString** namep, Value* vp, PIC
|
||||
/* Delegate to the op, if present. */
|
||||
PropertyIdOp op = obj->getOps()->getProperty;
|
||||
if (op) {
|
||||
bool result = op(cx, obj, id, vp);
|
||||
bool result = op(cx, obj, obj, id, vp);
|
||||
if (!result)
|
||||
SetBuiltinError(cx);
|
||||
return cx->tracerState->builtinStatus == 0;
|
||||
@ -12047,7 +12047,8 @@ GetPropertyByName(JSContext* cx, JSObject* obj, JSString** namep, Value* vp, PIC
|
||||
|
||||
const Shape *shape;
|
||||
JSObject *holder;
|
||||
if (!js_GetPropertyHelperWithShape(cx, obj, id, JSGET_METHOD_BARRIER, vp, &shape, &holder)) {
|
||||
if (!js_GetPropertyHelperWithShape(cx, obj, obj, id, JSGET_METHOD_BARRIER, vp, &shape,
|
||||
&holder)) {
|
||||
SetBuiltinError(cx);
|
||||
return false;
|
||||
}
|
||||
|
@ -493,7 +493,7 @@ class TypedArrayTemplate
|
||||
}
|
||||
|
||||
static JSBool
|
||||
obj_getProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||
obj_getProperty(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp)
|
||||
{
|
||||
ThisTypeArray *tarray = ThisTypeArray::fromJSObject(obj);
|
||||
JS_ASSERT(tarray);
|
||||
@ -535,7 +535,8 @@ class TypedArrayTemplate
|
||||
}
|
||||
|
||||
static JSBool
|
||||
obj_setProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict)
|
||||
obj_setProperty(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp,
|
||||
JSBool strict)
|
||||
{
|
||||
ThisTypeArray *tarray = ThisTypeArray::fromJSObject(obj);
|
||||
JS_ASSERT(tarray);
|
||||
@ -620,7 +621,7 @@ class TypedArrayTemplate
|
||||
return true;
|
||||
|
||||
Value tmp = *v;
|
||||
return obj_setProperty(cx, obj, id, &tmp, false);
|
||||
return obj_setProperty(cx, obj, obj, id, &tmp, false);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
|
@ -898,9 +898,12 @@ typedef JSBool
|
||||
(* DefinePropOp)(JSContext *cx, JSObject *obj, jsid id, const Value *value,
|
||||
PropertyOp getter, PropertyOp setter, uintN attrs);
|
||||
typedef JSBool
|
||||
(* PropertyIdOp)(JSContext *cx, JSObject *obj, jsid id, Value *vp);
|
||||
(* PropertyIdOp)(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp);
|
||||
typedef JSBool
|
||||
(* StrictPropertyIdOp)(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict);
|
||||
(* StrictPropertyIdOp)(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp,
|
||||
JSBool strict);
|
||||
typedef JSBool
|
||||
(* DeleteIdOp)(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict);
|
||||
typedef JSBool
|
||||
(* CallOp)(JSContext *cx, uintN argc, Value *vp);
|
||||
typedef JSBool
|
||||
@ -999,7 +1002,7 @@ struct ObjectOps {
|
||||
js::StrictPropertyIdOp setProperty;
|
||||
js::AttributesOp getAttributes;
|
||||
js::AttributesOp setAttributes;
|
||||
js::StrictPropertyIdOp deleteProperty;
|
||||
js::DeleteIdOp deleteProperty;
|
||||
js::NewEnumerateOp enumerate;
|
||||
js::TypeOfOp typeOf;
|
||||
js::TraceOp trace;
|
||||
|
@ -204,13 +204,14 @@ JSWrapper::hasOwn(JSContext *cx, JSObject *wrapper, jsid id, bool *bp)
|
||||
bool
|
||||
JSWrapper::get(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id, Value *vp)
|
||||
{
|
||||
GET(JS_GetPropertyById(cx, wrappedObject(wrapper), id, Jsvalify(vp)));
|
||||
GET(wrappedObject(wrapper)->getProperty(cx, receiver, id, vp));
|
||||
}
|
||||
|
||||
bool
|
||||
JSWrapper::set(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id, Value *vp)
|
||||
{
|
||||
SET(JS_SetPropertyById(cx, wrappedObject(wrapper), id, Jsvalify(vp)));
|
||||
// FIXME (bug 596351): Need deal with strict mode.
|
||||
SET(wrappedObject(wrapper)->setProperty(cx, receiver, id, vp, false));
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -4743,7 +4743,7 @@ xml_defineProperty(JSContext *cx, JSObject *obj, jsid id, const Value *v,
|
||||
}
|
||||
|
||||
static JSBool
|
||||
xml_getProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||
xml_getProperty(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp)
|
||||
{
|
||||
if (JSID_IS_DEFAULT_XML_NAMESPACE(id)) {
|
||||
vp->setUndefined();
|
||||
@ -4754,7 +4754,7 @@ xml_getProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||
}
|
||||
|
||||
static JSBool
|
||||
xml_setProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict)
|
||||
xml_setProperty(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp, JSBool strict)
|
||||
{
|
||||
return PutProperty(cx, obj, id, Jsvalify(vp));
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ stubs::SetName(VMFrame &f, JSAtom *origAtom)
|
||||
defineHow = JSDNP_CACHE_RESULT | JSDNP_UNQUALIFIED;
|
||||
else
|
||||
defineHow = JSDNP_CACHE_RESULT;
|
||||
if (!js_SetPropertyHelper(cx, obj, id, defineHow, &rval, strict))
|
||||
if (!js_SetPropertyHelper(cx, obj, obj, id, defineHow, &rval, strict))
|
||||
THROW();
|
||||
} else {
|
||||
if (!obj->setProperty(cx, id, &rval, strict))
|
||||
@ -2209,7 +2209,7 @@ InitPropOrMethod(VMFrame &f, JSAtom *atom, JSOp op)
|
||||
? JSDNP_CACHE_RESULT | JSDNP_SET_METHOD
|
||||
: JSDNP_CACHE_RESULT;
|
||||
if (!(JS_UNLIKELY(atom == cx->runtime->atomState.protoAtom)
|
||||
? js_SetPropertyHelper(cx, obj, id, defineHow, &rval, false)
|
||||
? js_SetPropertyHelper(cx, obj, obj, id, defineHow, &rval, false)
|
||||
: js_DefineNativeProperty(cx, obj, id, rval, NULL, NULL,
|
||||
JSPROP_ENUMERATE, 0, 0, NULL,
|
||||
defineHow))) {
|
||||
|
@ -12,7 +12,7 @@ script regress-551763-0.js
|
||||
script regress-551763-1.js
|
||||
script regress-551763-2.js
|
||||
script regress-555246-0.js
|
||||
fails-if(xulRuntime.shell) script regress-555246-1.js
|
||||
script regress-555246-1.js
|
||||
script regress-559438.js
|
||||
script regress-560101.js
|
||||
script regress-560998-1.js
|
||||
@ -48,3 +48,4 @@ script regress-598176.js
|
||||
script regress-600067.js
|
||||
script regress-600137.js
|
||||
script regress-602621.js
|
||||
fails-if(!xulRuntime.shell) script regress-607863.js
|
||||
|
13
js/src/tests/js1_8_5/regress/regress-607863.js
Normal file
13
js/src/tests/js1_8_5/regress/regress-607863.js
Normal file
@ -0,0 +1,13 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
*/
|
||||
|
||||
var sandbox = evalcx('');
|
||||
var foreign = evalcx('({ get f() this, set x(v) { result = this } })', sandbox);
|
||||
var local = Object.create(foreign);
|
||||
|
||||
reportCompare(local, local.f, "this should be set correctly in getters");
|
||||
local.x = 42;
|
||||
reportCompare(local, sandbox.result, "this should be set correctly in setters");
|
Loading…
x
Reference in New Issue
Block a user