Fixing bug 259117. Prevent popups when closing a window even if the close came from a user action that would normally enable popups. r=bzbarsky@mit.edu, sr=brendan@mozilla.org

This commit is contained in:
jst%mozilla.jstenback.com 2004-09-14 06:03:34 +00:00
Родитель 104a25fa65
Коммит 1a86b2d55d
2 изменённых файлов: 20 добавлений и 8 удалений

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

@ -3129,11 +3129,11 @@ nsDocShell::Create()
NS_IMETHODIMP
nsDocShell::Destroy()
{
mIsBeingDestroyed = PR_TRUE;
//Fire unload event before we blow anything away.
(void) FireUnloadNotification();
mIsBeingDestroyed = PR_TRUE;
// Stop any URLs that are currently being loaded...
Stop(nsIWebNavigation::STOP_ALL);
if (mDocLoader) {
@ -3771,10 +3771,6 @@ nsDocShell::ScrollByPages(PRInt32 numPages)
nsIScriptGlobalObject*
nsDocShell::GetScriptGlobalObject()
{
if (mIsBeingDestroyed) {
return nsnull;
}
NS_ENSURE_SUCCESS(EnsureScriptEnvironment(), nsnull);
return mScriptGlobal;

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

@ -2958,6 +2958,7 @@ PopupControlState
GlobalWindowImpl::CheckForAbusePoint()
{
nsCOMPtr<nsIDocShellTreeItem> item(do_QueryInterface(mDocShell));
PRBool isBeingDestroyed = PR_FALSE;
if (item) {
PRInt32 type = nsIDocShellTreeItem::typeChrome;
@ -2965,11 +2966,26 @@ GlobalWindowImpl::CheckForAbusePoint()
item->GetItemType(&type);
if (type != nsIDocShellTreeItem::typeContent)
return openAllowed;
while (item) {
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(item));
docShell->IsBeingDestroyed(&isBeingDestroyed);
if (isBeingDestroyed) {
break;
}
nsIDocShellTreeItem *tmp = item;
tmp->GetParent(getter_AddRefs(item));
}
}
// level of abuse we've detected, initialized to the current popup
// state
PopupControlState abuse = gPopupControlState;
// state, except in the case where this window is being destroyed
// since then we override the current state and prevent popups
// alltogether.
PopupControlState abuse = isBeingDestroyed ? openAbused : gPopupControlState;
// limit the number of simultaneously open popups
if (abuse == openAbused || abuse == openControlled) {