A user account is required in order to edit this wiki, but we've had to disable public user registrations due to spam.
To request an account, ask an autoconfirmed user on Chat (such as one of these permanent autoconfirmed members).
Modal prompts: Difference between revisions
(Initial proposal for dealing with modal dialogs) |
mNo edit summary |
||
(5 intermediate revisions by the same user not shown) | |||
Line 8: | Line 8: | ||
Furthermore, implementing <code>showModalDialog</code> might require running a nested message loop which caused several security issues in the past. | Furthermore, implementing <code>showModalDialog</code> might require running a nested message loop which caused several security issues in the past. | ||
===Issues with current implementations=== | |||
Chromium for example doesn't display a window created by <code>showModalDialog</code> in a modal way: http://crbug.com/16045 | |||
WebKit and Firefox don't suppress events while a modal dialog is running: https://bugs.webkit.org/show_bug.cgi?id=78240 and https://bugzilla.mozilla.org/show_bug.cgi?id=360872 | |||
Firefox displays modal prompts as tab-modal. However, it's possible to execute JavaScript in a tab that should be blocked by a modal prompt: https://bugzilla.mozilla.org/show_bug.cgi?id=727397 and the prompts from separate tabs can block each other: https://bugzilla.mozilla.org/show_bug.cgi?id=727801 | |||
==Proposal== | ==Proposal== | ||
Line 20: | Line 27: | ||
When these functions are invoked with a callback parameter, they return immediately (instead of blocking). The callback is invoked as soon as the modal dialog closes. For <code>confirm</code> and <code>prompt</code>, the callback takes one parameter which is set to the value to modal version would have returned. | When these functions are invoked with a callback parameter, they return immediately (instead of blocking). The callback is invoked as soon as the modal dialog closes. For <code>confirm</code> and <code>prompt</code>, the callback takes one parameter which is set to the value to modal version would have returned. | ||
====WebIDL==== | |||
Current interface | |||
<pre> | |||
void alert(DOMString message); | |||
boolean confirm(DOMString message); | |||
DOMString? prompt(DOMString message, optional DOMString default); | |||
</pre> | |||
Proposed interface | |||
<pre> | |||
void alert(DOMString message, optional VoidCallback complete); | |||
boolean confirm(DOMString message, BooleanCallback complete); | |||
DOMString? prompt(DOMString message, optional BooleanCallback complete); | |||
DOMString? prompt(DOMString message, DOMString default, optional BooleanCallback complete); | |||
</pre> | |||
<code>prompt</code> requires overloading, as the existing interface already has an optional parameter. | |||
===showModalDialog=== | ===showModalDialog=== | ||
<code>window.showModalDialog</code> | I would like to propose deprecating and eventually removing <code>window.showModalDialog</code> from the platform. Web sites can already now use e.g. <code>window.open</code> instead. However, I'm not quite sure how this could be achieved. | ||
==Examples== | ==Examples== | ||
Line 34: | Line 61: | ||
==Issues== | ==Issues== | ||
What would a reasonable plan to deprecate <code>showModalDialog</code> look like | * What would a reasonable plan to deprecate <code>showModalDialog</code> look like? | ||
* Does it make sense to add a callback to <code>alert</code> at all? | |||
* Should we rather invest in <code><dialog></code> and then try to deprecate all of the modal prompts and dialogs? | |||
[[Category:Proposals]] | [[Category:Proposals]] |
Latest revision as of 13:52, 16 February 2012
Overview
This document describes a proposal for gradually removing modal dialogs and prompts from the platform.
Rationale
In a tabbed browser, modal dialogs are potentially disrupting the work flow of the user as they can't interact with any other web site as long as the modal dialog is displayed.
Furthermore, implementing showModalDialog
might require running a nested message loop which caused several security issues in the past.
Issues with current implementations
Chromium for example doesn't display a window created by showModalDialog
in a modal way: http://crbug.com/16045
WebKit and Firefox don't suppress events while a modal dialog is running: https://bugs.webkit.org/show_bug.cgi?id=78240 and https://bugzilla.mozilla.org/show_bug.cgi?id=360872
Firefox displays modal prompts as tab-modal. However, it's possible to execute JavaScript in a tab that should be blocked by a modal prompt: https://bugzilla.mozilla.org/show_bug.cgi?id=727397 and the prompts from separate tabs can block each other: https://bugzilla.mozilla.org/show_bug.cgi?id=727801
Proposal
Callbacks
For the following modal prompts, a callback parameter is introduced
alert
confirm
prompt
When these functions are invoked with a callback parameter, they return immediately (instead of blocking). The callback is invoked as soon as the modal dialog closes. For confirm
and prompt
, the callback takes one parameter which is set to the value to modal version would have returned.
WebIDL
Current interface
void alert(DOMString message); boolean confirm(DOMString message); DOMString? prompt(DOMString message, optional DOMString default);
Proposed interface
void alert(DOMString message, optional VoidCallback complete); boolean confirm(DOMString message, BooleanCallback complete); DOMString? prompt(DOMString message, optional BooleanCallback complete); DOMString? prompt(DOMString message, DOMString default, optional BooleanCallback complete);
prompt
requires overloading, as the existing interface already has an optional parameter.
showModalDialog
I would like to propose deprecating and eventually removing window.showModalDialog
from the platform. Web sites can already now use e.g. window.open
instead. However, I'm not quite sure how this could be achieved.
Examples
window.confirm("Are you sure?", function(result) { if (result) doIt(); });
Issues
- What would a reasonable plan to deprecate
showModalDialog
look like? - Does it make sense to add a callback to
alert
at all? - Should we rather invest in
<dialog>
and then try to deprecate all of the modal prompts and dialogs?