mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-18 15:55:36 +00:00
Bug 636905 - part 2: check for document interactivity state when prompting for beforeunload, r=bz
--HG-- extra : commitid : 3jpKjuOULpC extra : rebase_source : 8f033b0febca4cda10a46b48169772e20b21c7b6
This commit is contained in:
parent
8e06164f35
commit
ff07a9d7e5
@ -128,6 +128,7 @@ using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
#define BEFOREUNLOAD_DISABLED_PREFNAME "dom.disable_beforeunload"
|
||||
#define BEFOREUNLOAD_REQUIRES_INTERACTION_PREFNAME "dom.require_user_interaction_for_beforeunload"
|
||||
|
||||
//-----------------------------------------------------
|
||||
// LOGGING
|
||||
@ -1074,12 +1075,15 @@ nsDocumentViewer::PermitUnloadInternal(bool aCallerClosesWindow,
|
||||
}
|
||||
|
||||
static bool sIsBeforeUnloadDisabled;
|
||||
static bool sBeforeUnloadPrefCached = false;
|
||||
static bool sBeforeUnloadRequiresInteraction;
|
||||
static bool sBeforeUnloadPrefsCached = false;
|
||||
|
||||
if (!sBeforeUnloadPrefCached ) {
|
||||
sBeforeUnloadPrefCached = true;
|
||||
if (!sBeforeUnloadPrefsCached ) {
|
||||
sBeforeUnloadPrefsCached = true;
|
||||
Preferences::AddBoolVarCache(&sIsBeforeUnloadDisabled,
|
||||
BEFOREUNLOAD_DISABLED_PREFNAME);
|
||||
Preferences::AddBoolVarCache(&sBeforeUnloadRequiresInteraction,
|
||||
BEFOREUNLOAD_REQUIRES_INTERACTION_PREFNAME);
|
||||
}
|
||||
|
||||
// First, get the script global object from the document...
|
||||
@ -1137,7 +1141,10 @@ nsDocumentViewer::PermitUnloadInternal(bool aCallerClosesWindow,
|
||||
nsAutoString text;
|
||||
beforeUnload->GetReturnValue(text);
|
||||
|
||||
if (!sIsBeforeUnloadDisabled && *aShouldPrompt && dialogsAreEnabled &&
|
||||
// NB: we nullcheck mDocument because it might now be dead as a result of
|
||||
// the event being dispatched.
|
||||
if (!sIsBeforeUnloadDisabled && *aShouldPrompt && dialogsAreEnabled && mDocument &&
|
||||
(!sBeforeUnloadRequiresInteraction || mDocument->UserHasInteracted()) &&
|
||||
(event->GetInternalNSEvent()->mFlags.mDefaultPrevented ||
|
||||
!text.IsEmpty())) {
|
||||
// Ask the user if it's ok to unload the current page
|
||||
|
@ -1030,6 +1030,8 @@ pref("dom.disable_window_open_feature.status", true);
|
||||
|
||||
pref("dom.allow_scripts_to_close_windows", false);
|
||||
|
||||
pref("dom.require_user_interaction_for_beforeunload", true);
|
||||
|
||||
pref("dom.disable_open_during_load", false);
|
||||
pref("dom.popup_maximum", 20);
|
||||
pref("dom.popup_allowed_events", "change click dblclick mouseup notificationclick reset submit touchend");
|
||||
|
Loading…
Reference in New Issue
Block a user