From 929c8ea7959a4b527bc4887d5e24b1c29bdb3d47 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Sun, 22 May 2005 21:30:15 +0000 Subject: [PATCH] Fix instanceof for DOM classes when XPCNativeWrappers are around. Bug 294926, r+sr=jst, a=dbaron git-svn-id: svn://10.0.0.236/trunk@173688 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/dom/src/base/nsDOMClassInfo.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mozilla/dom/src/base/nsDOMClassInfo.cpp b/mozilla/dom/src/base/nsDOMClassInfo.cpp index 19114a5ccc2..2f4ce6b9ed5 100644 --- a/mozilla/dom/src/base/nsDOMClassInfo.cpp +++ b/mozilla/dom/src/base/nsDOMClassInfo.cpp @@ -4088,6 +4088,16 @@ DOMJSClass_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp) JSObject *dom_obj = JSVAL_TO_OBJECT(v); NS_ASSERTION(dom_obj, "DOMJSClass_HasInstance couldn't get object"); + // This might not be the right object, if XPCNativeWrapping + // happened. Get the wrapped native for this object, then get its + // JS object. + nsCOMPtr wrapped_native; + nsContentUtils::XPConnect()-> + GetWrappedNativeOfJSObject(cx, dom_obj, getter_AddRefs(wrapped_native)); + if (wrapped_native) { + wrapped_native->GetJSObject(&dom_obj); + } + JSClass *dom_class = JS_GET_CLASS(cx, dom_obj); if (!dom_class) { NS_ERROR("DOMJSClass_HasInstance can't get class.");