From e705ef15dc1d7af10d685229f4fae460c71cd95f Mon Sep 17 00:00:00 2001 From: "jst%mozilla.jstenback.com" Date: Thu, 1 Sep 2005 23:08:57 +0000 Subject: [PATCH] Landing the second part of the fix for bug 304423. Make XPCWrappedNative::GetWrappedNativeOfJSObject() deal with the case where the prototype found through the funobj is not the current prototype for the given class (i.e. it's a prototype for the right class and scope, but one from before prototypes were refreshed). r=mrbkap@gmail.com, sr=brendan@mozilla.org git-svn-id: svn://10.0.0.236/trunk@179518 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/src/xpconnect/src/xpcwrappednative.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mozilla/js/src/xpconnect/src/xpcwrappednative.cpp b/mozilla/js/src/xpconnect/src/xpcwrappednative.cpp index 3f1c83f5e88..50abede452c 100644 --- a/mozilla/js/src/xpconnect/src/xpcwrappednative.cpp +++ b/mozilla/js/src/xpconnect/src/xpcwrappednative.cpp @@ -1147,6 +1147,7 @@ XPCWrappedNative::GetWrappedNativeOfJSObject(JSContext* cx, JSObject* cur; XPCWrappedNativeProto* proto = nsnull; + nsIClassInfo* protoClassInfo = nsnull; // If we were passed a function object then we need to find the correct // wrapper out of those that might be in the callee obj's proto chain. @@ -1162,6 +1163,8 @@ XPCWrappedNative::GetWrappedNativeOfJSObject(JSContext* cx, { NS_ASSERTION(JS_GetParent(cx, funObjParent), "funobj's parent (proto) is global"); proto = (XPCWrappedNativeProto*) JS_GetPrivate(cx, funObjParent); + if(proto) + protoClassInfo = proto->GetClassInfo(); } else if(IS_WRAPPER_CLASS(funObjParentClass)) { @@ -1192,7 +1195,10 @@ XPCWrappedNative::GetWrappedNativeOfJSObject(JSContext* cx, return_wrapper: XPCWrappedNative* wrapper = (XPCWrappedNative*) JS_GetPrivate(cx, cur); - if(proto && proto != wrapper->GetProto()) + if(proto && proto != wrapper->GetProto() && + (proto->GetScope() != wrapper->GetScope() || + !protoClassInfo || + protoClassInfo != wrapper->GetProto()->GetClassInfo())) continue; if(pobj2) *pobj2 = cur; @@ -1204,7 +1210,10 @@ return_wrapper: return_tearoff: XPCWrappedNative* wrapper = (XPCWrappedNative*) JS_GetPrivate(cx, JS_GetParent(cx,cur)); - if(proto && proto != wrapper->GetProto()) + if(proto && proto != wrapper->GetProto() && + (proto->GetScope() != wrapper->GetScope() || + !protoClassInfo || + protoClassInfo != wrapper->GetProto()->GetClassInfo())) continue; if(pobj2) *pobj2 = cur; @@ -2722,7 +2731,7 @@ static void DEBUG_PrintShadowObjectInfo(const char* header, if(header) printf("%s\n", header); - printf(" XPCNativeSet @ 0x%p for the class:\n", set); + printf(" XPCNativeSet @ 0x%p for the class:\n", (void*)set); char* className = nsnull; char* contractID = nsnull;