Prevent this page from creating addtional dialogs

Discuss how to use and promote Web standards with the Mozilla Gecko engine.
ksisteve
Posts: 10
Joined: April 20th, 2011, 11:57 am

Prevent this page from creating addtional dialogs

Post by ksisteve »

Need to have an about:config parameter to prevent the message:

Confirm Dialog Preference

? Prevent this page from creating additional dialogs

OK Cancel

we use javascript window.showModalDialog in several places where the user must make a decision before continuing, and this error is popping up every single time (unless they actually press OK instead of Cancel and the software just stops working in that tab altogether).

We have dom.popup_maximum set to 999999999 and the server site included in the Allowed Sites - Pop-ups

Thank you for your help.

Steve Owen
User avatar
DanRaisch
Moderator
Posts: 127187
Joined: September 23rd, 2004, 8:57 pm
Location: Somewhere on the right coast

Re: Prevent this page from creating addtional dialogs

Post by DanRaisch »

Moving to Web Development.
User avatar
jscher2000
Posts: 11742
Joined: December 19th, 2004, 12:26 am
Location: Silicon Valley, CA USA
Contact:

Re: Prevent this page from creating addtional dialogs

Post by jscher2000 »

How many modal dialogs can you display before getting a message? Does the count reset if you reload the page?
ksisteve
Posts: 10
Joined: April 20th, 2011, 11:57 am

Re: Prevent this page from creating addtional dialogs

Post by ksisteve »

Definitely a good question. It appears to be 10. I've searched thru about:config for all values=10, and none appear (to me) to be related to the problem.
ksisteve
Posts: 10
Joined: April 20th, 2011, 11:57 am

Re: Prevent this page from creating addtional dialogs

Post by ksisteve »

In reviewing the original post, I note that I omitted the relevant fact that this is a new problem in Firefox 4.0 downloaded on 4/20/2011.
User avatar
jscher2000
Posts: 11742
Joined: December 19th, 2004, 12:26 am
Location: Silicon Valley, CA USA
Contact:

Re: Prevent this page from creating addtional dialogs

Post by jscher2000 »

ksisteve wrote:I omitted the relevant fact that this is a new problem in Firefox 4.0 downloaded on 4/20/2011.

Yes, a maximum dialog count apparently was added as a result of the request in Bug #61098 (Bug 61098 – Exit all currently active scripts (allow aborting modal window.alert() loops in javascript (js))). That thread is insanely long, but if you search for MAX_DIALOG_COUNT someone mentions that it is set to 10 (and complains that it doesn't fire until the 12th dialog). That sounds as though it is in the code, and not a preference that could be altered by a user.

Curiously, there is another bug with test cases demonstrating you can trigger it on the second showModalDialog if the calls are sequential in the code. (See Bug 600189 – Minefield asks to prevent additional dialogs after showModalDialog, although they were not displayed.)

Anyway, yeah, legitimate uses are going to get caught up in this. You might need to rethink how you use pop-ups going forward.
ksisteve
Posts: 10
Joined: April 20th, 2011, 11:57 am

Re: Prevent this page from creating addtional dialogs

Post by ksisteve »

Thank you for your response. I'm new to this posting process. Does this mean that a new bug will be initiated, or am I supposed to do something further to initiate a new bug request, or was this a final answer and it's up to me to modify the thousands of lines of code before 3.6 is no longer supported? Thank you for your help.
User avatar
jscher2000
Posts: 11742
Joined: December 19th, 2004, 12:26 am
Location: Silicon Valley, CA USA
Contact:

Re: Prevent this page from creating addtional dialogs

Post by jscher2000 »

edit: Just a note that this is an unofficial forum. We're not the developers and have basically no say in what happens with Firefox.

I think you're stuck with the limit of 10 for now, unless someone has discovered a workaround. Fx4 might be too new for that, but you never know.

You could post a bug proposing that it be made a user preference, but would that really help you? How many users are going to change a preference before changing browsers?

(I don't know that this issue ultimately demands modifying thousands of lines of code -- I know nothing about your application -- but users don't really enjoy modal dialogs, so if nothing else it's an opportunity to think about alternatives.)
ksisteve
Posts: 10
Joined: April 20th, 2011, 11:57 am

Re: Prevent this page from creating addtional dialogs

Post by ksisteve »

"edit: Just a note that this is an unofficial forum. We're not the developers and have basically no say in what happens with Firefox."

ok, so i'm on the wrong site

and, in this particular case, we're talking intranet, not internet per se, so having the users change a preference solves the problem. And modal dialogs, despite the opinion of many, have an important place in large applications. I'm not defending the use by advertisers on small web pages.
User avatar
jscher2000
Posts: 11742
Joined: December 19th, 2004, 12:26 am
Location: Silicon Valley, CA USA
Contact:

Re: Prevent this page from creating addtional dialogs

Post by jscher2000 »

This isn't the wrong site for feedback on questions, but to actually get something into the development process, it makes sense to file a bug.

In an effort to be more helpful, I downloaded the source code for Firefox 4.0 and searched around a bit for MAX_DIALOG_COUNT. The file mozilla-2.0\dom\base\nsGlobalWindow.h contains:

Code: Select all

// Amount of time allowed between alert/prompt/confirm before enabling
// the stop dialog checkbox.
#define SUCCESSIVE_DIALOG_TIME_LIMIT 3 // 3 sec

// During click or mousedown events (and others, see nsDOMEvent) we allow modal
// dialogs up to this limit, even if they were disabled.
#define MAX_DIALOG_COUNT 10


I don't read C++ but it appears that unless the dialogs come closer together than that first setting, the "abuse count" does not increment (this is from mozilla-2.0\dom\base\nsGlobalWindow.cpp):

Code: Select all

bool
nsGlobalWindow::DialogOpenAttempted()
{
  nsGlobalWindow *topWindow = GetTop();
  if (!topWindow) {
    NS_ERROR("DialogOpenAttempted() called without a top window?");

    return false;
  }

  topWindow = topWindow->GetCurrentInnerWindowInternal();
  if (!topWindow ||
      topWindow->mLastDialogQuitTime.IsNull() ||
      nsContentUtils::IsCallerTrustedForCapability("UniversalXPConnect")) {
    return false;
  }

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

  if (dialogDuration.ToSeconds() <
      nsContentUtils::GetIntPref("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;
}


Based on that code, there appears to be a hidden preference for that first setting, which you can test by setting it to zero:

dom.successive_dialog_time_limit = 0

Does that solve the problem? Note that this is global, so users will lose the "dialog abuse" protection for all sites.

I couldn't find any place in nsGlobalWindow.cpp that a preference could override the predefined value of MAX_DIALOG_COUNT. Since mDialogAbuseCount appears to be a property of a window object, I wonder whether a script with elevated privileges (or a signed script) could reset mDialogAbuseCount to zero. I just don't know enough about how Firefox operates to know whether that is an option. If so, it would be a neater solution because Firefox will exhibit default behavior on other sites that do not have privileges to modify browser settings.
User avatar
trolly
Moderator
Posts: 39851
Joined: August 22nd, 2005, 7:25 am

Re: Prevent this page from creating addtional dialogs

Post by trolly »

The other direction.
dom.successive_dialog_time_limit is the minimum delta time between dialogues. If dialogues appear more frequent then the abuse counter is incremented and if the abuse counter reaches MAX_DIALOG_COUNT then no more dialogues can be opened.

But it is correct that setting it to zero should disable the behaviour.
Think for yourself. Otherwise you have to believe what other people tell you.
A society based on individualism is an oxymoron. || Freedom is at first the freedom to starve.
Constitution says: One man, one vote. Supreme court says: One dollar, one vote.
User avatar
dickvl
Posts: 54145
Joined: July 18th, 2005, 3:25 am

Re: Prevent this page from creating addtional dialogs

Post by dickvl »

You can hide that checkbox with code in userChrome.css

Code: Select all

@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
#content tabmodalprompt checkbox[label^="Prevent"] {display:none!important;}


See http://kb.mozillazine.org/Editing_configuration
ksisteve
Posts: 10
Joined: April 20th, 2011, 11:57 am

Re: Prevent this page from creating addtional dialogs

Post by ksisteve »

there is a bug report that users with the same problem can add their name to:

https://support.mozilla.com/en-US/questions/793625
User avatar
jscher2000
Posts: 11742
Joined: December 19th, 2004, 12:26 am
Location: Silicon Valley, CA USA
Contact:

Re: Prevent this page from creating addtional dialogs

Post by jscher2000 »

ksisteve wrote:there is a bug report that users with the same problem can add their name to:
https://support.mozilla.com/en-US/questions/793625

You can click "I have this problem, too" but actually it might be more useful to list the URLs of sites that have this problem.

Edit: I meant to ask, does this solve it?
dom.successive_dialog_time_limit = 0
ksisteve
Posts: 10
Joined: April 20th, 2011, 11:57 am

Re: Prevent this page from creating addtional dialogs

Post by ksisteve »

I'm sorry, i'm just not getting this. I followed the instructions in http://kb.mozillazine.org/index.php?tit ... Chrome.css
to locate the folder, created a file called userChrome.css with a cut & paste without modification of the text from dickvl above, restarted firefox and still have the same problem.

(On my windows 7 laptop running firefox 4, the file was created as c:\Users\steve\AppData\Roaming\Mozilla\Firefox\Profiles\f54slv98.default\Chrome\userChrome.css)

thanks for any help
Post Reply