mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 740469 - JSNative->JSFunction fixup should happen in DefinePropertyById, not DefineProperty. r=luke
This commit is contained in:
parent
86dea005e5
commit
dbae036f37
@ -3635,6 +3635,34 @@ DefinePropertyById(JSContext *cx, JSObject *obj, jsid id, const Value &value,
|
||||
if (attrs & (JSPROP_GETTER | JSPROP_SETTER))
|
||||
attrs &= ~JSPROP_READONLY;
|
||||
|
||||
/*
|
||||
* When we use DefineProperty, we need full scriptable Function objects rather
|
||||
* than JSNatives. However, we might be pulling this property descriptor off
|
||||
* of something with JSNative property descriptors. If we are, wrap them in
|
||||
* JS Function objects.
|
||||
*/
|
||||
if (attrs & JSPROP_NATIVE_ACCESSORS) {
|
||||
RootId idRoot(cx, &id);
|
||||
|
||||
JS_ASSERT(!(attrs & (JSPROP_GETTER | JSPROP_SETTER)));
|
||||
attrs &= ~JSPROP_NATIVE_ACCESSORS;
|
||||
if (getter) {
|
||||
JSObject *getobj = JS_NewFunction(cx, (Native) getter, 0, 0, &obj->global(), NULL);
|
||||
if (!getobj)
|
||||
return false;
|
||||
getter = JS_DATA_TO_FUNC_PTR(PropertyOp, getobj);
|
||||
attrs |= JSPROP_GETTER;
|
||||
}
|
||||
if (setter) {
|
||||
JSObject *setobj = JS_NewFunction(cx, (Native) setter, 1, 0, &obj->global(), NULL);
|
||||
if (!setobj)
|
||||
return false;
|
||||
setter = JS_DATA_TO_FUNC_PTR(StrictPropertyOp, setobj);
|
||||
attrs |= JSPROP_SETTER;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AssertNoGC(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id, value,
|
||||
@ -3694,27 +3722,6 @@ DefineProperty(JSContext *cx, JSObject *obj, const char *name, const Value &valu
|
||||
id = ATOM_TO_JSID(atom);
|
||||
}
|
||||
|
||||
if (attrs & JSPROP_NATIVE_ACCESSORS) {
|
||||
RootId idRoot(cx, &id);
|
||||
|
||||
JS_ASSERT(!(attrs & (JSPROP_GETTER | JSPROP_SETTER)));
|
||||
attrs &= ~JSPROP_NATIVE_ACCESSORS;
|
||||
if (getter) {
|
||||
JSObject *getobj = JS_NewFunction(cx, (Native) getter, 0, 0, &obj->global(), NULL);
|
||||
if (!getobj)
|
||||
return false;
|
||||
getter = JS_DATA_TO_FUNC_PTR(PropertyOp, getobj);
|
||||
attrs |= JSPROP_GETTER;
|
||||
}
|
||||
if (setter) {
|
||||
JSObject *setobj = JS_NewFunction(cx, (Native) setter, 1, 0, &obj->global(), NULL);
|
||||
if (!setobj)
|
||||
return false;
|
||||
setter = JS_DATA_TO_FUNC_PTR(StrictPropertyOp, setobj);
|
||||
attrs |= JSPROP_SETTER;
|
||||
}
|
||||
}
|
||||
|
||||
return DefinePropertyById(cx, obj, id, value, getter, setter, attrs, flags, tinyid);
|
||||
}
|
||||
|
||||
|
@ -4453,6 +4453,7 @@ DefineNativeProperty(JSContext *cx, JSObject *obj, jsid id, const Value &value_,
|
||||
{
|
||||
JS_ASSERT((defineHow & ~(DNP_CACHE_RESULT | DNP_DONT_PURGE |
|
||||
DNP_SKIP_TYPE)) == 0);
|
||||
JS_ASSERT(!(attrs & JSPROP_NATIVE_ACCESSORS));
|
||||
|
||||
RootObject objRoot(cx, &obj);
|
||||
RootId idRoot(cx, &id);
|
||||
|
@ -1029,6 +1029,7 @@ JSObject::defineGeneric(JSContext *cx, jsid id, const js::Value &value,
|
||||
JSStrictPropertyOp setter /* = JS_StrictPropertyStub */,
|
||||
unsigned attrs /* = JSPROP_ENUMERATE */)
|
||||
{
|
||||
JS_ASSERT(!(attrs & JSPROP_NATIVE_ACCESSORS));
|
||||
js::DefineGenericOp op = getOps()->defineGeneric;
|
||||
return (op ? op : js_DefineProperty)(cx, this, id, &value, getter, setter, attrs);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user