зеркало из https://github.com/mozilla/gecko-dev.git
Bug 874158 - Crash in GetNativeForGlobal. r=bholley
This commit is contained in:
Родитель
4f61dc3337
Коммит
5cbb7ab212
|
@ -132,9 +132,11 @@ nsDOMFileReader::Init()
|
|||
mPrincipal.swap(principal);
|
||||
|
||||
// Instead of grabbing some random global from the context stack,
|
||||
// let's use the default one (junk drawer) for now.
|
||||
// let's use the default one (junk scope) for now.
|
||||
// We should move away from this Init...
|
||||
BindToOwner(xpc::GetNativeForGlobal(xpc::GetJunkScope()));
|
||||
nsCOMPtr<nsIGlobalObject> global = xpc::GetJunkScopeGlobal();
|
||||
NS_ENSURE_TRUE(global, NS_ERROR_FAILURE);
|
||||
BindToOwner(global);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1954,7 +1954,9 @@ nsDocument::Init()
|
|||
// we use the default compartment for this document, instead of creating
|
||||
// wrapper in some random compartment when the document is exposed to js
|
||||
// via some events.
|
||||
mScopeObject = do_GetWeakReference(xpc::GetNativeForGlobal(xpc::GetJunkScope()));
|
||||
nsCOMPtr<nsIGlobalObject> global = xpc::GetJunkScopeGlobal();
|
||||
NS_ENSURE_TRUE(global, NS_ERROR_FAILURE);
|
||||
mScopeObject = do_GetWeakReference(global);
|
||||
MOZ_ASSERT(mScopeObject);
|
||||
|
||||
// Force initialization.
|
||||
|
|
|
@ -356,9 +356,11 @@ nsXMLHttpRequest::Init()
|
|||
NS_ENSURE_STATE(subjectPrincipal);
|
||||
|
||||
// Instead of grabbing some random global from the context stack,
|
||||
// let's use the default one (junk drawer) for now.
|
||||
// let's use the default one (junk scope) for now.
|
||||
// We should move away from this Init...
|
||||
Construct(subjectPrincipal, xpc::GetNativeForGlobal(xpc::GetJunkScope()));
|
||||
nsCOMPtr<nsIGlobalObject> global = xpc::GetJunkScopeGlobal();
|
||||
NS_ENSURE_TRUE(global, NS_ERROR_FAILURE);
|
||||
Construct(subjectPrincipal, global);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -396,6 +396,17 @@ GetJunkScope()
|
|||
return self->GetJunkScope();
|
||||
}
|
||||
|
||||
nsIGlobalObject *
|
||||
GetJunkScopeGlobal()
|
||||
{
|
||||
JSObject *junkScope = GetJunkScope();
|
||||
// GetJunkScope would ideally never fail, currently it is not yet the case
|
||||
// unfortunately...(see Bug 874158)
|
||||
if (!junkScope)
|
||||
return nullptr;
|
||||
return GetNativeForGlobal(junkScope);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -413,6 +413,13 @@ GetNativeForGlobal(JSObject *global);
|
|||
*/
|
||||
JSObject *
|
||||
GetJunkScope();
|
||||
|
||||
/**
|
||||
* Returns the native global of the junk scope. See comment of GetJunkScope
|
||||
* about the conditions of using it.
|
||||
*/
|
||||
nsIGlobalObject *
|
||||
GetJunkScopeGlobal();
|
||||
} // namespace xpc
|
||||
|
||||
namespace mozilla {
|
||||
|
|
Загрузка…
Ссылка в новой задаче