Bug 139090 - [GTK] Add API to handle beforeunload events
Summary: [GTK] Add API to handle beforeunload events
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: Gtk
Depends on:
Blocks:
 
Reported: 2014-11-28 05:47 PST by Carlos Garcia Campos
Modified: 2015-12-09 05:33 PST (History)
5 users (show)

See Also:


Attachments
Patch (22.90 KB, patch)
2014-11-28 05:59 PST, Carlos Garcia Campos
gustavo: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2014-11-28 05:47:06 PST
beforeunload is fired when a page is about to be closed, to ask the user for confirmation. This happens when reloading a page, when navigation to another page or when the page is closed by a user action (a tab or window closed). In the first two cases, the event is automatically fired by WebCore, but in the case of a user action we need additional API to ensure the event is fired before the page is closed.
Comment 1 Carlos Garcia Campos 2014-11-28 05:59:57 PST
Created attachment 242264 [details]
Patch
Comment 2 Michael Catanzaro 2015-01-08 09:56:47 PST
Don't forget to set mnemonics on the buttons: "_Stay on Page" and "_Leave Page" seem good.
Comment 3 Carlos Garcia Campos 2015-10-29 01:51:16 PDT
Ping reviewers. I know this is a so annoying web feature, we can add a setting and disable it by default, so that apps need to explicitly enable it if they really want to irritate their users.
Comment 4 Michael Catanzaro 2015-10-29 05:06:17 PDT
I think, based on the complaints I've heard from users, we should just have it enabled by default. I don't think many sites take advantage of this to create unnecessary "are you sure you want to leave" messages nowadays, except when the departure would cause some form of data loss (e.g. imgur uploads), and the proper solution to that is to add a "prevent this site from showing additional dialogs" button, anyway.

Anyway, I don't see anything to improve about the patch. I suspect that apps are not going to use the try_close() API and will wind up not executing the handlers even if they want to, but that's a consequence of the existing API....
Comment 5 Michael Catanzaro 2015-10-29 05:07:36 PDT
(In reply to comment #4)
> I think, based on the complaints I've heard from users, we should just have
> it enabled by default.

Anyway that doesn't matter for this bug, since you are just adding try_close(); we'll decide how to use it in Epiphany.
Comment 6 Gustavo Noronha (kov) 2015-12-09 03:14:35 PST
Comment on attachment 242264 [details]
Patch

LGTM, pretty straight-forward
Comment 7 Carlos Garcia Campos 2015-12-09 05:33:21 PST
Committed r193826: <http://trac.webkit.org/changeset/193826>