Stop bypassing the Xray layer when walking the prototype chain.

This commit is contained in:
wolfbeast 2017-10-06 19:47:11 +02:00 • committed by Roy Tam
commit 567399f367

View file

@ -456,27 +456,26 @@ nsJSIID::Enumerate(nsIXPConnectWrappedNative* wrapper,
static nsresult static nsresult
FindObjectForHasInstance(JSContext* cx, HandleObject objArg, MutableHandleObject target) FindObjectForHasInstance(JSContext* cx, HandleObject objArg, MutableHandleObject target)
{ {
using namespace mozilla::jsipc;
RootedObject obj(cx, objArg), proto(cx); RootedObject obj(cx, objArg), proto(cx);
while (true) {
while (obj && !IS_WN_REFLECTOR(obj) && // Try the object, or the wrappee if allowed.
!IsDOMObject(obj) && !mozilla::jsipc::IsCPOW(obj)) JSObject* o = js::IsWrapper(obj) ? js::CheckedUnwrap(obj, false) : obj;
{ if (o && (IS_WN_REFLECTOR(o) || IsDOMObject(o) || IsCPOW(o))) {
if (js::IsWrapper(obj)) { target.set(o);
obj = js::CheckedUnwrap(obj, /* stopAtWindowProxy = */ false); return NS_OK;
continue;
} }
{ // Walk the prototype chain from the perspective of the callee (i.e.
JSAutoCompartment ac(cx, obj); // respecting Xrays if they exist).
if (!js::GetObjectProto(cx, obj, &proto)) if (!js::GetObjectProto(cx, obj, &proto))
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
if (!proto) {
target.set(nullptr);
return NS_OK;
} }
obj = proto; obj = proto;
} }
target.set(obj);
return NS_OK;
} }
nsresult nsresult