diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-02-08 14:04:54 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-02-08 14:04:54 +0100 |
commit | bb828464e868b7571548f17ec3eaebd26f5078a2 (patch) | |
tree | 7bffaa4b17903de58996261ac465d08c601d6d85 /js/xpconnect/src/XPCJSID.cpp | |
parent | 44cd9f2a915a4879371c5e0b059acc3e5a2378b0 (diff) | |
parent | 4099ff7494f2add95d35eb4ae0de12ab1fcf2aa2 (diff) | |
download | UXP-bb828464e868b7571548f17ec3eaebd26f5078a2.tar UXP-bb828464e868b7571548f17ec3eaebd26f5078a2.tar.gz UXP-bb828464e868b7571548f17ec3eaebd26f5078a2.tar.lz UXP-bb828464e868b7571548f17ec3eaebd26f5078a2.tar.xz UXP-bb828464e868b7571548f17ec3eaebd26f5078a2.zip |
Merge branch 'ported-upstream'
Diffstat (limited to 'js/xpconnect/src/XPCJSID.cpp')
-rw-r--r-- | js/xpconnect/src/XPCJSID.cpp | 29 |
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 |