[GTK][Wayland] Crash when gdk_keymap_get_entries_for_keyval returns TRUE but n_keys=0
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Aug 2017 14:07:11 +0000 (14:07 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Aug 2017 14:07:11 +0000 (14:07 +0000)
commitb404bcd6453f6c966a3cd084a946af99674290ff
treed985d98faf4b6d1fa6806e2bace2ba82004d821f
parent7f5a6163ff248dc7d84c1c4326b3b4d48d2b60bb
[GTK][Wayland] Crash when gdk_keymap_get_entries_for_keyval returns TRUE but n_keys=0
https://bugs.webkit.org/show_bug.cgi?id=176154

Reviewed by Carlos Alberto Lopez Perez.

Source/WebKit:

In Wayland gdk_keymap_get_entries_for_keyval() can return TRUE with n_keys=0. We have several places in WebKit
where we just check the return value of gdk_keymap_get_entries_for_keyval() and then use the returned array to
get the first position assuming it has at least one item. This has always worked in X11 because the GDK X11
backend does the right thing, but it's crashing in Wayland now. It should be fixed in GTK+ but in the meantime
it's easy to workaround by also checking n_keys > 0.

* UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp:
(WebKit::doKeyStrokeEvent):

Tools:

Also check the n_keys > 0 when using gdk_keymap_get_entries_for_keyval().

* TestWebKitAPI/Tests/WebKit/gtk/InputMethodFilter.cpp:
(TestWebKitAPI::TestInputMethodFilter::sendKeyEventToFilter):
* TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp: Remove duplicated code and use WebViewTest::keyStroke instead.
* TestWebKitAPI/glib/WebKitGLib/gtk/WebViewTestGtk.cpp:
(WebViewTest::keyStroke):
* TestWebKitAPI/gtk/PlatformWebViewGtk.cpp:
(TestWebKitAPI::doKeyStroke):
* WebKitTestRunner/gtk/EventSenderProxyGtk.cpp:
(WTR::EventSenderProxy::keyDown):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221419 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit/gtk/InputMethodFilter.cpp
Tools/TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp
Tools/TestWebKitAPI/glib/WebKitGLib/gtk/WebViewTestGtk.cpp
Tools/TestWebKitAPI/gtk/PlatformWebViewGtk.cpp
Tools/WebKitTestRunner/gtk/EventSenderProxyGtk.cpp