Bug 181041 - [GTK] WebView create signal: navigation action modifiers not set
Summary: [GTK] WebView create signal: navigation action modifiers not set
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
Depends on:
Reported: 2017-12-20 09:28 PST by Cédric Bellegarde
Modified: 2019-03-07 09:09 PST (History)
2 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Cédric Bellegarde 2017-12-20 09:28:51 PST
While holding Ctrl or Shift key while a page is created via create signal, the navigation action modifiers are not set.

This code always print "0":

def on_create(related, navigation_action):

webview.connect("create", on_create)
Comment 1 Michael Catanzaro 2017-12-21 14:21:33 PST
The C API works perfectly fine for me, in trunk.

An introspection issue seems unlikely, since this is just a simple unsigned int.
Comment 2 Cédric Bellegarde 2017-12-21 23:49:41 PST
No the C API does not work, here a patch for epiphany tags/

diff --git a/src/ephy-window.c b/src/ephy-window.c
index 195ec9814..a9d71f7c5 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -1842,6 +1842,7 @@ create_web_view_cb (WebKitWebView          *web_view,
   EphyNewTabFlags flags;
   EphyWindow *target_window;
+  printf("create_web_view_cb(): %d\n", webkit_navigation_action_get_modifiers(navigation_action));
   if ((ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) != EPHY_EMBED_SHELL_MODE_APPLICATION) &&
       (g_settings_get_boolean (EPHY_SETTINGS_MAIN,
                                EPHY_PREFS_NEW_WINDOWS_IN_TABS) ||

Go to https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_win_open, click on try it with Shift pressed, it will always print "0"
Comment 3 Cédric Bellegarde 2017-12-21 23:51:00 PST
Can you test above patch with trunk to confirm it's fixed?
Comment 4 Michael Catanzaro 2017-12-22 11:47:15 PST
(In reply to Cédric Bellegarde from comment #3)
> Can you test above patch with trunk to confirm it's fixed?

Ah, you're thinking like me... that's almost exactly what I did to test yesterday. I used g_warning instead of printf (it's a bit more visible, and you don't need to write the \n), and I used __FUNCTION__ instead of writing out the function name in the printf... and I used w3school's tab opening example https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_tabs instead of their window opening example. Eerie.

That particular page is actually broken in trunk: none of the JS there seems to run. But you can test on https://www.w3schools.com/jsref/met_win_open.asp instead, by clicking on the Try it Yourself button. Shift+click is not going to work, because that triggers a download from navigation policy; it'll never rearch create_web_view_cb. But when I Alt+click I see it print 8.
Comment 5 Cédric Bellegarde 2017-12-22 12:10:51 PST
Ok, thanks, I would have tested my self but webkit 2.19 make gcc to segfault on ArchLinux :/
Comment 6 Cédric Bellegarde 2018-03-09 05:07:54 PST
Not fixed by 2.19.92

>when I Alt+click I see it print 8.

Mee too

Now do the same with the "Try it" button, I see 0.
Comment 7 Cédric Bellegarde 2019-03-07 09:09:28 PST
It is working with WebKitGTK 2.23.91!