Title: [123372] trunk/Source/WebKit2
Revision
123372
Author
[email protected]
Date
2012-07-23 13:26:00 -0700 (Mon, 23 Jul 2012)

Log Message

[EFL][WK2] Add unit tests for Ewk_Cookie_Manager
https://bugs.webkit.org/show_bug.cgi?id=91639

Patch by Christophe Dumez <[email protected]> on 2012-07-23
Reviewed by Antonio Gomes.

Add unit tests for Ewk_Cookie_Manager.

* PlatformEfl.cmake:
* UIProcess/API/efl/ewk_cookie_manager.h: Fix "accept policy" documentation
to indicate that only cookies set by the main document are accepted by default.
* UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.cpp: Added.
(EWK2UnitTestServer::EWK2UnitTestServer): Add HTTP server similar to the one
used by GTK port unit tests.
(EWK2UnitTestServer::~EWK2UnitTestServer):
(EWK2UnitTestServer::run):
(EWK2UnitTestServer::getURIForPath):
* UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.h: Added.
(EWK2UnitTestServer):
(EWK2UnitTestServer::baseURI):
* UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp: Added.
(serverCallback):
(getAcceptPolicyCallback):
(getAcceptPolicy):
(getHostnamesWithCookiesCallback):
(getHostnamesWithCookies):
(freeHostNames):
(countHostnamesWithCookies):
(TEST_F):
(cleanUpCookieFiles):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (123371 => 123372)


--- trunk/Source/WebKit2/ChangeLog	2012-07-23 20:23:47 UTC (rev 123371)
+++ trunk/Source/WebKit2/ChangeLog	2012-07-23 20:26:00 UTC (rev 123372)
@@ -1,3 +1,35 @@
+2012-07-23  Christophe Dumez  <[email protected]>
+
+        [EFL][WK2] Add unit tests for Ewk_Cookie_Manager
+        https://bugs.webkit.org/show_bug.cgi?id=91639
+
+        Reviewed by Antonio Gomes.
+
+        Add unit tests for Ewk_Cookie_Manager.
+
+        * PlatformEfl.cmake:
+        * UIProcess/API/efl/ewk_cookie_manager.h: Fix "accept policy" documentation
+        to indicate that only cookies set by the main document are accepted by default.
+        * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.cpp: Added.
+        (EWK2UnitTestServer::EWK2UnitTestServer): Add HTTP server similar to the one
+        used by GTK port unit tests.
+        (EWK2UnitTestServer::~EWK2UnitTestServer):
+        (EWK2UnitTestServer::run):
+        (EWK2UnitTestServer::getURIForPath):
+        * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.h: Added.
+        (EWK2UnitTestServer):
+        (EWK2UnitTestServer::baseURI):
+        * UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp: Added.
+        (serverCallback):
+        (getAcceptPolicyCallback):
+        (getAcceptPolicy):
+        (getHostnamesWithCookiesCallback):
+        (getHostnamesWithCookies):
+        (freeHostNames):
+        (countHostnamesWithCookies):
+        (TEST_F):
+        (cleanUpCookieFiles):
+
 2012-07-23  Pierre Rossi  <[email protected]>
 
         [Qt] Enable touch slider when touch events are enabled

Modified: trunk/Source/WebKit2/PlatformEfl.cmake (123371 => 123372)


--- trunk/Source/WebKit2/PlatformEfl.cmake	2012-07-23 20:23:47 UTC (rev 123371)
+++ trunk/Source/WebKit2/PlatformEfl.cmake	2012-07-23 20:26:00 UTC (rev 123372)
@@ -1,4 +1,5 @@
 LIST(APPEND WebKit2_LINK_FLAGS
+    ${CAIRO_LDFLAGS}
     ${ECORE_X_LDFLAGS}
     ${EDJE_LDFLAGS}
     ${EFLDEPS_LDFLAGS}
@@ -198,9 +199,11 @@
     ${_javascript_Core_LIBRARY_NAME}
     ${WebCore_LIBRARY_NAME}
     ${WebKit2_LIBRARY_NAME}
+    ${CAIRO_LIBRARIES}
     ${ECORE_LIBRARIES}
     ${ECORE_EVAS_LIBRARIES}
     ${EVAS_LIBRARIES}
+    ${LIBSOUP24_LIBRARIES}
     gtest
 )
 
@@ -226,6 +229,7 @@
     ${WEBKIT2_EFL_TEST_DIR}/UnitTestUtils/EWK2UnitTestBase.cpp
     ${WEBKIT2_EFL_TEST_DIR}/UnitTestUtils/EWK2UnitTestEnvironment.cpp
     ${WEBKIT2_EFL_TEST_DIR}/UnitTestUtils/EWK2UnitTestMain.cpp
+    ${WEBKIT2_EFL_TEST_DIR}/UnitTestUtils/EWK2UnitTestServer.cpp
 )
 
 TARGET_LINK_LIBRARIES(ewk2UnitTestUtils ${EWK2UnitTests_LIBRARIES})
@@ -233,6 +237,7 @@
 # The "ewk" on the test name needs to be suffixed with "2", otherwise it
 # will clash with tests from the WebKit 1 test suite.
 SET(EWK2UnitTests_BINARIES
+    test_ewk2_cookie_manager
     test_ewk2_view
 )
 

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.h (123371 => 123372)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.h	2012-07-23 20:23:47 UTC (rev 123371)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.h	2012-07-23 20:26:00 UTC (rev 123372)
@@ -51,7 +51,7 @@
     EWK_COOKIE_ACCEPT_POLICY_ALWAYS,
     /// Rejects all cookies.
     EWK_COOKIE_ACCEPT_POLICY_NEVER,
-    /// Accepts cookies only from the main page.
+    /// Accepts only cookies set by the main document loaded.
     EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY
 };
 
@@ -107,7 +107,7 @@
 /**
  * Set @a policy as the cookie acceptance policy for @a manager.
  *
- * By default, cookies are always accepted.
+ * By default, only cookies set by the main document loaded are accepted.
  *
  * @param manager The cookie manager to update.
  * @param policy a #Ewk_Cookie_Accept_Policy
@@ -118,7 +118,7 @@
 /**
  * Asynchronously get the cookie acceptance policy of @a manager.
  *
- * By default, cookies are always accepted.
+ * By default, only cookies set by the main document loaded are accepted.
  *
  * @param manager The cookie manager to query.
  * @param callback The function to call when the policy is received or an error occured.

Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp (123371 => 123372)


--- trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp	2012-07-23 20:23:47 UTC (rev 123371)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp	2012-07-23 20:26:00 UTC (rev 123372)
@@ -23,6 +23,7 @@
 #include "EWK2UnitTestEnvironment.h"
 #include <EWebKit2.h>
 #include <Ecore.h>
+#include <glib-object.h>
 #include <wtf/UnusedParam.h>
 
 extern EWK2UnitTest::EWK2UnitTestEnvironment* environment;
@@ -48,6 +49,11 @@
 {
     ASSERT_GT(ecore_evas_init(), 0);
 
+    // glib support (for libsoup).
+    g_type_init();
+    if (!ecore_main_loop_glib_integrate())
+        fprintf(stderr, "WARNING: Glib main loop integration is not working. Some tests may fail.");
+
     unsigned int width = environment->defaultWidth();
     unsigned int height = environment->defaultHeight();
 

Added: trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.cpp (0 => 123372)


--- trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.cpp	2012-07-23 20:26:00 UTC (rev 123372)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ * Copyright (C) 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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 "EWK2UnitTestServer.h"
+
+EWK2UnitTestServer::EWK2UnitTestServer()
+{
+    SoupAddress* address = soup_address_new("127.0.0.1", SOUP_ADDRESS_ANY_PORT);
+    soup_address_resolve_sync(address, 0);
+
+    m_soupServer = soup_server_new(SOUP_SERVER_INTERFACE, address, 0);
+    m_baseURI = soup_uri_new("http://127.0.0.1/");
+    soup_uri_set_port(m_baseURI, soup_server_get_port(m_soupServer));
+    g_object_unref(address);
+}
+
+EWK2UnitTestServer::~EWK2UnitTestServer()
+{
+    soup_uri_free(m_baseURI);
+    g_object_unref(m_soupServer);
+}
+
+void EWK2UnitTestServer::run(SoupServerCallback serverCallback)
+{
+    soup_server_run_async(m_soupServer);
+    soup_server_add_handler(m_soupServer, 0, serverCallback, 0, 0);
+}
+
+CString EWK2UnitTestServer::getURIForPath(const char* path) const
+{
+    SoupURI* soupURI = soup_uri_new_with_base(m_baseURI, path);
+    char* uri = soup_uri_to_string(soupURI, false);
+    CString uriString = uri;
+    free(uri);
+    soup_uri_free(soupURI);
+
+    return uriString;
+}

Added: trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.h (0 => 123372)


--- trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.h	2012-07-23 20:26:00 UTC (rev 123372)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ * Copyright (C) 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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.
+ */
+
+#ifndef EWK2UnitTestServer_h
+#define EWK2UnitTestServer_h
+
+#include <libsoup/soup.h>
+#include <wtf/text/CString.h>
+
+class EWK2UnitTestServer {
+public:
+    EWK2UnitTestServer();
+    virtual ~EWK2UnitTestServer();
+
+    SoupURI* baseURI() const { return m_baseURI; }
+
+    CString getURIForPath(const char* path) const;
+    void run(SoupServerCallback);
+
+private:
+    SoupServer* m_soupServer;
+    SoupURI* m_baseURI;
+};
+
+#endif // EWK2UnitTestServer_h
+

Added: trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp (0 => 123372)


--- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp	2012-07-23 20:26:00 UTC (rev 123372)
@@ -0,0 +1,239 @@
+/*
+ * Copyright (C) 2012 Igalia S.L.
+ * Copyright (C) 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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 "UnitTestUtils/EWK2UnitTestBase.h"
+#include "UnitTestUtils/EWK2UnitTestEnvironment.h"
+#include "UnitTestUtils/EWK2UnitTestServer.h"
+#include <EWebKit2.h>
+#include <Ecore.h>
+#include <Eina.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+
+using namespace EWK2UnitTest;
+using namespace WTF;
+
+extern EWK2UnitTestEnvironment* environment;
+
+static const char FIRST_PARTY_DOMAIN[] = "127.0.0.1";
+static const char THIRD_PARTY_DOMAIN[] = "localhost";
+static const char INDEX_HTML_STRING[] =
+    "<html><body>"
+    " <p>EFLWebKit2 Cookie Manager test</p>"
+    " <img src='' width=5 height=5></img>"
+    "</body></html>";
+
+static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
+{
+    if (message->method != SOUP_METHOD_GET) {
+        soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
+        return;
+    }
+
+    soup_message_set_status(message, SOUP_STATUS_OK);
+    if (!strcmp(path, "/index.html")) {
+        Eina_Strbuf* buffer = eina_strbuf_new();
+        eina_strbuf_append_printf(buffer, INDEX_HTML_STRING, soup_server_get_port(server));
+        soup_message_headers_replace(message->response_headers, "Set-Cookie", "foo=bar; Max-Age=60");
+        soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, eina_strbuf_string_steal(buffer), eina_strbuf_length_get(buffer));
+        eina_strbuf_string_free(buffer);
+    } else if (!strcmp(path, "/image.png"))
+        soup_message_headers_replace(message->response_headers, "Set-Cookie", "baz=qux; Max-Age=60");
+    else
+        FAIL();
+    soup_message_body_complete(message->response_body);
+}
+
+static void getAcceptPolicyCallback(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error* error, void* event_info)
+{
+    ASSERT_FALSE(error);
+    Ewk_Cookie_Accept_Policy* ret = static_cast<Ewk_Cookie_Accept_Policy*>(event_info);
+    *ret = policy;
+    ecore_main_loop_quit();
+}
+
+static Ewk_Cookie_Accept_Policy getAcceptPolicy(Ewk_Cookie_Manager* manager)
+{
+    Ewk_Cookie_Accept_Policy policy = EWK_COOKIE_ACCEPT_POLICY_ALWAYS;
+    ewk_cookie_manager_async_accept_policy_get(manager, getAcceptPolicyCallback, &policy);
+    ecore_main_loop_begin();
+    return policy;
+}
+
+static void getHostnamesWithCookiesCallback(Eina_List* hostnames, Ewk_Web_Error* error, void* event_info)
+{
+    ASSERT_FALSE(error);
+
+    Eina_List** ret = static_cast<Eina_List**>(event_info);
+    Eina_List* l;
+    void* data;
+    EINA_LIST_FOREACH(hostnames, l, data)
+        *ret = eina_list_append(*ret, eina_stringshare_ref(static_cast<char*>(data)));
+    ecore_main_loop_quit();
+}
+
+static Eina_List* getHostnamesWithCookies(Ewk_Cookie_Manager* manager)
+{
+    Eina_List* ret = 0;
+    ewk_cookie_manager_async_hostnames_with_cookies_get(manager, getHostnamesWithCookiesCallback, &ret);
+    ecore_main_loop_begin();
+    return ret;
+}
+
+static void freeHostNames(Eina_List* hostnames)
+{
+    void* data;
+    EINA_LIST_FREE(hostnames, data)
+        eina_stringshare_del(static_cast<char*>(data));
+}
+
+static int countHostnamesWithCookies(Ewk_Cookie_Manager* manager)
+{
+    Eina_List* hostnames = getHostnamesWithCookies(manager);
+    int count = eina_list_count(hostnames);
+    freeHostNames(hostnames);
+    return count;
+}
+
+TEST_F(EWK2UnitTestBase, ewk_cookie_manager_accept_policy)
+{
+    OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer);
+    httpServer->run(serverCallback);
+
+    Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_context_default_get());
+    ASSERT_TRUE(cookieManager);
+
+    // Default policy is EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY.
+    ASSERT_EQ(getAcceptPolicy(cookieManager), EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY);
+    loadUrlSync(httpServer->getURIForPath("/index.html").data());
+
+    Eina_List* hostnames = getHostnamesWithCookies(cookieManager);
+    ASSERT_EQ(eina_list_count(hostnames), 1);
+    ASSERT_STREQ(static_cast<char*>(eina_list_nth(hostnames, 0)), FIRST_PARTY_DOMAIN);
+    freeHostNames(hostnames);
+    ewk_cookie_manager_cookies_clear(cookieManager);
+
+    // Change policy to EWK_COOKIE_ACCEPT_POLICY_ALWAYS
+    ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
+    ASSERT_EQ(getAcceptPolicy(cookieManager), EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
+    loadUrlSync(httpServer->getURIForPath("/index.html").data());
+
+    hostnames = getHostnamesWithCookies(cookieManager);
+    ASSERT_EQ(eina_list_count(hostnames), 2);
+    ASSERT_STREQ(static_cast<char*>(eina_list_nth(hostnames, 0)), FIRST_PARTY_DOMAIN);
+    ASSERT_STREQ(static_cast<char*>(eina_list_nth(hostnames, 1)), THIRD_PARTY_DOMAIN);
+    freeHostNames(hostnames);
+    ewk_cookie_manager_cookies_clear(cookieManager);
+
+    // Change policy to EWK_COOKIE_ACCEPT_POLICY_NEVER
+    ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
+    ASSERT_EQ(getAcceptPolicy(cookieManager), EWK_COOKIE_ACCEPT_POLICY_NEVER);
+    loadUrlSync(httpServer->getURIForPath("/index.html").data());
+    ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0);
+}
+
+TEST_F(EWK2UnitTestBase, ewk_cookie_manager_cookies_delete)
+{
+    OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer);
+    httpServer->run(serverCallback);
+
+    Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_context_default_get());
+    ASSERT_TRUE(cookieManager);
+
+    ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
+    ASSERT_EQ(getAcceptPolicy(cookieManager), EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
+
+    loadUrlSync(httpServer->getURIForPath("/index.html").data());
+    Eina_List* hostnames = getHostnamesWithCookies(cookieManager);
+    ASSERT_EQ(eina_list_count(hostnames), 2);
+    freeHostNames(hostnames);
+
+    // Delete first party cookie
+    ewk_cookie_manager_hostname_cookies_clear(cookieManager, FIRST_PARTY_DOMAIN);
+    hostnames = getHostnamesWithCookies(cookieManager);
+    ASSERT_EQ(eina_list_count(hostnames), 1);
+    ASSERT_STREQ(static_cast<char*>(eina_list_nth(hostnames, 0)), THIRD_PARTY_DOMAIN);
+    freeHostNames(hostnames);
+
+    // Delete third party cookie
+    ewk_cookie_manager_hostname_cookies_clear(cookieManager, THIRD_PARTY_DOMAIN);
+    ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0);
+
+    // Get all cookies again
+    loadUrlSync(httpServer->getURIForPath("/index.html").data());
+    ASSERT_EQ(countHostnamesWithCookies(cookieManager), 2);
+
+    // Clear all cookies
+    ewk_cookie_manager_cookies_clear(cookieManager);
+    ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0);
+}
+
+TEST_F(EWK2UnitTestBase, ewk_cookie_manager_permanent_storage)
+{
+    OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer);
+    httpServer->run(serverCallback);
+
+    // Generate unique names for cookie storages.
+    char textStorage[] = "/tmp/txt-cookie.XXXXXX";
+    ASSERT_TRUE(mktemp(textStorage));
+    char sqliteStorage[] = "/tmp/sqlite-cookie.XXXXXX";
+    ASSERT_TRUE(mktemp(sqliteStorage));
+
+    Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_context_default_get());
+    ASSERT_TRUE(cookieManager);
+
+    ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
+    ASSERT_EQ(getAcceptPolicy(cookieManager), EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
+
+    // Text storage using a new file.
+    ewk_cookie_manager_persistent_storage_set(cookieManager, textStorage, EWK_COOKIE_PERSISTENT_STORAGE_TEXT);
+    ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0);
+
+    loadUrlSync(httpServer->getURIForPath("/index.html").data());
+    ASSERT_EQ(countHostnamesWithCookies(cookieManager), 2);
+
+    // SQLite storage using a new file.
+    ewk_cookie_manager_persistent_storage_set(cookieManager, sqliteStorage, EWK_COOKIE_PERSISTENT_STORAGE_SQLITE);
+    ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0);
+
+    loadUrlSync(httpServer->getURIForPath("/index.html").data());
+    ASSERT_EQ(countHostnamesWithCookies(cookieManager), 2);
+
+    // Text storage using an existing file.
+    ewk_cookie_manager_persistent_storage_set(cookieManager, textStorage, EWK_COOKIE_PERSISTENT_STORAGE_TEXT);
+    ASSERT_EQ(countHostnamesWithCookies(cookieManager), 2);
+    ewk_cookie_manager_cookies_clear(cookieManager);
+    ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0);
+
+    // SQLite storage with an existing file.
+    ewk_cookie_manager_persistent_storage_set(cookieManager, sqliteStorage, EWK_COOKIE_PERSISTENT_STORAGE_SQLITE);
+    ASSERT_EQ(countHostnamesWithCookies(cookieManager), 2);
+    ewk_cookie_manager_cookies_clear(cookieManager);
+    ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0);
+
+    // Final clean up.
+    unlink(textStorage);
+    unlink(sqliteStorage);
+}
+
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to