Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Disabling modal dialogs(alert, ...) for a specific tab only

21 views
Skip to first unread message

Hardip

unread,
Dec 27, 2009, 6:16:11 AM12/27/09
to
i have tried using a system like this (from browser.xul scope):

i am only focusing on alert() at the moment:
http://pastebin.mozilla.org/693218

this works if the alert() calls in the HTML of the loaded webpage are
initiated after the DOM of the webpage is loaded. However, alerts that
are called during the building of the DOM, still use the built-in alert
() call which hasn't been overridden yet like in the case of this
HTML:
http://pastebin.mozilla.org/693217

My aim is to disable alert(), prompt() and so on for a certain tab
only, but i can't seem to disable alert() at the right moment for the
content that is loading in a tab.

It has been suggested that i overwrite commonDialog.xul, but that
would probably disable alert for all tabs in the browser and that
wouldn't be cool.

Some have suggested looking into the Mozmill test app which deals with
UI testing automation (including automatically closing alert windows),
but it does not provide what i am looking for.

Maybe there are events such as DOMWillBeGeneratedShortly, after which
DOMContentLoaded gets called. I would probably need to do my alert
disabling after that 1st event and before the 2nd, because apparently
the runtime alerts that are bothering me happen just before the 2nd
event.
Is there such a hypothetical event? I haven't found any good resource
for finding out the event chains that are fired during the loading of
a tab.

Eric Jung

unread,
Dec 27, 2009, 5:09:11 PM12/27/09
to dev-ext...@lists.mozilla.org

How about executing your code in your windowLoaded() event handler instead
of DOMLoaded event handler()?

Another idea is to implement your own nsIPromptService XPCOM component, and
install your component as the default instead of Gecko's. You can then
delegate some call alert() calls to the Gecko implementation and eat others,
as you like.

Eric

Hardip

unread,
Dec 28, 2009, 11:07:27 AM12/28/09
to
> How about executing your code in your windowLoaded() event handler instead
> of DOMLoaded event handler()?
i will try this shortly and let know how it went

>
> Another idea is to implement your own nsIPromptService XPCOM component, and
> install your component as the default instead of Gecko's. You can then
> delegate some call alert() calls to the Gecko implementation and eat others,
> as you like.

that seems like a great idea. that would give me the most flexible
system for this. can you point me to a resource/example/tutorial that
talks me through such a process?

Hardip

unread,
Dec 29, 2009, 9:38:31 AM12/29/09
to

> How about executing your code in your windowLoaded() event handler instead
> of DOMLoaded event handler()?
the windowLoaded is called only when a new visible window is created.
that's not good enough.
0 new messages