[GTK] Split WebKit2APITests/TestWebKitWebView
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Dec 2013 09:58:14 +0000 (09:58 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Dec 2013 09:58:14 +0000 (09:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=126284

Reviewed by Philippe Normand.

Source/WebKit2:

WebKitWebView test is too big already making more difficult to
handle timeouts and skipped tests. Split it in 3 by moving
UIClient and auth tests to their own files.

* UIProcess/API/gtk/tests/GNUmakefile.am:
* UIProcess/API/gtk/tests/TestAuthentication.cpp: Added.
(testWebViewAuthenticationRequest):
(testWebViewAuthenticationCancel):
(testWebViewAuthenticationLoadCancelled):
(testWebViewAuthenticationFailure):
(testWebViewAuthenticationNoCredential):
(testWebViewAuthenticationStorage):
(testWebViewAuthenticationSuccess):
(serverCallback):
(beforeAll):
(afterAll):
* UIProcess/API/gtk/tests/TestUIClient.cpp: Added.
(testWebViewCreateReadyClose):
(checkMimeTypeForFilter):
(testWebViewAllowModalDialogs):
(testWebViewDisallowModalDialogs):
(testWebViewJavaScriptDialogs):
(testWebViewWindowProperties):
(testWebViewMouseTarget):
(testWebViewPermissionRequests):
(testWebViewFileChooserRequest):
(beforeAll):
(afterAll):
* UIProcess/API/gtk/tests/TestWebKitWebView.cpp:
(beforeAll):
(afterAll):

Tools:

Skip only WebKitWebView/mouse-target and all TestAuthentication
tests that are timing out when running under xvfb.

* Scripts/run-gtk-tests:
(TestRunner):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@161138 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am
Source/WebKit2/UIProcess/API/gtk/tests/TestAuthentication.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/gtk/tests/TestUIClient.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
Tools/ChangeLog
Tools/Scripts/run-gtk-tests

index e71ad15..a113dfc 100644 (file)
@@ -1,3 +1,42 @@
+2013-12-30  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Split WebKit2APITests/TestWebKitWebView
+        https://bugs.webkit.org/show_bug.cgi?id=126284
+
+        Reviewed by Philippe Normand.
+
+        WebKitWebView test is too big already making more difficult to
+        handle timeouts and skipped tests. Split it in 3 by moving
+        UIClient and auth tests to their own files.
+
+        * UIProcess/API/gtk/tests/GNUmakefile.am:
+        * UIProcess/API/gtk/tests/TestAuthentication.cpp: Added.
+        (testWebViewAuthenticationRequest):
+        (testWebViewAuthenticationCancel):
+        (testWebViewAuthenticationLoadCancelled):
+        (testWebViewAuthenticationFailure):
+        (testWebViewAuthenticationNoCredential):
+        (testWebViewAuthenticationStorage):
+        (testWebViewAuthenticationSuccess):
+        (serverCallback):
+        (beforeAll):
+        (afterAll):
+        * UIProcess/API/gtk/tests/TestUIClient.cpp: Added.
+        (testWebViewCreateReadyClose):
+        (checkMimeTypeForFilter):
+        (testWebViewAllowModalDialogs):
+        (testWebViewDisallowModalDialogs):
+        (testWebViewJavaScriptDialogs):
+        (testWebViewWindowProperties):
+        (testWebViewMouseTarget):
+        (testWebViewPermissionRequests):
+        (testWebViewFileChooserRequest):
+        (beforeAll):
+        (afterAll):
+        * UIProcess/API/gtk/tests/TestWebKitWebView.cpp:
+        (beforeAll):
+        (afterAll):
+
 2013-12-29  Martin Robinson  <mrobinson@igalia.com>
 
         [GTK] [CMake] Convenience libraries that export API should be compiled with --whole-archive on Unix
index e008ad0..98771b0 100644 (file)
@@ -2,6 +2,7 @@ if ENABLE_WEBKIT2
 
 TEST_PROGS += \
        Programs/WebKit2APITests/InspectorTestServer \
+       Programs/WebKit2APITests/TestAuthentication \
        Programs/WebKit2APITests/TestBackForwardList \
        Programs/WebKit2APITests/TestContextMenu \
        Programs/WebKit2APITests/TestCookieManager \
@@ -14,6 +15,7 @@ TEST_PROGS += \
        Programs/WebKit2APITests/TestPrinting \
        Programs/WebKit2APITests/TestResources \
        Programs/WebKit2APITests/TestSSL \
+       Programs/WebKit2APITests/TestUIClient \
        Programs/WebKit2APITests/TestWebExtensions \
        Programs/WebKit2APITests/TestWebKitVersion \
        Programs/WebKit2APITests/TestWebKitFaviconDatabase \
@@ -310,4 +312,16 @@ Programs_WebKit2APITests_TestFrame_CPPFLAGS = $(webkit2_tests_cppflags)
 Programs_WebKit2APITests_TestFrame_LDADD = $(webkit2_tests_ldadd)
 Programs_WebKit2APITests_TestFrame_LDFLAGS = $(webkit2_tests_ldflags)
 
+Programs_WebKit2APITests_TestAuthentication_SOURCES = \
+        Source/WebKit2/UIProcess/API/gtk/tests/TestAuthentication.cpp
+Programs_WebKit2APITests_TestAuthentication_CPPFLAGS = $(webkit2_tests_cppflags)
+Programs_WebKit2APITests_TestAuthentication_LDADD = $(webkit2_tests_ldadd)
+Programs_WebKit2APITests_TestAuthentication_LDFLAGS = $(webkit2_tests_ldflags)
+
+Programs_WebKit2APITests_TestUIClient_SOURCES = \
+        Source/WebKit2/UIProcess/API/gtk/tests/TestUIClient.cpp
+Programs_WebKit2APITests_TestUIClient_CPPFLAGS = $(webkit2_tests_cppflags)
+Programs_WebKit2APITests_TestUIClient_LDADD = $(webkit2_tests_ldadd)
+Programs_WebKit2APITests_TestUIClient_LDFLAGS = $(webkit2_tests_ldflags)
+
 endif # ENABLE_WEBKIT2
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestAuthentication.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestAuthentication.cpp
new file mode 100644 (file)
index 0000000..ede4225
--- /dev/null
@@ -0,0 +1,286 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2,1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "LoadTrackingTest.h"
+#include "WebKitTestServer.h"
+#include <wtf/gobject/GRefPtr.h>
+
+static WebKitTestServer* kServer;
+
+class AuthenticationTest: public LoadTrackingTest {
+public:
+    MAKE_GLIB_TEST_FIXTURE(AuthenticationTest);
+
+    AuthenticationTest()
+    {
+        g_signal_connect(m_webView, "authenticate", G_CALLBACK(runAuthenticationCallback), this);
+    }
+
+    ~AuthenticationTest()
+    {
+        g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+    }
+
+    static int authenticationRetries;
+    static bool authenticationCancelledReceived;
+
+    void loadURI(const char* uri)
+    {
+        // Reset the retry count of the fake server when a page is loaded.
+        authenticationRetries = 0;
+        authenticationCancelledReceived = false;
+        LoadTrackingTest::loadURI(uri);
+    }
+
+    static gboolean runAuthenticationCallback(WebKitWebView*, WebKitAuthenticationRequest* request, AuthenticationTest* test)
+    {
+        g_signal_connect(request, "cancelled", G_CALLBACK(authenticationCancelledCallback), test);
+        test->runAuthentication(request);
+        return TRUE;
+    }
+
+    static void authenticationCancelledCallback(WebKitAuthenticationRequest*, AuthenticationTest*)
+    {
+        authenticationCancelledReceived = true;
+    }
+
+    void runAuthentication(WebKitAuthenticationRequest* request)
+    {
+        assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request));
+        m_authenticationRequest = request;
+        g_main_loop_quit(m_mainLoop);
+    }
+
+    WebKitAuthenticationRequest* waitForAuthenticationRequest()
+    {
+        g_main_loop_run(m_mainLoop);
+        return m_authenticationRequest.get();
+    }
+
+private:
+    GRefPtr<WebKitAuthenticationRequest> m_authenticationRequest;
+};
+
+int AuthenticationTest::authenticationRetries = 0;
+bool AuthenticationTest::authenticationCancelledReceived = false;
+
+static const char authTestUsername[] = "username";
+static const char authTestPassword[] = "password";
+static const char authExpectedSuccessTitle[] = "WebKit2Gtk+ Authentication test";
+static const char authExpectedFailureTitle[] = "401 Authorization Required";
+static const char authExpectedAuthorization[] = "Basic dXNlcm5hbWU6cGFzc3dvcmQ="; // Base64 encoding of "username:password".
+static const char authSuccessHTMLString[] =
+    "<html>"
+    "<head><title>WebKit2Gtk+ Authentication test</title></head>"
+    "<body></body></html>";
+static const char authFailureHTMLString[] =
+    "<html>"
+    "<head><title>401 Authorization Required</title></head>"
+    "<body></body></html>";
+
+static void testWebViewAuthenticationRequest(AuthenticationTest* test, gconstpointer)
+{
+    // Test authentication request getters match soup authentication header.
+    test->loadURI(kServer->getURIForPath("/auth-test.html").data());
+    WebKitAuthenticationRequest* request = test->waitForAuthenticationRequest();
+    g_assert_cmpstr(webkit_authentication_request_get_host(request), ==, soup_uri_get_host(kServer->baseURI()));
+    g_assert_cmpuint(webkit_authentication_request_get_port(request), ==, soup_uri_get_port(kServer->baseURI()));
+    g_assert_cmpstr(webkit_authentication_request_get_realm(request), ==, "my realm");
+    g_assert(webkit_authentication_request_get_scheme(request) == WEBKIT_AUTHENTICATION_SCHEME_HTTP_BASIC);
+    g_assert(!webkit_authentication_request_is_for_proxy(request));
+    g_assert(!webkit_authentication_request_is_retry(request));
+}
+
+static void testWebViewAuthenticationCancel(AuthenticationTest* test, gconstpointer)
+{
+    // Test cancel.
+    test->loadURI(kServer->getURIForPath("/auth-test.html").data());
+    WebKitAuthenticationRequest* request = test->waitForAuthenticationRequest();
+    webkit_authentication_request_cancel(request);
+    // Server doesn't ask for new credentials.
+    test->waitUntilLoadFinished();
+
+    g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
+    g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+    g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::ProvisionalLoadFailed);
+    g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
+
+    g_assert_error(test->m_error.get(), WEBKIT_NETWORK_ERROR, WEBKIT_NETWORK_ERROR_CANCELLED);
+}
+
+static void testWebViewAuthenticationLoadCancelled(AuthenticationTest* test, gconstpointer)
+{
+    test->loadURI(kServer->getURIForPath("/auth-test.html").data());
+    test->waitForAuthenticationRequest();
+    webkit_web_view_stop_loading(test->m_webView);
+    // Expect empty page.
+    test->waitUntilLoadFinished();
+    g_assert(test->authenticationCancelledReceived);
+
+    g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
+    g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+    g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::ProvisionalLoadFailed);
+    g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
+
+    g_assert_error(test->m_error.get(), WEBKIT_NETWORK_ERROR, WEBKIT_NETWORK_ERROR_CANCELLED);
+}
+
+static void testWebViewAuthenticationFailure(AuthenticationTest* test, gconstpointer)
+{
+    // Test authentication failures.
+    test->loadURI(kServer->getURIForPath("/auth-test.html").data());
+    WebKitAuthenticationRequest* request = test->waitForAuthenticationRequest();
+    g_assert(!webkit_authentication_request_is_retry(request));
+    WebKitCredential* credential = webkit_credential_new(authTestUsername, "wrongpassword", WEBKIT_CREDENTIAL_PERSISTENCE_NONE);
+    webkit_authentication_request_authenticate(request, credential);
+    webkit_credential_free(credential);
+    // Expect a second authentication request.
+    request = test->waitForAuthenticationRequest();
+    g_assert(webkit_authentication_request_is_retry(request));
+    // Test second failure.
+    credential = webkit_credential_new(authTestUsername, "wrongpassword2", WEBKIT_CREDENTIAL_PERSISTENCE_NONE);
+    webkit_authentication_request_authenticate(request, credential);
+    webkit_credential_free(credential);
+    // Expect authentication failed page.
+    test->waitUntilLoadFinished();
+
+    g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
+    g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+    g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::LoadCommitted);
+    g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
+    g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, authExpectedFailureTitle);
+}
+
+static void testWebViewAuthenticationNoCredential(AuthenticationTest* test, gconstpointer)
+{
+    // Test continue without credentials.
+    test->loadURI(kServer->getURIForPath("/auth-test.html").data());
+    WebKitAuthenticationRequest* request = test->waitForAuthenticationRequest();
+    webkit_authentication_request_authenticate(request, 0);
+    // Server doesn't ask for new credentials.
+    test->waitUntilLoadFinished();
+
+    g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
+    g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+    g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::LoadCommitted);
+    g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
+    g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, authExpectedFailureTitle);
+}
+
+static void testWebViewAuthenticationStorage(AuthenticationTest* test, gconstpointer)
+{
+    // Enable private browsing before authentication request to test that credentials can't be saved.
+    webkit_settings_set_enable_private_browsing(webkit_web_view_get_settings(test->m_webView), TRUE);
+    test->loadURI(kServer->getURIForPath("/auth-test.html").data());
+    WebKitAuthenticationRequest* request = test->waitForAuthenticationRequest();
+    g_assert(!webkit_authentication_request_get_proposed_credential(request));
+    g_assert(!webkit_authentication_request_can_save_credentials(request));
+
+    // If WebKit has been compiled with libsecret, and private browsing is disabled
+    // then check that credentials can be saved.
+#if ENABLE(CREDENTIAL_STORAGE)
+    webkit_settings_set_enable_private_browsing(webkit_web_view_get_settings(test->m_webView), FALSE);
+    test->loadURI(kServer->getURIForPath("/auth-test.html").data());
+    request = test->waitForAuthenticationRequest();
+    g_assert(!webkit_authentication_request_get_proposed_credential(request));
+    g_assert(webkit_authentication_request_can_save_credentials(request));
+#endif
+}
+
+static void testWebViewAuthenticationSuccess(AuthenticationTest* test, gconstpointer)
+{
+    // Test correct authentication.
+    test->loadURI(kServer->getURIForPath("/auth-test.html").data());
+    WebKitAuthenticationRequest* request = test->waitForAuthenticationRequest();
+    WebKitCredential* credential = webkit_credential_new(authTestUsername, authTestPassword, WEBKIT_CREDENTIAL_PERSISTENCE_FOR_SESSION);
+    webkit_authentication_request_authenticate(request, credential);
+    webkit_credential_free(credential);
+    test->waitUntilLoadFinished();
+
+    g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
+    g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+    g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::LoadCommitted);
+    g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
+    g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, authExpectedSuccessTitle);
+
+    // Test loading the same (authorized) page again.
+    test->loadURI(kServer->getURIForPath("/auth-test.html").data());
+    // There is no authentication challenge.
+    test->waitUntilLoadFinished();
+
+    g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
+    g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+    g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::LoadCommitted);
+    g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
+    g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, authExpectedSuccessTitle);
+}
+
+static void serverCallback(SoupServer*, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, void*)
+{
+    if (message->method != SOUP_METHOD_GET) {
+        soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
+        return;
+    }
+
+    if (!strcmp(path, "/auth-test.html")) {
+        const char* authorization = soup_message_headers_get_one(message->request_headers, "Authorization");
+        // Require authentication.
+        if (!g_strcmp0(authorization, authExpectedAuthorization)) {
+            // Successful authentication.
+            soup_message_set_status(message, SOUP_STATUS_OK);
+            soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, authSuccessHTMLString, strlen(authSuccessHTMLString));
+            AuthenticationTest::authenticationRetries = 0;
+        } else if (++AuthenticationTest::authenticationRetries < 3) {
+            // No or invalid authorization header provided by the client, request authentication twice then fail.
+            soup_message_set_status(message, SOUP_STATUS_UNAUTHORIZED);
+            soup_message_headers_append(message->response_headers, "WWW-Authenticate", "Basic realm=\"my realm\"");
+            // Include a failure message in case the user attempts to proceed without authentication.
+            soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, authFailureHTMLString, strlen(authFailureHTMLString));
+        } else {
+            // Authentication not successful, display a "401 Authorization Required" page.
+            soup_message_set_status(message, SOUP_STATUS_OK);
+            soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, authFailureHTMLString, strlen(authFailureHTMLString));
+        }
+    } else
+        soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
+
+    soup_message_body_complete(message->response_body);
+}
+
+void beforeAll()
+{
+    kServer = new WebKitTestServer();
+    kServer->run(serverCallback);
+
+    AuthenticationTest::add("WebKitWebView", "authentication-request", testWebViewAuthenticationRequest);
+    AuthenticationTest::add("WebKitWebView", "authentication-cancel", testWebViewAuthenticationCancel);
+    AuthenticationTest::add("WebKitWebView", "authentication-load-cancelled", testWebViewAuthenticationLoadCancelled);
+    AuthenticationTest::add("WebKitWebView", "authentication-failure", testWebViewAuthenticationFailure);
+    AuthenticationTest::add("WebKitWebView", "authentication-no-credential", testWebViewAuthenticationNoCredential);
+    AuthenticationTest::add("WebKitWebView", "authentication-storage", testWebViewAuthenticationStorage);
+    // Testing authentication success must be done last because libsoup will never fire
+    // the authenticate signal again once authentication is successful.
+    AuthenticationTest::add("WebKitWebView", "authentication-success", testWebViewAuthenticationSuccess);
+}
+
+void afterAll()
+{
+    delete kServer;
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestUIClient.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestUIClient.cpp
new file mode 100644 (file)
index 0000000..bc30d6d
--- /dev/null
@@ -0,0 +1,679 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2,1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebViewTest.h"
+#include <wtf/HashSet.h>
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/StringHash.h>
+
+static const char* kAlertDialogMessage = "WebKitGTK+ alert dialog message";
+static const char* kConfirmDialogMessage = "WebKitGTK+ confirm dialog message";
+static const char* kPromptDialogMessage = "WebKitGTK+ prompt dialog message";
+static const char* kPromptDialogReturnedText = "WebKitGTK+ prompt dialog returned text";
+
+class UIClientTest: public WebViewTest {
+public:
+    MAKE_GLIB_TEST_FIXTURE(UIClientTest);
+
+    enum WebViewEvents {
+        Create,
+        ReadyToShow,
+        RunAsModal,
+        Close
+    };
+
+    class WindowProperties {
+    public:
+        WindowProperties()
+            : m_isNull(true)
+            , m_toolbarVisible(true)
+            , m_statusbarVisible(true)
+            , m_scrollbarsVisible(true)
+            , m_menubarVisible(true)
+            , m_locationbarVisible(true)
+            , m_resizable(true)
+            , m_fullscreen(false)
+        {
+            memset(&m_geometry, 0, sizeof(GdkRectangle));
+        }
+
+        WindowProperties(WebKitWindowProperties* windowProperties)
+            : m_isNull(false)
+            , m_toolbarVisible(webkit_window_properties_get_toolbar_visible(windowProperties))
+            , m_statusbarVisible(webkit_window_properties_get_statusbar_visible(windowProperties))
+            , m_scrollbarsVisible(webkit_window_properties_get_scrollbars_visible(windowProperties))
+            , m_menubarVisible(webkit_window_properties_get_menubar_visible(windowProperties))
+            , m_locationbarVisible(webkit_window_properties_get_locationbar_visible(windowProperties))
+            , m_resizable(webkit_window_properties_get_resizable(windowProperties))
+            , m_fullscreen(webkit_window_properties_get_fullscreen(windowProperties))
+        {
+            webkit_window_properties_get_geometry(windowProperties, &m_geometry);
+        }
+
+        WindowProperties(GdkRectangle* geometry, bool toolbarVisible, bool statusbarVisible, bool scrollbarsVisible, bool menubarVisible, bool locationbarVisible, bool resizable, bool fullscreen)
+            : m_isNull(false)
+            , m_geometry(*geometry)
+            , m_toolbarVisible(toolbarVisible)
+            , m_statusbarVisible(statusbarVisible)
+            , m_scrollbarsVisible(scrollbarsVisible)
+            , m_menubarVisible(menubarVisible)
+            , m_locationbarVisible(locationbarVisible)
+            , m_resizable(resizable)
+            , m_fullscreen(fullscreen)
+        {
+        }
+
+        bool isNull() const { return m_isNull; }
+
+        void assertEqual(const WindowProperties& other) const
+        {
+            g_assert_cmpint(m_geometry.x, ==, other.m_geometry.x);
+            g_assert_cmpint(m_geometry.y, ==, other.m_geometry.y);
+            g_assert_cmpint(m_geometry.width, ==, other.m_geometry.width);
+            g_assert_cmpint(m_geometry.height, ==, other.m_geometry.height);
+            g_assert_cmpint(static_cast<int>(m_toolbarVisible), ==, static_cast<int>(other.m_toolbarVisible));
+            g_assert_cmpint(static_cast<int>(m_statusbarVisible), ==, static_cast<int>(other.m_statusbarVisible));
+            g_assert_cmpint(static_cast<int>(m_scrollbarsVisible), ==, static_cast<int>(other.m_scrollbarsVisible));
+            g_assert_cmpint(static_cast<int>(m_menubarVisible), ==, static_cast<int>(other.m_menubarVisible));
+            g_assert_cmpint(static_cast<int>(m_locationbarVisible), ==, static_cast<int>(other.m_locationbarVisible));
+            g_assert_cmpint(static_cast<int>(m_resizable), ==, static_cast<int>(other.m_resizable));
+            g_assert_cmpint(static_cast<int>(m_fullscreen), ==, static_cast<int>(other.m_fullscreen));
+        }
+
+    private:
+        bool m_isNull;
+
+        GdkRectangle m_geometry;
+
+        bool m_toolbarVisible;
+        bool m_statusbarVisible;
+        bool m_scrollbarsVisible;
+        bool m_menubarVisible;
+        bool m_locationbarVisible;
+
+        bool m_resizable;
+        bool m_fullscreen;
+    };
+
+    static void windowPropertiesNotifyCallback(GObject*, GParamSpec* paramSpec, UIClientTest* test)
+    {
+        test->m_windowPropertiesChanged.add(g_param_spec_get_name(paramSpec));
+    }
+
+    static GtkWidget* viewCreateCallback(WebKitWebView* webView, UIClientTest* test)
+    {
+        return test->viewCreate(webView);
+    }
+
+    static void viewReadyToShowCallback(WebKitWebView* webView, UIClientTest* test)
+    {
+        test->viewReadyToShow(webView);
+    }
+
+    static void viewCloseCallback(WebKitWebView* webView, UIClientTest* test)
+    {
+        test->viewClose(webView);
+    }
+
+    void scriptAlert(WebKitScriptDialog* dialog)
+    {
+        switch (m_scriptDialogType) {
+        case WEBKIT_SCRIPT_DIALOG_ALERT:
+            g_assert_cmpstr(webkit_script_dialog_get_message(dialog), ==, kAlertDialogMessage);
+            break;
+        case WEBKIT_SCRIPT_DIALOG_CONFIRM:
+            g_assert(m_scriptDialogConfirmed);
+            g_assert_cmpstr(webkit_script_dialog_get_message(dialog), ==, "confirmed");
+
+            break;
+        case WEBKIT_SCRIPT_DIALOG_PROMPT:
+            g_assert_cmpstr(webkit_script_dialog_get_message(dialog), ==, kPromptDialogReturnedText);
+            break;
+        }
+
+        g_main_loop_quit(m_mainLoop);
+    }
+
+    void scriptConfirm(WebKitScriptDialog* dialog)
+    {
+        g_assert_cmpstr(webkit_script_dialog_get_message(dialog), ==, kConfirmDialogMessage);
+        m_scriptDialogConfirmed = !m_scriptDialogConfirmed;
+        webkit_script_dialog_confirm_set_confirmed(dialog, m_scriptDialogConfirmed);
+    }
+
+    void scriptPrompt(WebKitScriptDialog* dialog)
+    {
+        g_assert_cmpstr(webkit_script_dialog_get_message(dialog), ==, kPromptDialogMessage);
+        g_assert_cmpstr(webkit_script_dialog_prompt_get_default_text(dialog), ==, "default");
+        webkit_script_dialog_prompt_set_text(dialog, kPromptDialogReturnedText);
+    }
+
+    static gboolean scriptDialog(WebKitWebView*, WebKitScriptDialog* dialog, UIClientTest* test)
+    {
+        switch (webkit_script_dialog_get_dialog_type(dialog)) {
+        case WEBKIT_SCRIPT_DIALOG_ALERT:
+            test->scriptAlert(dialog);
+            break;
+        case WEBKIT_SCRIPT_DIALOG_CONFIRM:
+            test->scriptConfirm(dialog);
+            break;
+        case WEBKIT_SCRIPT_DIALOG_PROMPT:
+            test->scriptPrompt(dialog);
+            break;
+        }
+
+        return TRUE;
+    }
+
+    static void mouseTargetChanged(WebKitWebView*, WebKitHitTestResult* hitTestResult, guint modifiers, UIClientTest* test)
+    {
+        g_assert(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult));
+        test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(hitTestResult));
+
+        test->m_mouseTargetHitTestResult = hitTestResult;
+        test->m_mouseTargetModifiers = modifiers;
+        g_main_loop_quit(test->m_mainLoop);
+    }
+
+    static gboolean permissionRequested(WebKitWebView*, WebKitPermissionRequest* request, UIClientTest* test)
+    {
+        g_assert(WEBKIT_IS_PERMISSION_REQUEST(request));
+        test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request));
+
+        if (test->m_allowPermissionRequests)
+            webkit_permission_request_allow(request);
+        else
+            webkit_permission_request_deny(request);
+
+        return TRUE;
+    }
+
+    UIClientTest()
+        : m_scriptDialogType(WEBKIT_SCRIPT_DIALOG_ALERT)
+        , m_scriptDialogConfirmed(true)
+        , m_allowPermissionRequests(false)
+        , m_mouseTargetModifiers(0)
+    {
+        webkit_settings_set_javascript_can_open_windows_automatically(webkit_web_view_get_settings(m_webView), TRUE);
+        g_signal_connect(m_webView, "create", G_CALLBACK(viewCreateCallback), this);
+        g_signal_connect(m_webView, "script-dialog", G_CALLBACK(scriptDialog), this);
+        g_signal_connect(m_webView, "mouse-target-changed", G_CALLBACK(mouseTargetChanged), this);
+        g_signal_connect(m_webView, "permission-request", G_CALLBACK(permissionRequested), this);
+    }
+
+    ~UIClientTest()
+    {
+        g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+    }
+
+    void waitUntilMainLoopFinishes()
+    {
+        g_main_loop_run(m_mainLoop);
+    }
+
+    void setExpectedWindowProperties(const WindowProperties& windowProperties)
+    {
+        m_windowProperties = windowProperties;
+    }
+
+    WebKitHitTestResult* moveMouseAndWaitUntilMouseTargetChanged(int x, int y, unsigned mouseModifiers = 0)
+    {
+        mouseMoveTo(x, y, mouseModifiers);
+        g_main_loop_run(m_mainLoop);
+        return m_mouseTargetHitTestResult.get();
+    }
+
+    virtual GtkWidget* viewCreate(WebKitWebView* webView)
+    {
+        g_assert(webView == m_webView);
+
+        GtkWidget* newWebView = webkit_web_view_new_with_context(webkit_web_view_get_context(webView));
+        g_object_ref_sink(newWebView);
+
+        m_webViewEvents.append(Create);
+
+        WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(newWebView));
+        g_assert(windowProperties);
+        assertObjectIsDeletedWhenTestFinishes(G_OBJECT(windowProperties));
+        m_windowPropertiesChanged.clear();
+
+        g_signal_connect(windowProperties, "notify", G_CALLBACK(windowPropertiesNotifyCallback), this);
+        g_signal_connect(newWebView, "ready-to-show", G_CALLBACK(viewReadyToShowCallback), this);
+        g_signal_connect(newWebView, "close", G_CALLBACK(viewCloseCallback), this);
+
+        return newWebView;
+    }
+
+    virtual void viewReadyToShow(WebKitWebView* webView)
+    {
+        g_assert(webView != m_webView);
+
+        WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(webView);
+        g_assert(windowProperties);
+        if (!m_windowProperties.isNull())
+            WindowProperties(windowProperties).assertEqual(m_windowProperties);
+
+        m_webViewEvents.append(ReadyToShow);
+    }
+
+    virtual void viewClose(WebKitWebView* webView)
+    {
+        g_assert(webView != m_webView);
+
+        m_webViewEvents.append(Close);
+        g_object_unref(webView);
+
+        g_main_loop_quit(m_mainLoop);
+    }
+
+    Vector<WebViewEvents> m_webViewEvents;
+    WebKitScriptDialogType m_scriptDialogType;
+    bool m_scriptDialogConfirmed;
+    bool m_allowPermissionRequests;
+    WindowProperties m_windowProperties;
+    HashSet<WTF::String> m_windowPropertiesChanged;
+    GRefPtr<WebKitHitTestResult> m_mouseTargetHitTestResult;
+    unsigned m_mouseTargetModifiers;
+};
+
+static void testWebViewCreateReadyClose(UIClientTest* test, gconstpointer)
+{
+    test->loadHtml("<html><body onLoad=\"window.open().close();\"></html>", 0);
+    test->waitUntilMainLoopFinishes();
+
+    Vector<UIClientTest::WebViewEvents>& events = test->m_webViewEvents;
+    g_assert_cmpint(events.size(), ==, 3);
+    g_assert_cmpint(events[0], ==, UIClientTest::Create);
+    g_assert_cmpint(events[1], ==, UIClientTest::ReadyToShow);
+    g_assert_cmpint(events[2], ==, UIClientTest::Close);
+}
+
+static gboolean checkMimeTypeForFilter(GtkFileFilter* filter, const gchar* mimeType)
+{
+    GtkFileFilterInfo filterInfo;
+    filterInfo.contains = GTK_FILE_FILTER_MIME_TYPE;
+    filterInfo.mime_type = mimeType;
+    return gtk_file_filter_filter(filter, &filterInfo);
+}
+
+class ModalDialogsTest: public UIClientTest {
+public:
+    MAKE_GLIB_TEST_FIXTURE(ModalDialogsTest);
+
+    static void dialogRunAsModalCallback(WebKitWebView* webView, ModalDialogsTest* test)
+    {
+        g_assert(webView != test->m_webView);
+        test->m_webViewEvents.append(RunAsModal);
+    }
+
+    GtkWidget* viewCreate(WebKitWebView* webView)
+    {
+        g_assert(webView == m_webView);
+
+        GtkWidget* newWebView = UIClientTest::viewCreate(webView);
+        g_signal_connect(newWebView, "run-as-modal", G_CALLBACK(dialogRunAsModalCallback), this);
+        return newWebView;
+    }
+
+    void viewReadyToShow(WebKitWebView* webView)
+    {
+        g_assert(webView != m_webView);
+        m_webViewEvents.append(ReadyToShow);
+    }
+};
+
+static void testWebViewAllowModalDialogs(ModalDialogsTest* test, gconstpointer)
+{
+    WebKitSettings* settings = webkit_web_view_get_settings(test->m_webView);
+    webkit_settings_set_allow_modal_dialogs(settings, TRUE);
+
+    test->loadHtml("<html><body onload=\"window.showModalDialog('data:text/html,<html><body/><script>window.close();</script></html>')\"></body></html>", 0);
+    test->waitUntilMainLoopFinishes();
+
+    Vector<UIClientTest::WebViewEvents>& events = test->m_webViewEvents;
+    g_assert_cmpint(events.size(), ==, 4);
+    g_assert_cmpint(events[0], ==, UIClientTest::Create);
+    g_assert_cmpint(events[1], ==, UIClientTest::ReadyToShow);
+    g_assert_cmpint(events[2], ==, UIClientTest::RunAsModal);
+    g_assert_cmpint(events[3], ==, UIClientTest::Close);
+}
+
+static void testWebViewDisallowModalDialogs(ModalDialogsTest* test, gconstpointer)
+{
+    WebKitSettings* settings = webkit_web_view_get_settings(test->m_webView);
+    webkit_settings_set_allow_modal_dialogs(settings, FALSE);
+
+    test->loadHtml("<html><body onload=\"window.showModalDialog('data:text/html,<html><body/><script>window.close();</script></html>')\"></body></html>", 0);
+    // We need to use a timeout here because the viewClose() function
+    // won't ever be called as the dialog won't be created.
+    test->wait(1);
+
+    Vector<UIClientTest::WebViewEvents>& events = test->m_webViewEvents;
+    g_assert_cmpint(events.size(), ==, 0);
+}
+
+static void testWebViewJavaScriptDialogs(UIClientTest* test, gconstpointer)
+{
+    static const char* htmlOnLoadFormat = "<html><body onLoad=\"%s\"></body></html>";
+    static const char* jsAlertFormat = "alert('%s')";
+    static const char* jsConfirmFormat = "do { confirmed = confirm('%s'); } while (!confirmed); alert('confirmed');";
+    static const char* jsPromptFormat = "alert(prompt('%s', 'default'));";
+
+    test->m_scriptDialogType = WEBKIT_SCRIPT_DIALOG_ALERT;
+    GOwnPtr<char> alertDialogMessage(g_strdup_printf(jsAlertFormat, kAlertDialogMessage));
+    GOwnPtr<char> alertHTML(g_strdup_printf(htmlOnLoadFormat, alertDialogMessage.get()));
+    test->loadHtml(alertHTML.get(), 0);
+    test->waitUntilMainLoopFinishes();
+
+    test->m_scriptDialogType = WEBKIT_SCRIPT_DIALOG_CONFIRM;
+    GOwnPtr<char> confirmDialogMessage(g_strdup_printf(jsConfirmFormat, kConfirmDialogMessage));
+    GOwnPtr<char> confirmHTML(g_strdup_printf(htmlOnLoadFormat, confirmDialogMessage.get()));
+    test->loadHtml(confirmHTML.get(), 0);
+    test->waitUntilMainLoopFinishes();
+
+    test->m_scriptDialogType = WEBKIT_SCRIPT_DIALOG_PROMPT;
+    GOwnPtr<char> promptDialogMessage(g_strdup_printf(jsPromptFormat, kPromptDialogMessage));
+    GOwnPtr<char> promptHTML(g_strdup_printf(htmlOnLoadFormat, promptDialogMessage.get()));
+    test->loadHtml(promptHTML.get(), 0);
+    test->waitUntilMainLoopFinishes();
+}
+
+static void testWebViewWindowProperties(UIClientTest* test, gconstpointer)
+{
+    static const char* windowProrpertiesString = "left=100,top=150,width=400,height=400,location=no,menubar=no,status=no,toolbar=no,scrollbars=no";
+    GdkRectangle geometry = { 100, 150, 400, 400 };
+    test->setExpectedWindowProperties(UIClientTest::WindowProperties(&geometry, false, false, false, false, false, true, false));
+
+    GOwnPtr<char> htmlString(g_strdup_printf("<html><body onLoad=\"window.open('', '', '%s').close();\"></body></html>", windowProrpertiesString));
+    test->loadHtml(htmlString.get(), 0);
+    test->waitUntilMainLoopFinishes();
+
+    static const char* propertiesChanged[] = {
+        "geometry", "locationbar-visible", "menubar-visible", "statusbar-visible", "toolbar-visible", "scrollbars-visible"
+    };
+    for (size_t i = 0; i < G_N_ELEMENTS(propertiesChanged); ++i)
+        g_assert(test->m_windowPropertiesChanged.contains(propertiesChanged[i]));
+
+    Vector<UIClientTest::WebViewEvents>& events = test->m_webViewEvents;
+    g_assert_cmpint(events.size(), ==, 3);
+    g_assert_cmpint(events[0], ==, UIClientTest::Create);
+    g_assert_cmpint(events[1], ==, UIClientTest::ReadyToShow);
+    g_assert_cmpint(events[2], ==, UIClientTest::Close);
+}
+
+static void testWebViewMouseTarget(UIClientTest* test, gconstpointer)
+{
+    test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
+
+    const char* linksHoveredHTML =
+        "<html><body>"
+        " <a style='position:absolute; left:1; top:1' href='http://www.webkitgtk.org' title='WebKitGTK+ Title'>WebKitGTK+ Website</a>"
+        " <img style='position:absolute; left:1; top:10' src='0xdeadbeef' width=5 height=5></img>"
+        " <a style='position:absolute; left:1; top:20' href='http://www.webkitgtk.org/logo' title='WebKitGTK+ Logo'><img src='0xdeadbeef' width=5 height=5></img></a>"
+        " <input style='position:absolute; left:1; top:30' size='10'></input>"
+        " <div style='position:absolute; left:1; top:50; width:30; height:30; overflow:scroll'>&nbsp;</div>"
+        " <video style='position:absolute; left:1; top:100' width='300' height='300' controls='controls' preload='none'><source src='movie.ogg' type='video/ogg' /></video>"
+        "</body></html>";
+
+    test->loadHtml(linksHoveredHTML, "file:///");
+    test->waitUntilLoadFinished();
+
+    // Move over link.
+    WebKitHitTestResult* hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 1);
+    g_assert(webkit_hit_test_result_context_is_link(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
+    g_assert_cmpstr(webkit_hit_test_result_get_link_uri(hitTestResult), ==, "http://www.webkitgtk.org/");
+    g_assert_cmpstr(webkit_hit_test_result_get_link_title(hitTestResult), ==, "WebKitGTK+ Title");
+    g_assert_cmpstr(webkit_hit_test_result_get_link_label(hitTestResult), ==, "WebKitGTK+ Website");
+    g_assert(!test->m_mouseTargetModifiers);
+
+    // Move out of the link.
+    hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(0, 0);
+    g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
+    g_assert(!test->m_mouseTargetModifiers);
+
+    // Move over image with GDK_CONTROL_MASK.
+    hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 10, GDK_CONTROL_MASK);
+    g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
+    g_assert(webkit_hit_test_result_context_is_image(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult));
+    g_assert_cmpstr(webkit_hit_test_result_get_image_uri(hitTestResult), ==, "file:///0xdeadbeef");
+    g_assert(test->m_mouseTargetModifiers & GDK_CONTROL_MASK);
+
+    // Move over image link.
+    hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 20);
+    g_assert(webkit_hit_test_result_context_is_link(hitTestResult));
+    g_assert(webkit_hit_test_result_context_is_image(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult));
+    g_assert_cmpstr(webkit_hit_test_result_get_link_uri(hitTestResult), ==, "http://www.webkitgtk.org/logo");
+    g_assert_cmpstr(webkit_hit_test_result_get_image_uri(hitTestResult), ==, "file:///0xdeadbeef");
+    g_assert_cmpstr(webkit_hit_test_result_get_link_title(hitTestResult), ==, "WebKitGTK+ Logo");
+    g_assert(!webkit_hit_test_result_get_link_label(hitTestResult));
+    g_assert(!test->m_mouseTargetModifiers);
+
+    // Move over media.
+    hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 100);
+    g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
+    g_assert(webkit_hit_test_result_context_is_media(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult));
+    g_assert_cmpstr(webkit_hit_test_result_get_media_uri(hitTestResult), ==, "file:///movie.ogg");
+    g_assert(!test->m_mouseTargetModifiers);
+
+    // Mover over input.
+    hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(5, 35);
+    g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult));
+    g_assert(webkit_hit_test_result_context_is_editable(hitTestResult));
+    g_assert(!test->m_mouseTargetModifiers);
+
+    // Move over scrollbar.
+    hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(5, 75);
+    g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+    g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
+    g_assert(webkit_hit_test_result_context_is_scrollbar(hitTestResult));
+    g_assert(!test->m_mouseTargetModifiers);
+}
+
+static void testWebViewPermissionRequests(UIClientTest* test, gconstpointer)
+{
+    // Some versions of geoclue give a runtime warning because it tries
+    // 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);
+    test->showInWindowAndWaitUntilMapped();
+    static const char* geolocationRequestHTML =
+        "<html>"
+        "  <script>"
+        "  function runTest()"
+        "  {"
+        "    navigator.geolocation.getCurrentPosition(function(p) { document.title = \"OK\" },"
+        "                                             function(e) { document.title = e.code });"
+        "  }"
+        "  </script>"
+        "  <body onload='runTest();'></body>"
+        "</html>";
+
+    // Test denying a permission request.
+    test->m_allowPermissionRequests = false;
+    test->loadHtml(geolocationRequestHTML, 0);
+    test->waitUntilTitleChanged();
+
+    // According to the Geolocation API specification, '1' is the
+    // error code returned for the PERMISSION_DENIED error.
+    // http://dev.w3.org/geo/api/spec-source.html#position_error_interface
+    const gchar* result = webkit_web_view_get_title(test->m_webView);
+    g_assert_cmpstr(result, ==, "1");
+
+    // Test allowing a permission request.
+    test->m_allowPermissionRequests = true;
+    test->loadHtml(geolocationRequestHTML, 0);
+    test->waitUntilTitleChanged();
+
+    // Check that we did not get the PERMISSION_DENIED error now.
+    result = webkit_web_view_get_title(test->m_webView);
+    g_assert_cmpstr(result, !=, "1");
+    test->addLogFatalFlag(G_LOG_LEVEL_WARNING);
+}
+
+class FileChooserTest: public UIClientTest {
+public:
+    MAKE_GLIB_TEST_FIXTURE(FileChooserTest);
+
+    FileChooserTest()
+    {
+        g_signal_connect(m_webView, "run-file-chooser", G_CALLBACK(runFileChooserCallback), this);
+    }
+
+    static gboolean runFileChooserCallback(WebKitWebView*, WebKitFileChooserRequest* request, FileChooserTest* test)
+    {
+        test->runFileChooser(request);
+        return TRUE;
+    }
+
+    void runFileChooser(WebKitFileChooserRequest* request)
+    {
+        assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request));
+        m_fileChooserRequest = request;
+        g_main_loop_quit(m_mainLoop);
+    }
+
+    WebKitFileChooserRequest* clickMouseButtonAndWaitForFileChooserRequest(int x, int y)
+    {
+        clickMouseButton(x, y);
+        g_main_loop_run(m_mainLoop);
+        return m_fileChooserRequest.get();
+    }
+
+private:
+    GRefPtr<WebKitFileChooserRequest> m_fileChooserRequest;
+};
+
+static void testWebViewFileChooserRequest(FileChooserTest* test, gconstpointer)
+{
+    test->showInWindowAndWaitUntilMapped();
+    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.
+    GOwnPtr<char> simpleFileUploadHTML(g_strdup_printf(fileChooserHTMLFormat, ""));
+    test->loadHtml(simpleFileUploadHTML.get(), 0);
+    test->waitUntilLoadFinished();
+    WebKitFileChooserRequest* fileChooserRequest = test->clickMouseButtonAndWaitForFileChooserRequest(5, 5);
+    g_assert(!webkit_file_chooser_request_get_select_multiple(fileChooserRequest));
+
+    const gchar* const* mimeTypes = webkit_file_chooser_request_get_mime_types(fileChooserRequest);
+    g_assert(!mimeTypes);
+    GtkFileFilter* filter = webkit_file_chooser_request_get_mime_types_filter(fileChooserRequest);
+    g_assert(!filter);
+    const gchar* const* selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest);
+    g_assert(!selectedFiles);
+    webkit_file_chooser_request_cancel(fileChooserRequest);
+
+    // Multiple selections allowed, no MIME filtering, some pre-selected files.
+    GOwnPtr<char> multipleSelectionFileUploadHTML(g_strdup_printf(fileChooserHTMLFormat, "multiple"));
+    test->loadHtml(multipleSelectionFileUploadHTML.get(), 0);
+    test->waitUntilLoadFinished();
+    fileChooserRequest = test->clickMouseButtonAndWaitForFileChooserRequest(5, 5);
+    g_assert(webkit_file_chooser_request_get_select_multiple(fileChooserRequest));
+
+    mimeTypes = webkit_file_chooser_request_get_mime_types(fileChooserRequest);
+    g_assert(!mimeTypes);
+    filter = webkit_file_chooser_request_get_mime_types_filter(fileChooserRequest);
+    g_assert(!filter);
+    selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest);
+    g_assert(!selectedFiles);
+
+    // Select some files.
+    const gchar* filesToSelect[4] = { "/foo", "/foo/bar", "/foo/bar/baz", 0 };
+    webkit_file_chooser_request_select_files(fileChooserRequest, filesToSelect);
+
+    // Check the files that have been just selected.
+    selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest);
+    g_assert(selectedFiles);
+    g_assert_cmpstr(selectedFiles[0], ==, "/foo");
+    g_assert_cmpstr(selectedFiles[1], ==, "/foo/bar");
+    g_assert_cmpstr(selectedFiles[2], ==, "/foo/bar/baz");
+    g_assert(!selectedFiles[3]);
+
+    // Perform another request to check if the list of files selected
+    // in the previous step appears now as part of the new request.
+    fileChooserRequest = test->clickMouseButtonAndWaitForFileChooserRequest(5, 5);
+    selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest);
+    g_assert(selectedFiles);
+    g_assert_cmpstr(selectedFiles[0], ==, "/foo");
+    g_assert_cmpstr(selectedFiles[1], ==, "/foo/bar");
+    g_assert_cmpstr(selectedFiles[2], ==, "/foo/bar/baz");
+    g_assert(!selectedFiles[3]);
+    webkit_file_chooser_request_cancel(fileChooserRequest);
+
+    // Multiple selections not allowed, only accept images, audio and video files..
+    GOwnPtr<char> mimeFilteredFileUploadHTML(g_strdup_printf(fileChooserHTMLFormat, "accept='audio/*,video/*,image/*'"));
+    test->loadHtml(mimeFilteredFileUploadHTML.get(), 0);
+    test->waitUntilLoadFinished();
+    fileChooserRequest = test->clickMouseButtonAndWaitForFileChooserRequest(5, 5);
+    g_assert(!webkit_file_chooser_request_get_select_multiple(fileChooserRequest));
+
+    mimeTypes = webkit_file_chooser_request_get_mime_types(fileChooserRequest);
+    g_assert(mimeTypes);
+    g_assert_cmpstr(mimeTypes[0], ==, "audio/*");
+    g_assert_cmpstr(mimeTypes[1], ==, "video/*");
+    g_assert_cmpstr(mimeTypes[2], ==, "image/*");
+    g_assert(!mimeTypes[3]);
+
+    filter = webkit_file_chooser_request_get_mime_types_filter(fileChooserRequest);
+    g_assert(GTK_IS_FILE_FILTER(filter));
+    g_assert(checkMimeTypeForFilter(filter, "audio/*"));
+    g_assert(checkMimeTypeForFilter(filter, "video/*"));
+    g_assert(checkMimeTypeForFilter(filter, "image/*"));
+
+    selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest);
+    g_assert(!selectedFiles);
+    webkit_file_chooser_request_cancel(fileChooserRequest);
+}
+
+void beforeAll()
+{
+    UIClientTest::add("WebKitWebView", "create-ready-close", testWebViewCreateReadyClose);
+    ModalDialogsTest::add("WebKitWebView", "allow-modal-dialogs", testWebViewAllowModalDialogs);
+    ModalDialogsTest::add("WebKitWebView", "disallow-modal-dialogs", testWebViewDisallowModalDialogs);
+    UIClientTest::add("WebKitWebView", "javascript-dialogs", testWebViewJavaScriptDialogs);
+    UIClientTest::add("WebKitWebView", "window-properties", testWebViewWindowProperties);
+    UIClientTest::add("WebKitWebView", "mouse-target", testWebViewMouseTarget);
+    UIClientTest::add("WebKitWebView", "permission-requests", testWebViewPermissionRequests);
+    FileChooserTest::add("WebKitWebView", "file-chooser-request", testWebViewFileChooserRequest);
+}
+
+void afterAll()
+{
+}
index 7a53104..d70b0a2 100644 (file)
  */
 
 #include "config.h"
-#include "LoadTrackingTest.h"
-#include "WebKitTestServer.h"
 #include "WebViewTest.h"
 #include <JavaScriptCore/JSStringRef.h>
 #include <JavaScriptCore/JSValueRef.h>
 #include <glib/gstdio.h>
-#include <wtf/HashSet.h>
 #include <wtf/gobject/GRefPtr.h>
-#include <wtf/text/StringHash.h>
-
-static WebKitTestServer* kServer;
 
 static void testWebViewDefaultContext(WebViewTest* test, gconstpointer)
 {
@@ -75,531 +69,6 @@ static void testWebViewSettings(WebViewTest* test, gconstpointer)
     g_assert(webkit_settings_get_enable_javascript(settings));
 }
 
-static const char* kAlertDialogMessage = "WebKitGTK+ alert dialog message";
-static const char* kConfirmDialogMessage = "WebKitGTK+ confirm dialog message";
-static const char* kPromptDialogMessage = "WebKitGTK+ prompt dialog message";
-static const char* kPromptDialogReturnedText = "WebKitGTK+ prompt dialog returned text";
-
-class UIClientTest: public WebViewTest {
-public:
-    MAKE_GLIB_TEST_FIXTURE(UIClientTest);
-
-    enum WebViewEvents {
-        Create,
-        ReadyToShow,
-        RunAsModal,
-        Close
-    };
-
-    class WindowProperties {
-    public:
-        WindowProperties()
-            : m_isNull(true)
-            , m_toolbarVisible(true)
-            , m_statusbarVisible(true)
-            , m_scrollbarsVisible(true)
-            , m_menubarVisible(true)
-            , m_locationbarVisible(true)
-            , m_resizable(true)
-            , m_fullscreen(false)
-        {
-            memset(&m_geometry, 0, sizeof(GdkRectangle));
-        }
-
-        WindowProperties(WebKitWindowProperties* windowProperties)
-            : m_isNull(false)
-            , m_toolbarVisible(webkit_window_properties_get_toolbar_visible(windowProperties))
-            , m_statusbarVisible(webkit_window_properties_get_statusbar_visible(windowProperties))
-            , m_scrollbarsVisible(webkit_window_properties_get_scrollbars_visible(windowProperties))
-            , m_menubarVisible(webkit_window_properties_get_menubar_visible(windowProperties))
-            , m_locationbarVisible(webkit_window_properties_get_locationbar_visible(windowProperties))
-            , m_resizable(webkit_window_properties_get_resizable(windowProperties))
-            , m_fullscreen(webkit_window_properties_get_fullscreen(windowProperties))
-        {
-            webkit_window_properties_get_geometry(windowProperties, &m_geometry);
-        }
-
-        WindowProperties(GdkRectangle* geometry, bool toolbarVisible, bool statusbarVisible, bool scrollbarsVisible, bool menubarVisible,
-                         bool locationbarVisible, bool resizable, bool fullscreen)
-            : m_isNull(false)
-            , m_geometry(*geometry)
-            , m_toolbarVisible(toolbarVisible)
-            , m_statusbarVisible(statusbarVisible)
-            , m_scrollbarsVisible(scrollbarsVisible)
-            , m_menubarVisible(menubarVisible)
-            , m_locationbarVisible(locationbarVisible)
-            , m_resizable(resizable)
-            , m_fullscreen(fullscreen)
-        {
-        }
-
-        bool isNull() const { return m_isNull; }
-
-        void assertEqual(const WindowProperties& other) const
-        {
-            g_assert_cmpint(m_geometry.x, ==, other.m_geometry.x);
-            g_assert_cmpint(m_geometry.y, ==, other.m_geometry.y);
-            g_assert_cmpint(m_geometry.width, ==, other.m_geometry.width);
-            g_assert_cmpint(m_geometry.height, ==, other.m_geometry.height);
-            g_assert_cmpint(static_cast<int>(m_toolbarVisible), ==, static_cast<int>(other.m_toolbarVisible));
-            g_assert_cmpint(static_cast<int>(m_statusbarVisible), ==, static_cast<int>(other.m_statusbarVisible));
-            g_assert_cmpint(static_cast<int>(m_scrollbarsVisible), ==, static_cast<int>(other.m_scrollbarsVisible));
-            g_assert_cmpint(static_cast<int>(m_menubarVisible), ==, static_cast<int>(other.m_menubarVisible));
-            g_assert_cmpint(static_cast<int>(m_locationbarVisible), ==, static_cast<int>(other.m_locationbarVisible));
-            g_assert_cmpint(static_cast<int>(m_resizable), ==, static_cast<int>(other.m_resizable));
-            g_assert_cmpint(static_cast<int>(m_fullscreen), ==, static_cast<int>(other.m_fullscreen));
-        }
-
-    private:
-        bool m_isNull;
-
-        GdkRectangle m_geometry;
-
-        bool m_toolbarVisible;
-        bool m_statusbarVisible;
-        bool m_scrollbarsVisible;
-        bool m_menubarVisible;
-        bool m_locationbarVisible;
-
-        bool m_resizable;
-        bool m_fullscreen;
-    };
-
-    static void windowPropertiesNotifyCallback(GObject*, GParamSpec* paramSpec, UIClientTest* test)
-    {
-        test->m_windowPropertiesChanged.add(g_param_spec_get_name(paramSpec));
-    }
-
-    static GtkWidget* viewCreateCallback(WebKitWebView* webView, UIClientTest* test)
-    {
-        return test->viewCreate(webView);
-    }
-
-    static void viewReadyToShowCallback(WebKitWebView* webView, UIClientTest* test)
-    {
-        test->viewReadyToShow(webView);
-    }
-
-    static void viewCloseCallback(WebKitWebView* webView, UIClientTest* test)
-    {
-        test->viewClose(webView);
-    }
-
-    void scriptAlert(WebKitScriptDialog* dialog)
-    {
-        switch (m_scriptDialogType) {
-        case WEBKIT_SCRIPT_DIALOG_ALERT:
-            g_assert_cmpstr(webkit_script_dialog_get_message(dialog), ==, kAlertDialogMessage);
-            break;
-        case WEBKIT_SCRIPT_DIALOG_CONFIRM:
-            g_assert(m_scriptDialogConfirmed);
-            g_assert_cmpstr(webkit_script_dialog_get_message(dialog), ==, "confirmed");
-
-            break;
-        case WEBKIT_SCRIPT_DIALOG_PROMPT:
-            g_assert_cmpstr(webkit_script_dialog_get_message(dialog), ==, kPromptDialogReturnedText);
-            break;
-        }
-
-        g_main_loop_quit(m_mainLoop);
-    }
-
-    void scriptConfirm(WebKitScriptDialog* dialog)
-    {
-        g_assert_cmpstr(webkit_script_dialog_get_message(dialog), ==, kConfirmDialogMessage);
-        m_scriptDialogConfirmed = !m_scriptDialogConfirmed;
-        webkit_script_dialog_confirm_set_confirmed(dialog, m_scriptDialogConfirmed);
-    }
-
-    void scriptPrompt(WebKitScriptDialog* dialog)
-    {
-        g_assert_cmpstr(webkit_script_dialog_get_message(dialog), ==, kPromptDialogMessage);
-        g_assert_cmpstr(webkit_script_dialog_prompt_get_default_text(dialog), ==, "default");
-        webkit_script_dialog_prompt_set_text(dialog, kPromptDialogReturnedText);
-    }
-
-    static gboolean scriptDialog(WebKitWebView*, WebKitScriptDialog* dialog, UIClientTest* test)
-    {
-        switch (webkit_script_dialog_get_dialog_type(dialog)) {
-        case WEBKIT_SCRIPT_DIALOG_ALERT:
-            test->scriptAlert(dialog);
-            break;
-        case WEBKIT_SCRIPT_DIALOG_CONFIRM:
-            test->scriptConfirm(dialog);
-            break;
-        case WEBKIT_SCRIPT_DIALOG_PROMPT:
-            test->scriptPrompt(dialog);
-            break;
-        }
-
-        return TRUE;
-    }
-
-    static void mouseTargetChanged(WebKitWebView*, WebKitHitTestResult* hitTestResult, guint modifiers, UIClientTest* test)
-    {
-        g_assert(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult));
-        test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(hitTestResult));
-
-        test->m_mouseTargetHitTestResult = hitTestResult;
-        test->m_mouseTargetModifiers = modifiers;
-        g_main_loop_quit(test->m_mainLoop);
-    }
-
-    static gboolean permissionRequested(WebKitWebView*, WebKitPermissionRequest* request, UIClientTest* test)
-    {
-        g_assert(WEBKIT_IS_PERMISSION_REQUEST(request));
-        test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request));
-
-        if (test->m_allowPermissionRequests)
-            webkit_permission_request_allow(request);
-        else
-            webkit_permission_request_deny(request);
-
-        return TRUE;
-    }
-
-    UIClientTest()
-        : m_scriptDialogType(WEBKIT_SCRIPT_DIALOG_ALERT)
-        , m_scriptDialogConfirmed(true)
-        , m_allowPermissionRequests(false)
-        , m_mouseTargetModifiers(0)
-    {
-        webkit_settings_set_javascript_can_open_windows_automatically(webkit_web_view_get_settings(m_webView), TRUE);
-        g_signal_connect(m_webView, "create", G_CALLBACK(viewCreateCallback), this);
-        g_signal_connect(m_webView, "script-dialog", G_CALLBACK(scriptDialog), this);
-        g_signal_connect(m_webView, "mouse-target-changed", G_CALLBACK(mouseTargetChanged), this);
-        g_signal_connect(m_webView, "permission-request", G_CALLBACK(permissionRequested), this);
-    }
-
-    ~UIClientTest()
-    {
-        g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
-    }
-
-    void waitUntilMainLoopFinishes()
-    {
-        g_main_loop_run(m_mainLoop);
-    }
-
-    void setExpectedWindowProperties(const WindowProperties& windowProperties)
-    {
-        m_windowProperties = windowProperties;
-    }
-
-    WebKitHitTestResult* moveMouseAndWaitUntilMouseTargetChanged(int x, int y, unsigned int mouseModifiers = 0)
-    {
-        mouseMoveTo(x, y, mouseModifiers);
-        g_main_loop_run(m_mainLoop);
-        return m_mouseTargetHitTestResult.get();
-    }
-
-    virtual GtkWidget* viewCreate(WebKitWebView* webView)
-    {
-        g_assert(webView == m_webView);
-
-        GtkWidget* newWebView = webkit_web_view_new_with_context(webkit_web_view_get_context(webView));
-        g_object_ref_sink(newWebView);
-
-        m_webViewEvents.append(Create);
-
-        WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(newWebView));
-        g_assert(windowProperties);
-        assertObjectIsDeletedWhenTestFinishes(G_OBJECT(windowProperties));
-        m_windowPropertiesChanged.clear();
-
-        g_signal_connect(windowProperties, "notify", G_CALLBACK(windowPropertiesNotifyCallback), this);
-        g_signal_connect(newWebView, "ready-to-show", G_CALLBACK(viewReadyToShowCallback), this);
-        g_signal_connect(newWebView, "close", G_CALLBACK(viewCloseCallback), this);
-
-        return newWebView;
-    }
-
-    virtual void viewReadyToShow(WebKitWebView* webView)
-    {
-        g_assert(webView != m_webView);
-
-        WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(webView);
-        g_assert(windowProperties);
-        if (!m_windowProperties.isNull())
-            WindowProperties(windowProperties).assertEqual(m_windowProperties);
-
-        m_webViewEvents.append(ReadyToShow);
-    }
-
-    virtual void viewClose(WebKitWebView* webView)
-    {
-        g_assert(webView != m_webView);
-
-        m_webViewEvents.append(Close);
-        g_object_unref(webView);
-
-        g_main_loop_quit(m_mainLoop);
-    }
-
-    Vector<WebViewEvents> m_webViewEvents;
-    WebKitScriptDialogType m_scriptDialogType;
-    bool m_scriptDialogConfirmed;
-    bool m_allowPermissionRequests;
-    WindowProperties m_windowProperties;
-    HashSet<WTF::String> m_windowPropertiesChanged;
-    GRefPtr<WebKitHitTestResult> m_mouseTargetHitTestResult;
-    unsigned int m_mouseTargetModifiers;
-};
-
-static void testWebViewCreateReadyClose(UIClientTest* test, gconstpointer)
-{
-    test->loadHtml("<html><body onLoad=\"window.open().close();\"></html>", 0);
-    test->waitUntilMainLoopFinishes();
-
-    Vector<UIClientTest::WebViewEvents>& events = test->m_webViewEvents;
-    g_assert_cmpint(events.size(), ==, 3);
-    g_assert_cmpint(events[0], ==, UIClientTest::Create);
-    g_assert_cmpint(events[1], ==, UIClientTest::ReadyToShow);
-    g_assert_cmpint(events[2], ==, UIClientTest::Close);
-}
-
-static gboolean checkMimeTypeForFilter(GtkFileFilter* filter, const gchar* mimeType)
-{
-    GtkFileFilterInfo filterInfo;
-    filterInfo.contains = GTK_FILE_FILTER_MIME_TYPE;
-    filterInfo.mime_type = mimeType;
-    return gtk_file_filter_filter(filter, &filterInfo);
-}
-
-class ModalDialogsTest: public UIClientTest {
-public:
-    MAKE_GLIB_TEST_FIXTURE(ModalDialogsTest);
-
-    static void dialogRunAsModalCallback(WebKitWebView* webView, ModalDialogsTest* test)
-    {
-        g_assert(webView != test->m_webView);
-        test->m_webViewEvents.append(RunAsModal);
-    }
-
-    GtkWidget* viewCreate(WebKitWebView* webView)
-    {
-        g_assert(webView == m_webView);
-
-        GtkWidget* newWebView = UIClientTest::viewCreate(webView);
-        g_signal_connect(newWebView, "run-as-modal", G_CALLBACK(dialogRunAsModalCallback), this);
-        return newWebView;
-    }
-
-    void viewReadyToShow(WebKitWebView* webView)
-    {
-        g_assert(webView != m_webView);
-        m_webViewEvents.append(ReadyToShow);
-    }
-};
-
-static void testWebViewAllowModalDialogs(ModalDialogsTest* test, gconstpointer)
-{
-    WebKitSettings* settings = webkit_web_view_get_settings(test->m_webView);
-    webkit_settings_set_allow_modal_dialogs(settings, TRUE);
-
-    test->loadHtml("<html><body onload=\"window.showModalDialog('data:text/html,<html><body/><script>window.close();</script></html>')\"></body></html>", 0);
-    test->waitUntilMainLoopFinishes();
-
-    Vector<UIClientTest::WebViewEvents>& events = test->m_webViewEvents;
-    g_assert_cmpint(events.size(), ==, 4);
-    g_assert_cmpint(events[0], ==, UIClientTest::Create);
-    g_assert_cmpint(events[1], ==, UIClientTest::ReadyToShow);
-    g_assert_cmpint(events[2], ==, UIClientTest::RunAsModal);
-    g_assert_cmpint(events[3], ==, UIClientTest::Close);
-}
-
-static void testWebViewDisallowModalDialogs(ModalDialogsTest* test, gconstpointer)
-{
-    WebKitSettings* settings = webkit_web_view_get_settings(test->m_webView);
-    webkit_settings_set_allow_modal_dialogs(settings, FALSE);
-
-    test->loadHtml("<html><body onload=\"window.showModalDialog('data:text/html,<html><body/><script>window.close();</script></html>')\"></body></html>", 0);
-    // We need to use a timeout here because the viewClose() function
-    // won't ever be called as the dialog won't be created.
-    test->wait(1);
-
-    Vector<UIClientTest::WebViewEvents>& events = test->m_webViewEvents;
-    g_assert_cmpint(events.size(), ==, 0);
-}
-
-static void testWebViewJavaScriptDialogs(UIClientTest* test, gconstpointer)
-{
-    static const char* htmlOnLoadFormat = "<html><body onLoad=\"%s\"></body></html>";
-    static const char* jsAlertFormat = "alert('%s')";
-    static const char* jsConfirmFormat = "do { confirmed = confirm('%s'); } while (!confirmed); alert('confirmed');";
-    static const char* jsPromptFormat = "alert(prompt('%s', 'default'));";
-
-    test->m_scriptDialogType = WEBKIT_SCRIPT_DIALOG_ALERT;
-    GOwnPtr<char> alertDialogMessage(g_strdup_printf(jsAlertFormat, kAlertDialogMessage));
-    GOwnPtr<char> alertHTML(g_strdup_printf(htmlOnLoadFormat, alertDialogMessage.get()));
-    test->loadHtml(alertHTML.get(), 0);
-    test->waitUntilMainLoopFinishes();
-
-    test->m_scriptDialogType = WEBKIT_SCRIPT_DIALOG_CONFIRM;
-    GOwnPtr<char> confirmDialogMessage(g_strdup_printf(jsConfirmFormat, kConfirmDialogMessage));
-    GOwnPtr<char> confirmHTML(g_strdup_printf(htmlOnLoadFormat, confirmDialogMessage.get()));
-    test->loadHtml(confirmHTML.get(), 0);
-    test->waitUntilMainLoopFinishes();
-
-    test->m_scriptDialogType = WEBKIT_SCRIPT_DIALOG_PROMPT;
-    GOwnPtr<char> promptDialogMessage(g_strdup_printf(jsPromptFormat, kPromptDialogMessage));
-    GOwnPtr<char> promptHTML(g_strdup_printf(htmlOnLoadFormat, promptDialogMessage.get()));
-    test->loadHtml(promptHTML.get(), 0);
-    test->waitUntilMainLoopFinishes();
-}
-
-static void testWebViewWindowProperties(UIClientTest* test, gconstpointer)
-{
-    static const char* windowProrpertiesString = "left=100,top=150,width=400,height=400,location=no,menubar=no,status=no,toolbar=no,scrollbars=no";
-    GdkRectangle geometry = { 100, 150, 400, 400 };
-    test->setExpectedWindowProperties(UIClientTest::WindowProperties(&geometry, false, false, false, false, false, true, false));
-
-    GOwnPtr<char> htmlString(g_strdup_printf("<html><body onLoad=\"window.open('', '', '%s').close();\"></body></html>", windowProrpertiesString));
-    test->loadHtml(htmlString.get(), 0);
-    test->waitUntilMainLoopFinishes();
-
-    static const char* propertiesChanged[] = {
-        "geometry", "locationbar-visible", "menubar-visible", "statusbar-visible", "toolbar-visible", "scrollbars-visible"
-    };
-    for (size_t i = 0; i < G_N_ELEMENTS(propertiesChanged); ++i)
-        g_assert(test->m_windowPropertiesChanged.contains(propertiesChanged[i]));
-
-    Vector<UIClientTest::WebViewEvents>& events = test->m_webViewEvents;
-    g_assert_cmpint(events.size(), ==, 3);
-    g_assert_cmpint(events[0], ==, UIClientTest::Create);
-    g_assert_cmpint(events[1], ==, UIClientTest::ReadyToShow);
-    g_assert_cmpint(events[2], ==, UIClientTest::Close);
-}
-
-static void testWebViewMouseTarget(UIClientTest* test, gconstpointer)
-{
-    test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
-
-    const char* linksHoveredHTML =
-        "<html><body>"
-        " <a style='position:absolute; left:1; top:1' href='http://www.webkitgtk.org' title='WebKitGTK+ Title'>WebKitGTK+ Website</a>"
-        " <img style='position:absolute; left:1; top:10' src='0xdeadbeef' width=5 height=5></img>"
-        " <a style='position:absolute; left:1; top:20' href='http://www.webkitgtk.org/logo' title='WebKitGTK+ Logo'><img src='0xdeadbeef' width=5 height=5></img></a>"
-        " <input style='position:absolute; left:1; top:30' size='10'></input>"
-        " <div style='position:absolute; left:1; top:50; width:30; height:30; overflow:scroll'>&nbsp;</div>"
-        " <video style='position:absolute; left:1; top:100' width='300' height='300' controls='controls' preload='none'><source src='movie.ogg' type='video/ogg' /></video>"
-        "</body></html>";
-
-    test->loadHtml(linksHoveredHTML, "file:///");
-    test->waitUntilLoadFinished();
-
-    // Move over link.
-    WebKitHitTestResult* hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 1);
-    g_assert(webkit_hit_test_result_context_is_link(hitTestResult));
-    g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
-    g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
-    g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
-    g_assert_cmpstr(webkit_hit_test_result_get_link_uri(hitTestResult), ==, "http://www.webkitgtk.org/");
-    g_assert_cmpstr(webkit_hit_test_result_get_link_title(hitTestResult), ==, "WebKitGTK+ Title");
-    g_assert_cmpstr(webkit_hit_test_result_get_link_label(hitTestResult), ==, "WebKitGTK+ Website");
-    g_assert(!test->m_mouseTargetModifiers);
-
-    // Move out of the link.
-    hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(0, 0);
-    g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
-    g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
-    g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
-    g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
-    g_assert(!test->m_mouseTargetModifiers);
-
-    // Move over image with GDK_CONTROL_MASK.
-    hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 10, GDK_CONTROL_MASK);
-    g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
-    g_assert(webkit_hit_test_result_context_is_image(hitTestResult));
-    g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
-    g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
-    g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult));
-    g_assert_cmpstr(webkit_hit_test_result_get_image_uri(hitTestResult), ==, "file:///0xdeadbeef");
-    g_assert(test->m_mouseTargetModifiers & GDK_CONTROL_MASK);
-
-    // Move over image link.
-    hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 20);
-    g_assert(webkit_hit_test_result_context_is_link(hitTestResult));
-    g_assert(webkit_hit_test_result_context_is_image(hitTestResult));
-    g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
-    g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
-    g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult));
-    g_assert_cmpstr(webkit_hit_test_result_get_link_uri(hitTestResult), ==, "http://www.webkitgtk.org/logo");
-    g_assert_cmpstr(webkit_hit_test_result_get_image_uri(hitTestResult), ==, "file:///0xdeadbeef");
-    g_assert_cmpstr(webkit_hit_test_result_get_link_title(hitTestResult), ==, "WebKitGTK+ Logo");
-    g_assert(!webkit_hit_test_result_get_link_label(hitTestResult));
-    g_assert(!test->m_mouseTargetModifiers);
-
-    // Move over media.
-    hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 100);
-    g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
-    g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
-    g_assert(webkit_hit_test_result_context_is_media(hitTestResult));
-    g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
-    g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult));
-    g_assert_cmpstr(webkit_hit_test_result_get_media_uri(hitTestResult), ==, "file:///movie.ogg");
-    g_assert(!test->m_mouseTargetModifiers);
-
-    // Mover over input.
-    hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(5, 35);
-    g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
-    g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
-    g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
-    g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult));
-    g_assert(webkit_hit_test_result_context_is_editable(hitTestResult));
-    g_assert(!test->m_mouseTargetModifiers);
-
-    // Move over scrollbar.
-    hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(5, 75);
-    g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
-    g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
-    g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
-    g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
-    g_assert(webkit_hit_test_result_context_is_scrollbar(hitTestResult));
-    g_assert(!test->m_mouseTargetModifiers);
-}
-
-static void testWebViewPermissionRequests(UIClientTest* test, gconstpointer)
-{
-    // Some versions of geoclue give a runtime warning because it tries
-    // 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);
-    test->showInWindowAndWaitUntilMapped();
-    static const char* geolocationRequestHTML =
-        "<html>"
-        "  <script>"
-        "  function runTest()"
-        "  {"
-        "    navigator.geolocation.getCurrentPosition(function(p) { document.title = \"OK\" },"
-        "                                             function(e) { document.title = e.code });"
-        "  }"
-        "  </script>"
-        "  <body onload='runTest();'></body>"
-        "</html>";
-
-    // Test denying a permission request.
-    test->m_allowPermissionRequests = false;
-    test->loadHtml(geolocationRequestHTML, 0);
-    test->waitUntilTitleChanged();
-
-    // According to the Geolocation API specification, '1' is the
-    // error code returned for the PERMISSION_DENIED error.
-    // http://dev.w3.org/geo/api/spec-source.html#position_error_interface
-    const gchar* result = webkit_web_view_get_title(test->m_webView);
-    g_assert_cmpstr(result, ==, "1");
-
-    // Test allowing a permission request.
-    test->m_allowPermissionRequests = true;
-    test->loadHtml(geolocationRequestHTML, 0);
-    test->waitUntilTitleChanged();
-
-    // Check that we did not get the PERMISSION_DENIED error now.
-    result = webkit_web_view_get_title(test->m_webView);
-    g_assert_cmpstr(result, !=, "1");
-    test->addLogFatalFlag(G_LOG_LEVEL_WARNING);
-}
-
 static void testWebViewZoomLevel(WebViewTest* test, gconstpointer)
 {
     g_assert_cmpfloat(webkit_web_view_get_zoom_level(test->m_webView), ==, 1);
@@ -682,121 +151,6 @@ static void testWebViewRunJavaScript(WebViewTest* test, gconstpointer)
     g_assert_error(error.get(), WEBKIT_JAVASCRIPT_ERROR, WEBKIT_JAVASCRIPT_ERROR_SCRIPT_FAILED);
 }
 
-class FileChooserTest: public UIClientTest {
-public:
-    MAKE_GLIB_TEST_FIXTURE(FileChooserTest);
-
-    FileChooserTest()
-    {
-        g_signal_connect(m_webView, "run-file-chooser", G_CALLBACK(runFileChooserCallback), this);
-    }
-
-    static gboolean runFileChooserCallback(WebKitWebView*, WebKitFileChooserRequest* request, FileChooserTest* test)
-    {
-        test->runFileChooser(request);
-        return TRUE;
-    }
-
-    void runFileChooser(WebKitFileChooserRequest* request)
-    {
-        assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request));
-        m_fileChooserRequest = request;
-        g_main_loop_quit(m_mainLoop);
-    }
-
-    WebKitFileChooserRequest* clickMouseButtonAndWaitForFileChooserRequest(int x, int y)
-    {
-        clickMouseButton(x, y);
-        g_main_loop_run(m_mainLoop);
-        return m_fileChooserRequest.get();
-    }
-
-private:
-    GRefPtr<WebKitFileChooserRequest> m_fileChooserRequest;
-};
-
-static void testWebViewFileChooserRequest(FileChooserTest* test, gconstpointer)
-{
-    test->showInWindowAndWaitUntilMapped();
-    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.
-    GOwnPtr<char> simpleFileUploadHTML(g_strdup_printf(fileChooserHTMLFormat, ""));
-    test->loadHtml(simpleFileUploadHTML.get(), 0);
-    test->waitUntilLoadFinished();
-    WebKitFileChooserRequest* fileChooserRequest = test->clickMouseButtonAndWaitForFileChooserRequest(5, 5);
-    g_assert(!webkit_file_chooser_request_get_select_multiple(fileChooserRequest));
-
-    const gchar* const* mimeTypes = webkit_file_chooser_request_get_mime_types(fileChooserRequest);
-    g_assert(!mimeTypes);
-    GtkFileFilter* filter = webkit_file_chooser_request_get_mime_types_filter(fileChooserRequest);
-    g_assert(!filter);
-    const gchar* const* selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest);
-    g_assert(!selectedFiles);
-    webkit_file_chooser_request_cancel(fileChooserRequest);
-
-    // Multiple selections allowed, no MIME filtering, some pre-selected files.
-    GOwnPtr<char> multipleSelectionFileUploadHTML(g_strdup_printf(fileChooserHTMLFormat, "multiple"));
-    test->loadHtml(multipleSelectionFileUploadHTML.get(), 0);
-    test->waitUntilLoadFinished();
-    fileChooserRequest = test->clickMouseButtonAndWaitForFileChooserRequest(5, 5);
-    g_assert(webkit_file_chooser_request_get_select_multiple(fileChooserRequest));
-
-    mimeTypes = webkit_file_chooser_request_get_mime_types(fileChooserRequest);
-    g_assert(!mimeTypes);
-    filter = webkit_file_chooser_request_get_mime_types_filter(fileChooserRequest);
-    g_assert(!filter);
-    selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest);
-    g_assert(!selectedFiles);
-
-    // Select some files.
-    const gchar* filesToSelect[4] = { "/foo", "/foo/bar", "/foo/bar/baz", 0 };
-    webkit_file_chooser_request_select_files(fileChooserRequest, filesToSelect);
-
-    // Check the files that have been just selected.
-    selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest);
-    g_assert(selectedFiles);
-    g_assert_cmpstr(selectedFiles[0], ==, "/foo");
-    g_assert_cmpstr(selectedFiles[1], ==, "/foo/bar");
-    g_assert_cmpstr(selectedFiles[2], ==, "/foo/bar/baz");
-    g_assert(!selectedFiles[3]);
-
-    // Perform another request to check if the list of files selected
-    // in the previous step appears now as part of the new request.
-    fileChooserRequest = test->clickMouseButtonAndWaitForFileChooserRequest(5, 5);
-    selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest);
-    g_assert(selectedFiles);
-    g_assert_cmpstr(selectedFiles[0], ==, "/foo");
-    g_assert_cmpstr(selectedFiles[1], ==, "/foo/bar");
-    g_assert_cmpstr(selectedFiles[2], ==, "/foo/bar/baz");
-    g_assert(!selectedFiles[3]);
-    webkit_file_chooser_request_cancel(fileChooserRequest);
-
-    // Multiple selections not allowed, only accept images, audio and video files..
-    GOwnPtr<char> mimeFilteredFileUploadHTML(g_strdup_printf(fileChooserHTMLFormat, "accept='audio/*,video/*,image/*'"));
-    test->loadHtml(mimeFilteredFileUploadHTML.get(), 0);
-    test->waitUntilLoadFinished();
-    fileChooserRequest = test->clickMouseButtonAndWaitForFileChooserRequest(5, 5);
-    g_assert(!webkit_file_chooser_request_get_select_multiple(fileChooserRequest));
-
-    mimeTypes = webkit_file_chooser_request_get_mime_types(fileChooserRequest);
-    g_assert(mimeTypes);
-    g_assert_cmpstr(mimeTypes[0], ==, "audio/*");
-    g_assert_cmpstr(mimeTypes[1], ==, "video/*");
-    g_assert_cmpstr(mimeTypes[2], ==, "image/*");
-    g_assert(!mimeTypes[3]);
-
-    filter = webkit_file_chooser_request_get_mime_types_filter(fileChooserRequest);
-    g_assert(GTK_IS_FILE_FILTER(filter));
-    g_assert(checkMimeTypeForFilter(filter, "audio/*"));
-    g_assert(checkMimeTypeForFilter(filter, "video/*"));
-    g_assert(checkMimeTypeForFilter(filter, "image/*"));
-
-    selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest);
-    g_assert(!selectedFiles);
-    webkit_file_chooser_request_cancel(fileChooserRequest);
-}
-
 class FullScreenClientTest: public WebViewTest {
 public:
     MAKE_GLIB_TEST_FIXTURE(FullScreenClientTest);
@@ -1233,264 +587,13 @@ static void testWebViewSnapshot(SnapshotWebViewTest* test, gconstpointer)
     g_assert(test->getSnapshotAndCancel());
 }
 
-class AuthenticationTest: public LoadTrackingTest {
-public:
-    MAKE_GLIB_TEST_FIXTURE(AuthenticationTest);
-
-    AuthenticationTest()
-    {
-        g_signal_connect(m_webView, "authenticate", G_CALLBACK(runAuthenticationCallback), this);
-    }
-
-    ~AuthenticationTest()
-    {
-        g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
-    }
-
-    static int authenticationRetries;
-    static bool authenticationCancelledReceived;
-
-    void loadURI(const char* uri)
-    {
-        // Reset the retry count of the fake server when a page is loaded.
-        authenticationRetries = 0;
-        authenticationCancelledReceived = false;
-        LoadTrackingTest::loadURI(uri);
-    }
-
-    static gboolean runAuthenticationCallback(WebKitWebView*, WebKitAuthenticationRequest* request, AuthenticationTest* test)
-    {
-        g_signal_connect(request, "cancelled", G_CALLBACK(authenticationCancelledCallback), test);
-        test->runAuthentication(request);
-        return TRUE;
-    }
-
-    static void authenticationCancelledCallback(WebKitAuthenticationRequest*, AuthenticationTest*)
-    {
-        authenticationCancelledReceived = true;
-    }
-
-    void runAuthentication(WebKitAuthenticationRequest* request)
-    {
-        assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request));
-        m_authenticationRequest = request;
-        g_main_loop_quit(m_mainLoop);
-    }
-
-    WebKitAuthenticationRequest* waitForAuthenticationRequest()
-    {
-        g_main_loop_run(m_mainLoop);
-        return m_authenticationRequest.get();
-    }
-
-private:
-    GRefPtr<WebKitAuthenticationRequest> m_authenticationRequest;
-};
-
-int AuthenticationTest::authenticationRetries = 0;
-bool AuthenticationTest::authenticationCancelledReceived = false;
-
-static const char authTestUsername[] = "username";
-static const char authTestPassword[] = "password";
-static const char authExpectedSuccessTitle[] = "WebKit2Gtk+ Authentication test";
-static const char authExpectedFailureTitle[] = "401 Authorization Required";
-static const char authExpectedAuthorization[] = "Basic dXNlcm5hbWU6cGFzc3dvcmQ="; // Base64 encoding of "username:password".
-static const char authSuccessHTMLString[] =
-    "<html>"
-    "<head><title>WebKit2Gtk+ Authentication test</title></head>"
-    "<body></body></html>";
-static const char authFailureHTMLString[] =
-    "<html>"
-    "<head><title>401 Authorization Required</title></head>"
-    "<body></body></html>";
-
-static void testWebViewAuthenticationRequest(AuthenticationTest* test, gconstpointer)
-{
-    // Test authentication request getters match soup authentication header.
-    test->loadURI(kServer->getURIForPath("/auth-test.html").data());
-    WebKitAuthenticationRequest* request = test->waitForAuthenticationRequest();
-    g_assert_cmpstr(webkit_authentication_request_get_host(request), ==, soup_uri_get_host(kServer->baseURI()));
-    g_assert_cmpuint(webkit_authentication_request_get_port(request), ==, soup_uri_get_port(kServer->baseURI()));
-    g_assert_cmpstr(webkit_authentication_request_get_realm(request), ==, "my realm");
-    g_assert(webkit_authentication_request_get_scheme(request) == WEBKIT_AUTHENTICATION_SCHEME_HTTP_BASIC);
-    g_assert(!webkit_authentication_request_is_for_proxy(request));
-    g_assert(!webkit_authentication_request_is_retry(request));
-}
-
-static void testWebViewAuthenticationCancel(AuthenticationTest* test, gconstpointer)
-{
-    // Test cancel.
-    test->loadURI(kServer->getURIForPath("/auth-test.html").data());
-    WebKitAuthenticationRequest* request = test->waitForAuthenticationRequest();
-    webkit_authentication_request_cancel(request);
-    // Server doesn't ask for new credentials.
-    test->waitUntilLoadFinished();
-
-    g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
-    g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
-    g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::ProvisionalLoadFailed);
-    g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
-
-    g_assert_error(test->m_error.get(), WEBKIT_NETWORK_ERROR, WEBKIT_NETWORK_ERROR_CANCELLED);
-}
-
-static void testWebViewAuthenticationLoadCancelled(AuthenticationTest* test, gconstpointer)
-{
-    test->loadURI(kServer->getURIForPath("/auth-test.html").data());
-    test->waitForAuthenticationRequest();
-    webkit_web_view_stop_loading(test->m_webView);
-    // Expect empty page.
-    test->waitUntilLoadFinished();
-    g_assert(test->authenticationCancelledReceived);
-
-    g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
-    g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
-    g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::ProvisionalLoadFailed);
-    g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
-
-    g_assert_error(test->m_error.get(), WEBKIT_NETWORK_ERROR, WEBKIT_NETWORK_ERROR_CANCELLED);
-}
-
-static void testWebViewAuthenticationFailure(AuthenticationTest* test, gconstpointer)
-{
-    // Test authentication failures.
-    test->loadURI(kServer->getURIForPath("/auth-test.html").data());
-    WebKitAuthenticationRequest* request = test->waitForAuthenticationRequest();
-    g_assert(!webkit_authentication_request_is_retry(request));
-    WebKitCredential* credential = webkit_credential_new(authTestUsername, "wrongpassword", WEBKIT_CREDENTIAL_PERSISTENCE_NONE);
-    webkit_authentication_request_authenticate(request, credential);
-    webkit_credential_free(credential);
-    // Expect a second authentication request.
-    request = test->waitForAuthenticationRequest();
-    g_assert(webkit_authentication_request_is_retry(request));
-    // Test second failure.
-    credential = webkit_credential_new(authTestUsername, "wrongpassword2", WEBKIT_CREDENTIAL_PERSISTENCE_NONE);
-    webkit_authentication_request_authenticate(request, credential);
-    webkit_credential_free(credential);
-    // Expect authentication failed page.
-    test->waitUntilLoadFinished();
-
-    g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
-    g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
-    g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::LoadCommitted);
-    g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
-    g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, authExpectedFailureTitle);
-}
-
-static void testWebViewAuthenticationNoCredential(AuthenticationTest* test, gconstpointer)
-{
-    // Test continue without credentials.
-    test->loadURI(kServer->getURIForPath("/auth-test.html").data());
-    WebKitAuthenticationRequest* request = test->waitForAuthenticationRequest();
-    webkit_authentication_request_authenticate(request, 0);
-    // Server doesn't ask for new credentials.
-    test->waitUntilLoadFinished();
-
-    g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
-    g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
-    g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::LoadCommitted);
-    g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
-    g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, authExpectedFailureTitle);
-}
-
-static void testWebViewAuthenticationStorage(AuthenticationTest* test, gconstpointer)
-{
-    // Enable private browsing before authentication request to test that credentials can't be saved.
-    webkit_settings_set_enable_private_browsing(webkit_web_view_get_settings(test->m_webView), TRUE);
-    test->loadURI(kServer->getURIForPath("/auth-test.html").data());
-    WebKitAuthenticationRequest* request = test->waitForAuthenticationRequest();
-    g_assert(!webkit_authentication_request_get_proposed_credential(request));
-    g_assert(!webkit_authentication_request_can_save_credentials(request));
-
-    // If WebKit has been compiled with libsecret, and private browsing is disabled
-    // then check that credentials can be saved.
-#if ENABLE(CREDENTIAL_STORAGE)
-    webkit_settings_set_enable_private_browsing(webkit_web_view_get_settings(test->m_webView), FALSE);
-    test->loadURI(kServer->getURIForPath("/auth-test.html").data());
-    request = test->waitForAuthenticationRequest();
-    g_assert(!webkit_authentication_request_get_proposed_credential(request));
-    g_assert(webkit_authentication_request_can_save_credentials(request));
-#endif
-}
-
-static void testWebViewAuthenticationSuccess(AuthenticationTest* test, gconstpointer)
-{
-    // Test correct authentication.
-    test->loadURI(kServer->getURIForPath("/auth-test.html").data());
-    WebKitAuthenticationRequest* request = test->waitForAuthenticationRequest();
-    WebKitCredential* credential = webkit_credential_new(authTestUsername, authTestPassword, WEBKIT_CREDENTIAL_PERSISTENCE_FOR_SESSION);
-    webkit_authentication_request_authenticate(request, credential);
-    webkit_credential_free(credential);
-    test->waitUntilLoadFinished();
-
-    g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
-    g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
-    g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::LoadCommitted);
-    g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
-    g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, authExpectedSuccessTitle);
-
-    // Test loading the same (authorized) page again.
-    test->loadURI(kServer->getURIForPath("/auth-test.html").data());
-    // There is no authentication challenge.
-    test->waitUntilLoadFinished();
-
-    g_assert_cmpint(test->m_loadEvents.size(), ==, 3);
-    g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
-    g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::LoadCommitted);
-    g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
-    g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, authExpectedSuccessTitle);
-}
-
-static void serverCallback(SoupServer*, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, void*)
-{
-    if (message->method != SOUP_METHOD_GET) {
-        soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
-        return;
-    }
-
-    if (!strcmp(path, "/auth-test.html")) {
-        const char* authorization = soup_message_headers_get_one(message->request_headers, "Authorization");
-        // Require authentication.
-        if (!g_strcmp0(authorization, authExpectedAuthorization)) {
-            // Successful authentication.
-            soup_message_set_status(message, SOUP_STATUS_OK);
-            soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, authSuccessHTMLString, strlen(authSuccessHTMLString));
-            AuthenticationTest::authenticationRetries = 0;
-        } else if (++AuthenticationTest::authenticationRetries < 3) {
-            // No or invalid authorization header provided by the client, request authentication twice then fail.
-            soup_message_set_status(message, SOUP_STATUS_UNAUTHORIZED);
-            soup_message_headers_append(message->response_headers, "WWW-Authenticate", "Basic realm=\"my realm\"");
-            // Include a failure message in case the user attempts to proceed without authentication.
-            soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, authFailureHTMLString, strlen(authFailureHTMLString));
-        } else {
-            // Authentication not successful, display a "401 Authorization Required" page.
-            soup_message_set_status(message, SOUP_STATUS_OK);
-            soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, authFailureHTMLString, strlen(authFailureHTMLString));
-        }
-    } else
-        soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
-
-    soup_message_body_complete(message->response_body);
-}
-
 void beforeAll()
 {
-    kServer = new WebKitTestServer();
-    kServer->run(serverCallback);
-
     WebViewTest::add("WebKitWebView", "default-context", testWebViewDefaultContext);
     WebViewTest::add("WebKitWebView", "custom-charset", testWebViewCustomCharset);
     WebViewTest::add("WebKitWebView", "settings", testWebViewSettings);
-    UIClientTest::add("WebKitWebView", "create-ready-close", testWebViewCreateReadyClose);
-    ModalDialogsTest::add("WebKitWebView", "allow-modal-dialogs", testWebViewAllowModalDialogs);
-    ModalDialogsTest::add("WebKitWebView", "disallow-modal-dialogs", testWebViewDisallowModalDialogs);
-    UIClientTest::add("WebKitWebView", "javascript-dialogs", testWebViewJavaScriptDialogs);
-    UIClientTest::add("WebKitWebView", "window-properties", testWebViewWindowProperties);
-    UIClientTest::add("WebKitWebView", "mouse-target", testWebViewMouseTarget);
-    UIClientTest::add("WebKitWebView", "permission-requests", testWebViewPermissionRequests);
     WebViewTest::add("WebKitWebView", "zoom-level", testWebViewZoomLevel);
     WebViewTest::add("WebKitWebView", "run-javascript", testWebViewRunJavaScript);
-    FileChooserTest::add("WebKitWebView", "file-chooser-request", testWebViewFileChooserRequest);
     FullScreenClientTest::add("WebKitWebView", "fullscreen", testWebViewFullScreen);
     WebViewTest::add("WebKitWebView", "can-show-mime-type", testWebViewCanShowMIMEType);
     FormClientTest::add("WebKitWebView", "submit-form", testWebViewSubmitForm);
@@ -1498,18 +601,8 @@ void beforeAll()
     WebViewTest::add("WebKitWebView", "view-mode", testWebViewMode);
     SnapshotWebViewTest::add("WebKitWebView", "snapshot", testWebViewSnapshot);
     WebViewTest::add("WebKitWebView", "page-visibility", testWebViewPageVisibility);
-    AuthenticationTest::add("WebKitWebView", "authentication-request", testWebViewAuthenticationRequest);
-    AuthenticationTest::add("WebKitWebView", "authentication-cancel", testWebViewAuthenticationCancel);
-    AuthenticationTest::add("WebKitWebView", "authentication-load-cancelled", testWebViewAuthenticationLoadCancelled);
-    AuthenticationTest::add("WebKitWebView", "authentication-failure", testWebViewAuthenticationFailure);
-    AuthenticationTest::add("WebKitWebView", "authentication-no-credential", testWebViewAuthenticationNoCredential);
-    AuthenticationTest::add("WebKitWebView", "authentication-storage", testWebViewAuthenticationStorage);
-    // Testing authentication success must be done last because libsoup will never fire
-    // the authenticate signal again once authentication is successful.
-    AuthenticationTest::add("WebKitWebView", "authentication-success", testWebViewAuthenticationSuccess);
 }
 
 void afterAll()
 {
-    delete kServer;
 }
index 1442939..6c824e5 100644 (file)
@@ -1,3 +1,16 @@
+2013-12-30  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Split WebKit2APITests/TestWebKitWebView
+        https://bugs.webkit.org/show_bug.cgi?id=126284
+
+        Reviewed by Philippe Normand.
+
+        Skip only WebKitWebView/mouse-target and all TestAuthentication
+        tests that are timing out when running under xvfb.
+
+        * Scripts/run-gtk-tests:
+        (TestRunner):
+
 2013-12-29  Michał Pakuła vel Rutka  <m.pakula@samsung.com>
 
         [EFL][WK2] Disable geolocation API test
index 97bb119..d8e156b 100755 (executable)
@@ -67,7 +67,8 @@ class TestRunner:
         SkippedTest("unittests/testwebresource", "/webkit/webresource/sub_resource_loading", "Test fails in GTK Linux 64-bit Release bot", 82330),
         SkippedTest("unittests/testwebview", "/webkit/webview/icon-uri", "Test times out in GTK Linux 64-bit Release bot", 82328),
         SkippedTest("WebKit2APITests/TestResources", "/webkit2/WebKitWebView/resources", "Test is flaky in GTK Linux 32-bit Release bot", 82868),
-        SkippedTest("WebKit2APITests/TestWebKitWebView", SkippedTest.ENTIRE_SUITE, "Test times out after r150890", 117689),
+        SkippedTest("WebKit2APITests/TestUIClient", "/webkit2/WebKitWebView/mouse-target", "Test times out after r150890", 117689),
+        SkippedTest("WebKit2APITests/TestAuthentication", SkippedTest.ENTIRE_SUITE, "Test times out after r150890", 117689),
         SkippedTest("WebKit2APITests/TestContextMenu", SkippedTest.ENTIRE_SUITE, "Test times out after r150890", 117689),
         SkippedTest("TestWebKitAPI/TestWebKit2", "WebKit2.MouseMoveAfterCrash", "Test is flaky", 85066),
         SkippedTest("TestWebKitAPI/TestWebKit2", "WebKit2.NewFirstVisuallyNonEmptyLayoutForImages", "Test is flaky", 85066),