DescriptionIgnore JavaScript messages (alert/confirm/prompt) during unload handlers.
When in an unload handler (onunload() or onbeforeunload()), calls to alert()
will result in no dialog being shown. Calls to confirm() or prompt() will also
show no dialog, and will receive false/empty-string as the return value.
If onbeforeunload() returns a non-NULL value, the "Stay or Leave?" dialog is
still shown as usual.
A page that has an onbeforeunload() that shows an alert/confirm/prompt as well
as returns a non-NULL value behaves differently depending on how the unload was
initiated:
+ If it was a within-renderer navigation (such as clicking a link), the
renderer continues unloading as usual. I.e., the alert/confirm/prompt is
not displayed, but the "Stay or Leave?" dialog is, and the user can choose
whether to continue the navigation.
+ If it was browser-initiated (such as typing into the omnibox), the page is
killed (due to the "is_waiting && are_javascript_messages_suppressed_" check
in render_view_host.cc). I.e., the alert/confirm/prompt is not displayed as
before, but the "Stay or Leave?" dialog appears briefly and disappears as the
page is killed, and the navigation happens anyway.
This CL doesn't address the showModalDialog() JavaScript call, because:
1. Currently such dialogs are not modal at all (http://crbug.com/16045), so
while the page is paused (waiting for the dialog to be closed), the user can
ignore the dialog and interact with the tab anyway.
2. It wreaks havoc inside unload handlers already (see http://crbug.com/44357).
3. It seems non-trivial to handle: The RenderViewHost of the main frame doesn't
get any message. The dialog window is created in webkit, and runModal() is
called on the RenderView of the dialog (and not the main frame).
BUG=68780
TEST=Open a page that has an alert() message in its onunload() handler. Navigate away. No dialog should appear.
Patch Set 1 #
Total comments: 1
Patch Set 2 : Added a browsertest #Messages
Total messages: 4 (0 generated)
|