mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1077587 - Handle non-existent properties in CPOW descriptor code (r=mrbkap)
This commit is contained in:
parent
1809fa7212
commit
3b3399bdc4
@ -537,8 +537,7 @@ JavaScriptShared::fromDescriptor(JSContext *cx, Handle<JSPropertyDescriptor> des
|
||||
if (!toVariant(cx, desc.value(), &out->value()))
|
||||
return false;
|
||||
|
||||
MOZ_ASSERT(desc.object());
|
||||
if (!toObjectVariant(cx, desc.object(), &out->obj()))
|
||||
if (!toObjectOrNullVariant(cx, desc.object(), &out->obj()))
|
||||
return false;
|
||||
|
||||
if (!desc.getter()) {
|
||||
@ -595,11 +594,7 @@ JavaScriptShared::toDescriptor(JSContext *cx, const PPropertyDescriptor &in,
|
||||
out.setAttributes(in.attrs());
|
||||
if (!fromVariant(cx, in.value(), out.value()))
|
||||
return false;
|
||||
Rooted<JSObject*> obj(cx);
|
||||
obj = fromObjectVariant(cx, in.obj());
|
||||
if (!obj)
|
||||
return false;
|
||||
out.object().set(obj);
|
||||
out.object().set(fromObjectOrNullVariant(cx, in.obj()));
|
||||
|
||||
if (in.getter().type() == GetterSetter::Tuint64_t && !in.getter().get_uint64_t()) {
|
||||
out.setGetter(nullptr);
|
||||
@ -634,6 +629,31 @@ JavaScriptShared::toDescriptor(JSContext *cx, const PPropertyDescriptor &in,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
JavaScriptShared::toObjectOrNullVariant(JSContext *cx, JSObject *obj, ObjectOrNullVariant *objVarp)
|
||||
{
|
||||
if (!obj) {
|
||||
*objVarp = NullVariant();
|
||||
return true;
|
||||
}
|
||||
|
||||
ObjectVariant objVar;
|
||||
if (!toObjectVariant(cx, obj, &objVar))
|
||||
return false;
|
||||
|
||||
*objVarp = objVar;
|
||||
return true;
|
||||
}
|
||||
|
||||
JSObject *
|
||||
JavaScriptShared::fromObjectOrNullVariant(JSContext *cx, ObjectOrNullVariant objVar)
|
||||
{
|
||||
if (objVar.type() == ObjectOrNullVariant::TNullVariant)
|
||||
return nullptr;
|
||||
|
||||
return fromObjectVariant(cx, objVar.get_ObjectVariant());
|
||||
}
|
||||
|
||||
CpowIdHolder::CpowIdHolder(dom::CPOWManagerGetter *managerGetter, const InfallibleTArray<CpowEntry> &cpows)
|
||||
: js_(nullptr),
|
||||
cpows_(cpows)
|
||||
|
@ -169,6 +169,9 @@ class JavaScriptShared
|
||||
bool toDescriptor(JSContext *cx, const PPropertyDescriptor &in,
|
||||
JS::MutableHandle<JSPropertyDescriptor> out);
|
||||
|
||||
bool toObjectOrNullVariant(JSContext *cx, JSObject *obj, ObjectOrNullVariant *objVarp);
|
||||
JSObject *fromObjectOrNullVariant(JSContext *cx, ObjectOrNullVariant objVar);
|
||||
|
||||
bool convertIdToGeckoString(JSContext *cx, JS::HandleId id, nsString *to);
|
||||
bool convertGeckoStringToId(JSContext *cx, const nsString &from, JS::MutableHandleId id);
|
||||
|
||||
|
@ -62,6 +62,12 @@ union SymbolVariant
|
||||
struct UndefinedVariant {};
|
||||
struct NullVariant {};
|
||||
|
||||
union ObjectOrNullVariant
|
||||
{
|
||||
ObjectVariant;
|
||||
NullVariant;
|
||||
};
|
||||
|
||||
union JSVariant
|
||||
{
|
||||
UndefinedVariant;
|
||||
@ -115,7 +121,7 @@ union GetterSetter
|
||||
|
||||
struct PPropertyDescriptor
|
||||
{
|
||||
ObjectVariant obj;
|
||||
ObjectOrNullVariant obj;
|
||||
uint32_t attrs;
|
||||
JSVariant value;
|
||||
|
||||
|
@ -111,9 +111,6 @@ WrapperAnswer::RecvGetPropertyDescriptor(const ObjectId &objId, const JSIDVarian
|
||||
if (!JS_GetPropertyDescriptorById(cx, obj, id, &desc))
|
||||
return fail(cx, rs);
|
||||
|
||||
if (!desc.object())
|
||||
return ok(rs);
|
||||
|
||||
if (!fromDescriptor(cx, desc, out))
|
||||
return fail(cx, rs);
|
||||
|
||||
@ -142,12 +139,9 @@ WrapperAnswer::RecvGetOwnPropertyDescriptor(const ObjectId &objId, const JSIDVar
|
||||
return fail(cx, rs);
|
||||
|
||||
Rooted<JSPropertyDescriptor> desc(cx);
|
||||
if (!JS_GetPropertyDescriptorById(cx, obj, id, &desc))
|
||||
if (!JS_GetOwnPropertyDescriptorById(cx, obj, id, &desc))
|
||||
return fail(cx, rs);
|
||||
|
||||
if (desc.object() != obj)
|
||||
return ok(rs);
|
||||
|
||||
if (!fromDescriptor(cx, desc, out))
|
||||
return fail(cx, rs);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user