<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>223160</bug_id>
          
          <creation_ts>2021-03-14 06:33:53 -0700</creation_ts>
          <short_desc>[GTK] Clicking on a custom context menu item doesn&apos;t activate action (WebExtension)</short_desc>
          <delta_ts>2021-03-16 12:34:50 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKitGTK</component>
          <version>Other</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>Gtk</keywords>
          <priority>P3</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>samuel.dudik</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bugs-noreply</cc>
    
    <cc>mcatanzaro</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1739224</commentid>
    <comment_count>0</comment_count>
    <who name="">samuel.dudik</who>
    <bug_when>2021-03-14 06:33:53 -0700</bug_when>
    <thetext>Clicking on a custom &apos;right-click&apos; context menu item created with webkit_context_menu_item_new_from_gaction doesn&apos;t activate the specified action (no errors or warnings). This behavior only appears when using the &quot;context-menu&quot; signal from a WebKitWebPage (which is the only way when connecting from a WebExtension). Using it from WebKitWebView works fine.

static void web_page_created_callback(WebKitWebExtension *extension, WebKitWebPage *web_page, gpointer user_data)
{
	g_signal_connect(web_page, &quot;context-menu&quot;, G_CALLBACK(context_menu_opened_callback), NULL);
}

static void open_adblock_settings(GSimpleAction *action, GVariant *parameter, gpointer user_data)
{
	g_print(&quot;Opened settings\n&quot;);
}

static gboolean context_menu_opened_callback(WebKitWebPage *web_page, WebKitContextMenu *context_menu, WebKitWebHitTestResult *hit_test_result, gpointer user_data)
{
	g_print(&quot;Context menu opened\n&quot;);

	webkit_context_menu_append(context_menu, webkit_context_menu_item_new_separator());

	GSimpleAction *action = g_simple_action_new(&quot;open-settings&quot;, NULL);
	g_signal_connect(action, &quot;activate&quot;, G_CALLBACK(open_adblock_settings), NULL);

	WebKitContextMenuItem *item = webkit_context_menu_item_new_from_gaction(G_ACTION(action), &quot;Settings&quot;, NULL);
	webkit_context_menu_append(context_menu, item);

	return TRUE;
}

After clicking on the &quot;Settings&quot; menu item:
Expected Results: &quot;Opened settings&quot; gets printed.
Actual Results: &quot;Opened settings&quot; doesn&apos;t get printed.

Encountered on Void Linux, WebKitGTK 2.30.5.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>