Bug 903891 - Default the iid to nsISupports in NativeInterface2JSObject, and assert |Interface| when getting an XPCWrappedNative. r=mrbkap

This commit is contained in:
Bobby Holley 2013-08-22 15:51:35 -07:00
Родитель ae571db69f
Коммит e4d85c190a
2 изменённых файлов: 10 добавлений и 9 удалений

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

@ -801,8 +801,9 @@ XPCConvert::NativeInterface2JSObject(jsval* d,
bool allowNativeWrapper,
nsresult* pErr)
{
MOZ_ASSERT(!Interface || iid,
"Need the iid if you pass in an XPCNativeInterface cache.");
MOZ_ASSERT_IF(Interface, iid);
if (!iid)
iid = &NS_GET_IID(nsISupports);
*d = JSVAL_NULL;
if (dest)

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

@ -423,6 +423,7 @@ XPCWrappedNative::GetNewOrUsed(xpcObjectHelper& helper,
XPCNativeInterface* Interface,
XPCWrappedNative** resultWrapper)
{
MOZ_ASSERT(Interface);
AutoJSContext cx;
nsWrapperCache *cache = helper.GetWrapperCache();
@ -456,8 +457,7 @@ XPCWrappedNative::GetNewOrUsed(xpcObjectHelper& helper,
}
if (wrapper) {
if (Interface &&
!wrapper->FindTearOff(Interface, false, &rv)) {
if (!wrapper->FindTearOff(Interface, false, &rv)) {
MOZ_ASSERT(NS_FAILED(rv), "returning NS_OK on failure");
return rv;
}
@ -477,8 +477,7 @@ XPCWrappedNative::GetNewOrUsed(xpcObjectHelper& helper,
// If we are making a wrapper for the nsIClassInfo interface then
// We *don't* want to have it use the prototype meant for instances
// of that class.
bool iidIsClassInfo = Interface &&
Interface->GetIID()->Equals(NS_GET_IID(nsIClassInfo));
bool iidIsClassInfo = Interface->GetIID()->Equals(NS_GET_IID(nsIClassInfo));
uint32_t classInfoFlags;
bool isClassInfoSingleton = helper.GetClassInfo() == helper.Object() &&
NS_SUCCEEDED(helper.GetClassInfo()
@ -552,7 +551,7 @@ XPCWrappedNative::GetNewOrUsed(xpcObjectHelper& helper,
}
if (wrapper) {
if (Interface && !wrapper->FindTearOff(Interface, false, &rv)) {
if (wrapper->FindTearOff(Interface, false, &rv)) {
MOZ_ASSERT(NS_FAILED(rv), "returning NS_OK on failure");
return rv;
}
@ -615,7 +614,7 @@ XPCWrappedNative::GetNewOrUsed(xpcObjectHelper& helper,
if (!wrapper->Init(parent, &sciWrapper))
return NS_ERROR_FAILURE;
if (Interface && !wrapper->FindTearOff(Interface, false, &rv)) {
if (!wrapper->FindTearOff(Interface, false, &rv)) {
MOZ_ASSERT(NS_FAILED(rv), "returning NS_OK on failure");
return rv;
}
@ -724,6 +723,7 @@ XPCWrappedNative::GetUsedOnly(nsISupports* Object,
{
AutoJSContext cx;
MOZ_ASSERT(Object, "XPCWrappedNative::GetUsedOnly was called with a null Object");
MOZ_ASSERT(Interface);
nsRefPtr<XPCWrappedNative> wrapper;
nsWrapperCache* cache = nullptr;
@ -756,7 +756,7 @@ XPCWrappedNative::GetUsedOnly(nsISupports* Object,
}
nsresult rv;
if (Interface && !wrapper->FindTearOff(Interface, false, &rv)) {
if (!wrapper->FindTearOff(Interface, false, &rv)) {
MOZ_ASSERT(NS_FAILED(rv), "returning NS_OK on failure");
return rv;
}