event.preventDefault no longer works in DOMWillOpenModalDialog

NEW
Unassigned

Status

Thunderbird
General
6 years ago
10 months ago

People

(Reporter: M8R-948xqx, Unassigned)

Tracking

({regression})

Trunk
All
Other
regression

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

6 years ago
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.30 (KHTML, like Gecko) Ubuntu/10.10 Chromium/12.0.742.91 Chrome/12.0.742.91 Safari/534.30

Steps to reproduce:

When I used event.preventDefault after hearing the DOMWillOpenModalDialog event in Firefox versions < 4.0 the DOM dialog did not open.


Actual results:

In Version 4.0 and above, calling event.preventDefault has no effect on the modal dialog, even though it should prevent the dialog from appearing.

furthermore, event.cancelable is true


Expected results:

the dialog should not be created at all

Updated

6 years ago
Keywords: regression
Hmm. nsPrompter.js :: fireDialogEvent() just fires the event and moves on. I remember this issue coming up, but I thought we were still supporting it... Guess not!

What are you using this event for?

Long term, the idea was to make is a notification instead of a DOM event.
Status: UNCONFIRMED → NEW
Component: Extension Compatibility → General
Ever confirmed: true
Product: Firefox → Thunderbird
QA Contact: extension.compatibility → general
Version: 4.0 Branch → Trunk

Comment 2

5 years ago
I am using this event for cancelling the Modal Dialog. This is necessary for a feature in an extension i am building. Having the ability to prevent the modal dialog from popping up is a feature which in my case is very useful and convenient. Having it removed/malfunction is a deal-breaker in my case.

In any case, I think it should be treated as a DOM Event and should be cancelable, like it was when it was still working.

Comment 3

4 years ago
Have you found the solution?

I believe this bug is still in Firefox, why was the Product switched to Thunderbird?

Comment 4

4 years ago
There is no solution as of yet, only workarounds for specific cases.

The bug is in Firefox indeed, I don't know why it was switched to Thunderbird.

Comment 5

4 years ago
Thanks for your reply!

So, for those who will stumble upon this bug in future and need any solution to simply dismiss dialogs from chrome code here is quick workaround I came to:

gBrowser.selectedBrowser.addEventListener("DOMWillOpenModalDialog", function (e)
	Services.obs.addObserver(function observer (subject, topic, data) {
		// hacky way to get dialog chrome window,
		// subject and data are both null here
		let window = Services.wm.getMostRecentWindow(null)
		  , document = window.document.documentElement
		  , button = document.getButton("accept");
		if (button) {
			// we now sure that we got kind of dialog
			button.doCommand();
			Services.obs.removeObserver(observer, "xul-window-visible");
		}
	}, "xul-window-visible", false)
, true);
You need to log in before you can comment on or make changes to this bug.