7

I try to understand Firefox's behavior regarding the added "prevent this page from creating additional dialogs" on dialog boxes.

Using jquery, if I add the following listeners :

//html
<input class="testInput" />

//javascript
$('.testInput')
.click(function(){ alert('clicked') })
.keyup(function(){ alert('keyup') })
  1. When clicking on the input, the alert box appears normally, until the ~13th time.
  2. When hitting a key, on the other hand, the second message box already appears with the message "prevent this page from creating additional dialogs". Actually, there seems to be some tiemout, and if I wait like 2 seconds between two keystrokes, the message disappears.

From my informal tests, 2. actually applies whenever the alert box is not called from within a onclick callback (e.g : keyup callback, displaying an alert box in answer to an ajax action...)

I am using Firefox 9.0.1 under Ubuntu, as far as I know I haven't tweaked firefox's settings regarding these thresholds. I imagine it happens with any recent version of any browser.

I am using the jQuery library, but I don't think it is relevant here.

My question is : What are the exact rules which make this warning appear in a dialog box ?

[Edit]

Using Chromium/Ubuntu (version 17.0.963.26), the threshold seems to be only the delay between two dialog boxes.

You can test this from jsfiddle here (thx Rory McCrossan)

5
  • 1
    FYI: testing with this fiddle (jsfiddle.net/RoryMcCrossan/9XwTn) I get the checkbox in the alert on the 12th iteration for both click and keyup. Commented Jan 13, 2012 at 13:33
  • @Rory : I still have my behavior. What browser do you have ? thx for the jsfiddle link.
    – LeGEC
    Commented Jan 13, 2012 at 13:37
  • Just to fill in with some more data input; I get it on the 12th click iteration and 2nd keyup iteration on FF 9.0.1 Windows XP SP3. Commented Jan 13, 2012 at 13:40
  • @LeGEC sorry forgot to mention browser, FF9.0.1 on W7 Pro x64 Commented Jan 13, 2012 at 14:41
  • How to reset this ? Now I want the dialogs again ! Commented Jan 22, 2014 at 13:24

2 Answers 2

6

The exact rule(s): A timed interval between the dialog boxes popping up. The value used to determine this is set in SUCCESSIVE_DIALOG_TIME_LIMIT

Check out line 2614 in the link below the snippet:

nsGlobalWindow::DialogOpenAttempted()

TimeDuration dialogDuration(TimeStamp::Now() - topWindow->mLastDialogQuitTime);

if (dialogDuration.ToSeconds() < Preferences::GetInt("dom.successive_dialog_time_limit",SUCCESSIVE_DIALOG_TIME_LIMIT)){topWindow->mDialogAbuseCount++;return (topWindow->GetPopupControlState() > openAllowed || topWindow->mDialogAbuseCount > MAX_DIALOG_COUNT);}topWindow->mDialogAbuseCount = 0; return false;}

Link to source

1
1

You can kick around the Firefox source if you like. Note that different browsers will have different rules.

The relevant code for Firefox is in nsGlobalWindow.cpp and nsGlobalWindow.h (the links below are to line numbers, and so will slowly rot as the source changes). It appears to be controlled by the constants MAX_DIALOG_COUNT (10) in nsGlobalWindow.h and SUCCESSIVE_DIALOG_TIME_LIMIT (3, units are seconds). nsGlobalWindow.cpp keeps a count (mDialogAbuseCount). Apparently, the dialogDuration function either increments or clears mDialogAbuseCount depending on whether the dialog has been open longer than the SUCCESSIVE_DIALOG_TIME_LIMIT. The AreDialogsBlocked function uses the mDialogAbuseCount (in part) to decide whether they're blocked.

So in short: If you're repeatedly opening pop-ups and then closing them within three seconds, after 10 or so you'll trigger something.

Not the answer you're looking for? Browse other questions tagged or ask your own question.