<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[161138] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/161138">161138</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2013-12-30 01:58:14 -0800 (Mon, 30 Dec 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>[GTK] Split WebKit2APITests/TestWebKitWebView
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):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtktestsGNUmakefileam">trunk/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtktestsTestWebKitWebViewcpp">trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptsrungtktests">trunk/Tools/Scripts/run-gtk-tests</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtktestsTestAuthenticationcpp">trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestAuthentication.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtktestsTestUIClientcpp">trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestUIClient.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (161137 => 161138)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2013-12-30 06:31:41 UTC (rev 161137)
+++ trunk/Source/WebKit2/ChangeLog        2013-12-30 09:58:14 UTC (rev 161138)
</span><span class="lines">@@ -1,3 +1,42 @@
</span><ins>+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):
+
</ins><span class="cx"> 2013-12-29 Martin Robinson <mrobinson@igalia.com>
</span><span class="cx">
</span><span class="cx"> [GTK] [CMake] Convenience libraries that export API should be compiled with --whole-archive on Unix
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtktestsGNUmakefileam"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am (161137 => 161138)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am        2013-12-30 06:31:41 UTC (rev 161137)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am        2013-12-30 09:58:14 UTC (rev 161138)
</span><span class="lines">@@ -2,6 +2,7 @@
</span><span class="cx">
</span><span class="cx"> TEST_PROGS += \
</span><span class="cx">         Programs/WebKit2APITests/InspectorTestServer \
</span><ins>+        Programs/WebKit2APITests/TestAuthentication \
</ins><span class="cx">         Programs/WebKit2APITests/TestBackForwardList \
</span><span class="cx">         Programs/WebKit2APITests/TestContextMenu \
</span><span class="cx">         Programs/WebKit2APITests/TestCookieManager \
</span><span class="lines">@@ -14,6 +15,7 @@
</span><span class="cx">         Programs/WebKit2APITests/TestPrinting \
</span><span class="cx">         Programs/WebKit2APITests/TestResources \
</span><span class="cx">         Programs/WebKit2APITests/TestSSL \
</span><ins>+        Programs/WebKit2APITests/TestUIClient \
</ins><span class="cx">         Programs/WebKit2APITests/TestWebExtensions \
</span><span class="cx">         Programs/WebKit2APITests/TestWebKitVersion \
</span><span class="cx">         Programs/WebKit2APITests/TestWebKitFaviconDatabase \
</span><span class="lines">@@ -310,4 +312,16 @@
</span><span class="cx"> Programs_WebKit2APITests_TestFrame_LDADD = $(webkit2_tests_ldadd)
</span><span class="cx"> Programs_WebKit2APITests_TestFrame_LDFLAGS = $(webkit2_tests_ldflags)
</span><span class="cx">
</span><ins>+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)
+
</ins><span class="cx"> endif # ENABLE_WEBKIT2
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtktestsTestAuthenticationcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestAuthentication.cpp (0 => 161138)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestAuthentication.cpp         (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestAuthentication.cpp        2013-12-30 09:58:14 UTC (rev 161138)
</span><span class="lines">@@ -0,0 +1,286 @@
</span><ins>+/*
+ * 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;
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtktestsTestUIClientcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestUIClient.cpp (0 => 161138)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestUIClient.cpp         (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestUIClient.cpp        2013-12-30 09:58:14 UTC (rev 161138)
</span><span class="lines">@@ -0,0 +1,679 @@
</span><ins>+/*
+ * 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()
+{
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtktestsTestWebKitWebViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp (161137 => 161138)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp        2013-12-30 06:31:41 UTC (rev 161137)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp        2013-12-30 09:58:14 UTC (rev 161138)
</span><span class="lines">@@ -18,18 +18,12 @@
</span><span class="cx"> */
</span><span class="cx">
</span><span class="cx"> #include "config.h"
</span><del>-#include "LoadTrackingTest.h"
-#include "WebKitTestServer.h"
</del><span class="cx"> #include "WebViewTest.h"
</span><span class="cx"> #include <JavaScriptCore/JSStringRef.h>
</span><span class="cx"> #include <JavaScriptCore/JSValueRef.h>
</span><span class="cx"> #include <glib/gstdio.h>
</span><del>-#include <wtf/HashSet.h>
</del><span class="cx"> #include <wtf/gobject/GRefPtr.h>
</span><del>-#include <wtf/text/StringHash.h>
</del><span class="cx">
</span><del>-static WebKitTestServer* kServer;
-
</del><span class="cx"> static void testWebViewDefaultContext(WebViewTest* test, gconstpointer)
</span><span class="cx"> {
</span><span class="cx"> g_assert(webkit_web_view_get_context(test->m_webView) == webkit_web_context_get_default());
</span><span class="lines">@@ -75,531 +69,6 @@
</span><span class="cx"> g_assert(webkit_settings_get_enable_javascript(settings));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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);
-}
-
</del><span class="cx"> static void testWebViewZoomLevel(WebViewTest* test, gconstpointer)
</span><span class="cx"> {
</span><span class="cx"> g_assert_cmpfloat(webkit_web_view_get_zoom_level(test->m_webView), ==, 1);
</span><span class="lines">@@ -682,121 +151,6 @@
</span><span class="cx"> g_assert_error(error.get(), WEBKIT_JAVASCRIPT_ERROR, WEBKIT_JAVASCRIPT_ERROR_SCRIPT_FAILED);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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);
-}
-
</del><span class="cx"> class FullScreenClientTest: public WebViewTest {
</span><span class="cx"> public:
</span><span class="cx"> MAKE_GLIB_TEST_FIXTURE(FullScreenClientTest);
</span><span class="lines">@@ -1233,264 +587,13 @@
</span><span class="cx"> g_assert(test->getSnapshotAndCancel());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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);
-}
-
</del><span class="cx"> void beforeAll()
</span><span class="cx"> {
</span><del>- kServer = new WebKitTestServer();
- kServer->run(serverCallback);
-
</del><span class="cx"> WebViewTest::add("WebKitWebView", "default-context", testWebViewDefaultContext);
</span><span class="cx"> WebViewTest::add("WebKitWebView", "custom-charset", testWebViewCustomCharset);
</span><span class="cx"> WebViewTest::add("WebKitWebView", "settings", testWebViewSettings);
</span><del>- 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);
</del><span class="cx"> WebViewTest::add("WebKitWebView", "zoom-level", testWebViewZoomLevel);
</span><span class="cx"> WebViewTest::add("WebKitWebView", "run-javascript", testWebViewRunJavaScript);
</span><del>- FileChooserTest::add("WebKitWebView", "file-chooser-request", testWebViewFileChooserRequest);
</del><span class="cx"> FullScreenClientTest::add("WebKitWebView", "fullscreen", testWebViewFullScreen);
</span><span class="cx"> WebViewTest::add("WebKitWebView", "can-show-mime-type", testWebViewCanShowMIMEType);
</span><span class="cx"> FormClientTest::add("WebKitWebView", "submit-form", testWebViewSubmitForm);
</span><span class="lines">@@ -1498,18 +601,8 @@
</span><span class="cx"> WebViewTest::add("WebKitWebView", "view-mode", testWebViewMode);
</span><span class="cx"> SnapshotWebViewTest::add("WebKitWebView", "snapshot", testWebViewSnapshot);
</span><span class="cx"> WebViewTest::add("WebKitWebView", "page-visibility", testWebViewPageVisibility);
</span><del>- 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);
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void afterAll()
</span><span class="cx"> {
</span><del>- delete kServer;
</del><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (161137 => 161138)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2013-12-30 06:31:41 UTC (rev 161137)
+++ trunk/Tools/ChangeLog        2013-12-30 09:58:14 UTC (rev 161138)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+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):
+
</ins><span class="cx"> 2013-12-29 Michał Pakuła vel Rutka <m.pakula@samsung.com>
</span><span class="cx">
</span><span class="cx"> [EFL][WK2] Disable geolocation API test
</span></span></pre></div>
<a id="trunkToolsScriptsrungtktests"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/run-gtk-tests (161137 => 161138)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/run-gtk-tests        2013-12-30 06:31:41 UTC (rev 161137)
+++ trunk/Tools/Scripts/run-gtk-tests        2013-12-30 09:58:14 UTC (rev 161138)
</span><span class="lines">@@ -67,7 +67,8 @@
</span><span class="cx"> SkippedTest("unittests/testwebresource", "/webkit/webresource/sub_resource_loading", "Test fails in GTK Linux 64-bit Release bot", 82330),
</span><span class="cx"> SkippedTest("unittests/testwebview", "/webkit/webview/icon-uri", "Test times out in GTK Linux 64-bit Release bot", 82328),
</span><span class="cx"> SkippedTest("WebKit2APITests/TestResources", "/webkit2/WebKitWebView/resources", "Test is flaky in GTK Linux 32-bit Release bot", 82868),
</span><del>- SkippedTest("WebKit2APITests/TestWebKitWebView", SkippedTest.ENTIRE_SUITE, "Test times out after r150890", 117689),
</del><ins>+ 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),
</ins><span class="cx"> SkippedTest("WebKit2APITests/TestContextMenu", SkippedTest.ENTIRE_SUITE, "Test times out after r150890", 117689),
</span><span class="cx"> SkippedTest("TestWebKitAPI/TestWebKit2", "WebKit2.MouseMoveAfterCrash", "Test is flaky", 85066),
</span><span class="cx"> SkippedTest("TestWebKitAPI/TestWebKit2", "WebKit2.NewFirstVisuallyNonEmptyLayoutForImages", "Test is flaky", 85066),
</span></span></pre>
</div>
</div>
</body>
</html>