Skip to content

Commit b9bb795

Browse files
committed
[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): Canonical link: https://commits.webkit.org/227393@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@264647 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent ce3ffc8 commit b9bb795

23 files changed

Lines changed: 291 additions & 365 deletions

Source/WebKit/ChangeLog

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
2020-07-21 Carlos Garcia Campos <[email protected]>
2+
3+
[GTK] Prepare unit tests for GTK4
4+
https://bugs.webkit.org/show_bug.cgi?id=214251
5+
6+
Reviewed by Adrian Perez de Castro.
7+
8+
Make it possible to test input methods.
9+
10+
* UIProcess/API/glib/InputMethodFilter.h:
11+
* UIProcess/API/gtk/InputMethodFilterGtk.cpp:
12+
(WebKit::InputMethodFilter::filterKeyEvent): Added to receive the key event properties instead of the GdkEvent.
13+
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
14+
(webkitWebViewBaseSynthesizeMouseEvent): Create a GdkEvent for right clicks since it's needed by GTK3 API.
15+
(webkitWebViewBaseSynthesizeKeyEvent): Send key press and release events to the IM filter.
16+
117
2020-07-20 Megan Gardner <[email protected]>
218

319
Add OK button to Date/Time form controls.

Source/WebKit/UIProcess/API/glib/InputMethodFilter.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ class InputMethodFilter {
6767
};
6868
FilterResult filterKeyEvent(PlatformEventKey*);
6969

70+
#if PLATFORM(GTK)
71+
FilterResult filterKeyEvent(unsigned type, unsigned keyval, unsigned keycode, unsigned modifiers);
72+
#endif
73+
7074
void notifyFocusedIn();
7175
void notifyFocusedOut();
7276
void notifyMouseButtonPress();

Source/WebKit/UIProcess/API/gtk/InputMethodFilterGtk.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "InputMethodFilter.h"
2222

2323
#include "WebKitInputMethodContextPrivate.h"
24+
#include <WebCore/GUniquePtrGtk.h>
2425
#include <WebCore/IntRect.h>
2526
#include <gdk/gdk.h>
2627

@@ -41,4 +42,27 @@ bool InputMethodFilter::platformEventKeyIsKeyPress(PlatformEventKey* event) cons
4142
return gdk_event_get_event_type(event) == GDK_KEY_PRESS;
4243
}
4344

45+
InputMethodFilter::FilterResult InputMethodFilter::filterKeyEvent(unsigned type, unsigned keyval, unsigned keycode, unsigned modifiers)
46+
{
47+
if (!isEnabled() || !m_context)
48+
return { };
49+
50+
#if !USE(GTK4)
51+
auto* webView = webkitInputMethodContextGetWebView(m_context.get());
52+
ASSERT(webView);
53+
54+
GUniquePtr<GdkEvent> event(gdk_event_new(static_cast<GdkEventType>(type)));
55+
event->key.window = gtk_widget_get_window(GTK_WIDGET(webView));
56+
g_object_ref(event->key.window);
57+
event->key.time = GDK_CURRENT_TIME;
58+
event->key.keyval = keyval;
59+
event->key.hardware_keycode = keycode;
60+
event->key.state = modifiers;
61+
gdk_event_set_device(event.get(), gdk_seat_get_keyboard(gdk_display_get_default_seat(gtk_widget_get_display(GTK_WIDGET(webView)))));
62+
return filterKeyEvent(event.get());
63+
#else
64+
return { };
65+
#endif
66+
}
67+
4468
} // namespace WebKit

Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp

Lines changed: 60 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2545,6 +2545,25 @@ void webkitWebViewBaseSynthesizeMouseEvent(WebKitWebViewBase* webViewBase, Mouse
25452545
case MouseEventType::Press:
25462546
webEventType = WebEvent::MouseDown;
25472547
priv->inputMethodFilter.cancelComposition();
2548+
#if !USE(GTK4)
2549+
if (webEventButton == WebMouseEvent::RightButton) {
2550+
GUniquePtr<GdkEvent> event(gdk_event_new(GDK_BUTTON_PRESS));
2551+
event->button.window = gtk_widget_get_window(GTK_WIDGET(webViewBase));
2552+
g_object_ref(event->button.window);
2553+
event->button.time = GDK_CURRENT_TIME;
2554+
event->button.x = x;
2555+
event->button.y = y;
2556+
event->button.axes = 0;
2557+
event->button.state = modifiers;
2558+
event->button.button = button;
2559+
event->button.device = gdk_seat_get_pointer(gdk_display_get_default_seat(gtk_widget_get_display(GTK_WIDGET(webViewBase))));
2560+
int xRoot, yRoot;
2561+
gdk_window_get_root_coords(event->button.window, x, y, &xRoot, &yRoot);
2562+
event->button.x_root = xRoot;
2563+
event->button.y_root = yRoot;
2564+
priv->contextMenuEvent = WTFMove(event);
2565+
}
2566+
#endif
25482567
gtk_widget_grab_focus(GTK_WIDGET(webViewBase));
25492568
break;
25502569
case MouseEventType::Release:
@@ -2603,8 +2622,21 @@ void webkitWebViewBaseSynthesizeKeyEvent(WebKitWebViewBase* webViewBase, KeyEven
26032622
#endif
26042623

26052624
#if !USE(GTK4)
2625+
if (priv->activeContextMenuProxy && keyval == GDK_KEY_Escape) {
2626+
gtk_menu_shell_deactivate(GTK_MENU_SHELL(priv->activeContextMenuProxy->gtkWidget()));
2627+
return;
2628+
}
2629+
26062630
if (keyval == GDK_KEY_Menu) {
2607-
webkitWebViewBasePopupMenu(GTK_WIDGET(webViewBase));
2631+
GUniquePtr<GdkEvent> event(gdk_event_new(GDK_KEY_PRESS));
2632+
event->key.window = gtk_widget_get_window(GTK_WIDGET(webViewBase));
2633+
g_object_ref(event->key.window);
2634+
event->key.time = GDK_CURRENT_TIME;
2635+
event->key.keyval = keyval;
2636+
event->key.state = modifiers;
2637+
gdk_event_set_device(event.get(), gdk_seat_get_keyboard(gdk_display_get_default_seat(gtk_widget_get_display(GTK_WIDGET(webViewBase)))));
2638+
priv->contextMenuEvent = WTFMove(event);
2639+
priv->pageProxy->handleContextMenuKeyEvent();
26082640
return;
26092641
}
26102642
#endif
@@ -2622,31 +2654,36 @@ void webkitWebViewBaseSynthesizeKeyEvent(WebKitWebViewBase* webViewBase, KeyEven
26222654
auto webEventModifiers = toWebKitModifiers(modifiers);
26232655

26242656
if (type != KeyEventType::Release) {
2625-
priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(
2626-
WebEvent::KeyDown,
2627-
PlatformKeyboardEvent::singleCharacterString(keyval),
2628-
PlatformKeyboardEvent::keyValueForGdkKeyCode(keyval),
2629-
PlatformKeyboardEvent::keyCodeForHardwareKeyCode(keycode),
2630-
PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyval),
2631-
PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(keyval),
2632-
static_cast<int>(keyval),
2633-
priv->keyBindingTranslator.commandsForKeyval(keyval, modifiers),
2634-
keyval >= GDK_KEY_KP_Space && keyval <= GDK_KEY_KP_9,
2635-
webEventModifiers));
2657+
auto filterResult = priv->inputMethodFilter.filterKeyEvent(GDK_KEY_PRESS, keyval, keycode, modifiers);
2658+
if (!filterResult.handled) {
2659+
priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(
2660+
WebEvent::KeyDown,
2661+
filterResult.keyText.isNull() ? PlatformKeyboardEvent::singleCharacterString(keyval) : filterResult.keyText,
2662+
PlatformKeyboardEvent::keyValueForGdkKeyCode(keyval),
2663+
PlatformKeyboardEvent::keyCodeForHardwareKeyCode(keycode),
2664+
PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyval),
2665+
PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(keyval),
2666+
static_cast<int>(keyval),
2667+
priv->keyBindingTranslator.commandsForKeyval(keyval, modifiers),
2668+
keyval >= GDK_KEY_KP_Space && keyval <= GDK_KEY_KP_9,
2669+
webEventModifiers));
2670+
}
26362671
}
26372672

26382673
if (type != KeyEventType::Press) {
2639-
priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(
2640-
WebEvent::KeyUp,
2641-
PlatformKeyboardEvent::singleCharacterString(keyval),
2642-
PlatformKeyboardEvent::keyValueForGdkKeyCode(keyval),
2643-
PlatformKeyboardEvent::keyCodeForHardwareKeyCode(keycode),
2644-
PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyval),
2645-
PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(keyval),
2646-
static_cast<int>(keyval),
2647-
{ },
2648-
keyval >= GDK_KEY_KP_Space && keyval <= GDK_KEY_KP_9,
2649-
webEventModifiers));
2674+
if (!priv->inputMethodFilter.filterKeyEvent(GDK_KEY_RELEASE, keyval, keycode, modifiers).handled) {
2675+
priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(
2676+
WebEvent::KeyUp,
2677+
PlatformKeyboardEvent::singleCharacterString(keyval),
2678+
PlatformKeyboardEvent::keyValueForGdkKeyCode(keyval),
2679+
PlatformKeyboardEvent::keyCodeForHardwareKeyCode(keycode),
2680+
PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyval),
2681+
PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(keyval),
2682+
static_cast<int>(keyval),
2683+
{ },
2684+
keyval >= GDK_KEY_KP_Space && keyval <= GDK_KEY_KP_9,
2685+
webEventModifiers));
2686+
}
26502687
}
26512688
}
26522689

Tools/ChangeLog

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,86 @@
1+
2020-07-21 Carlos Garcia Campos <[email protected]>
2+
3+
[GTK] Prepare unit tests for GTK4
4+
https://bugs.webkit.org/show_bug.cgi?id=214251
5+
6+
Reviewed by Adrian Perez de Castro.
7+
8+
In GTK4 there isn't GTK_WINDOW_POPUP and we can't create GdkEvents, so we need to use toplevel windows
9+
everywhere and use the new internal api to synthesize events.
10+
11+
* TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp:
12+
(testContextMenuDownloadActions):
13+
(testBlobDownload):
14+
* TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp:
15+
* TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp:
16+
(testOptionMenuSimple):
17+
(testOptionMenuGroups):
18+
(testOptionMenuActivate):
19+
(testOptionMenuSelect):
20+
* TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp:
21+
(testWebViewCreateNavigationData):
22+
(testWebViewJavaScriptDialogs):
23+
(testWebViewOpenWindowNoDefaultSize):
24+
(testWebViewMouseTarget):
25+
(testWebViewGeolocationPermissionRequests):
26+
(testWebViewUserMediaEnumerateDevicesPermissionCheck):
27+
(testWebViewUserMediaPermissionRequests):
28+
(testWebViewAudioOnlyUserMediaPermissionRequests):
29+
(testWebViewPointerLockPermissionRequest):
30+
(testWebViewFileChooserRequest):
31+
(testWebViewColorChooserRequest):
32+
* TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp:
33+
(testWebExtensionInputElementIsUserEdited):
34+
(testInstallMissingPluginsPermissionRequest):
35+
* TestWebKitAPI/Tests/WebKitGLib/TestWebKitFindController.cpp:
36+
(testFindControllerHide):
37+
* TestWebKitAPI/Tests/WebKitGLib/TestWebKitPolicyClient.cpp:
38+
(testAutoplayPolicy):
39+
* TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:
40+
(testWebViewFullScreen):
41+
(testWebViewSubmitForm):
42+
(testWebViewSnapshot):
43+
(testWebViewIsPlayingAudio):
44+
(testWebViewPreferredSize):
45+
* TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp:
46+
(testContextMenuDefaultMenu):
47+
(testPopupEventSignal):
48+
(testContextMenuKey):
49+
(testContextMenuPopulateMenu):
50+
(testContextMenuCustomMenu):
51+
(testContextMenuSubMenu):
52+
(testContextMenuDismissed):
53+
(testContextMenuWebExtensionMenu):
54+
(testContextMenuWebExtensionNode):
55+
(testContextMenuLiveStream):
56+
(beforeAll):
57+
* TestWebKitAPI/Tests/WebKitGtk/TestDOMDOMWindow.cpp:
58+
(signalsNotifyCallback):
59+
* TestWebKitAPI/Tests/WebKitGtk/TestInspector.cpp:
60+
(testInspectorDefault):
61+
(testInspectorManualAttachDetach):
62+
(testInspectorCustomContainerDestroyed):
63+
* TestWebKitAPI/Tests/WebKitGtk/TestInspectorServer.cpp:
64+
(testInspectorServerPageList):
65+
* TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp:
66+
(testPrintCustomWidget):
67+
* TestWebKitAPI/Tests/WebKitGtk/TestWebViewEditor.cpp:
68+
* TestWebKitAPI/glib/WebKitGLib/WebViewTest.h:
69+
* TestWebKitAPI/glib/WebKitGLib/gtk/WebViewTestGtk.cpp:
70+
(WebViewTest::quitMainLoopAfterProcessingPendingEvents):
71+
(WebViewTest::showInWindow):
72+
(WebViewTest::mouseMoveTo):
73+
(WebViewTest::clickMouseButton):
74+
(WebViewTest::keyStroke):
75+
* TestWebKitAPI/glib/WebKitGLib/wpe/WebViewTestWPE.cpp:
76+
(WebViewTest::showInWindow):
77+
* TestWebKitAPI/gtk/PlatformWebViewGtk.cpp:
78+
(TestWebKitAPI::toWebKitGLibAPI):
79+
(TestWebKitAPI::PlatformWebView::simulateSpacebarKeyPress):
80+
(TestWebKitAPI::PlatformWebView::simulateAltKeyPress):
81+
(TestWebKitAPI::PlatformWebView::simulateRightClick):
82+
(TestWebKitAPI::PlatformWebView::simulateMouseMove):
83+
184
2020-07-20 Aakash Jain <[email protected]>
285

386
[ews] Use -q while unzipping layout-test-results.zip

Tools/TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,41 @@ class WebViewDownloadTest: public WebViewTest {
559559
g_main_loop_run(m_mainLoop);
560560
}
561561

562+
#if PLATFORM(GTK)
563+
static gboolean contextMenuCallback(WebKitWebView* webView, WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult* hitTestResult, WebViewDownloadTest* test)
564+
{
565+
g_assert_true(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult));
566+
GList* items = webkit_context_menu_get_items(contextMenu);
567+
for (GList* l = items; l; l = g_list_next(l)) {
568+
g_assert_true(WEBKIT_IS_CONTEXT_MENU_ITEM(l->data));
569+
auto* item = WEBKIT_CONTEXT_MENU_ITEM(l->data);
570+
if (webkit_context_menu_item_get_stock_action(item) == WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_LINK_TO_DISK) {
571+
test->m_contextMenuDownloadItem = item;
572+
break;
573+
}
574+
}
575+
test->quitMainLoop();
576+
return FALSE;
577+
}
578+
579+
WebKitContextMenuItem* showContextMenuAndGetDownloadItem(int x, int y)
580+
{
581+
m_contextMenuDownloadItem = nullptr;
582+
auto id = g_signal_connect(m_webView, "context-menu", G_CALLBACK(contextMenuCallback), this);
583+
RunLoop::main().dispatch([this, x, y] {
584+
clickMouseButton(x, y, 3);
585+
});
586+
g_main_loop_run(m_mainLoop);
587+
g_signal_handler_disconnect(m_webView, id);
588+
return m_contextMenuDownloadItem.get();
589+
}
590+
#endif
591+
562592
GRefPtr<WebKitDownload> m_download;
563593
bool m_shouldDelayDecideDestination { false };
594+
#if PLATFORM(GTK)
595+
GRefPtr<WebKitContextMenuItem> m_contextMenuDownloadItem;
596+
#endif
564597
};
565598

566599
static void testWebViewDownloadURI(WebViewDownloadTest* test, gconstpointer)
@@ -689,51 +722,18 @@ static void testDownloadMIMEType(DownloadTest* test, gconstpointer)
689722
}
690723

691724
#if PLATFORM(GTK)
692-
static gboolean contextMenuCallback(WebKitWebView* webView, WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult* hitTestResult, WebViewDownloadTest* test)
693-
{
694-
g_assert_true(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult));
695-
g_assert_true(webkit_hit_test_result_context_is_link(hitTestResult));
696-
GList* items = webkit_context_menu_get_items(contextMenu);
697-
GRefPtr<WebKitContextMenuItem> contextMenuItem;
698-
for (GList* l = items; l; l = g_list_next(l)) {
699-
g_assert_true(WEBKIT_IS_CONTEXT_MENU_ITEM(l->data));
700-
auto* item = WEBKIT_CONTEXT_MENU_ITEM(l->data);
701-
if (webkit_context_menu_item_get_stock_action(item) == WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_LINK_TO_DISK) {
702-
contextMenuItem = item;
703-
break;
704-
}
705-
}
706-
g_assert_nonnull(contextMenuItem.get());
707-
webkit_context_menu_remove_all(contextMenu);
708-
webkit_context_menu_append(contextMenu, contextMenuItem.get());
709-
test->quitMainLoop();
710-
return FALSE;
711-
}
712-
713725
static void testContextMenuDownloadActions(WebViewDownloadTest* test, gconstpointer)
714726
{
715-
test->showInWindowAndWaitUntilMapped();
727+
test->showInWindow();
716728

717729
static const char* linkHTMLFormat = "<html><body><a style='position:absolute; left:1; top:1' href='%s'>Download Me</a></body></html>";
718730
GUniquePtr<char> linkHTML(g_strdup_printf(linkHTMLFormat, kServer->getURIForPath("/test.pdf").data()));
719731
test->loadHtml(linkHTML.get(), kServer->getURIForPath("/").data());
720732
test->waitUntilLoadFinished();
721733

722-
g_signal_connect(test->m_webView, "context-menu", G_CALLBACK(contextMenuCallback), test);
723-
g_idle_add([](gpointer userData) -> gboolean {
724-
auto* test = static_cast<WebViewDownloadTest*>(userData);
725-
test->clickMouseButton(1, 1, 3);
726-
return FALSE;
727-
}, test);
728-
g_main_loop_run(test->m_mainLoop);
729-
730-
g_idle_add([](gpointer userData) -> gboolean {
731-
auto* test = static_cast<WebViewDownloadTest*>(userData);
732-
// Select and activate the context menu action.
733-
test->keyStroke(GDK_KEY_Down);
734-
test->keyStroke(GDK_KEY_Return);
735-
return FALSE;
736-
}, test);
734+
auto* item = test->showContextMenuAndGetDownloadItem(1, 1);
735+
g_assert(WEBKIT_IS_CONTEXT_MENU_ITEM(item));
736+
g_action_activate(webkit_context_menu_item_get_gaction(item), nullptr);
737737
test->waitUntilDownloadStarted();
738738

739739
g_assert_true(test->m_webView == webkit_download_get_web_view(test->m_download.get()));
@@ -755,7 +755,7 @@ static void testContextMenuDownloadActions(WebViewDownloadTest* test, gconstpoin
755755

756756
static void testBlobDownload(WebViewDownloadTest* test, gconstpointer)
757757
{
758-
test->showInWindowAndWaitUntilMapped();
758+
test->showInWindow();
759759

760760
static const char* linkBlobHTML =
761761
"<html><body>"

Tools/TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,12 @@ class InputMethodTest: public WebViewTest {
250250
InputMethodTest()
251251
: m_context(adoptGRef(static_cast<WebKitInputMethodContextMock*>(g_object_new(webkit_input_method_context_mock_get_type(), nullptr))))
252252
{
253+
WebViewTest::showInWindow();
253254
#if PLATFORM(GTK)
254-
WebViewTest::showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
255255
auto* defaultContext = webkit_web_view_get_input_method_context(m_webView);
256256
g_assert_true(WEBKIT_IS_INPUT_METHOD_CONTEXT(defaultContext));
257257
assertObjectIsDeletedWhenTestFinishes(G_OBJECT(defaultContext));
258258
#elif PLATFORM(WPE)
259-
WebViewTest::showInWindow();
260259
g_assert_null(webkit_web_view_get_input_method_context(m_webView));
261260
#endif
262261
assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_context.get()));

0 commit comments

Comments
 (0)