Bug 738244: Fix proxy behavior when assigning to inherited properties.

This commit is contained in:
Gabor Krizsanits 2012-06-07 18:31:31 -07:00
parent 8c3ac14da3
commit e6258a30e4
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,21 @@
// When we assign to a property that a proxy claims is inherited, the
// defineProperty handler call to create the new own property should get
// the newly assigned value.
var hits;
var handlers = {
getOwnPropertyDescriptor: function(name) {
return undefined;
},
getPropertyDescriptor: function(name) {
return { value:42, writable:true, enumerable:true, configurable:true };
},
defineProperty: function(name, descriptor) {
hits++;
assertEq(name, 'x');
assertEq(descriptor.value, 43);
}
};
hits = 0;
Proxy.create(handlers).x = 43;
assertEq(hits, 1);

View File

@ -205,6 +205,7 @@ BaseProxyHandler::set(JSContext *cx, JSObject *proxy, JSObject *receiver_, jsid
if (!(desc.attrs & JSPROP_GETTER))
desc.getter = JS_PropertyStub;
}
desc.value = *vp;
return defineProperty(cx, receiver, id, &desc);
}