зеркало из https://github.com/mozilla/gecko-dev.git
Bug 903891 - Default the iid to nsISupports in NativeInterface2JSObject, and assert |Interface| when getting an XPCWrappedNative. r=mrbkap
This commit is contained in:
Родитель
ae571db69f
Коммит
e4d85c190a
|
@ -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;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче