<?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>171492</bug_id>
          
          <creation_ts>2017-05-01 01:37:40 -0700</creation_ts>
          <short_desc>REGRESSION(r215188?): Test platform/gtk/fast/forms/menulist-typeahead-find.html is failing</short_desc>
          <delta_ts>2017-07-02 09:19:43 -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>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=170680</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=40601</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>Gtk, LayoutTestFailure</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>171792</dependson>
    
    <dependson>172708</dependson>
          <blocked>171803</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Carlos Garcia Campos">cgarcia</reporter>
          <assigned_to name="Adrian Perez">aperez</assigned_to>
          <cc>aperez</cc>
    
    <cc>bugs-noreply</cc>
    
    <cc>mcatanzaro</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1303207</commentid>
    <comment_count>0</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2017-05-01 01:37:40 -0700</bug_when>
    <thetext>r215187                       NOERROR
[r215188-r215192]             UNKNOWN
r215193                       TEXT (Expected: PASS)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1303209</commentid>
    <comment_count>1</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2017-05-01 01:40:15 -0700</bug_when>
    <thetext>Expectations updated in r216011</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1305712</commentid>
    <comment_count>2</comment_count>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2017-05-07 05:41:38 -0700</bug_when>
    <thetext>This started failing after the following set of fixes which I made for
fixing the following popup-related bugs:

 * Bug #145866: [GTK] Attach popup menu to web view widget
   Landed: http://trac.webkit.org/changeset/215225

 * Bug #170553: [GTK] Misplaced right click menu on web page due to deprecated gtk_menu_popup()
   Landed: http://trac.webkit.org/changeset/215190

 * Bug #170680: [GTK] Opening a popup menu does not pre-select the active item
   Landed: http://trac.webkit.org/changeset/215188

Reverting r215225 makes the typeahead find elements again, but the
items being found sometimes are not exactly the ones from the test
expectation. The diff is:

  --- /home/aperez/devel/WebKit/WebKitBuild/Release/layout-test-results/platform/gtk/fast/forms/menulist-typeahead-find-expected.txt
  +++ /home/aperez/devel/WebKit/WebKitBuild/Release/layout-test-results/platform/gtk/fast/forms/menulist-typeahead-find-actual.txt
  @@ -3,8 +3,8 @@
   Cannot run interactively.
   Expected Apple: was Apple
   Expected Carrot: was Carrot
  -Expected Cauliflower: was Cauliflower
  -Expected Corn: was Corn
  +Expected Cauliflower: was Carrot
  +Expected Corn: was Cauliflower
   Expected Carrot: was Carrot
   Expected Apple: was Apple
   Expected Cauliflower: was Cauliflower

The bit that is not working is this part of the test:

   // This tests that iterating via pressing the same key works.
   testTypeAheadFind([&apos;c&apos;, &apos;c&apos;], &quot;Cauliflower&quot;);
   testTypeAheadFind([&apos;c&apos;, &apos;c&apos;, &apos;c&apos;], &quot;Corn&quot;);

Checking the code of the “testTypeAheadFind()” function, I see that it
does not attempt to reset the status of the form element to an initial
know state, so each call to this function will behave differently
depending on the state leftover from the previous call.

After fixing bug #170680 now the code is pre-selecting the active item
on popup (simulated here by sending a pair of button-down/button-up
events): that was not happening before and the typeahead was searching
always from the beginning of the list. IMHO the correct thing to do in
this regard is to always reset the form element to a known state at the
beginning of “testTypeAheadFind()”.

I still don&apos;t know why attaching the popup menu to the web widget makes
the test function always choose the “Apple” item, though. That needs more
investigation.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1305720</commentid>
    <comment_count>3</comment_count>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2017-05-07 10:45:44 -0700</bug_when>
    <thetext>The following is the diff with the patch in bug #171792 applied, but
*not* reverting the patch to attach the popup to the web view:

  --- /home/aperez/devel/WebKit/WebKitBuild/Release/layout-test-results/platform/gtk/fast/forms/menulist-typeahead-find-expected.txt
  +++ /home/aperez/devel/WebKit/WebKitBuild/Release/layout-test-results/platform/gtk/fast/forms/menulist-typeahead-find-actual.txt
  @@ -2,10 +2,10 @@
 
   Cannot run interactively.
   Expected Apple: was Apple
  -Expected Carrot: was Carrot
  -Expected Cauliflower: was Cauliflower
  -Expected Corn: was Corn
  -Expected Carrot: was Carrot
  -Expected Apple: was Apple
  -Expected Cauliflower: was Cauliflower
  -Expected Star fruit: was Star fruit
  +Expected Carrot: was 
  +Expected Cauliflower: was 
  +Expected Corn: was 
  +Expected Carrot: was 
  +Expected Apple: was 
  +Expected Cauliflower: was 
  +Expected Star fruit: was

It&apos;s quite interesting that the first attempt of using the type ahead
search works, but the rest don&apos;t. This leads me to think that it might
be needed to detach the popup from the web view after the popup menu
is closed (either by choosing a new value with keyboard/mouse, or by
cancelling it e.g. with “Escape”). I&apos;ll give that a try, but if that
doesn&apos;t solve the issue, it could be that some digging into the GTK+
code for gtk_menu_attach_to_widget() may be needed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1305751</commentid>
    <comment_count>4</comment_count>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2017-05-07 15:13:17 -0700</bug_when>
    <thetext>(In reply to Adrian Perez from comment #3)
&gt; The following is the diff with the patch in bug #171792 applied, but
&gt; *not* reverting the patch to attach the popup to the web view:
&gt;
&gt;    [...] 
&gt;
&gt; It&apos;s quite interesting that the first attempt of using the type ahead
&gt; search works, but the rest don&apos;t [...]

This happens because gtk_menu_attach_to_widget() is sinking the floating
reference to the passed GtkMenu, making the GTK+ innards “own” the widget.
That means that GTK+ unrefs the GtkMenu and we are left with an invalid
“m_popup” pointer. We need to either sink the reference ourselves when
constructing a WebPopupMenuProxyGtk, or add an additional reference.
Doing one of those fixes the case of no items appearing as selectd after
the first one — but I still need to figure out how to get the test to
pass.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1307241</commentid>
    <comment_count>5</comment_count>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2017-05-11 05:21:15 -0700</bug_when>
    <thetext>Some observations I made while trying to figure out what&apos;s going on:

 1. The first time a popup is opened, a WebPopupMenuProxyGtk is
    instantiated, and ::showPopupMenu() called on it.

 2. Once the menu is dismissed, the WebPopupMenuGtk instance is kept
    around.

 3. The next times a menu is opened:

     3.a. The object created in (1) is destroyed.
     3.b. Then a new WebPopupMenuProxyGtk is created (even if the
          menu being opened is exactly the same one used previously).
     3.c. WebPopupMenuProxyGtk::showPopupMenu() is called.

I double-checked the above by debugging while using MiniBrowser. When
using WebKitTestRunner to run the test, only steps (1) to (3.a) happen,
and new instances of WebPopupMenuProxyGtk are not ever created. It looks
like the events synthesized with “eventSender.mouse{Down,Up}()” used to
programmatically open the popup menu from the test are only reaching
WebCore on the first use, and then things get stalled from there.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1313676</commentid>
    <comment_count>6</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2017-05-30 05:49:02 -0700</bug_when>
    <thetext>(In reply to Adrian Perez from comment #2)
&gt; This started failing after the following set of fixes which I made for
&gt; fixing the following popup-related bugs:
&gt; 
&gt;  * Bug #145866: [GTK] Attach popup menu to web view widget
&gt;    Landed: http://trac.webkit.org/changeset/215225
&gt; 
&gt;  * Bug #170553: [GTK] Misplaced right click menu on web page due to
&gt; deprecated gtk_menu_popup()
&gt;    Landed: http://trac.webkit.org/changeset/215190
&gt; 
&gt;  * Bug #170680: [GTK] Opening a popup menu does not pre-select the active
&gt; item
&gt;    Landed: http://trac.webkit.org/changeset/215188
&gt; 
&gt; Reverting r215225 makes the typeahead find elements again, but the
&gt; items being found sometimes are not exactly the ones from the test
&gt; expectation. The diff is:
&gt; 
&gt;   ---
&gt; /home/aperez/devel/WebKit/WebKitBuild/Release/layout-test-results/platform/
&gt; gtk/fast/forms/menulist-typeahead-find-expected.txt
&gt;   +++
&gt; /home/aperez/devel/WebKit/WebKitBuild/Release/layout-test-results/platform/
&gt; gtk/fast/forms/menulist-typeahead-find-actual.txt
&gt;   @@ -3,8 +3,8 @@
&gt;    Cannot run interactively.
&gt;    Expected Apple: was Apple
&gt;    Expected Carrot: was Carrot
&gt;   -Expected Cauliflower: was Cauliflower
&gt;   -Expected Corn: was Corn
&gt;   +Expected Cauliflower: was Carrot
&gt;   +Expected Corn: was Cauliflower
&gt;    Expected Carrot: was Carrot
&gt;    Expected Apple: was Apple
&gt;    Expected Cauliflower: was Cauliflower
&gt; 
&gt; The bit that is not working is this part of the test:
&gt; 
&gt;    // This tests that iterating via pressing the same key works.
&gt;    testTypeAheadFind([&apos;c&apos;, &apos;c&apos;], &quot;Cauliflower&quot;);
&gt;    testTypeAheadFind([&apos;c&apos;, &apos;c&apos;, &apos;c&apos;], &quot;Corn&quot;);
&gt; 
&gt; Checking the code of the “testTypeAheadFind()” function, I see that it
&gt; does not attempt to reset the status of the form element to an initial
&gt; know state, so each call to this function will behave differently
&gt; depending on the state leftover from the previous call.
&gt; 
&gt; After fixing bug #170680 now the code is pre-selecting the active item
&gt; on popup (simulated here by sending a pair of button-down/button-up
&gt; events): that was not happening before and the typeahead was searching
&gt; always from the beginning of the list. IMHO the correct thing to do in
&gt; this regard is to always reset the form element to a known state at the
&gt; beginning of “testTypeAheadFind()”.
&gt; 
&gt; I still don&apos;t know why attaching the popup menu to the web widget makes
&gt; the test function always choose the “Apple” item, though. That needs more
&gt; investigation.

This is because we are dismissing any menus attached to the web view for every event we inject. This was done for the context menu in r184015, but now we are also attaching popup menus. So, we show the popup menu and as soon as we try to inject a keyevent, the popup is dismissed. That was a workaround in the end, so it&apos;s time to properly fix bug #40601.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1313754</commentid>
    <comment_count>7</comment_count>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2017-05-30 10:01:11 -0700</bug_when>
    <thetext>(In reply to Carlos Garcia Campos from comment #6)
 
&gt; This is because we are dismissing any menus attached to the web view for
&gt; every event we inject. This was done for the context menu in r184015, but
&gt; now we are also attaching popup menus. So, we show the popup menu and as
&gt; soon as we try to inject a keyevent, the popup is dismissed. That was a
&gt; workaround in the end, so it&apos;s time to properly fix bug #40601.

Wow, I wasn&apos;t aware of the workaround. Thanks a lot for looking into this
and figuring out the reason for the weird behavior of the event handling
in WebKitTestRunner.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1319959</commentid>
    <comment_count>8</comment_count>
      <attachid>313077</attachid>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2017-06-16 08:27:04 -0700</bug_when>
    <thetext>Created attachment 313077
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1319960</commentid>
    <comment_count>9</comment_count>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2017-06-16 08:34:20 -0700</bug_when>
    <thetext>Committed r218391: &lt;http://trac.webkit.org/changeset/218391&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>313077</attachid>
            <date>2017-06-16 08:27:04 -0700</date>
            <delta_ts>2017-07-02 09:19:43 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-171492-20170616182702.patch</filename>
            <type>text/plain</type>
            <size>1593</size>
            <attacher name="Adrian Perez">aperez</attacher>
            
              <data encoding="base64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