Fix bug 670319. r=jst
authorBlake Kaplan <mrbkap@gmail.com>
Tue, 30 Aug 2011 15:25:59 -0700
changeset 76238 ec2131a5351d655e2d92ea503ba55e90977036f7
parent 76237 7d9ed22b7b49c4c4eb54ad590bb74e67a3245ddb
child 76239 854fad6cbc3134cd8b7e36b948ef6a96e15ba70a
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersjst
bugs670319
milestone9.0a1
Fix bug 670319. r=jst
js/src/xpconnect/src/xpccomponents.cpp
--- a/js/src/xpconnect/src/xpccomponents.cpp
+++ b/js/src/xpconnect/src/xpccomponents.cpp
@@ -2752,16 +2752,23 @@ nsXPCComponents_Utils::LookupMethod()
     if(NS_FAILED(rv) || !argv)
         return NS_ERROR_FAILURE;
 
     // first param must be a JSObject
     if(JSVAL_IS_PRIMITIVE(argv[0]))
         return NS_ERROR_XPC_BAD_CONVERT_JS;
 
     JSObject* obj = JSVAL_TO_OBJECT(argv[0]);
+    while(obj && !obj->isWrapper() && !IS_WRAPPER_CLASS(obj->getClass()))
+        obj = JS_GetPrototype(cx, obj);
+
+    if(!obj)
+        return NS_ERROR_XPC_BAD_CONVERT_JS;
+
+    argv[0] = OBJECT_TO_JSVAL(obj);
     rv = nsXPConnect::GetXPConnect()->GetJSObjectOfWrapper(cx, obj, &obj);
     if(NS_FAILED(rv))
         return rv;
 
     OBJ_TO_INNER_OBJECT(cx, obj);
     if(!obj)
         return NS_ERROR_XPC_BAD_CONVERT_JS;