mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-28 01:57:30 +09:00
Stop bypassing the Xray layer when walking the prototype chain.
This commit is contained in:
parent
b67e03dc90
commit
567399f367
1 changed files with 14 additions and 15 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue