summaryrefslogtreecommitdiff
path: root/js/xpconnect
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2017-10-06 19:47:11 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-02-08 13:10:17 +0100
commitc2a1e50197fc85fa746b7dd60c4d1c7e1e84f868 (patch)
tree8c446e712a6a0e332b66966dacc8fc860793ad4a /js/xpconnect
parentef62ff68987222ef1471fc825213af5fafa89d2c (diff)
downloadaura-central-c2a1e50197fc85fa746b7dd60c4d1c7e1e84f868.tar.gz
Stop bypassing the Xray layer when walking the prototype chain.
Diffstat (limited to 'js/xpconnect')
-rw-r--r--js/xpconnect/src/XPCJSID.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/js/xpconnect/src/XPCJSID.cpp b/js/xpconnect/src/XPCJSID.cpp
index b9cbee7be..1e14c1bdf 100644
--- a/js/xpconnect/src/XPCJSID.cpp
+++ b/js/xpconnect/src/XPCJSID.cpp
@@ -456,27 +456,26 @@ nsJSIID::Enumerate(nsIXPConnectWrappedNative* wrapper,
static nsresult
FindObjectForHasInstance(JSContext* cx, HandleObject objArg, MutableHandleObject target)
{
+ using namespace mozilla::jsipc;
RootedObject obj(cx, objArg), proto(cx);
-
- while (obj && !IS_WN_REFLECTOR(obj) &&
- !IsDOMObject(obj) && !mozilla::jsipc::IsCPOW(obj))
- {
- if (js::IsWrapper(obj)) {
- obj = js::CheckedUnwrap(obj, /* stopAtWindowProxy = */ false);
- continue;
+ while (true) {
+ // Try the object, or the wrappee if allowed.
+ JSObject* o = js::IsWrapper(obj) ? js::CheckedUnwrap(obj, false) : obj;
+ if (o && (IS_WN_REFLECTOR(o) || IsDOMObject(o) || IsCPOW(o))) {
+ target.set(o);
+ return NS_OK;
}
- {
- JSAutoCompartment ac(cx, obj);
- if (!js::GetObjectProto(cx, obj, &proto))
- return NS_ERROR_FAILURE;
+ // Walk the prototype chain from the perspective of the callee (i.e.
+ // respecting Xrays if they exist).
+ if (!js::GetObjectProto(cx, obj, &proto))
+ return NS_ERROR_FAILURE;
+ if (!proto) {
+ target.set(nullptr);
+ return NS_OK;
}
-
obj = proto;
}
-
- target.set(obj);
- return NS_OK;
}
nsresult