Fix instanceof for DOM classes when XPCNativeWrappers are around. Bug 294926,

r+sr=jst, a=dbaron
This commit is contained in:
bzbarsky%mit.edu 2005-05-22 21:30:15 +00:00
Родитель 1864138655
Коммит 0749d74bf2
1 изменённых файлов: 10 добавлений и 0 удалений

Просмотреть файл

@ -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<nsIXPConnectWrappedNative> 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.");