diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index d4df769127c..b450cac9669 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -1599,6 +1599,11 @@ evt.initUIEvent("TabClose", true, false, window, aTabWillBeMoved ? 1 : 0); aTab.dispatchEvent(evt); + // Prevent this tab from showing further dialogs, since we're closing it + var windowUtils = browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor). + getInterface(Ci.nsIDOMWindowUtils); + windowUtils.preventFurtherDialogs(); + // Remove the tab's filter and progress listener. const filter = this.mTabFilters[aTab._tPos]; #ifdef MOZ_E10S_COMPAT diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 5ae971245d3..669302005e3 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -1936,3 +1936,8 @@ nsDOMWindowUtils::CheckAndClearPaintedState(nsIDOMElement* aElement, bool* aResu return NS_OK; } +NS_IMETHODIMP +nsDOMWindowUtils::PreventFurtherDialogs() { + mWindow->PreventFurtherDialogs(); + return NS_OK; +} diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 52211ee2540..e49b89d31ea 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -2627,10 +2627,7 @@ nsGlobalWindow::AreDialogsBlocked() topWindow = topWindow->GetCurrentInnerWindowInternal(); - return !topWindow || - (topWindow->mDialogDisabled && - (topWindow->GetPopupControlState() > openAllowed || - topWindow->mDialogAbuseCount >= MAX_DIALOG_COUNT)); + return !topWindow || topWindow->mDialogDisabled; } bool diff --git a/dom/interfaces/base/nsIDOMWindowUtils.idl b/dom/interfaces/base/nsIDOMWindowUtils.idl index 09dd00d6dc4..438aefc0051 100644 --- a/dom/interfaces/base/nsIDOMWindowUtils.idl +++ b/dom/interfaces/base/nsIDOMWindowUtils.idl @@ -926,4 +926,9 @@ interface nsIDOMWindowUtils : nsISupports { */ boolean checkAndClearPaintedState(in nsIDOMElement aElement); + /** + * Prevent this window (and any child windows) from displaying any further + * dialogs (e.g. window.alert()). + */ + void preventFurtherDialogs(); };