Fix for bug 499777 (Cannot convert WrappedNative to function (NS_ERROR_XPC_CANT_CONVERT_WN_TO_FUN)). r/sr=mrbkap.

--HG--
extra : rebase_source : 08180bab30c83d82620de0812b89d90f9e038d13
This commit is contained in:
Peter Van der Beken 2009-06-24 08:30:11 +02:00
parent 184c5dcd50
commit 5d8c1964f8

View File

@ -4113,7 +4113,7 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
const nsDOMClassInfoData *ci_data,
const nsGlobalNameStruct *name_struct,
nsScriptNameSpaceManager *nameSpaceManager,
JSObject *dot_prototype, PRBool *did_resolve);
JSObject *dot_prototype, PRBool install, PRBool *did_resolve);
NS_IMETHODIMP
@ -4195,13 +4195,21 @@ nsDOMClassInfo::PostCreatePrototype(JSContext * cx, JSObject * proto)
}
}
// Don't overwrite a property set by content.
JSBool found;
if (!::JS_AlreadyHasOwnUCProperty(cx, global, mData->mNameUTF16,
nsCRT::strlen(mData->mNameUTF16), &found)) {
return NS_ERROR_FAILURE;
}
nsScriptNameSpaceManager *nameSpaceManager =
nsJSRuntime::GetNameSpaceManager();
NS_ENSURE_TRUE(nameSpaceManager, NS_OK);
PRBool unused;
return ResolvePrototype(sXPConnect, win, cx, global, mData->mNameUTF16,
mData, nsnull, nameSpaceManager, proto, &unused);
mData, nsnull, nameSpaceManager, proto, !found,
&unused);
}
// static
@ -5589,7 +5597,7 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
const nsDOMClassInfoData *ci_data,
const nsGlobalNameStruct *name_struct,
nsScriptNameSpaceManager *nameSpaceManager,
JSObject *dot_prototype, PRBool *did_resolve)
JSObject *dot_prototype, PRBool install, PRBool *did_resolve)
{
NS_ASSERTION(ci_data ||
(name_struct &&
@ -5615,8 +5623,10 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
NS_ENSURE_SUCCESS(rv, rv);
rv = constructor->Install(cx, obj, v);
NS_ENSURE_SUCCESS(rv, rv);
if (install) {
rv = constructor->Install(cx, obj, v);
NS_ENSURE_SUCCESS(rv, rv);
}
JSObject *class_obj;
holder->GetJSObject(&class_obj);
@ -5840,7 +5850,8 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
// We don't have a XPConnect prototype object, let ResolvePrototype create
// one.
return ResolvePrototype(sXPConnect, aWin, cx, obj, class_name, nsnull,
name_struct, nameSpaceManager, nsnull, did_resolve);
name_struct, nameSpaceManager, nsnull, PR_TRUE,
did_resolve);
}
if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
@ -5870,7 +5881,8 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
}
return ResolvePrototype(sXPConnect, aWin, cx, obj, class_name, ci_data,
name_struct, nameSpaceManager, nsnull, did_resolve);
name_struct, nameSpaceManager, nsnull, PR_TRUE,
did_resolve);
}
if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructor) {