Bug 809674 - Fail at call time when invoking an XPCWrappedJS method with [implicit_jscontext] or [optional_argc]. r=mrbkap

I think this is the path of least resistance here.
This commit is contained in:
Bobby Holley 2012-11-15 10:16:36 -08:00
parent 6c5fecc57a
commit 29ae85a79e

View File

@ -1113,7 +1113,7 @@ nsXPCWrappedJSClass::CheckForException(XPCCallContext & ccx,
NS_IMETHODIMP
nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16_t methodIndex,
const XPTMethodDescriptor* info,
const XPTMethodDescriptor* info_,
nsXPTCMiniVariant* nativeParams)
{
jsval* sp = nullptr;
@ -1124,6 +1124,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16_t methodIndex,
JSBool success;
JSBool readyToDoTheCall = false;
nsID param_iid;
const nsXPTMethodInfo* info = static_cast<const nsXPTMethodInfo*>(info_);
const char* name = info->name;
jsval fval;
JSBool foundDependentParam;
@ -1143,6 +1144,17 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16_t methodIndex,
if (!cx || !xpcc || !IsReflectable(methodIndex))
return NS_ERROR_FAILURE;
// [implicit_jscontext] and [optional_argc] have a different calling
// convention, which we don't support for JS-implemented components.
if (info->WantsOptArgc() || info->WantsContext()) {
const char *str = "IDL methods marked with [implicit_jscontext] "
"or [optional_argc] may not be implemented in JS";
// Throw and warn for good measure.
JS_ReportError(cx, str);
NS_WARNING(str);
return NS_ERROR_FAILURE;
}
JSObject *obj = wrapper->GetJSObject();
JSObject *thisObj = obj;