[webkit-dev] The case for disallowing alerts in unload, redux

Sreeram Ramachandran sreeram at chromium.org
Sun Jun 26 13:34:00 PDT 2011


On Sun, Jun 26, 2011 at 13:19, Ryosuke Niwa <rniwa at webkit.org> wrote:
> On Sun, Jun 26, 2011 at 12:38 PM, Sreeram Ramachandran
> <sreeram at chromium.org> wrote:
>>
>> I did see a couple of confirm() calls in beforeunload. The examples I
>> found were also annoying ("Are you sure you want to leave? Yes/No"),
>> but I can imagine those could instead have been more useful ("Do you
>> want to save some state? Yes/No"). I think if there are indeed such
>> uses, they can be transformed into  something that returns a non-NULL
>> value in beforeunload and then saves state.
>
> "Do you want to save some state? Yes/No" seems like a valid use of confirm
> because there are 3 possible actions users can take:
>
> Don't leave
> Save state and leave
> Discard state and leave

A confirm() can't actually do the first option ("Don't leave"). I
believe there's nothing a page can do to prevent the navigation once
it is in unload. The only way it can prevent it is by installing a
beforeunload and returning a string.

I do see that there can be potential uses for confirm and prompt
during page dismissal. However, I haven't seen any such uses in my
manual inspection; also, the number of such instances in the
histograms is very tiny (orders of magnitude smaller than alert()).


More information about the webkit-dev mailing list