Bug 785096 - part2: Removing XPCCallContext dependency from XPCVariant; r=bholley

This commit is contained in:
Gabor Krizsanits 2012-09-20 15:03:28 +02:00
Родитель ca6baf3206
Коммит dc6a0acf70
10 изменённых файлов: 126 добавлений и 99 удалений

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

@ -365,15 +365,13 @@ bool ConvertToPrimitive(JSContext *cx, const JS::Value& v, T *retval)
// static
JSBool
XPCConvert::JSData2Native(XPCCallContext& ccx, void* d, jsval s,
XPCConvert::JSData2Native(JSContext* cx, void* d, jsval s,
const nsXPTType& type,
JSBool useAllocator, const nsID* iid,
nsresult* pErr)
{
NS_PRECONDITION(d, "bad param");
JSContext* cx = ccx.GetJSContext();
JSBool isDOMString = true;
if (pErr)
@ -515,7 +513,7 @@ XPCConvert::JSData2Native(XPCCallContext& ccx, void* d, jsval s,
return false;
XPCReadableJSStringWrapper *wrapper =
ccx.NewStringWrapper(strChars, strLength);
nsXPConnect::GetRuntimeInstance()->NewStringWrapper(strChars, strLength);
if (!wrapper)
return false;
@ -715,7 +713,7 @@ XPCConvert::JSData2Native(XPCCallContext& ccx, void* d, jsval s,
NS_ASSERTION(iid,"can't do interface conversions without iid");
if (iid->Equals(NS_GET_IID(nsIVariant))) {
XPCVariant* variant = XPCVariant::newVariant(ccx, s);
XPCVariant* variant = XPCVariant::newVariant(cx, s);
if (!variant)
return false;
*((nsISupports**)d) = static_cast<nsIVariant*>(variant);
@ -752,7 +750,7 @@ XPCConvert::JSData2Native(XPCCallContext& ccx, void* d, jsval s,
return false;
}
return JSObject2NativeInterface(ccx, (void**)d, &s.toObject(), iid,
return JSObject2NativeInterface(cx, (void**)d, &s.toObject(), iid,
nullptr, pErr);
}
default:
@ -1010,7 +1008,7 @@ XPCConvert::NativeInterface2JSObject(XPCLazyCallContext& lccx,
// static
JSBool
XPCConvert::JSObject2NativeInterface(XPCCallContext& ccx,
XPCConvert::JSObject2NativeInterface(JSContext* cx,
void** dest, JSObject* src,
const nsID* iid,
nsISupports* aOuter,
@ -1020,7 +1018,6 @@ XPCConvert::JSObject2NativeInterface(XPCCallContext& ccx,
NS_ASSERTION(src, "bad param");
NS_ASSERTION(iid, "bad param");
JSContext* cx = ccx.GetJSContext();
JSAutoCompartment ac(cx, src);
*dest = nullptr;
@ -1078,7 +1075,7 @@ XPCConvert::JSObject2NativeInterface(XPCCallContext& ccx,
// else...
nsXPCWrappedJS* wrapper;
nsresult rv = nsXPCWrappedJS::GetNewOrUsed(ccx, src, *iid, aOuter, &wrapper);
nsresult rv = nsXPCWrappedJS::GetNewOrUsed(cx, src, *iid, aOuter, &wrapper);
if (pErr)
*pErr = rv;
if (NS_SUCCEEDED(rv) && wrapper) {
@ -1534,7 +1531,7 @@ CheckTargetAndPopulate(JSContext *cx,
// static
JSBool
XPCConvert::JSTypedArray2Native(XPCCallContext& ccx,
XPCConvert::JSTypedArray2Native(JSContext* cx,
void** d,
JSObject* jsArray,
uint32_t count,
@ -1543,7 +1540,6 @@ XPCConvert::JSTypedArray2Native(XPCCallContext& ccx,
{
NS_ABORT_IF_FALSE(jsArray, "bad param");
NS_ABORT_IF_FALSE(d, "bad param");
JSContext* cx = ccx.GetJSContext();
NS_ABORT_IF_FALSE(JS_IsTypedArrayObject(jsArray, cx), "not a typed array");
// Check the actual length of the input array against the
@ -1641,14 +1637,12 @@ XPCConvert::JSTypedArray2Native(XPCCallContext& ccx,
// static
JSBool
XPCConvert::JSArray2Native(XPCCallContext& ccx, void** d, JS::Value s,
XPCConvert::JSArray2Native(JSContext* cx, void** d, JS::Value s,
uint32_t count, const nsXPTType& type,
const nsID* iid, nsresult* pErr)
{
NS_ABORT_IF_FALSE(d, "bad param");
JSContext* cx = ccx.GetJSContext();
// XXX add support for getting chars from strings
// XXX add support to indicate *which* array element was not convertable
@ -1674,7 +1668,7 @@ XPCConvert::JSArray2Native(XPCCallContext& ccx, void** d, JS::Value s,
// If this is a typed array, then try a fast conversion with memcpy.
if (JS_IsTypedArrayObject(jsarray, cx)) {
return JSTypedArray2Native(ccx, d, jsarray, count, type, pErr);
return JSTypedArray2Native(cx, d, jsarray, count, type, pErr);
}
if (!JS_IsArrayObject(cx, jsarray)) {
@ -1705,7 +1699,7 @@ XPCConvert::JSArray2Native(XPCCallContext& ccx, void** d, JS::Value s,
} \
for (initedCount = 0; initedCount < count; initedCount++) { \
if (!JS_GetElement(cx, jsarray, initedCount, &current) || \
!JSData2Native(ccx, ((_t*)array)+initedCount, current, type, \
!JSData2Native(cx, ((_t*)array)+initedCount, current, type, \
true, iid, pErr)) \
goto failure; \
} \

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

@ -25,12 +25,12 @@ NS_IMPL_CI_INTERFACE_GETTER2(XPCVariant, XPCVariant, nsIVariant)
NS_IMPL_CYCLE_COLLECTING_ADDREF(XPCVariant)
NS_IMPL_CYCLE_COLLECTING_RELEASE(XPCVariant)
XPCVariant::XPCVariant(XPCCallContext& ccx, jsval aJSVal)
XPCVariant::XPCVariant(JSContext* cx, jsval aJSVal)
: mJSVal(aJSVal), mCCGeneration(0)
{
nsVariant::Initialize(&mData);
if (!JSVAL_IS_PRIMITIVE(mJSVal)) {
JSObject *obj = JS_ObjectToInnerObject(ccx, JSVAL_TO_OBJECT(mJSVal));
JSObject *obj = JS_ObjectToInnerObject(cx, JSVAL_TO_OBJECT(mJSVal));
mJSVal = OBJECT_TO_JSVAL(obj);
@ -40,7 +40,7 @@ XPCVariant::XPCVariant(XPCCallContext& ccx, jsval aJSVal)
JSObject* proto;
XPCWrappedNative* wn =
XPCWrappedNative::GetWrappedNativeOfJSObject(ccx,
XPCWrappedNative::GetWrappedNativeOfJSObject(cx,
JSVAL_TO_OBJECT(mJSVal),
nullptr,
&proto);
@ -107,20 +107,20 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(XPCVariant)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
// static
XPCVariant* XPCVariant::newVariant(XPCCallContext& ccx, jsval aJSVal)
XPCVariant* XPCVariant::newVariant(JSContext* cx, jsval aJSVal)
{
XPCVariant* variant;
if (!JSVAL_IS_TRACEABLE(aJSVal))
variant = new XPCVariant(ccx, aJSVal);
variant = new XPCVariant(cx, aJSVal);
else
variant = new XPCTraceableVariant(ccx, aJSVal);
variant = new XPCTraceableVariant(cx, aJSVal);
if (!variant)
return nullptr;
NS_ADDREF(variant);
if (!variant->InitializeData(ccx))
if (!variant->InitializeData(cx))
NS_RELEASE(variant); // Also sets variant to nullptr.
return variant;
@ -152,7 +152,7 @@ private:
static const Type StateTable[tTypeCount][tTypeCount-1];
public:
static JSBool GetTypeForArray(XPCCallContext& ccx, JSObject* array,
static JSBool GetTypeForArray(JSContext* cx, JSObject* array,
uint32_t length,
nsXPTType* resultType, nsID* resultID);
};
@ -177,7 +177,7 @@ XPCArrayHomogenizer::StateTable[tTypeCount][tTypeCount-1] = {
// static
JSBool
XPCArrayHomogenizer::GetTypeForArray(XPCCallContext& ccx, JSObject* array,
XPCArrayHomogenizer::GetTypeForArray(JSContext* cx, JSObject* array,
uint32_t length,
nsXPTType* resultType, nsID* resultID)
{
@ -186,7 +186,7 @@ XPCArrayHomogenizer::GetTypeForArray(XPCCallContext& ccx, JSObject* array,
for (uint32_t i = 0; i < length; i++) {
JS::Value val;
if (!JS_GetElement(ccx, array, i, &val))
if (!JS_GetElement(cx, array, i, &val))
return false;
if (val.isInt32()) {
@ -205,9 +205,9 @@ XPCArrayHomogenizer::GetTypeForArray(XPCCallContext& ccx, JSObject* array,
} else {
NS_ASSERTION(val.isObject(), "invalid type of jsval!");
JSObject* jsobj = &val.toObject();
if (JS_IsArrayObject(ccx, jsobj))
if (JS_IsArrayObject(cx, jsobj))
type = tArr;
else if (xpc_JSObjectIsID(ccx, jsobj))
else if (xpc_JSObjectIsID(cx, jsobj))
type = tID;
else
type = tISup;
@ -266,9 +266,9 @@ XPCArrayHomogenizer::GetTypeForArray(XPCCallContext& ccx, JSObject* array,
return true;
}
JSBool XPCVariant::InitializeData(XPCCallContext& ccx)
JSBool XPCVariant::InitializeData(JSContext* cx)
{
JS_CHECK_RECURSION(ccx.GetJSContext(), return false);
JS_CHECK_RECURSION(cx, return false);
JS::Value val = GetJSVal();
@ -296,7 +296,7 @@ JSBool XPCVariant::InitializeData(XPCCallContext& ccx)
// Despite the fact that the variant holds the length, there are
// implicit assumptions that mWStringValue[mWStringLength] == 0
size_t length;
const jschar *chars = JS_GetStringCharsZAndLength(ccx, str, &length);
const jschar *chars = JS_GetStringCharsZAndLength(cx, str, &length);
if (!chars)
return false;
@ -316,7 +316,7 @@ JSBool XPCVariant::InitializeData(XPCCallContext& ccx)
// Let's see if it is a xpcJSID.
const nsID* id = xpc_JSObjectToID(ccx, jsobj);
const nsID* id = xpc_JSObjectToID(cx, jsobj);
if (id)
return NS_SUCCEEDED(nsVariant::SetFromID(&mData, *id));
@ -324,7 +324,7 @@ JSBool XPCVariant::InitializeData(XPCCallContext& ccx)
uint32_t len;
if (JS_IsArrayObject(ccx, jsobj) && JS_GetArrayLength(ccx, jsobj, &len)) {
if (JS_IsArrayObject(cx, jsobj) && JS_GetArrayLength(cx, jsobj, &len)) {
if (!len) {
// Zero length array
nsVariant::SetToEmptyArray(&mData);
@ -334,10 +334,10 @@ JSBool XPCVariant::InitializeData(XPCCallContext& ccx)
nsXPTType type;
nsID id;
if (!XPCArrayHomogenizer::GetTypeForArray(ccx, jsobj, len, &type, &id))
if (!XPCArrayHomogenizer::GetTypeForArray(cx, jsobj, len, &type, &id))
return false;
if (!XPCConvert::JSArray2Native(ccx, &mData.u.array.mArrayValue,
if (!XPCConvert::JSArray2Native(cx, &mData.u.array.mArrayValue,
val, len, type, &id, nullptr))
return false;
@ -357,7 +357,7 @@ JSBool XPCVariant::InitializeData(XPCCallContext& ccx)
const nsIID& iid = NS_GET_IID(nsISupports);
return nullptr != (xpc = nsXPConnect::GetXPConnect()) &&
NS_SUCCEEDED(xpc->WrapJS(ccx, jsobj,
NS_SUCCEEDED(xpc->WrapJS(cx, jsobj,
iid, getter_AddRefs(wrapper))) &&
NS_SUCCEEDED(nsVariant::SetFromInterface(&mData, iid, wrapper));
}

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

@ -273,7 +273,7 @@ CheckMainThreadOnly(nsXPCWrappedJS *aWrapper)
// static
nsresult
nsXPCWrappedJS::GetNewOrUsed(XPCCallContext& ccx,
nsXPCWrappedJS::GetNewOrUsed(JSContext* cx,
JSObject* aJSObj,
REFNSIID aIID,
nsISupports* aOuter,
@ -284,7 +284,7 @@ nsXPCWrappedJS::GetNewOrUsed(XPCCallContext& ccx,
nsXPCWrappedJS* root = nullptr;
nsXPCWrappedJS* wrapper = nullptr;
nsXPCWrappedJSClass* clazz = nullptr;
XPCJSRuntime* rt = ccx.GetRuntime();
XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
JSBool release_root = false;
map = rt->GetWrappedJSMap();
@ -293,13 +293,13 @@ nsXPCWrappedJS::GetNewOrUsed(XPCCallContext& ccx,
return NS_ERROR_FAILURE;
}
nsXPCWrappedJSClass::GetNewOrUsed(ccx, aIID, &clazz);
nsXPCWrappedJSClass::GetNewOrUsed(cx, aIID, &clazz);
if (!clazz)
return NS_ERROR_FAILURE;
// from here on we need to return through 'return_wrapper'
// always find the root JSObject
rootJSObj = clazz->GetRootJSObject(ccx, aJSObj);
rootJSObj = clazz->GetRootJSObject(cx, aJSObj);
if (!rootJSObj)
goto return_wrapper;
@ -322,7 +322,7 @@ nsXPCWrappedJS::GetNewOrUsed(XPCCallContext& ccx,
// build the root wrapper
if (rootJSObj == aJSObj) {
// the root will do double duty as the interface wrapper
wrapper = root = new nsXPCWrappedJS(ccx, aJSObj, clazz, nullptr,
wrapper = root = new nsXPCWrappedJS(cx, aJSObj, clazz, nullptr,
aOuter);
if (!root)
goto return_wrapper;
@ -347,12 +347,12 @@ nsXPCWrappedJS::GetNewOrUsed(XPCCallContext& ccx,
} else {
// just a root wrapper
nsXPCWrappedJSClass* rootClazz = nullptr;
nsXPCWrappedJSClass::GetNewOrUsed(ccx, NS_GET_IID(nsISupports),
nsXPCWrappedJSClass::GetNewOrUsed(cx, NS_GET_IID(nsISupports),
&rootClazz);
if (!rootClazz)
goto return_wrapper;
root = new nsXPCWrappedJS(ccx, rootJSObj, rootClazz, nullptr, aOuter);
root = new nsXPCWrappedJS(cx, rootJSObj, rootClazz, nullptr, aOuter);
NS_RELEASE(rootClazz);
if (!root)
@ -383,7 +383,7 @@ nsXPCWrappedJS::GetNewOrUsed(XPCCallContext& ccx,
NS_ASSERTION(clazz,"bad clazz");
if (!wrapper) {
wrapper = new nsXPCWrappedJS(ccx, aJSObj, clazz, root, aOuter);
wrapper = new nsXPCWrappedJS(cx, aJSObj, clazz, root, aOuter);
if (!wrapper)
goto return_wrapper;
#if DEBUG_xpc_leaks
@ -409,7 +409,7 @@ return_wrapper:
return NS_OK;
}
nsXPCWrappedJS::nsXPCWrappedJS(XPCCallContext& ccx,
nsXPCWrappedJS::nsXPCWrappedJS(JSContext* cx,
JSObject* aJSObj,
nsXPCWrappedJSClass* aClass,
nsXPCWrappedJS* root,

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

@ -107,11 +107,11 @@ JSBool xpc_IsReportableErrorCode(nsresult code)
// static
nsresult
nsXPCWrappedJSClass::GetNewOrUsed(XPCCallContext& ccx, REFNSIID aIID,
nsXPCWrappedJSClass::GetNewOrUsed(JSContext* cx, REFNSIID aIID,
nsXPCWrappedJSClass** resultClazz)
{
nsXPCWrappedJSClass* clazz = nullptr;
XPCJSRuntime* rt = ccx.GetRuntime();
XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
{ // scoped lock
XPCAutoLock lock(rt->GetMapLock());
@ -122,13 +122,13 @@ nsXPCWrappedJSClass::GetNewOrUsed(XPCCallContext& ccx, REFNSIID aIID,
if (!clazz) {
nsCOMPtr<nsIInterfaceInfo> info;
ccx.GetXPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info));
nsXPConnect::GetXPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info));
if (info) {
bool canScript, isBuiltin;
if (NS_SUCCEEDED(info->IsScriptable(&canScript)) && canScript &&
NS_SUCCEEDED(info->IsBuiltinClass(&isBuiltin)) && !isBuiltin &&
nsXPConnect::IsISupportsDescendant(info)) {
clazz = new nsXPCWrappedJSClass(ccx, aIID, info);
clazz = new nsXPCWrappedJSClass(cx, aIID, info);
if (clazz && !clazz->mDescriptors)
NS_RELEASE(clazz); // sets clazz to nullptr
}
@ -138,9 +138,9 @@ nsXPCWrappedJSClass::GetNewOrUsed(XPCCallContext& ccx, REFNSIID aIID,
return NS_OK;
}
nsXPCWrappedJSClass::nsXPCWrappedJSClass(XPCCallContext& ccx, REFNSIID aIID,
nsXPCWrappedJSClass::nsXPCWrappedJSClass(JSContext* cx, REFNSIID aIID,
nsIInterfaceInfo* aInfo)
: mRuntime(ccx.GetRuntime()),
: mRuntime(nsXPConnect::GetRuntimeInstance()),
mInfo(aInfo),
mName(nullptr),
mIID(aIID),
@ -196,11 +196,10 @@ nsXPCWrappedJSClass::~nsXPCWrappedJSClass()
}
JSObject*
nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(XPCCallContext& ccx,
nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(JSContext* cx,
JSObject* jsobj,
REFNSIID aIID)
{
JSContext* cx = ccx.GetJSContext();
JSObject* id;
jsval retval;
JSObject* retObj;
@ -230,7 +229,7 @@ nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(XPCCallContext& ccx,
return nullptr;
// protect fun so that we're sure it's alive when we call it
AUTO_MARK_JSVAL(ccx, fun);
AUTO_MARK_JSVAL(cx, fun);
// Ensure that we are asking for a scriptable interface.
// NB: It's important for security that this check is here rather
@ -240,7 +239,7 @@ nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(XPCCallContext& ccx,
// We so often ask for nsISupports that we can short-circuit the test...
if (!aIID.Equals(NS_GET_IID(nsISupports))) {
nsCOMPtr<nsIInterfaceInfo> info;
ccx.GetXPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info));
nsXPConnect::GetXPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info));
if (!info)
return nullptr;
bool canScript, isBuiltin;
@ -268,7 +267,7 @@ nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(XPCCallContext& ccx,
"JS failed without setting an exception!");
jsval jsexception = JSVAL_NULL;
AUTO_MARK_JSVAL(ccx, &jsexception);
AUTO_MARK_JSVAL(cx, &jsexception);
if (JS_GetPendingException(cx, &jsexception)) {
nsresult rv;
@ -278,7 +277,7 @@ nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(XPCCallContext& ccx,
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
nsXPConnect::GetXPConnect()->
GetWrappedNativeOfJSObject(ccx,
GetWrappedNativeOfJSObject(cx,
&jsexception.toObject(),
getter_AddRefs(wrapper));
@ -746,13 +745,13 @@ nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
}
JSObject*
nsXPCWrappedJSClass::GetRootJSObject(XPCCallContext& ccx, JSObject* aJSObj)
nsXPCWrappedJSClass::GetRootJSObject(JSContext* cx, JSObject* aJSObj)
{
JSObject* result = CallQueryInterfaceOnJSObject(ccx, aJSObj,
JSObject* result = CallQueryInterfaceOnJSObject(cx, aJSObj,
NS_GET_IID(nsISupports));
if (!result)
return aJSObj;
JSObject* inner = XPCWrapper::Unwrap(ccx, result);
JSObject* inner = XPCWrapper::Unwrap(cx, result);
if (inner)
return inner;
return result;

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

@ -3024,7 +3024,7 @@ CallMethodHelper::CleanupParam(nsXPTCMiniVariant& param, nsXPTType& type)
break;
case nsXPTType::T_ASTRING:
case nsXPTType::T_DOMSTRING:
mCallContext.DeleteString((nsAString*)param.val.p);
nsXPConnect::GetRuntimeInstance()->DeleteString((nsAString*)param.val.p);
break;
case nsXPTType::T_UTF8STRING:
case nsXPTType::T_CSTRING:

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

@ -208,12 +208,11 @@ def writeArgumentUnboxing(f, i, name, type, haveCcx, optional, rvdeclared,
elif isInterfaceType(type):
if type.name == 'nsIVariant':
# Totally custom.
assert haveCcx
template = (
" nsCOMPtr<nsIVariant> ${name}(already_AddRefed<nsIVariant>("
"XPCVariant::newVariant(ccx, ${argVal})));\n"
"XPCVariant::newVariant(cx, ${argVal})));\n"
" if (!${name}) {\n"
" xpc_qsThrowBadArgWithCcx(ccx, NS_ERROR_XPC_BAD_CONVERT_JS, %d);\n"
" xpc_qsThrowBadArg(cx, NS_ERROR_INVALID_ARG, vp, %d);\n"
" return JS_FALSE;\n"
" }\n") % i
f.write(string.Template(template).substitute(params))
@ -392,9 +391,6 @@ def writeResultConv(f, type, interfaceResultTemplate, jsvalPtr, jsvalRef):
f.write(" return xpc_qsThrow(cx, NS_ERROR_UNEXPECTED); // FIXME\n")
def anyParamRequiresCcx(member):
for p in member.params:
if isVariantType(p.realtype):
return True
return False
def memberNeedsCcx(member):

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

@ -537,12 +537,11 @@ def writeArgumentUnboxing(f, i, name, type, haveCcx, optional, rvdeclared,
elif isInterfaceType(type):
if type.name == 'nsIVariant':
# Totally custom.
assert haveCcx
template = (
" nsCOMPtr<nsIVariant> ${name}(already_AddRefed<nsIVariant>("
"XPCVariant::newVariant(ccx, ${argVal})));\n"
"XPCVariant::newVariant(cx, ${argVal})));\n"
" if (!${name}) {\n"
" xpc_qsThrowBadArgWithCcx(ccx, NS_ERROR_XPC_BAD_CONVERT_JS, %d);\n"
" xpc_qsThrowBadArg(cx, NS_ERROR_INVALID_ARG, vp, %d);\n"
" return JS_FALSE;\n"
" }") % i
f.write(substitute(template, params))
@ -725,9 +724,6 @@ def writeResultConv(f, type, jsvalPtr, jsvalRef):
f.write(" return xpc_qsThrow(cx, NS_ERROR_UNEXPECTED); // FIXME\n")
def anyParamRequiresCcx(member):
for p in member.params:
if isVariantType(p.realtype):
return True
return False
def memberNeedsCcx(member):

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

@ -958,7 +958,7 @@ private:
{
StringWrapperEntry() : mInUse(false) { }
js::AlignedStorage2<XPCReadableJSStringWrapper> mString;
mozilla::AlignedStorage2<XPCReadableJSStringWrapper> mString;
bool mInUse;
};
@ -3037,7 +3037,7 @@ class nsXPCWrappedJSClass : public nsIXPCWrappedJSClass
public:
static nsresult
GetNewOrUsed(XPCCallContext& ccx,
GetNewOrUsed(JSContext* cx,
REFNSIID aIID,
nsXPCWrappedJSClass** clazz);
@ -3051,13 +3051,13 @@ public:
NS_IMETHOD DelegatedQueryInterface(nsXPCWrappedJS* self, REFNSIID aIID,
void** aInstancePtr);
JSObject* GetRootJSObject(XPCCallContext& ccx, JSObject* aJSObj);
JSObject* GetRootJSObject(JSContext* cx, JSObject* aJSObj);
NS_IMETHOD CallMethod(nsXPCWrappedJS* wrapper, uint16_t methodIndex,
const XPTMethodDescriptor* info,
nsXPTCMiniVariant* params);
JSObject* CallQueryInterfaceOnJSObject(XPCCallContext& ccx,
JSObject* CallQueryInterfaceOnJSObject(JSContext* cx,
JSObject* jsobj, REFNSIID aIID);
static nsresult BuildPropertyEnumerator(XPCCallContext& ccx,
@ -3077,7 +3077,7 @@ public:
bool aForceReport);
private:
nsXPCWrappedJSClass(); // not implemented
nsXPCWrappedJSClass(XPCCallContext& ccx, REFNSIID aIID,
nsXPCWrappedJSClass(JSContext* cx, REFNSIID aIID,
nsIInterfaceInfo* aInfo);
JSObject* NewOutObject(JSContext* cx, JSObject* scope);
@ -3151,7 +3151,7 @@ public:
*/
static nsresult
GetNewOrUsed(XPCCallContext& ccx,
GetNewOrUsed(JSContext* cx,
JSObject* aJSObj,
REFNSIID aIID,
nsISupports* aOuter,
@ -3209,7 +3209,7 @@ public:
virtual ~nsXPCWrappedJS();
protected:
nsXPCWrappedJS(); // not implemented
nsXPCWrappedJS(XPCCallContext& ccx,
nsXPCWrappedJS(JSContext* cx,
JSObject* aJSObj,
nsXPCWrappedJSClass* aClass,
nsXPCWrappedJS* root,
@ -3295,6 +3295,7 @@ public:
* chain
* @param pErr [out] relevant error code, if any.
*/
static JSBool NativeData2JS(XPCCallContext& ccx, jsval* d, const void* s,
const nsXPTType& type, const nsID* iid,
nsresult* pErr)
@ -3302,11 +3303,12 @@ public:
XPCLazyCallContext lccx(ccx);
return NativeData2JS(lccx, d, s, type, iid, pErr);
}
static JSBool NativeData2JS(XPCLazyCallContext& lccx, jsval* d,
const void* s, const nsXPTType& type,
const nsID* iid, nsresult* pErr);
static JSBool JSData2Native(XPCCallContext& ccx, void* d, jsval s,
static JSBool JSData2Native(JSContext* cx, void* d, jsval s,
const nsXPTType& type,
JSBool useAllocator, const nsID* iid,
nsresult* pErr);
@ -3353,7 +3355,7 @@ public:
void** dest, JSObject* src,
const nsID* iid,
nsresult* pErr);
static JSBool JSObject2NativeInterface(XPCCallContext& ccx,
static JSBool JSObject2NativeInterface(JSContext* cx,
void** dest, JSObject* src,
const nsID* iid,
nsISupports* aOuter,
@ -3377,11 +3379,11 @@ public:
const nsXPTType& type, const nsID* iid,
uint32_t count, nsresult* pErr);
static JSBool JSArray2Native(XPCCallContext& ccx, void** d, jsval s,
static JSBool JSArray2Native(JSContext* cx, void** d, jsval s,
uint32_t count, const nsXPTType& type,
const nsID* iid, nsresult* pErr);
static JSBool JSTypedArray2Native(XPCCallContext& ccx,
static JSBool JSTypedArray2Native(JSContext* cx,
void** d,
JSObject* jsarray,
uint32_t count,
@ -3938,7 +3940,7 @@ private:
class AutoMarkingPtr
{
public:
AutoMarkingPtr(XPCCallContext& ccx) {
AutoMarkingPtr(JSContext* cx) {
mRoot = XPCJSRuntime::Get()->GetAutoRootsAdr();
mNext = *mRoot;
*mRoot = this;
@ -3974,8 +3976,8 @@ template<class T>
class TypedAutoMarkingPtr : public AutoMarkingPtr
{
public:
TypedAutoMarkingPtr(XPCCallContext& ccx) : AutoMarkingPtr(ccx), mPtr(nullptr) {}
TypedAutoMarkingPtr(XPCCallContext& ccx, T* ptr) : AutoMarkingPtr(ccx), mPtr(ptr) {}
TypedAutoMarkingPtr(JSContext* cx) : AutoMarkingPtr(cx), mPtr(nullptr) {}
TypedAutoMarkingPtr(JSContext* cx, T* ptr) : AutoMarkingPtr(cx), mPtr(ptr) {}
T* get() const { return mPtr; }
operator T *() const { return mPtr; }
@ -4014,10 +4016,10 @@ template<class T>
class ArrayAutoMarkingPtr : public AutoMarkingPtr
{
public:
ArrayAutoMarkingPtr(XPCCallContext& ccx)
: AutoMarkingPtr(ccx), mPtr(nullptr), mCount(0) {}
ArrayAutoMarkingPtr(XPCCallContext& ccx, T** ptr, uint32_t count, bool clear)
: AutoMarkingPtr(ccx), mPtr(ptr), mCount(count)
ArrayAutoMarkingPtr(JSContext* cx)
: AutoMarkingPtr(cx), mPtr(nullptr), mCount(0) {}
ArrayAutoMarkingPtr(JSContext* cx, T** ptr, uint32_t count, bool clear)
: AutoMarkingPtr(cx), mPtr(ptr), mCount(count)
{
if (!mPtr) mCount = 0;
else if (clear) memset(mPtr, 0, mCount*sizeof(T*));
@ -4063,10 +4065,10 @@ typedef ArrayAutoMarkingPtr<XPCNativeInterface> AutoMarkingNativeInterfacePtrArr
#define AUTO_MARK_JSVAL_HELPER2(tok, line) tok##line
#define AUTO_MARK_JSVAL_HELPER(tok, line) AUTO_MARK_JSVAL_HELPER2(tok, line)
#define AUTO_MARK_JSVAL(ccx, val) \
#define AUTO_MARK_JSVAL(cx, val) \
XPCMarkableJSVal AUTO_MARK_JSVAL_HELPER(_val_,__LINE__)(val); \
AutoMarkingJSVal AUTO_MARK_JSVAL_HELPER(_automarker_,__LINE__) \
(ccx, &AUTO_MARK_JSVAL_HELPER(_val_,__LINE__))
(cx, &AUTO_MARK_JSVAL_HELPER(_val_,__LINE__))
/***************************************************************************/
// Allocates a string that grants all access ("AllAccess")
@ -4105,7 +4107,7 @@ public:
// if a given nsIVariant is in fact an XPCVariant.
NS_DECLARE_STATIC_IID_ACCESSOR(XPCVARIANT_IID)
static XPCVariant* newVariant(XPCCallContext& ccx, jsval aJSVal);
static XPCVariant* newVariant(JSContext* cx, jsval aJSVal);
/**
* This getter clears the gray bit before handing out the jsval if the jsval
@ -4128,7 +4130,7 @@ public:
*/
jsval GetJSValPreserveColor() const {return mJSVal;}
XPCVariant(XPCCallContext& ccx, jsval aJSVal);
XPCVariant(JSContext* cx, jsval aJSVal);
/**
* Convert a variant into a jsval.
@ -4162,7 +4164,7 @@ public:
protected:
virtual ~XPCVariant() { }
JSBool InitializeData(XPCCallContext& ccx);
JSBool InitializeData(JSContext* cx);
protected:
nsDiscriminatedUnion mData;
@ -4177,10 +4179,10 @@ class XPCTraceableVariant: public XPCVariant,
public XPCRootSetElem
{
public:
XPCTraceableVariant(XPCCallContext& ccx, jsval aJSVal)
: XPCVariant(ccx, aJSVal)
XPCTraceableVariant(JSContext* cx, jsval aJSVal)
: XPCVariant(cx, aJSVal)
{
ccx.GetRuntime()->AddVariantRoot(this);
nsXPConnect::GetRuntimeInstance()->AddVariantRoot(this);
}
virtual ~XPCTraceableVariant();

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

@ -77,6 +77,7 @@ MOCHITEST_FILES = bug500931_helper.html \
file_mozMatchesSelector.html \
file_bug720619.html \
test_bug720619.html \
test_bug785096.html \
$(NULL)
MOCHITEST_CHROME_FILES = \

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

@ -0,0 +1,39 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=390488
-->
<head>
<title>Test for Bug 785096</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="test()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=785096">Mozilla Bug 785096</a>
<script class="testbody" type="text/javascript">
/** Test for Bug 785096 **/
SimpleTest.waitForExplicitFinish();
function test()
{
var sel = document.createElementNS('http://www.w3.org/1999/xhtml', 'select');
var option=document.createElement("option");
option.text="Fubar";
sel.options.add(option);
try {
Components.lookupMethod(sel.options, "add")(option);
ok(true, "function call should not throw")
} catch(e) {
do_throw("this call should just work without any exceptions");
}
SimpleTest.finish();
}
</script>
</pre>
</body>
</html>