mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 22:32:51 +00:00
Bug 762432 - Handle proxies on __lookupGetter__ and __lookupSetter__. r=jorendorff
This commit is contained in:
parent
7625c2a0a5
commit
89b078af98
21
js/src/jit-test/tests/basic/testBug762432.js
Normal file
21
js/src/jit-test/tests/basic/testBug762432.js
Normal file
@ -0,0 +1,21 @@
|
||||
function getter() { return 1; }
|
||||
function setter() { }
|
||||
function getDescriptor(name) {
|
||||
if (name != 'prop')
|
||||
throw "Unknown property: " + name;
|
||||
return { configurable: true, enumerable: true, get: getter, set: setter };
|
||||
}
|
||||
function getNames() { return ['prop']; }
|
||||
var handler = {
|
||||
getOwnPropertyDescriptor: getDescriptor,
|
||||
getPropertyDescriptor: getDescriptor,
|
||||
getOwnPropertyNames: getNames,
|
||||
getPropertyNames: getNames,
|
||||
defineProperty: function() {},
|
||||
delete: function() {}
|
||||
};
|
||||
|
||||
// Make sure that __lookup{Getter,Setter}__ works on proxies.
|
||||
var proxy = Proxy.create(handler);
|
||||
assertEq(Object.prototype.__lookupGetter__.call(proxy, 'prop'), getter);
|
||||
assertEq(Object.prototype.__lookupSetter__.call(proxy, 'prop'), setter);
|
@ -1436,6 +1436,17 @@ obj_lookupGetter(JSContext *cx, unsigned argc, Value *vp)
|
||||
RootedObject obj(cx, ToObject(cx, &vp[1]));
|
||||
if (!obj)
|
||||
return JS_FALSE;
|
||||
if (obj->isProxy()) {
|
||||
// The vanilla getter lookup code below requires that the object is
|
||||
// native. Handle proxies separately.
|
||||
vp->setUndefined();
|
||||
PropertyDescriptor desc;
|
||||
if (!Proxy::getPropertyDescriptor(cx, obj, id, false, &desc))
|
||||
return JS_FALSE;
|
||||
if ((desc.attrs & JSPROP_GETTER) && desc.getter)
|
||||
*vp = CastAsObjectJsval(desc.getter);
|
||||
return JS_TRUE;
|
||||
}
|
||||
JSObject *pobj;
|
||||
JSProperty *prop;
|
||||
if (!obj->lookupGeneric(cx, id, &pobj, &prop))
|
||||
@ -1460,6 +1471,17 @@ obj_lookupSetter(JSContext *cx, unsigned argc, Value *vp)
|
||||
RootedObject obj(cx, ToObject(cx, &vp[1]));
|
||||
if (!obj)
|
||||
return JS_FALSE;
|
||||
if (obj->isProxy()) {
|
||||
// The vanilla setter lookup code below requires that the object is
|
||||
// native. Handle proxies separately.
|
||||
vp->setUndefined();
|
||||
PropertyDescriptor desc;
|
||||
if (!Proxy::getPropertyDescriptor(cx, obj, id, false, &desc))
|
||||
return JS_FALSE;
|
||||
if ((desc.attrs & JSPROP_SETTER) && desc.setter)
|
||||
*vp = CastAsObjectJsval(desc.setter);
|
||||
return JS_TRUE;
|
||||
}
|
||||
JSObject *pobj;
|
||||
JSProperty *prop;
|
||||
if (!obj->lookupGeneric(cx, id, &pobj, &prop))
|
||||
|
@ -63,6 +63,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=500931
|
||||
|
||||
is(win.XPathResult.NUMBER_TYPE, 1, "can access constants on constructors");
|
||||
is(typeof win.IDBKeyRange.bound, "function", "can access crazy IDBKeyRange static functions");
|
||||
|
||||
// Test getter/setter lookup on Xray wrappers.
|
||||
ok(Object.prototype.__lookupGetter__.call(win.document, 'title'), 'found getter on document');
|
||||
ok(Object.prototype.__lookupGetter__.call(win.document, 'title'), 'found getter on document');
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
@ -143,6 +143,11 @@ function starttest(){
|
||||
noxray.b = 122;
|
||||
is(noxray_wrapper.b, 122, "Should be able to shadow.");
|
||||
|
||||
// Try setting file input values via an Xray wrapper.
|
||||
SpecialPowers.wrap(document).title = "foo";
|
||||
is(document.title, "foo", "Set property correctly on Xray-wrapped DOM object");
|
||||
is(SpecialPowers.wrap(document).URI, document.URI, "Got property correctly on Xray-wrapped DOM object");
|
||||
|
||||
info("\nProfile::SpecialPowersRunTime: " + (new Date() - startTime) + "\n");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user