Title: [264647] trunk
Revision
264647
Author
carlo...@webkit.org
Date
2020-07-21 01:08:18 -0700 (Tue, 21 Jul 2020)

Log Message

[GTK] Prepare unit tests for GTK4
https://bugs.webkit.org/show_bug.cgi?id=214251

Reviewed by Adrian Perez de Castro.

Source/WebKit:

Make it possible to test input methods.

* UIProcess/API/glib/InputMethodFilter.h:
* UIProcess/API/gtk/InputMethodFilterGtk.cpp:
(WebKit::InputMethodFilter::filterKeyEvent): Added to receive the key event properties instead of the GdkEvent.
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseSynthesizeMouseEvent): Create a GdkEvent for right clicks since it's needed by GTK3 API.
(webkitWebViewBaseSynthesizeKeyEvent): Send key press and release events to the IM filter.

Tools:

In GTK4 there isn't GTK_WINDOW_POPUP and we can't create GdkEvents, so we need to use toplevel windows
everywhere and use the new internal api to synthesize events.

* TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp:
(testContextMenuDownloadActions):
(testBlobDownload):
* TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp:
* TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp:
(testOptionMenuSimple):
(testOptionMenuGroups):
(testOptionMenuActivate):
(testOptionMenuSelect):
* TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp:
(testWebViewCreateNavigationData):
(testWebViewJavaScriptDialogs):
(testWebViewOpenWindowNoDefaultSize):
(testWebViewMouseTarget):
(testWebViewGeolocationPermissionRequests):
(testWebViewUserMediaEnumerateDevicesPermissionCheck):
(testWebViewUserMediaPermissionRequests):
(testWebViewAudioOnlyUserMediaPermissionRequests):
(testWebViewPointerLockPermissionRequest):
(testWebViewFileChooserRequest):
(testWebViewColorChooserRequest):
* TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp:
(testWebExtensionInputElementIsUserEdited):
(testInstallMissingPluginsPermissionRequest):
* TestWebKitAPI/Tests/WebKitGLib/TestWebKitFindController.cpp:
(testFindControllerHide):
* TestWebKitAPI/Tests/WebKitGLib/TestWebKitPolicyClient.cpp:
(testAutoplayPolicy):
* TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:
(testWebViewFullScreen):
(testWebViewSubmitForm):
(testWebViewSnapshot):
(testWebViewIsPlayingAudio):
(testWebViewPreferredSize):
* TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp:
(testContextMenuDefaultMenu):
(testPopupEventSignal):
(testContextMenuKey):
(testContextMenuPopulateMenu):
(testContextMenuCustomMenu):
(testContextMenuSubMenu):
(testContextMenuDismissed):
(testContextMenuWebExtensionMenu):
(testContextMenuWebExtensionNode):
(testContextMenuLiveStream):
(beforeAll):
* TestWebKitAPI/Tests/WebKitGtk/TestDOMDOMWindow.cpp:
(signalsNotifyCallback):
* TestWebKitAPI/Tests/WebKitGtk/TestInspector.cpp:
(testInspectorDefault):
(testInspectorManualAttachDetach):
(testInspectorCustomContainerDestroyed):
* TestWebKitAPI/Tests/WebKitGtk/TestInspectorServer.cpp:
(testInspectorServerPageList):
* TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp:
(testPrintCustomWidget):
* TestWebKitAPI/Tests/WebKitGtk/TestWebViewEditor.cpp:
* TestWebKitAPI/glib/WebKitGLib/WebViewTest.h:
* TestWebKitAPI/glib/WebKitGLib/gtk/WebViewTestGtk.cpp:
(WebViewTest::quitMainLoopAfterProcessingPendingEvents):
(WebViewTest::showInWindow):
(WebViewTest::mouseMoveTo):
(WebViewTest::clickMouseButton):
(WebViewTest::keyStroke):
* TestWebKitAPI/glib/WebKitGLib/wpe/WebViewTestWPE.cpp:
(WebViewTest::showInWindow):
* TestWebKitAPI/gtk/PlatformWebViewGtk.cpp:
(TestWebKitAPI::toWebKitGLibAPI):
(TestWebKitAPI::PlatformWebView::simulateSpacebarKeyPress):
(TestWebKitAPI::PlatformWebView::simulateAltKeyPress):
(TestWebKitAPI::PlatformWebView::simulateRightClick):
(TestWebKitAPI::PlatformWebView::simulateMouseMove):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (264646 => 264647)


--- trunk/Source/WebKit/ChangeLog	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Source/WebKit/ChangeLog	2020-07-21 08:08:18 UTC (rev 264647)
@@ -1,3 +1,19 @@
+2020-07-21  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [GTK] Prepare unit tests for GTK4
+        https://bugs.webkit.org/show_bug.cgi?id=214251
+
+        Reviewed by Adrian Perez de Castro.
+
+        Make it possible to test input methods.
+
+        * UIProcess/API/glib/InputMethodFilter.h:
+        * UIProcess/API/gtk/InputMethodFilterGtk.cpp:
+        (WebKit::InputMethodFilter::filterKeyEvent): Added to receive the key event properties instead of the GdkEvent.
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (webkitWebViewBaseSynthesizeMouseEvent): Create a GdkEvent for right clicks since it's needed by GTK3 API.
+        (webkitWebViewBaseSynthesizeKeyEvent): Send key press and release events to the IM filter.
+
 2020-07-20  Megan Gardner  <megan_gard...@apple.com>
 
         Add OK button to Date/Time form controls.

Modified: trunk/Source/WebKit/UIProcess/API/glib/InputMethodFilter.h (264646 => 264647)


--- trunk/Source/WebKit/UIProcess/API/glib/InputMethodFilter.h	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Source/WebKit/UIProcess/API/glib/InputMethodFilter.h	2020-07-21 08:08:18 UTC (rev 264647)
@@ -67,6 +67,10 @@
     };
     FilterResult filterKeyEvent(PlatformEventKey*);
 
+#if PLATFORM(GTK)
+    FilterResult filterKeyEvent(unsigned type, unsigned keyval, unsigned keycode, unsigned modifiers);
+#endif
+
     void notifyFocusedIn();
     void notifyFocusedOut();
     void notifyMouseButtonPress();

Modified: trunk/Source/WebKit/UIProcess/API/gtk/InputMethodFilterGtk.cpp (264646 => 264647)


--- trunk/Source/WebKit/UIProcess/API/gtk/InputMethodFilterGtk.cpp	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Source/WebKit/UIProcess/API/gtk/InputMethodFilterGtk.cpp	2020-07-21 08:08:18 UTC (rev 264647)
@@ -21,6 +21,7 @@
 #include "InputMethodFilter.h"
 
 #include "WebKitInputMethodContextPrivate.h"
+#include <WebCore/GUniquePtrGtk.h>
 #include <WebCore/IntRect.h>
 #include <gdk/gdk.h>
 
@@ -41,4 +42,27 @@
     return gdk_event_get_event_type(event) == GDK_KEY_PRESS;
 }
 
+InputMethodFilter::FilterResult InputMethodFilter::filterKeyEvent(unsigned type, unsigned keyval, unsigned keycode, unsigned modifiers)
+{
+    if (!isEnabled() || !m_context)
+        return { };
+
+#if !USE(GTK4)
+    auto* webView = webkitInputMethodContextGetWebView(m_context.get());
+    ASSERT(webView);
+
+    GUniquePtr<GdkEvent> event(gdk_event_new(static_cast<GdkEventType>(type)));
+    event->key.window = gtk_widget_get_window(GTK_WIDGET(webView));
+    g_object_ref(event->key.window);
+    event->key.time = GDK_CURRENT_TIME;
+    event->key.keyval = keyval;
+    event->key.hardware_keycode = keycode;
+    event->key.state = modifiers;
+    gdk_event_set_device(event.get(), gdk_seat_get_keyboard(gdk_display_get_default_seat(gtk_widget_get_display(GTK_WIDGET(webView)))));
+    return filterKeyEvent(event.get());
+#else
+    return { };
+#endif
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp (264646 => 264647)


--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp	2020-07-21 08:08:18 UTC (rev 264647)
@@ -2545,6 +2545,25 @@
     case MouseEventType::Press:
         webEventType = WebEvent::MouseDown;
         priv->inputMethodFilter.cancelComposition();
+#if !USE(GTK4)
+        if (webEventButton == WebMouseEvent::RightButton) {
+            GUniquePtr<GdkEvent> event(gdk_event_new(GDK_BUTTON_PRESS));
+            event->button.window = gtk_widget_get_window(GTK_WIDGET(webViewBase));
+            g_object_ref(event->button.window);
+            event->button.time = GDK_CURRENT_TIME;
+            event->button.x = x;
+            event->button.y = y;
+            event->button.axes = 0;
+            event->button.state = modifiers;
+            event->button.button = button;
+            event->button.device = gdk_seat_get_pointer(gdk_display_get_default_seat(gtk_widget_get_display(GTK_WIDGET(webViewBase))));
+            int xRoot, yRoot;
+            gdk_window_get_root_coords(event->button.window, x, y, &xRoot, &yRoot);
+            event->button.x_root = xRoot;
+            event->button.y_root = yRoot;
+            priv->contextMenuEvent = WTFMove(event);
+        }
+#endif
         gtk_widget_grab_focus(GTK_WIDGET(webViewBase));
         break;
     case MouseEventType::Release:
@@ -2603,8 +2622,21 @@
 #endif
 
 #if !USE(GTK4)
+        if (priv->activeContextMenuProxy && keyval == GDK_KEY_Escape) {
+            gtk_menu_shell_deactivate(GTK_MENU_SHELL(priv->activeContextMenuProxy->gtkWidget()));
+            return;
+        }
+
         if (keyval == GDK_KEY_Menu) {
-            webkitWebViewBasePopupMenu(GTK_WIDGET(webViewBase));
+            GUniquePtr<GdkEvent> event(gdk_event_new(GDK_KEY_PRESS));
+            event->key.window = gtk_widget_get_window(GTK_WIDGET(webViewBase));
+            g_object_ref(event->key.window);
+            event->key.time = GDK_CURRENT_TIME;
+            event->key.keyval = keyval;
+            event->key.state = modifiers;
+            gdk_event_set_device(event.get(), gdk_seat_get_keyboard(gdk_display_get_default_seat(gtk_widget_get_display(GTK_WIDGET(webViewBase)))));
+            priv->contextMenuEvent = WTFMove(event);
+            priv->pageProxy->handleContextMenuKeyEvent();
             return;
         }
 #endif
@@ -2622,31 +2654,36 @@
     auto webEventModifiers = toWebKitModifiers(modifiers);
 
     if (type != KeyEventType::Release) {
-        priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(
-            WebEvent::KeyDown,
-            PlatformKeyboardEvent::singleCharacterString(keyval),
-            PlatformKeyboardEvent::keyValueForGdkKeyCode(keyval),
-            PlatformKeyboardEvent::keyCodeForHardwareKeyCode(keycode),
-            PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyval),
-            PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(keyval),
-            static_cast<int>(keyval),
-            priv->keyBindingTranslator.commandsForKeyval(keyval, modifiers),
-            keyval >= GDK_KEY_KP_Space && keyval <= GDK_KEY_KP_9,
-            webEventModifiers));
+        auto filterResult = priv->inputMethodFilter.filterKeyEvent(GDK_KEY_PRESS, keyval, keycode, modifiers);
+        if (!filterResult.handled) {
+            priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(
+                WebEvent::KeyDown,
+                filterResult.keyText.isNull() ? PlatformKeyboardEvent::singleCharacterString(keyval) : filterResult.keyText,
+                PlatformKeyboardEvent::keyValueForGdkKeyCode(keyval),
+                PlatformKeyboardEvent::keyCodeForHardwareKeyCode(keycode),
+                PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyval),
+                PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(keyval),
+                static_cast<int>(keyval),
+                priv->keyBindingTranslator.commandsForKeyval(keyval, modifiers),
+                keyval >= GDK_KEY_KP_Space && keyval <= GDK_KEY_KP_9,
+                webEventModifiers));
+        }
     }
 
     if (type != KeyEventType::Press) {
-        priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(
-            WebEvent::KeyUp,
-            PlatformKeyboardEvent::singleCharacterString(keyval),
-            PlatformKeyboardEvent::keyValueForGdkKeyCode(keyval),
-            PlatformKeyboardEvent::keyCodeForHardwareKeyCode(keycode),
-            PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyval),
-            PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(keyval),
-            static_cast<int>(keyval),
-            { },
-            keyval >= GDK_KEY_KP_Space && keyval <= GDK_KEY_KP_9,
-            webEventModifiers));
+        if (!priv->inputMethodFilter.filterKeyEvent(GDK_KEY_RELEASE, keyval, keycode, modifiers).handled) {
+            priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(
+                WebEvent::KeyUp,
+                PlatformKeyboardEvent::singleCharacterString(keyval),
+                PlatformKeyboardEvent::keyValueForGdkKeyCode(keyval),
+                PlatformKeyboardEvent::keyCodeForHardwareKeyCode(keycode),
+                PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyval),
+                PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(keyval),
+                static_cast<int>(keyval),
+                { },
+                keyval >= GDK_KEY_KP_Space && keyval <= GDK_KEY_KP_9,
+                webEventModifiers));
+        }
     }
 }
 

Modified: trunk/Tools/ChangeLog (264646 => 264647)


--- trunk/Tools/ChangeLog	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Tools/ChangeLog	2020-07-21 08:08:18 UTC (rev 264647)
@@ -1,3 +1,86 @@
+2020-07-21  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [GTK] Prepare unit tests for GTK4
+        https://bugs.webkit.org/show_bug.cgi?id=214251
+
+        Reviewed by Adrian Perez de Castro.
+
+        In GTK4 there isn't GTK_WINDOW_POPUP and we can't create GdkEvents, so we need to use toplevel windows
+        everywhere and use the new internal api to synthesize events.
+
+        * TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp:
+        (testContextMenuDownloadActions):
+        (testBlobDownload):
+        * TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp:
+        * TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp:
+        (testOptionMenuSimple):
+        (testOptionMenuGroups):
+        (testOptionMenuActivate):
+        (testOptionMenuSelect):
+        * TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp:
+        (testWebViewCreateNavigationData):
+        (testWebViewJavaScriptDialogs):
+        (testWebViewOpenWindowNoDefaultSize):
+        (testWebViewMouseTarget):
+        (testWebViewGeolocationPermissionRequests):
+        (testWebViewUserMediaEnumerateDevicesPermissionCheck):
+        (testWebViewUserMediaPermissionRequests):
+        (testWebViewAudioOnlyUserMediaPermissionRequests):
+        (testWebViewPointerLockPermissionRequest):
+        (testWebViewFileChooserRequest):
+        (testWebViewColorChooserRequest):
+        * TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp:
+        (testWebExtensionInputElementIsUserEdited):
+        (testInstallMissingPluginsPermissionRequest):
+        * TestWebKitAPI/Tests/WebKitGLib/TestWebKitFindController.cpp:
+        (testFindControllerHide):
+        * TestWebKitAPI/Tests/WebKitGLib/TestWebKitPolicyClient.cpp:
+        (testAutoplayPolicy):
+        * TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:
+        (testWebViewFullScreen):
+        (testWebViewSubmitForm):
+        (testWebViewSnapshot):
+        (testWebViewIsPlayingAudio):
+        (testWebViewPreferredSize):
+        * TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp:
+        (testContextMenuDefaultMenu):
+        (testPopupEventSignal):
+        (testContextMenuKey):
+        (testContextMenuPopulateMenu):
+        (testContextMenuCustomMenu):
+        (testContextMenuSubMenu):
+        (testContextMenuDismissed):
+        (testContextMenuWebExtensionMenu):
+        (testContextMenuWebExtensionNode):
+        (testContextMenuLiveStream):
+        (beforeAll):
+        * TestWebKitAPI/Tests/WebKitGtk/TestDOMDOMWindow.cpp:
+        (signalsNotifyCallback):
+        * TestWebKitAPI/Tests/WebKitGtk/TestInspector.cpp:
+        (testInspectorDefault):
+        (testInspectorManualAttachDetach):
+        (testInspectorCustomContainerDestroyed):
+        * TestWebKitAPI/Tests/WebKitGtk/TestInspectorServer.cpp:
+        (testInspectorServerPageList):
+        * TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp:
+        (testPrintCustomWidget):
+        * TestWebKitAPI/Tests/WebKitGtk/TestWebViewEditor.cpp:
+        * TestWebKitAPI/glib/WebKitGLib/WebViewTest.h:
+        * TestWebKitAPI/glib/WebKitGLib/gtk/WebViewTestGtk.cpp:
+        (WebViewTest::quitMainLoopAfterProcessingPendingEvents):
+        (WebViewTest::showInWindow):
+        (WebViewTest::mouseMoveTo):
+        (WebViewTest::clickMouseButton):
+        (WebViewTest::keyStroke):
+        * TestWebKitAPI/glib/WebKitGLib/wpe/WebViewTestWPE.cpp:
+        (WebViewTest::showInWindow):
+        * TestWebKitAPI/gtk/PlatformWebViewGtk.cpp:
+        (TestWebKitAPI::toWebKitGLibAPI):
+        (TestWebKitAPI::PlatformWebView::simulateSpacebarKeyPress):
+        (TestWebKitAPI::PlatformWebView::simulateAltKeyPress):
+        (TestWebKitAPI::PlatformWebView::simulateRightClick):
+        (TestWebKitAPI::PlatformWebView::simulateMouseMove):
+
 2020-07-20  Aakash Jain  <aakash_j...@apple.com>
 
         [ews] Use -q while unzipping layout-test-results.zip

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp (264646 => 264647)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp	2020-07-21 08:08:18 UTC (rev 264647)
@@ -559,8 +559,41 @@
         g_main_loop_run(m_mainLoop);
     }
 
+#if PLATFORM(GTK)
+    static gboolean contextMenuCallback(WebKitWebView* webView, WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult* hitTestResult, WebViewDownloadTest* test)
+    {
+        g_assert_true(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult));
+        GList* items = webkit_context_menu_get_items(contextMenu);
+        for (GList* l = items; l; l = g_list_next(l)) {
+            g_assert_true(WEBKIT_IS_CONTEXT_MENU_ITEM(l->data));
+            auto* item = WEBKIT_CONTEXT_MENU_ITEM(l->data);
+            if (webkit_context_menu_item_get_stock_action(item) == WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_LINK_TO_DISK) {
+                test->m_contextMenuDownloadItem = item;
+                break;
+            }
+        }
+        test->quitMainLoop();
+        return FALSE;
+    }
+
+    WebKitContextMenuItem* showContextMenuAndGetDownloadItem(int x, int y)
+    {
+        m_contextMenuDownloadItem = nullptr;
+        auto id = g_signal_connect(m_webView, "context-menu", G_CALLBACK(contextMenuCallback), this);
+        RunLoop::main().dispatch([this, x, y] {
+            clickMouseButton(x, y, 3);
+        });
+        g_main_loop_run(m_mainLoop);
+        g_signal_handler_disconnect(m_webView, id);
+        return m_contextMenuDownloadItem.get();
+    }
+#endif
+
     GRefPtr<WebKitDownload> m_download;
     bool m_shouldDelayDecideDestination { false };
+#if PLATFORM(GTK)
+    GRefPtr<WebKitContextMenuItem> m_contextMenuDownloadItem;
+#endif
 };
 
 static void testWebViewDownloadURI(WebViewDownloadTest* test, gconstpointer)
@@ -689,30 +722,9 @@
 }
 
 #if PLATFORM(GTK)
-static gboolean contextMenuCallback(WebKitWebView* webView, WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult* hitTestResult, WebViewDownloadTest* test)
-{
-    g_assert_true(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult));
-    g_assert_true(webkit_hit_test_result_context_is_link(hitTestResult));
-    GList* items = webkit_context_menu_get_items(contextMenu);
-    GRefPtr<WebKitContextMenuItem> contextMenuItem;
-    for (GList* l = items; l; l = g_list_next(l)) {
-        g_assert_true(WEBKIT_IS_CONTEXT_MENU_ITEM(l->data));
-        auto* item = WEBKIT_CONTEXT_MENU_ITEM(l->data);
-        if (webkit_context_menu_item_get_stock_action(item) == WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_LINK_TO_DISK) {
-            contextMenuItem = item;
-            break;
-        }
-    }
-    g_assert_nonnull(contextMenuItem.get());
-    webkit_context_menu_remove_all(contextMenu);
-    webkit_context_menu_append(contextMenu, contextMenuItem.get());
-    test->quitMainLoop();
-    return FALSE;
-}
-
 static void testContextMenuDownloadActions(WebViewDownloadTest* test, gconstpointer)
 {
-    test->showInWindowAndWaitUntilMapped();
+    test->showInWindow();
 
     static const char* linkHTMLFormat = "<html><body><a style='position:absolute; left:1; top:1' href=''>Download Me</a></body></html>";
     GUniquePtr<char> linkHTML(g_strdup_printf(linkHTMLFormat, kServer->getURIForPath("/test.pdf").data()));
@@ -719,21 +731,9 @@
     test->loadHtml(linkHTML.get(), kServer->getURIForPath("/").data());
     test->waitUntilLoadFinished();
 
-    g_signal_connect(test->m_webView, "context-menu", G_CALLBACK(contextMenuCallback), test);
-    g_idle_add([](gpointer userData) -> gboolean {
-        auto* test = static_cast<WebViewDownloadTest*>(userData);
-        test->clickMouseButton(1, 1, 3);
-        return FALSE;
-    }, test);
-    g_main_loop_run(test->m_mainLoop);
-
-    g_idle_add([](gpointer userData) -> gboolean {
-        auto* test = static_cast<WebViewDownloadTest*>(userData);
-        // Select and activate the context menu action.
-        test->keyStroke(GDK_KEY_Down);
-        test->keyStroke(GDK_KEY_Return);
-        return FALSE;
-    }, test);
+    auto* item = test->showContextMenuAndGetDownloadItem(1, 1);
+    g_assert(WEBKIT_IS_CONTEXT_MENU_ITEM(item));
+    g_action_activate(webkit_context_menu_item_get_gaction(item), nullptr);
     test->waitUntilDownloadStarted();
 
     g_assert_true(test->m_webView == webkit_download_get_web_view(test->m_download.get()));
@@ -755,7 +755,7 @@
 
 static void testBlobDownload(WebViewDownloadTest* test, gconstpointer)
 {
-    test->showInWindowAndWaitUntilMapped();
+    test->showInWindow();
 
     static const char* linkBlobHTML =
         "<html><body>"

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp (264646 => 264647)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp	2020-07-21 08:08:18 UTC (rev 264647)
@@ -250,13 +250,12 @@
     InputMethodTest()
         : m_context(adoptGRef(static_cast<WebKitInputMethodContextMock*>(g_object_new(webkit_input_method_context_mock_get_type(), nullptr))))
     {
+        WebViewTest::showInWindow();
 #if PLATFORM(GTK)
-        WebViewTest::showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
         auto* defaultContext = webkit_web_view_get_input_method_context(m_webView);
         g_assert_true(WEBKIT_IS_INPUT_METHOD_CONTEXT(defaultContext));
         assertObjectIsDeletedWhenTestFinishes(G_OBJECT(defaultContext));
 #elif PLATFORM(WPE)
-        WebViewTest::showInWindow();
         g_assert_null(webkit_web_view_get_input_method_context(m_webView));
 #endif
         assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_context.get()));

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp (264646 => 264647)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp	2020-07-21 08:08:18 UTC (rev 264647)
@@ -122,7 +122,7 @@
         "    <option selected>Bar</option>"
         "    <option disabled>Baz</option>"
         "  </select></body></html>";
-    test->showInWindowAndWaitUntilMapped();
+    test->showInWindow();
     test->loadHtml(html, nullptr);
     test->waitUntilLoadFinished();
 
@@ -171,7 +171,7 @@
         "    </optgroup>"
         "    <option>Tail</option>"
         "  </select></body></html>";
-    test->showInWindowAndWaitUntilMapped();
+    test->showInWindow();
     test->loadHtml(html, nullptr);
     test->waitUntilLoadFinished();
 
@@ -245,7 +245,7 @@
         "    <option>Bar</option>"
         "    <option>Baz</option>"
         "  </select></body></html>";
-    test->showInWindowAndWaitUntilMapped();
+    test->showInWindow();
     test->loadHtml(html, nullptr);
     test->waitUntilLoadFinished();
 
@@ -275,7 +275,7 @@
         "    <option>Bar</option>"
         "    <option>Baz</option>"
         "  </select></body></html>";
-    test->showInWindowAndWaitUntilMapped();
+    test->showInWindow();
     test->loadHtml(html, nullptr);
     test->waitUntilLoadFinished();
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp (264646 => 264647)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp	2020-07-21 08:08:18 UTC (rev 264647)
@@ -481,10 +481,7 @@
 
 static void testWebViewCreateNavigationData(CreateNavigationDataTest* test, gconstpointer)
 {
-#if PLATFORM(GTK)
-    test->showInWindowAndWaitUntilMapped();
-#endif
-
+    test->showInWindow();
     test->loadHTML(
         "<html><body>"
         "<input style=\"position:absolute; left:0; top:0; margin:0; padding:0\" type=\"button\" value=\"click to show a popup\" _onclick_=\"window.open('data:foo');\"/>"
@@ -590,9 +587,7 @@
 
 static void testWebViewJavaScriptDialogs(UIClientTest* test, gconstpointer)
 {
-#if PLATFORM(GTK)
-    test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
-#endif
+    test->showInWindow();
 
     static const char* htmlOnLoadFormat = "<html><body _onLoad_=\"%s\"></body></html>";
     static const char* jsAlertFormat = "alert('%s')";
@@ -721,7 +716,7 @@
     // If no size specified for window.open(), and new windows are not set to a specific default size with gtk_window_set_default_size()
     // on the create signal, then new windows open with the size of the previous window.
     cairo_rectangle_int_t expectedGeometry = { 0, 0, 527, 671 };
-    test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL, expectedGeometry.width, expectedGeometry.height);
+    test->showInWindow(expectedGeometry.width, expectedGeometry.height);
     test->setExpectedWindowProperties(UIClientTest::WindowProperties(&expectedGeometry, false, false, false, false, false, true, false));
     test->loadHtml("<html><body _onLoad_=\"window.open('', '', 'left=0,top=0,location=no,menubar=no,status=no,toolbar=no,scrollbars=no').close();\"></body></html>", nullptr);
     test->waitUntilMainLoopFinishes();
@@ -731,7 +726,7 @@
 #if PLATFORM(GTK)
 static void testWebViewMouseTarget(UIClientTest* test, gconstpointer)
 {
-    test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
+    test->showInWindow();
 
     const char* linksHoveredHTML =
         "<html><head>"
@@ -850,9 +845,7 @@
     // to register the error quark twice. See https://bugs.webkit.org/show_bug.cgi?id=89858.
     // Make warnings non-fatal for this test to make it pass.
     Test::removeLogFatalFlag(G_LOG_LEVEL_WARNING);
-#if PLATFORM(GTK)
-    test->showInWindowAndWaitUntilMapped();
-#endif
+    test->showInWindow();
     static const char* geolocationRequestHTML =
         "<html>"
         "  <script>"
@@ -898,9 +891,7 @@
     webkitSettingsSetMediaCaptureRequiresSecureConnection(settings, FALSE);
     webkit_settings_set_enable_mock_capture_devices(settings, TRUE);
 
-#if PLATFORM(GTK)
-    test->showInWindowAndWaitUntilMapped();
-#endif
+    test->showInWindow();
     static const char* userMediaRequestHTML =
         "<html>"
         "  <script>"
@@ -943,9 +934,7 @@
     webkit_settings_set_enable_mock_capture_devices(settings, TRUE);
     webkitSettingsSetMediaCaptureRequiresSecureConnection(settings, FALSE);
 
-#if PLATFORM(GTK)
-    test->showInWindowAndWaitUntilMapped();
-#endif
+    test->showInWindow();
     static const char* userMediaRequestHTML = "<html>"
         "  <script>"
         "  function runTest()"
@@ -985,9 +974,7 @@
     webkit_settings_set_enable_mock_capture_devices(settings, TRUE);
     webkitSettingsSetMediaCaptureRequiresSecureConnection(settings, FALSE);
 
-#if PLATFORM(GTK)
-    test->showInWindowAndWaitUntilMapped();
-#endif
+    test->showInWindow();
     static const char* userMediaRequestHTML = "<html>"
         "  <script>"
         "  function runTest()"
@@ -1018,10 +1005,7 @@
 #if ENABLE(POINTER_LOCK)
 static void testWebViewPointerLockPermissionRequest(UIClientTest* test, gconstpointer)
 {
-#if PLATFORM(GTK)
-    test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
-#endif
-
+    test->showInWindow();
     static const char* pointerLockRequestHTML =
         "<html>"
         "  <script>"
@@ -1089,9 +1073,7 @@
 
 static void testWebViewFileChooserRequest(FileChooserTest* test, gconstpointer)
 {
-#if PLATFORM(GTK)
-    test->showInWindowAndWaitUntilMapped();
-#endif
+    test->showInWindow();
     static const char* fileChooserHTMLFormat = "<html><body><input style='position:absolute;left:0;top:0;margin:0;padding:0' type='file' %s/></body></html>";
 
     // Multiple selections not allowed, no MIME filtering.
@@ -1240,7 +1222,7 @@
 static void testWebViewColorChooserRequest(ColorChooserTest* test, gconstpointer)
 {
     static const char* colorChooserHTMLFormat = "<html><body><input style='position:absolute;left:1;top:1;margin:0;padding:0;width:45;height:25' type='color' %s/></body></html>";
-    test->showInWindowAndWaitUntilMapped();
+    test->showInWindow();
 
     GUniquePtr<char> defaultColorHTML(g_strdup_printf(colorChooserHTMLFormat, ""));
     test->loadHtml(defaultColorHTML.get(), nullptr);

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp (264646 => 264647)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp	2020-07-21 08:08:18 UTC (rev 264647)
@@ -73,7 +73,7 @@
 
 static void testWebExtensionInputElementIsUserEdited(WebViewTest* test, gconstpointer)
 {
-    test->showInWindowAndWaitUntilMapped();
+    test->showInWindow();
     test->loadHtml("<html><body id='body'><input id='input'></input><textarea id='textarea'></textarea></body></html>", nullptr);
     test->waitUntilLoadFinished();
 
@@ -262,7 +262,7 @@
     GRefPtr<GVariant> result = adoptGRef(g_dbus_proxy_call_sync(proxy.get(), "RemoveAVPluginsFromGSTRegistry",
         nullptr, G_DBUS_CALL_FLAGS_NONE, -1, nullptr, nullptr));
 
-    test->showInWindowAndWaitUntilMapped();
+    test->showInWindow();
 
     gulong permissionRequestSignalID = g_signal_connect(test->m_webView, "permission-request", G_CALLBACK(permissionRequestCallback), test);
     // FIXME: the base URI needs to finish with / to work, that shouldn't happen.

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitFindController.cpp (264646 => 264647)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitFindController.cpp	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitFindController.cpp	2020-07-21 08:08:18 UTC (rev 264647)
@@ -265,7 +265,7 @@
     test->loadHtml(testString, 0);
     test->waitUntilLoadFinished();
 
-    test->showInWindowAndWaitUntilMapped();
+    test->showInWindow();
 
     cairo_surface_t* originalSurface = cairo_surface_reference(
         test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT, WEBKIT_SNAPSHOT_OPTIONS_NONE));

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitPolicyClient.cpp (264646 => 264647)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitPolicyClient.cpp	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitPolicyClient.cpp	2020-07-21 08:08:18 UTC (rev 264647)
@@ -311,10 +311,8 @@
 
 static void testAutoplayPolicy(PolicyClientTest* test, gconstpointer)
 {
-#if PLATFORM(GTK)
     // The web view must be realized for the video to start playback.
-    test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
-#endif
+    test->showInWindow();
 
     test->m_policyDecisionTypeFilter = WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION;
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp (264646 => 264647)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp	2020-07-21 08:08:18 UTC (rev 264647)
@@ -464,9 +464,7 @@
 #if ENABLE(FULLSCREEN_API)
 static void testWebViewFullScreen(FullScreenClientTest* test, gconstpointer)
 {
-#if PLATFORM(GTK)
-    test->showInWindowAndWaitUntilMapped();
-#endif
+    test->showInWindow();
     test->loadHtml("<html><body>FullScreen test</body></html>", 0);
     test->waitUntilLoadFinished();
     test->requestFullScreenAndWaitUntilEnteredFullScreen();
@@ -570,7 +568,7 @@
 
 static void testWebViewSubmitForm(FormClientTest* test, gconstpointer)
 {
-    test->showInWindowAndWaitUntilMapped();
+    test->showInWindow();
 
     const char* formHTML =
         "<html><body>"
@@ -821,7 +819,7 @@
     g_assert_cmpint(cairo_image_surface_get_height(surface1), ==, 100);
 
     // Show the WebView in a popup widow of 50x50 and try again with WEBKIT_SNAPSHOT_REGION_VISIBLE.
-    test->showInWindowAndWaitUntilMapped(GTK_WINDOW_POPUP, 50, 50);
+    test->showInWindow(50, 50);
     surface1 = cairo_surface_reference(test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_NONE));
     g_assert_nonnull(surface1);
     g_assert_cmpuint(cairo_surface_get_type(surface1), ==, CAIRO_SURFACE_TYPE_IMAGE);
@@ -1106,11 +1104,9 @@
 
 static void testWebViewIsPlayingAudio(IsPlayingAudioWebViewTest* test, gconstpointer)
 {
-#if PLATFORM(GTK)
     // The web view must be realized for the video to start playback and
     // trigger changes in WebKitWebView::is-playing-audio.
-    test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
-#endif
+    test->showInWindow();
 
     // Initially, web views should always report no audio being played.
     g_assert_false(webkit_web_view_is_playing_audio(test->m_webView));
@@ -1196,7 +1192,7 @@
 {
     test->loadHtml("<html style='width: 325px; height: 615px'></html>", nullptr);
     test->waitUntilLoadFinished();
-    test->showInWindowAndWaitUntilMapped();
+    test->showInWindow();
     GtkRequisition minimunSize, naturalSize;
     gtk_widget_get_preferred_size(GTK_WIDGET(test->m_webView), &minimunSize, &naturalSize);
     g_assert_cmpint(minimunSize.width, ==, 0);

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp (264646 => 264647)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp	2020-07-21 08:08:18 UTC (rev 264647)
@@ -530,8 +530,7 @@
 
 static void testContextMenuDefaultMenu(ContextMenuDefaultTest* test, gconstpointer)
 {
-    test->showInWindowAndWaitUntilMapped();
-
+    test->showInWindow();
     prepareContextMenuTestView(test);
 
     // Context menu for selection.
@@ -578,8 +577,7 @@
 
 static void testPopupEventSignal(ContextMenuDefaultTest* test, gconstpointer)
 {
-    test->showInWindowAndWaitUntilMapped();
-
+    test->showInWindow();
     prepareContextMenuTestView(test);
 
     test->m_expectedMenuType = ContextMenuDefaultTest::Selection;
@@ -588,8 +586,7 @@
 
 static void testContextMenuKey(ContextMenuDefaultTest* test, gconstpointer)
 {
-    test->showInWindowAndWaitUntilMapped();
-
+    test->showInWindow();
     prepareContextMenuTestView(test);
 
     test->m_expectedMenuType = ContextMenuDefaultTest::Selection;
@@ -746,8 +743,7 @@
 
 static void testContextMenuPopulateMenu(ContextMenuCustomTest* test, gconstpointer)
 {
-    test->showInWindowAndWaitUntilMapped();
-
+    test->showInWindow();
     test->loadHtml("<html><body>WebKitGTK Context menu tests</body></html>", "file:///");
     test->waitUntilLoadFinished();
 
@@ -869,8 +865,7 @@
 
 static void testContextMenuCustomMenu(ContextMenuCustomFullTest* test, gconstpointer)
 {
-    test->showInWindowAndWaitUntilMapped();
-
+    test->showInWindow();
     test->loadHtml("<html><body>WebKitGTK Context menu tests</body></html>", "file:///");
     test->waitUntilLoadFinished();
 
@@ -877,64 +872,6 @@
     test->showContextMenuAndWaitUntilFinished();
 }
 
-class ContextMenuDisabledTest: public ContextMenuTest {
-public:
-    MAKE_GLIB_TEST_FIXTURE(ContextMenuDisabledTest);
-
-    enum DisableMode {
-        IgnoreClicks,
-        IgnoreDefaultMenu
-    };
-
-    static gboolean buttonPressEventCallback(GtkWidget*, GdkEvent* event, ContextMenuDisabledTest* test)
-    {
-        if (event->button.button != 3)
-            return FALSE;
-        return test->rightButtonPressed();
-    }
-
-    ContextMenuDisabledTest()
-        : m_disableMode(IgnoreClicks)
-    {
-        g_signal_connect(m_webView, "button-press-event", G_CALLBACK(buttonPressEventCallback), this);
-    }
-
-    bool contextMenu(WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult*)
-    {
-        if (m_disableMode == IgnoreClicks)
-            g_assert_not_reached();
-        else
-            quitMainLoop();
-
-        return true;
-    }
-
-    bool rightButtonPressed()
-    {
-        if (m_disableMode == IgnoreClicks) {
-            quitMainLoopAfterProcessingPendingEvents();
-            return true;
-        }
-        return false;
-    }
-
-    DisableMode m_disableMode;
-};
-
-static void testContextMenuDisableMenu(ContextMenuDisabledTest* test, gconstpointer)
-{
-    test->showInWindowAndWaitUntilMapped();
-
-    test->loadHtml("<html><body>WebKitGTK Context menu tests</body></html>", "file:///");
-    test->waitUntilLoadFinished();
-
-    test->m_disableMode = ContextMenuDisabledTest::IgnoreDefaultMenu;
-    test->showContextMenuAndWaitUntilFinished();
-
-    test->m_disableMode = ContextMenuDisabledTest::IgnoreClicks;
-    test->showContextMenuAndWaitUntilFinished();
-}
-
 class ContextMenuSubmenuTest: public ContextMenuTest {
 public:
     MAKE_GLIB_TEST_FIXTURE(ContextMenuSubmenuTest);
@@ -976,8 +913,7 @@
 
 static void testContextMenuSubMenu(ContextMenuSubmenuTest* test, gconstpointer)
 {
-    test->showInWindowAndWaitUntilMapped();
-
+    test->showInWindow();
     test->loadHtml("<html><body>WebKitGTK Context menu tests</body></html>", "file:///");
     test->waitUntilLoadFinished();
 
@@ -1017,8 +953,7 @@
 
 static void testContextMenuDismissed(ContextMenuDismissedTest* test, gconstpointer)
 {
-    test->showInWindowAndWaitUntilMapped();
-
+    test->showInWindow();
     test->loadHtml("<html><body>WebKitGTK Context menu tests</body></html>", "file:///");
     test->waitUntilLoadFinished();
 
@@ -1067,7 +1002,7 @@
 
 static void testContextMenuWebExtensionMenu(ContextMenuWebExtensionTest* test, gconstpointer)
 {
-    test->showInWindowAndWaitUntilMapped();
+    test->showInWindow();
     test->loadHtml("<html><body>WebKitGTK Context menu tests<br>"
         "<a style='position:absolute; left:1; top:10' href=''>WebKitGTK Website</a></body></html>",
         "ContextMenuTestDefault");
@@ -1157,7 +1092,7 @@
 
 static void testContextMenuWebExtensionNode(ContextMenuWebExtensionNodeTest* test, gconstpointer)
 {
-    test->showInWindowAndWaitUntilMapped();
+    test->showInWindow();
     test->loadHtml("<html><body><p style='position:absolute; left:1; top:1'>WebKitGTK Context menu tests</p><br>"
         "<a style='position:absolute; left:1; top:100' href=''>WebKitGTK Website</a></body></html>",
         "ContextMenuTestNode");
@@ -1227,8 +1162,7 @@
 
 static void testContextMenuLiveStream(ContextMenuDefaultTest* test, gconstpointer)
 {
-    test->showInWindowAndWaitUntilMapped();
-
+    test->showInWindow();
     test->loadURI(kServer->getURIForPath("/live-stream").data());
     test->waitUntilLoadFinished();
 
@@ -1247,7 +1181,6 @@
     ContextMenuDefaultTest::add("WebKitWebView", "live-stream", testContextMenuLiveStream);
     ContextMenuCustomTest::add("WebKitWebView", "populate-menu", testContextMenuPopulateMenu);
     ContextMenuCustomFullTest::add("WebKitWebView", "custom-menu", testContextMenuCustomMenu);
-    ContextMenuDisabledTest::add("WebKitWebView", "disable-menu", testContextMenuDisableMenu);
     ContextMenuSubmenuTest::add("WebKitWebView", "submenu", testContextMenuSubMenu);
     ContextMenuDismissedTest::add("WebKitWebView", "menu-dismissed", testContextMenuDismissed);
     ContextMenuWebExtensionTest::add("WebKitWebPage", "context-menu", testContextMenuWebExtensionMenu);

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestDOMDOMWindow.cpp (264646 => 264647)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestDOMDOMWindow.cpp	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestDOMDOMWindow.cpp	2020-07-21 08:08:18 UTC (rev 264647)
@@ -47,7 +47,7 @@
 
     if (g_str_equal(key, "loaded")) {
         status.loaded = TRUE;
-        status.test->showInWindowAndWaitUntilMapped();
+        status.test->showInWindow();
 
         // Click in a known location where the text is
         status.test->clickMouseButton(20, 18, 1, 0);

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestInspector.cpp (264646 => 264647)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestInspector.cpp	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestInspector.cpp	2020-07-21 08:08:18 UTC (rev 264647)
@@ -167,7 +167,7 @@
 
 static void testInspectorDefault(InspectorTest* test, gconstpointer)
 {
-    test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
+    test->showInWindow();
     test->resizeView(200, 200);
     test->loadHtml("<html><body><p>WebKitGTK Inspector test</p></body></html>", 0);
     test->waitUntilLoadFinished();
@@ -298,7 +298,7 @@
 
 static void testInspectorManualAttachDetach(CustomInspectorTest* test, gconstpointer)
 {
-    test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
+    test->showInWindow();
     test->resizeView(200, 200);
     test->loadHtml("<html><body><p>WebKitGTK Inspector test</p></body></html>", 0);
     test->waitUntilLoadFinished();
@@ -340,7 +340,7 @@
 
 static void testInspectorCustomContainerDestroyed(CustomInspectorTest* test, gconstpointer)
 {
-    test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
+    test->showInWindow();
     test->resizeView(200, 200);
     test->loadHtml("<html><body><p>WebKitGTK Inspector test</p></body></html>", 0);
     test->waitUntilLoadFinished();

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestInspectorServer.cpp (264646 => 264647)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestInspectorServer.cpp	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestInspectorServer.cpp	2020-07-21 08:08:18 UTC (rev 264647)
@@ -138,7 +138,7 @@
 {
     GUniqueOutPtr<GError> error;
 
-    test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
+    test->showInWindow();
     g_assert_true(test->getPageList());
 
     WebKitJavascriptResult* _javascript_Result = test->runJavaScriptAndWaitUntilFinished("document.getElementsByClassName('targetname').length;", &error.outPtr());

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp (264646 => 264647)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp	2020-07-21 08:08:18 UTC (rev 264647)
@@ -421,8 +421,7 @@
 
 static void testPrintCustomWidget(PrintCustomWidgetTest* test, gconstpointer)
 {
-    test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL, 0, 0);
-
+    test->showInWindow();
     test->loadHtml("<html><body>Text</body></html>", 0);
     test->waitUntilLoadFinished();
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebViewEditor.cpp (264646 => 264647)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebViewEditor.cpp	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebViewEditor.cpp	2020-07-21 08:08:18 UTC (rev 264647)
@@ -34,7 +34,7 @@
         , m_triesCount(0)
         , m_editorState(nullptr)
     {
-        showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
+        showInWindow();
         loadURI("about:blank");
         waitUntilLoadFinished();
         gtk_clipboard_clear(m_clipboard);

Modified: trunk/Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.h (264646 => 264647)


--- trunk/Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.h	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.h	2020-07-21 08:08:18 UTC (rev 264647)
@@ -65,17 +65,12 @@
     void clickMouseButton(int x, int y, unsigned button = 1, unsigned mouseModifiers = 0);
     void keyStroke(unsigned keyVal, unsigned keyModifiers = 0);
 
+    void showInWindow(int width = 0, int height = 0);
+
 #if PLATFORM(GTK)
-    void showInWindow(GtkWindowType = GTK_WINDOW_POPUP);
-    void showInWindowAndWaitUntilMapped(GtkWindowType = GTK_WINDOW_POPUP, int width = 0, int height = 0);
     void emitPopupMenuSignal();
 #endif
 
-#if PLATFORM(WPE)
-    void showInWindowAndWaitUntilMapped() { showInWindow(); };
-    void showInWindow();
-#endif
-
     WebKitJavascriptResult* runJavaScriptAndWaitUntilFinished(const char* _javascript_, GError**);
     WebKitJavascriptResult* runJavaScriptFromGResourceAndWaitUntilFinished(const char* resource, GError**);
     WebKitJavascriptResult* runJavaScriptInWorldAndWaitUntilFinished(const char* _javascript_, const char* world, GError**);
@@ -119,9 +114,4 @@
 #if PLATFORM(GTK)
     GtkWidget* m_parentWindow { nullptr };
 #endif
-
-private:
-#if PLATFORM(GTK)
-    void doMouseButtonEvent(GdkEventType, int, int, unsigned, unsigned);
-#endif
 };

Modified: trunk/Tools/TestWebKitAPI/glib/WebKitGLib/gtk/WebViewTestGtk.cpp (264646 => 264647)


--- trunk/Tools/TestWebKitAPI/glib/WebKitGLib/gtk/WebViewTestGtk.cpp	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Tools/TestWebKitAPI/glib/WebKitGLib/gtk/WebViewTestGtk.cpp	2020-07-21 08:08:18 UTC (rev 264647)
@@ -21,6 +21,7 @@
 #include "config.h"
 #include "WebViewTest.h"
 
+#include "WebKitWebViewBaseInternal.h"
 #include <WebCore/GUniquePtrGtk.h>
 #include <WebCore/GtkVersioning.h>
 #include <gtk/gtk.h>
@@ -40,8 +41,8 @@
 
 void WebViewTest::quitMainLoopAfterProcessingPendingEvents()
 {
-    while (gtk_events_pending())
-        gtk_main_iteration();
+    while (g_main_context_pending(nullptr))
+        g_main_context_iteration(nullptr, TRUE);
     quitMainLoop();
 }
 
@@ -61,65 +62,30 @@
     gtk_widget_hide(GTK_WIDGET(m_webView));
 }
 
-static gboolean parentWindowMapped(GtkWidget* widget, GdkEvent*, WebViewTest* test)
+void WebViewTest::showInWindow(int width, int height)
 {
-    g_signal_handlers_disconnect_by_func(widget, reinterpret_cast<void*>(parentWindowMapped), test);
-    g_main_loop_quit(test->m_mainLoop);
-
-    return FALSE;
-}
-
-void WebViewTest::showInWindow(GtkWindowType windowType)
-{
     g_assert_null(m_parentWindow);
-    m_parentWindow = gtk_window_new(windowType);
+    m_parentWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    if (width && height)
+        gtk_window_set_default_size(GTK_WINDOW(m_parentWindow), width, height);
     gtk_container_add(GTK_CONTAINER(m_parentWindow), GTK_WIDGET(m_webView));
     gtk_widget_show(GTK_WIDGET(m_webView));
     gtk_widget_show(m_parentWindow);
-}
 
-void WebViewTest::showInWindowAndWaitUntilMapped(GtkWindowType windowType, int width, int height)
-{
-    g_assert_null(m_parentWindow);
-    m_parentWindow = gtk_window_new(windowType);
-    if (width && height)
-        gtk_window_resize(GTK_WINDOW(m_parentWindow), width, height);
-    gtk_container_add(GTK_CONTAINER(m_parentWindow), GTK_WIDGET(m_webView));
-    gtk_widget_show(GTK_WIDGET(m_webView));
-
-    g_signal_connect(m_parentWindow, "map-event", G_CALLBACK(parentWindowMapped), this);
-    gtk_widget_show(m_parentWindow);
-    g_main_loop_run(m_mainLoop);
+    while (g_main_context_pending(nullptr))
+        g_main_context_iteration(nullptr, TRUE);
 }
 
 void WebViewTest::mouseMoveTo(int x, int y, unsigned mouseModifiers)
 {
     g_assert_nonnull(m_parentWindow);
-    GtkWidget* viewWidget = GTK_WIDGET(m_webView);
-    g_assert_true(gtk_widget_get_realized(viewWidget));
-
-    GUniquePtr<GdkEvent> event(gdk_event_new(GDK_MOTION_NOTIFY));
-    event->motion.x = x;
-    event->motion.y = y;
-
-    event->motion.time = GDK_CURRENT_TIME;
-    event->motion.window = gtk_widget_get_window(viewWidget);
-    g_object_ref(event->motion.window);
-    event->motion.device = gdk_seat_get_pointer(gdk_display_get_default_seat(gtk_widget_get_display(viewWidget)));
-    event->motion.state = mouseModifiers;
-    event->motion.axes = 0;
-
-    int xRoot, yRoot;
-    gdk_window_get_root_coords(gtk_widget_get_window(viewWidget), x, y, &xRoot, &yRoot);
-    event->motion.x_root = xRoot;
-    event->motion.y_root = yRoot;
-    gtk_main_do_event(event.get());
+    webkitWebViewBaseSynthesizeMouseEvent(WEBKIT_WEB_VIEW_BASE(m_webView), MouseEventType::Motion, 0, 0, x, y, mouseModifiers, 0);
 }
 
 void WebViewTest::clickMouseButton(int x, int y, unsigned button, unsigned mouseModifiers)
 {
-    doMouseButtonEvent(GDK_BUTTON_PRESS, x, y, button, mouseModifiers);
-    doMouseButtonEvent(GDK_BUTTON_RELEASE, x, y, button, mouseModifiers);
+    webkitWebViewBaseSynthesizeMouseEvent(WEBKIT_WEB_VIEW_BASE(m_webView), MouseEventType::Press, button, 1 << (8 + button - 1), x, y, mouseModifiers, 1);
+    webkitWebViewBaseSynthesizeMouseEvent(WEBKIT_WEB_VIEW_BASE(m_webView), MouseEventType::Release, button, 0, x, y, mouseModifiers, 0);
 }
 
 void WebViewTest::emitPopupMenuSignal()
@@ -134,52 +100,5 @@
 void WebViewTest::keyStroke(unsigned keyVal, unsigned keyModifiers)
 {
     g_assert_nonnull(m_parentWindow);
-    GtkWidget* viewWidget = GTK_WIDGET(m_webView);
-    g_assert_true(gtk_widget_get_realized(viewWidget));
-
-    GUniquePtr<GdkEvent> event(gdk_event_new(GDK_KEY_PRESS));
-    event->key.keyval = keyVal;
-
-    event->key.time = GDK_CURRENT_TIME;
-    event->key.window = gtk_widget_get_window(viewWidget);
-    g_object_ref(event->key.window);
-    GdkDisplay* display = gtk_widget_get_display(viewWidget);
-    gdk_event_set_device(event.get(), gdk_seat_get_pointer(gdk_display_get_default_seat(display)));
-    event->key.state = keyModifiers;
-
-    // When synthesizing an event, an invalid hardware_keycode value can cause it to be badly processed by GTK+.
-    GUniqueOutPtr<GdkKeymapKey> keys;
-    int keysCount;
-    if (gdk_keymap_get_entries_for_keyval(gdk_keymap_get_for_display(display), keyVal, &keys.outPtr(), &keysCount) && keysCount)
-        event->key.hardware_keycode = keys.get()[0].keycode;
-
-    gtk_main_do_event(event.get());
-    event->key.type = GDK_KEY_RELEASE;
-    gtk_main_do_event(event.get());
+    webkitWebViewBaseSynthesizeKeyEvent(WEBKIT_WEB_VIEW_BASE(m_webView), KeyEventType::Insert, keyVal, keyModifiers, ShouldTranslateKeyboardState::No);
 }
-
-void WebViewTest::doMouseButtonEvent(GdkEventType eventType, int x, int y, unsigned button, unsigned mouseModifiers)
-{
-    g_assert_nonnull(m_parentWindow);
-    GtkWidget* viewWidget = GTK_WIDGET(m_webView);
-    g_assert_true(gtk_widget_get_realized(viewWidget));
-
-    GUniquePtr<GdkEvent> event(gdk_event_new(eventType));
-    event->button.window = gtk_widget_get_window(viewWidget);
-    g_object_ref(event->button.window);
-
-    event->button.time = GDK_CURRENT_TIME;
-    event->button.x = x;
-    event->button.y = y;
-    event->button.axes = 0;
-    event->button.state = mouseModifiers;
-    event->button.button = button;
-
-    event->button.device = gdk_seat_get_pointer(gdk_display_get_default_seat(gtk_widget_get_display(viewWidget)));
-
-    int xRoot, yRoot;
-    gdk_window_get_root_coords(gtk_widget_get_window(viewWidget), x, y, &xRoot, &yRoot);
-    event->button.x_root = xRoot;
-    event->button.y_root = yRoot;
-    gtk_main_do_event(event.get());
-}

Modified: trunk/Tools/TestWebKitAPI/glib/WebKitGLib/wpe/WebViewTestWPE.cpp (264646 => 264647)


--- trunk/Tools/TestWebKitAPI/glib/WebKitGLib/wpe/WebViewTestWPE.cpp	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Tools/TestWebKitAPI/glib/WebKitGLib/wpe/WebViewTestWPE.cpp	2020-07-21 08:08:18 UTC (rev 264647)
@@ -41,7 +41,7 @@
     // FIXME: implement.
 }
 
-void WebViewTest::showInWindow()
+void WebViewTest::showInWindow(int, int)
 {
     auto* backend = webkit_web_view_backend_get_wpe_backend(webkit_web_view_get_backend(m_webView));
     wpe_view_backend_add_activity_state(backend, wpe_view_activity_state_visible | wpe_view_activity_state_in_window | wpe_view_activity_state_focused);

Modified: trunk/Tools/TestWebKitAPI/gtk/PlatformWebViewGtk.cpp (264646 => 264647)


--- trunk/Tools/TestWebKitAPI/gtk/PlatformWebViewGtk.cpp	2020-07-21 08:06:34 UTC (rev 264646)
+++ trunk/Tools/TestWebKitAPI/gtk/PlatformWebViewGtk.cpp	2020-07-21 08:08:18 UTC (rev 264647)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "PlatformWebView.h"
 
+#include "WebKitWebViewBaseInternal.h"
 #include <WebCore/GUniquePtrGtk.h>
 #include <WebCore/GtkVersioning.h>
 #include <WebKit/WKRetainPtr.h>
@@ -83,26 +84,9 @@
     gtk_window_resize(GTK_WINDOW(m_window), width, height);
 }
 
-static void doKeyStroke(GtkWidget* viewWidget, unsigned int keyVal)
+static inline WebKitWebViewBase* toWebKitGLibAPI(PlatformWKView view)
 {
-    GUniquePtr<GdkEvent> event(gdk_event_new(GDK_KEY_PRESS));
-    event->key.keyval = keyVal;
-    event->key.time = GDK_CURRENT_TIME;
-    event->key.state = 0;
-    event->key.window = gtk_widget_get_window(viewWidget);
-    g_object_ref(event->key.window);
-    GdkDisplay* display = gtk_widget_get_display(viewWidget);
-    gdk_event_set_device(event.get(), gdk_seat_get_pointer(gdk_display_get_default_seat(display)));
-
-    // When synthesizing an event, an invalid hardware_keycode value can cause it to be badly processed by GTK+.
-    GUniqueOutPtr<GdkKeymapKey> keys;
-    int keysCount;
-    if (gdk_keymap_get_entries_for_keyval(gdk_keymap_get_for_display(display), keyVal, &keys.outPtr(), &keysCount) && keysCount)
-        event->key.hardware_keycode = keys.get()[0].keycode;
-
-    gtk_main_do_event(event.get());
-    event->key.type = GDK_KEY_RELEASE;
-    gtk_main_do_event(event.get());
+    return const_cast<WebKitWebViewBase*>(reinterpret_cast<const WebKitWebViewBase*>(view));
 }
 
 void PlatformWebView::simulateSpacebarKeyPress()
@@ -110,7 +94,7 @@
     GtkWidget* viewWidget = GTK_WIDGET(m_view);
     if (!gtk_widget_get_realized(viewWidget))
         gtk_widget_show(m_window);
-    doKeyStroke(viewWidget, GDK_KEY_KP_Space);
+    webkitWebViewBaseSynthesizeKeyEvent(toWebKitGLibAPI(m_view), KeyEventType::Insert, GDK_KEY_KP_Space, 0, ShouldTranslateKeyboardState::No);
 }
 
 void PlatformWebView::simulateAltKeyPress()
@@ -118,59 +102,21 @@
     GtkWidget* viewWidget = GTK_WIDGET(m_view);
     if (!gtk_widget_get_realized(viewWidget))
         gtk_widget_show(m_window);
-    doKeyStroke(viewWidget, GDK_KEY_Alt_L);
+    webkitWebViewBaseSynthesizeKeyEvent(toWebKitGLibAPI(m_view), KeyEventType::Insert, GDK_KEY_Alt_L, 0, ShouldTranslateKeyboardState::No);
 }
 
-static void doMouseButtonEvent(GtkWidget* viewWidget, GdkEventType eventType, int x, int y, unsigned int button)
-{
-    GUniquePtr<GdkEvent> event(gdk_event_new(eventType));
-    event->button.x = x;
-    event->button.y = y;
-    event->button.button = button;
-    event->button.time = GDK_CURRENT_TIME;
-    event->button.axes = 0;
-    event->button.state = 0;
-    event->button.window = gtk_widget_get_window(viewWidget);
-    g_object_ref(event->button.window);
-    event->button.device = gdk_seat_get_pointer(gdk_display_get_default_seat(gtk_widget_get_display(viewWidget)));
-
-    int xRoot, yRoot;
-    gdk_window_get_root_coords(gtk_widget_get_window(viewWidget), x, y, &xRoot, &yRoot);
-    event->button.x_root = xRoot;
-    event->button.y_root = yRoot;
-    gtk_main_do_event(event.get());
-}
-
 void PlatformWebView::simulateRightClick(unsigned x, unsigned y)
 {
     GtkWidget* viewWidget = GTK_WIDGET(m_view);
     if (!gtk_widget_get_realized(viewWidget))
         gtk_widget_show(m_window);
-    doMouseButtonEvent(viewWidget, GDK_BUTTON_PRESS, x, y, 3);
-    doMouseButtonEvent(viewWidget, GDK_BUTTON_RELEASE, x, y, 3);
+    webkitWebViewBaseSynthesizeMouseEvent(toWebKitGLibAPI(m_view), MouseEventType::Press, 3, 0, x, y, 0, 1);
+    webkitWebViewBaseSynthesizeMouseEvent(toWebKitGLibAPI(m_view), MouseEventType::Release, 3, 0, x, y, 0, 0);
 }
 
 void PlatformWebView::simulateMouseMove(unsigned x, unsigned y, WKEventModifiers)
 {
-    GUniquePtr<GdkEvent> event(gdk_event_new(GDK_MOTION_NOTIFY));
-    event->motion.x = x;
-    event->motion.y = y;
-    event->motion.time = GDK_CURRENT_TIME;
-    event->motion.state = 0;
-    event->motion.axes = 0;
-
-    GtkWidget* viewWidget = GTK_WIDGET(m_view);
-    if (!gtk_widget_get_realized(viewWidget))
-        gtk_widget_show(m_window);
-    event->motion.window = gtk_widget_get_window(viewWidget);
-    g_object_ref(event->motion.window);
-    event->motion.device = gdk_seat_get_pointer(gdk_display_get_default_seat(gtk_widget_get_display(viewWidget)));
-
-    int xRoot, yRoot;
-    gdk_window_get_root_coords(gtk_widget_get_window(viewWidget), x, y, &xRoot, &yRoot);
-    event->motion.x_root = xRoot;
-    event->motion.y_root = yRoot;
-    gtk_main_do_event(event.get());
+    webkitWebViewBaseSynthesizeMouseEvent(toWebKitGLibAPI(m_view), MouseEventType::Motion, 0, 0, x, y, 0, 0);
 }
 
 } // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to