Bug 1094176 - Remove lookup API from browser. r=bholley

This commit is contained in:
Tom Schuster 2014-12-17 00:28:39 +01:00
parent aeab57a533
commit f64a27048c
7 changed files with 36 additions and 37 deletions

View File

@ -1026,17 +1026,17 @@ nsDOMClassInfo::Resolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JS::Rooted<JSObject*> global(cx, ::JS_GetGlobalForObject(cx, obj));
JS::Rooted<JS::Value> val(cx);
if (!::JS_LookupProperty(cx, global, mData->mName, &val)) {
JS::Rooted<JSPropertyDescriptor> desc(cx);
if (!JS_GetPropertyDescriptor(cx, global, mData->mName, &desc)) {
return NS_ERROR_UNEXPECTED;
}
if (!val.isPrimitive()) {
if (desc.object() && !desc.hasGetterOrSetter() && desc.value().isObject()) {
// If val is not an (non-null) object there either is no
// constructor for this class, or someone messed with
// window.classname, just fall through and let the JS engine
// return the Object constructor.
if (!::JS_DefinePropertyById(cx, obj, id, val,
if (!::JS_DefinePropertyById(cx, obj, id, desc.value(),
JSPROP_ENUMERATE,
JS_STUBGETTER, JS_STUBSETTER)) {
return NS_ERROR_UNEXPECTED;
@ -1620,16 +1620,16 @@ nsDOMConstructor::HasInstance(nsIXPConnectWrappedNative *wrapper,
if (!name_struct) {
// This isn't a normal DOM object, see if this constructor lives on its
// prototype chain.
JS::Rooted<JS::Value> val(cx);
if (!JS_GetProperty(cx, obj, "prototype", &val)) {
JS::Rooted<JSPropertyDescriptor> desc(cx);
if (!JS_GetPropertyDescriptor(cx, obj, "prototype", &desc)) {
return NS_ERROR_UNEXPECTED;
}
if (val.isPrimitive()) {
if (!desc.object() || desc.hasGetterOrSetter() || !desc.value().isObject()) {
return NS_OK;
}
JS::Rooted<JSObject*> dot_prototype(cx, val.toObjectOrNull());
JS::Rooted<JSObject*> dot_prototype(cx, &desc.value().toObject());
JS::Rooted<JSObject*> proto(cx, dom_obj);
for (;;) {
@ -1933,19 +1933,19 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
if (class_parent_name) {
JSAutoCompartment ac(cx, winobj);
JS::Rooted<JS::Value> val(cx);
if (!JS_LookupProperty(cx, winobj, CutPrefix(class_parent_name), &val)) {
JS::Rooted<JSPropertyDescriptor> desc(cx);
if (!JS_GetPropertyDescriptor(cx, winobj, CutPrefix(class_parent_name), &desc)) {
return NS_ERROR_UNEXPECTED;
}
if (val.isObject()) {
JS::Rooted<JSObject*> obj(cx, &val.toObject());
if (!JS_LookupProperty(cx, obj, "prototype", &val)) {
if (desc.object() && !desc.hasGetterOrSetter() && desc.value().isObject()) {
JS::Rooted<JSObject*> obj(cx, &desc.value().toObject());
if (!JS_GetPropertyDescriptor(cx, obj, "prototype", &desc)) {
return NS_ERROR_UNEXPECTED;
}
if (val.isObject()) {
proto = &val.toObject();
if (desc.object() && !desc.hasGetterOrSetter() && desc.value().isObject()) {
proto = &desc.value().toObject();
}
}
}

View File

@ -7681,9 +7681,9 @@ class CGEnumerateHook(CGAbstractBindingMethod):
if (rv.Failed()) {
return ThrowMethodFailedWithDetails(cx, rv, "%s", "enumerate");
}
JS::Rooted<JS::Value> dummy(cx);
bool dummy;
for (uint32_t i = 0; i < names.Length(); ++i) {
if (!JS_LookupUCProperty(cx, obj, names[i].get(), names[i].Length(), &dummy)) {
if (!JS_HasUCProperty(cx, obj, names[i].get(), names[i].Length(), &dummy)) {
return false;
}
}

View File

@ -321,12 +321,9 @@ bool
nsXBLProtoImpl::ResolveAllFields(JSContext *cx, JS::Handle<JSObject*> obj) const
{
for (nsXBLProtoImplField* f = mFields; f; f = f->GetNext()) {
// Using OBJ_LOOKUP_PROPERTY is a pain, since what we have is a
// char16_t* for the property name. Let's just use the public API and
// all.
nsDependentString name(f->GetName());
JS::Rooted<JS::Value> dummy(cx);
if (!::JS_LookupUCProperty(cx, obj, name.get(), name.Length(), &dummy)) {
bool dummy;
if (!::JS_HasUCProperty(cx, obj, name.get(), name.Length(), &dummy)) {
return false;
}
}

View File

@ -148,17 +148,14 @@ ConnectWorkerToRIL::RunTask(JSContext *aCx)
JS::Rooted<JSObject*> workerGlobal(aCx, JS::CurrentGlobalOrNull(aCx));
// Check whether |postRILMessage| has been defined. No one but this class
// should ever define |postRILMessage| in a RIL worker, so we call to
// |JS_LookupProperty| instead of |JS_GetProperty| here.
// should ever define |postRILMessage| in a RIL worker.
JS::Rooted<JS::Value> val(aCx);
if (!JS_LookupProperty(aCx, workerGlobal, "postRILMessage", &val)) {
if (!JS_GetProperty(aCx, workerGlobal, "postRILMessage", &val)) {
JS_ReportPendingException(aCx);
return false;
}
// |JS_LookupProperty| could still return JS_TRUE with an "undefined"
// |postRILMessage|, so we have to make sure that with an additional call
// to |JS_TypeOfValue|.
// Make sure that |postRILMessage| is a function.
if (JSTYPE_FUNCTION == JS_TypeOfValue(aCx, val)) {
return true;
}

View File

@ -336,7 +336,7 @@ CPOWToString(JSContext *cx, unsigned argc, Value *vp)
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject callee(cx, &args.callee());
RootedValue cpowValue(cx);
if (!JS_LookupProperty(cx, callee, "__cpow__", &cpowValue))
if (!JS_GetProperty(cx, callee, "__cpow__", &cpowValue))
return false;
if (!cpowValue.isObject() || !IsCPOW(&cpowValue.toObject())) {

View File

@ -545,12 +545,9 @@ XPCWrappedNative::SweepTearOffs()
inline bool
xpc_ForcePropertyResolve(JSContext* cx, JS::HandleObject obj, jsid idArg)
{
JS::RootedValue prop(cx);
JS::RootedId id(cx, idArg);
if (!JS_LookupPropertyById(cx, obj, id, &prop))
return false;
return true;
bool dummy;
return JS_HasPropertyById(cx, obj, id, &dummy);
}
inline jsid

View File

@ -328,10 +328,19 @@ ExposedPropertiesOnly::check(JSContext *cx, HandleObject wrapper, HandleId id, W
if (id == JSID_VOID)
return true;
RootedValue exposedProps(cx);
if (!JS_LookupPropertyById(cx, wrappedObject, exposedPropsId, &exposedProps))
Rooted<JSPropertyDescriptor> desc(cx);
if (!JS_GetPropertyDescriptorById(cx, wrappedObject, exposedPropsId, &desc))
return false;
if (!desc.object())
return false;
if (desc.hasGetterOrSetter()) {
EnterAndThrow(cx, wrapper, "__exposedProps__ must be a value property");
return false;
}
RootedValue exposedProps(cx, desc.value());
if (exposedProps.isNullOrUndefined())
return false;
@ -349,7 +358,6 @@ ExposedPropertiesOnly::check(JSContext *cx, HandleObject wrapper, HandleId id, W
Access access = NO_ACCESS;
Rooted<JSPropertyDescriptor> desc(cx);
if (!JS_GetPropertyDescriptorById(cx, hallpass, id, &desc)) {
return false; // Error
}