Bug 353851 - "accumulation of outer chrome windows in mOpener chains (window.opener)". r+sr=jst. a=blocking1.9.

This commit is contained in:
bent.mozilla%gmail.com 2008-02-07 23:13:01 +00:00
Родитель 40b7a3a598
Коммит 35ec38a6cd
2 изменённых файлов: 12 добавлений и 10 удалений

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

@ -930,8 +930,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsGlobalWindow)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mContext)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOpener)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mControllers)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mArguments)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mArgumentsLast)
@ -974,8 +972,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindow)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mContext)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOpener)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mControllers)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mArguments)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mArgumentsLast)
@ -2073,7 +2069,9 @@ nsGlobalWindow::SetOpenerWindow(nsIDOMWindowInternal* aOpener,
NS_ASSERTION(aOpener || !aOriginalOpener,
"Shouldn't set mHadOriginalOpener if aOpener is null");
mOpener = aOpener;
mOpener = do_GetWeakReference(aOpener);
NS_ASSERTION(mOpener, "Opener must support weak references!");
if (aOriginalOpener) {
mHadOriginalOpener = PR_TRUE;
}
@ -2801,11 +2799,15 @@ nsGlobalWindow::GetOpener(nsIDOMWindowInternal** aOpener)
FORWARD_TO_OUTER(GetOpener, (aOpener), NS_ERROR_NOT_INITIALIZED);
*aOpener = nsnull;
// First, check if we were called from a privileged chrome script
nsCOMPtr<nsIDOMWindowInternal> opener = do_QueryReferent(mOpener);
if (!opener) {
return NS_OK;
}
// First, check if we were called from a privileged chrome script
if (nsContentUtils::IsCallerTrustedForRead()) {
*aOpener = mOpener;
NS_IF_ADDREF(*aOpener);
NS_ADDREF(*aOpener = opener);
return NS_OK;
}
@ -2825,7 +2827,7 @@ nsGlobalWindow::GetOpener(nsIDOMWindowInternal** aOpener)
PRUint32 appType;
nsresult rv = openerRootDocShell->GetAppType(&appType);
if (NS_SUCCEEDED(rv) && appType != nsIDocShell::APP_TYPE_MAIL) {
*aOpener = mOpener;
*aOpener = opener;
}
}
}

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

@ -663,7 +663,7 @@ protected:
PRPackedBool mIsChrome : 1;
nsCOMPtr<nsIScriptContext> mContext;
nsCOMPtr<nsIDOMWindowInternal> mOpener;
nsWeakPtr mOpener;
nsCOMPtr<nsIControllers> mControllers;
nsCOMPtr<nsIArray> mArguments;
nsCOMPtr<nsIArray> mArgumentsLast;