RESOLVED FIXED152690
[GTK] JavaScript prompt uses title of page to be loaded rather than title of current page
https://bugs.webkit.org/show_bug.cgi?id=152690
Summary [GTK] JavaScript prompt uses title of page to be loaded rather than title of ...
Michael Catanzaro
Reported 2016-01-04 08:33:43 PST
Created attachment 268193 [details] screenshot When viewing an internal page with some forms, I decided to switch to the WebKit bot watcher dashboard. The attached dialog popped up when I tried to change the page. The URL in the title bar is messed up -- it's a prompt related to the page I was currently viewing, not the bot watcher dashboard that I was trying to switch to, so it it showing the wrong URL. (Unrelated: this dialog looks like shit thanks to GTK+ 3.19.)
Attachments
screenshot (14.28 KB, image/png)
2016-01-04 08:33 PST, Michael Catanzaro
no flags
Patch (1.90 KB, patch)
2017-05-10 12:04 PDT, Claudio Saavedra
no flags
Patch for landing (1.89 KB, patch)
2017-05-11 00:14 PDT, Claudio Saavedra
no flags
Claudio Saavedra
Comment 1 2017-05-10 12:04:10 PDT
Claudio Saavedra
Comment 2 2017-05-10 12:04:48 PDT
Comment on attachment 309623 [details] Patch I confess I didn't test this.
Claudio Saavedra
Comment 3 2017-05-10 12:06:09 PDT
Well okay, I did test it but only with a window.alert(), but it should fix this bug.
Build Bot
Comment 4 2017-05-10 12:06:43 PDT
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Michael Catanzaro
Comment 5 2017-05-10 12:39:01 PDT
Comment on attachment 309623 [details] Patch The change looks correct. One nit: I'm not super comfortable with using the current title without having tested an actual beforeunload prompt. So I would change the title of this bug, and the title in the changelog to match. I think you can just remove the word "beforeunload" from the title: "JavaScript prompt uses title of page to be loaded rather than title of current page." (Oh look, I forgot a "than" in the original title!)
Claudio Saavedra
Comment 6 2017-05-11 00:14:48 PDT
Created attachment 309695 [details] Patch for landing
Carlos Garcia Campos
Comment 7 2017-05-11 00:24:50 PDT
(In reply to Claudio Saavedra from comment #3) > Well okay, I did test it but only with a window.alert(), but it should fix > this bug. No, beforeunload are different to alert, that's why this bug only happens with beforeunload. Unless you tried an alert called from an unload event handler. In case of alerts, the prompts nomrally happen when the load has already been committed, so webkit_web_view_get_uri() returns the committed URL. Same for all other prompts, unless they are called from page unload, of course. But beforeunload events can be called when a new navigation starts and the previous page is going to be replaced by a new one. In this case webkit_web_get_uri() returns the pending API request URL, but we want the committed URL in this case.
Claudio Saavedra
Comment 8 2017-05-11 00:40:45 PDT
(In reply to Carlos Garcia Campos from comment #7) > (In reply to Claudio Saavedra from comment #3) > > Well okay, I did test it but only with a window.alert(), but it should fix > > this bug. > > No, beforeunload are different to alert, that's why this bug only happens > with beforeunload. Unless you tried an alert called from an unload event > handler. In case of alerts, the prompts nomrally happen when the load has > already been committed, so webkit_web_view_get_uri() returns the committed > URL. Same for all other prompts, unless they are called from page unload, of > course. But beforeunload events can be called when a new navigation starts > and the previous page is going to be replaced by a new one. In this case > webkit_web_get_uri() returns the pending API request URL, but we want the > committed URL in this case. But using the committed URL always is safe for all four different prompts, no? That's my point and that's what this patch is doing.
WebKit Commit Bot
Comment 9 2017-05-11 00:55:25 PDT
Comment on attachment 309695 [details] Patch for landing Clearing flags on attachment: 309695 Committed r216670: <http://trac.webkit.org/changeset/216670>
WebKit Commit Bot
Comment 10 2017-05-11 00:55:27 PDT
All reviewed patches have been landed. Closing bug.
Carlos Garcia Campos
Comment 11 2017-05-11 00:59:08 PDT
(In reply to Claudio Saavedra from comment #8) > (In reply to Carlos Garcia Campos from comment #7) > > (In reply to Claudio Saavedra from comment #3) > > > Well okay, I did test it but only with a window.alert(), but it should fix > > > this bug. > > > > No, beforeunload are different to alert, that's why this bug only happens > > with beforeunload. Unless you tried an alert called from an unload event > > handler. In case of alerts, the prompts nomrally happen when the load has > > already been committed, so webkit_web_view_get_uri() returns the committed > > URL. Same for all other prompts, unless they are called from page unload, of > > course. But beforeunload events can be called when a new navigation starts > > and the previous page is going to be replaced by a new one. In this case > > webkit_web_get_uri() returns the pending API request URL, but we want the > > committed URL in this case. > > But using the committed URL always is safe for all four different prompts, > no? That's my point and that's what this patch is doing. Yes, I haven't said the patch is wrong, only that testing with an alert doesn't help with this bug. And that the actual cause should be explained in the ChangeLog instead of current text that is not accurate: "webkit_web_view_get_uri() returns the page to be loaded, use internal api for this." webkit_web_view_get_uri() returns page to be loaded right after a navigation and before the provisional load, but only in that case, that's why this bug was never noticed with other prompts, webkit_web_view_get_uri() returns the committed URL when the load has been committed. What you call the internal API is not accurate either, becaus there's internal API to get the active URL, the provisional URL, the committed URL and unreachable URL. What the patch dos now is not using internal API, but always getting the committed URL.
Note You need to log in before you can comment on or make changes to this bug.