Bug 1107771 - disabling beforeunload should only disable the dialog, not the event, r=bz

This commit is contained in:
Gijs Kruitbosch 2014-12-05 10:31:30 -08:00
Родитель 8793667ad9
Коммит b714ba6ff5
1 изменённых файлов: 4 добавлений и 7 удалений

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

@ -1088,11 +1088,6 @@ nsDocumentViewer::PermitUnloadInternal(bool aCallerClosesWindow,
BEFOREUNLOAD_DISABLED_PREFNAME);
}
// If the user has turned off onbeforeunload warnings, no need to check.
if (sIsBeforeUnloadDisabled) {
return NS_OK;
}
// First, get the script global object from the document...
nsPIDOMWindow *window = mDocument->GetWindow();
@ -1147,8 +1142,10 @@ nsDocumentViewer::PermitUnloadInternal(bool aCallerClosesWindow,
nsCOMPtr<nsIDocShell> docShell(mContainer);
nsAutoString text;
beforeUnload->GetReturnValue(text);
if (*aShouldPrompt && (event->GetInternalNSEvent()->mFlags.mDefaultPrevented ||
!text.IsEmpty())) {
if (!sIsBeforeUnloadDisabled && *aShouldPrompt &&
(event->GetInternalNSEvent()->mFlags.mDefaultPrevented ||
!text.IsEmpty())) {
// Ask the user if it's ok to unload the current page
nsCOMPtr<nsIPrompt> prompt = do_GetInterface(docShell);