[Curl][WinCairo] Add Public Suffix support to WinCairo
authorchris.reid@sony.com <chris.reid@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Oct 2018 16:33:56 +0000 (16:33 +0000)
committerchris.reid@sony.com <chris.reid@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Oct 2018 16:33:56 +0000 (16:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=183060

Reviewed by Alex Christensen.

.:

* Source/cmake/FindLibPSL.cmake: Added.
* Source/cmake/OptionsWin.cmake:
* Source/cmake/OptionsWinCairo.cmake:

Source/WebCore:

Add Public Suffix support to WinCairo using LibPSL.
LibPSL has been added to WinCairoRequirements in v2018.10.09.

* platform/Curl.cmake:
* platform/network/curl/CookieJarDB.cpp:
(WebCore::CookieJarDB::searchCookies): Search for cookies using the topPrivatelyControlledDomain
(WebCore::CookieJarDB::setCookie): Prevent cookies from being added under TLDs
* platform/network/curl/PublicSuffixCurl.cpp: Added.
(WebCore::isPublicSuffix):
(WebCore::topPrivatelyControlledDomainInternal):
(WebCore::topPrivatelyControlledDomain):

Tools:

Share mac's PublicSuffix tests with all ports.

* TestWebKitAPI/PlatformWin.cmake:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebCore/PublicSuffix.cpp:
* TestWebKitAPI/Tests/mac/PublicSuffix.mm: Removed.

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

13 files changed:
ChangeLog
Source/WebCore/ChangeLog
Source/WebCore/platform/Curl.cmake
Source/WebCore/platform/network/curl/CookieJarDB.cpp
Source/WebCore/platform/network/curl/PublicSuffixCurl.cpp [new file with mode: 0644]
Source/cmake/FindLibPSL.cmake [new file with mode: 0644]
Source/cmake/OptionsWin.cmake
Source/cmake/OptionsWinCairo.cmake
Tools/ChangeLog
Tools/TestWebKitAPI/PlatformWin.cmake
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebCore/PublicSuffix.cpp
Tools/TestWebKitAPI/Tests/mac/PublicSuffix.mm [deleted file]

index 2d02dbe..386f62c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2018-10-15  Christopher Reid  <chris.reid@sony.com>
+
+        [Curl][WinCairo] Add Public Suffix support to WinCairo
+        https://bugs.webkit.org/show_bug.cgi?id=183060
+
+        Reviewed by Alex Christensen.
+
+        * Source/cmake/FindLibPSL.cmake: Added.
+        * Source/cmake/OptionsWin.cmake:
+        * Source/cmake/OptionsWinCairo.cmake:
+
 2018-10-15  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         Add new files missing from previous commit.
index c5cd281..3ba98e6 100644 (file)
@@ -1,3 +1,22 @@
+2018-10-15  Christopher Reid  <chris.reid@sony.com>
+
+        [Curl][WinCairo] Add Public Suffix support to WinCairo
+        https://bugs.webkit.org/show_bug.cgi?id=183060
+
+        Reviewed by Alex Christensen.
+
+        Add Public Suffix support to WinCairo using LibPSL.
+        LibPSL has been added to WinCairoRequirements in v2018.10.09.
+
+        * platform/Curl.cmake:
+        * platform/network/curl/CookieJarDB.cpp:
+        (WebCore::CookieJarDB::searchCookies): Search for cookies using the topPrivatelyControlledDomain
+        (WebCore::CookieJarDB::setCookie): Prevent cookies from being added under TLDs
+        * platform/network/curl/PublicSuffixCurl.cpp: Added.
+        (WebCore::isPublicSuffix):
+        (WebCore::topPrivatelyControlledDomainInternal):
+        (WebCore::topPrivatelyControlledDomain):
+
 2018-10-15  Simon Fraser  <simon.fraser@apple.com>
 
         RenderLayer tree-related cleanup
index 1603ef8..1cd8d9d 100644 (file)
@@ -25,6 +25,7 @@ list(APPEND WebCore_SOURCES
     platform/network/curl/DNSResolveQueueCurl.cpp
     platform/network/curl/NetworkStorageSessionCurl.cpp
     platform/network/curl/ProxyServerCurl.cpp
+    platform/network/curl/PublicSuffixCurl.cpp
     platform/network/curl/ResourceErrorCurl.cpp
     platform/network/curl/ResourceHandleCurl.cpp
     platform/network/curl/ResourceResponseCurl.cpp
@@ -34,10 +35,12 @@ list(APPEND WebCore_SOURCES
 
 list(APPEND WebCore_SYSTEM_INCLUDE_DIRECTORIES
     ${CURL_INCLUDE_DIRS}
+    ${LIBPSL_INCLUDE_DIR}
     ${OPENSSL_INCLUDE_DIR}
 )
 
 list(APPEND WebCore_LIBRARIES
     ${CURL_LIBRARIES}
+    ${LIBPSL_LIBRARIES}
     ${OPENSSL_LIBRARIES}
 )
index 650038d..42049ed 100644 (file)
 
 #include <wtf/MonotonicTime.h>
 
+#if ENABLE(PUBLIC_SUFFIX_LIST)
+#include "PublicSuffix.h"
+#endif
+
 namespace WebCore {
 
 #define CORRUPT_MARKER_SUFFIX "-corrupted"
@@ -334,28 +338,35 @@ bool CookieJarDB::searchCookies(const String& requestUrl, const std::optional<bo
         "AND ((domain = ?) OR (domain GLOB ?)) "\
         "ORDER BY length(path) DESC, lastupdated";
 
-    std::unique_ptr<SQLiteStatement> pstmt = std::make_unique<SQLiteStatement>(m_database, sql);
+    auto pstmt = std::make_unique<SQLiteStatement>(m_database, sql);
+    if (!pstmt)
+        return false;
+
     pstmt->prepare();
     pstmt->bindInt(1, httpOnly ? *httpOnly : -1);
     pstmt->bindInt(2, secure ? *secure : -1);
     pstmt->bindInt(3, session ? *session : -1);
     pstmt->bindText(4, requestHost);
 
-    size_t topLevelSeparator = requestHost.reverseFind('.');
-    if (CookieUtil::isIPAddress(requestHost) || topLevelSeparator == notFound)
+    if (CookieUtil::isIPAddress(requestHost) || !requestHost.contains('.'))
         pstmt->bindNull(5);
     else {
-        /* FIXME: currently we currently do not have a public suffic list in wincairo
-           so right now we glob using just the second level domain e.g. *.DOMAIN.com
-           This will return too many cookies under multilevel tlds such as *.co.uk
-           but we filter those out later
-        */
-
+#if ENABLE(PUBLIC_SUFFIX_LIST)
+        String topPrivateDomain = topPrivatelyControlledDomain(requestHost);
+        if (!topPrivateDomain.isEmpty())
+            pstmt->bindText(5, String("*.") + topPrivateDomain);
+        else
+            pstmt->bindNull(5);
+#else
+        // Fallback to glob for cookies under the second level domain e.g. *.domain.com
+        // This will return too many cookies under multilevel tlds such as *.co.uk, but they will get filtered out later.
+        size_t topLevelSeparator = requestHost.reverseFind('.');
         size_t secondLevelSeparator = requestHost.reverseFind('.', topLevelSeparator-1);
         String localDomain = secondLevelSeparator == notFound ? requestHost : requestHost.substring(secondLevelSeparator+1);
 
         ASSERT(!localDomain.isEmpty());
         pstmt->bindText(5, String("*.") + localDomain);
+#endif
     }
 
     if (!pstmt)
@@ -468,7 +479,10 @@ int CookieJarDB::setCookie(const String& url, const String& cookie, bool fromJav
     if (cookieObj.path.isEmpty())
         cookieObj.path = CookieUtil::defaultPathForURL(urlObj);
 
-    // FIXME: Need to check that a domain doesn't a set cookie for a tld when wincairo supports PSL
+#if ENABLE(PUBLIC_SUFFIX_LIST)
+    if (isPublicSuffix(cookieObj.domain))
+        return -1;
+#endif
 
     if (fromJavaScript && cookieObj.httpOnly)
         return -1;
diff --git a/Source/WebCore/platform/network/curl/PublicSuffixCurl.cpp b/Source/WebCore/platform/network/curl/PublicSuffixCurl.cpp
new file mode 100644 (file)
index 0000000..5e8d5c8
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2018 Sony Interactive Entertainment Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PublicSuffix.h"
+
+#if ENABLE(PUBLIC_SUFFIX_LIST)
+
+#include "URL.h"
+#include <libpsl.h>
+
+namespace WebCore {
+
+bool isPublicSuffix(const String& domain)
+{
+    if (domain.isEmpty())
+        return false;
+
+    const psl_ctx_t* psl = psl_builtin();
+    ASSERT(psl);
+    bool ret = psl_is_public_suffix2(psl, domain.convertToLowercaseWithoutLocale().utf8().data(), PSL_TYPE_ANY | PSL_TYPE_NO_STAR_RULE);
+    return ret;
+}
+
+static String topPrivatelyControlledDomainInternal(const psl_ctx_t* psl, const char* domain)
+{
+    // psl_registerable_domain returns a pointer to domain's data or null if there is no private domain
+    if (const char* topPrivateDomain = psl_registrable_domain(psl, domain))
+        return topPrivateDomain;
+    return String();
+}
+
+String topPrivatelyControlledDomain(const String& domain)
+{
+    if (URL::hostIsIPAddress(domain) || !domain.isAllASCII())
+        return domain;
+
+    String lowercaseDomain = domain.convertToASCIILowercase();
+    if (lowercaseDomain == "localhost")
+        return lowercaseDomain;
+
+    if (isPublicSuffix(lowercaseDomain))
+        return String();
+
+    const psl_ctx_t* psl = psl_builtin();
+    ASSERT(psl);
+    return topPrivatelyControlledDomainInternal(psl, lowercaseDomain.utf8().data());
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(PUBLIC_SUFFIX_LIST)
diff --git a/Source/cmake/FindLibPSL.cmake b/Source/cmake/FindLibPSL.cmake
new file mode 100644 (file)
index 0000000..cf4b3fa
--- /dev/null
@@ -0,0 +1,67 @@
+# - Try to find LibPSL
+# This module defines the following variables:
+#
+#  LIBPSL_FOUND - LibPSL was found
+#  LIBPSL_INCLUDE_DIRS - the LibPSL include directories
+#  LIBPSL_LIBRARIES - link these to use LibPSL
+#
+# Copyright (C) 2018 Sony Interactive Entertainment Inc.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
+# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+find_path(LIBPSL_INCLUDE_DIRS
+    NAMES libpsl.h
+    PATH_SUFFIXES libpsl
+)
+
+find_library(LIBPSL_LIBRARIES
+    NAMES psl
+)
+
+if (LIBPSL_INCLUDE_DIRS)
+    if (EXISTS "${LIBPSL_INCLUDE_DIRS}/libpsl.h")
+        file(READ "${LIBPSL_INCLUDE_DIRS}/libpsl.h" LIBPSL_VERSION_CONTENT)
+
+        string(REGEX MATCH "#define +PSL_VERSION_MAJOR +([0-9]+)" _dummy "${LIBPSL_VERSION_CONTENT}")
+        set(LIBPSL_VERSION_MAJOR "${CMAKE_MATCH_1}")
+
+        string(REGEX MATCH "#define +PSL_VERSION_MINOR +([0-9]+)" _dummy "${LIBPSL_VERSION_CONTENT}")
+        set(LIBPSL_VERSION_MINOR "${CMAKE_MATCH_1}")
+
+        string(REGEX MATCH "#define +PSL_VERSION_PATCH +([0-9]+)" _dummy "${LIBPSL_VERSION_CONTENT}")
+        set(LIBPSL_VERSION_PATCH "${CMAKE_MATCH_1}")
+
+        set(LIBPSL_VERSION "${LIBPSL_VERSION_MAJOR}.${LIBPSL_VERSION_MINOR}.${LIBPSL_VERSION_PATCH}")
+    endif ()
+endif ()
+
+if ("${LibPSL_FIND_VERSION}" VERSION_GREATER "${LIBPSL_VERSION}")
+    message(FATAL_ERROR "Required version (" ${LibPSL_FIND_VERSION} ") is higher than found version (" ${LIBPSL_VERSION} ")")
+endif ()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(LIBPSL REQUIRED_VARS LIBPSL_INCLUDE_DIRS LIBPSL_LIBRARIES)
+
+mark_as_advanced(
+    LIBPSL_INCLUDE_DIRS
+    LIBPSL_LIBRARIES
+)
index 38292f3..f22f3f1 100644 (file)
@@ -67,7 +67,6 @@ WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_AUDIO PUBLIC OFF)
 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBVTT_REGIONS PUBLIC ON)
 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_XSLT PUBLIC ON)
 
-WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_PUBLIC_SUFFIX_LIST PRIVATE OFF)
 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_REMOTE_INSPECTOR PRIVATE OFF)
 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SMOOTH_SCROLLING PRIVATE OFF)
 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SUBTLE_CRYPTO PRIVATE OFF)
@@ -83,6 +82,7 @@ if (${WTF_PLATFORM_WIN_CAIRO})
     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_LEGACY_CUSTOM_PROTOCOL_MANAGER PUBLIC OFF)
     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_LEGACY_ENCRYPTED_MEDIA PUBLIC OFF)
     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INTL PUBLIC ON)
+    WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_PUBLIC_SUFFIX_LIST PRIVATE ON)
     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBGL PUBLIC ON)
 
     # FIXME: Implement plugin process on Modern WebKit. https://bugs.webkit.org/show_bug.cgi?id=185313
@@ -90,6 +90,7 @@ if (${WTF_PLATFORM_WIN_CAIRO})
 else ()
     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_LEGACY_ENCRYPTED_MEDIA PUBLIC ON)
     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INTL PUBLIC OFF)
+    WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_PUBLIC_SUFFIX_LIST PRIVATE OFF)
     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBGL PUBLIC OFF)
 endif ()
 
index fa618f7..4ad2c4b 100644 (file)
@@ -10,6 +10,7 @@ find_package(OpenSSL 2.0.0 REQUIRED)
 find_package(PNG 1.6.34 REQUIRED)
 find_package(Sqlite 3.23.1 REQUIRED)
 find_package(ZLIB 1.2.11 REQUIRED)
+find_package(LibPSL 0.20.2 REQUIRED)
 
 find_package(WebP 1.0.0)
 
index b8ad5ec..6d62216 100644 (file)
@@ -1,3 +1,17 @@
+2018-10-15  Christopher Reid  <chris.reid@sony.com>
+
+        [Curl][WinCairo] Add Public Suffix support to WinCairo
+        https://bugs.webkit.org/show_bug.cgi?id=183060
+
+        Reviewed by Alex Christensen.
+
+        Share mac's PublicSuffix tests with all ports.
+
+        * TestWebKitAPI/PlatformWin.cmake:
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebCore/PublicSuffix.cpp:
+        * TestWebKitAPI/Tests/mac/PublicSuffix.mm: Removed.
+
 2018-10-15  Myles C. Maxfield  <mmaxfield@apple.com>
 
         [WHLSL] Migrated WebGPUShadingLanguageRI to the W3C
index 0e415a1..f13b82e 100644 (file)
@@ -76,6 +76,7 @@ if (${WTF_PLATFORM_WIN_CAIRO})
     list(APPEND TestWebCoreLib_SOURCES
         ${TESTWEBKITAPI_DIR}/Tests/WebCore/win/BitmapImage.cpp
         ${TESTWEBKITAPI_DIR}/Tests/WebCore/CryptoDigest.cpp
+        ${TESTWEBKITAPI_DIR}/Tests/WebCore/PublicSuffix.cpp
     )
 else ()
     list(APPEND test_webcore_LIBRARIES
index a44232f..4982f4f 100644 (file)
@@ -22,6 +22,7 @@
 /* End PBXAggregateTarget section */
 
 /* Begin PBXBuildFile section */
+               041A1E34216FFDBC00789E0A /* PublicSuffix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 041A1E33216FFDBC00789E0A /* PublicSuffix.cpp */; };
                07492B3B1DF8B14C00633DE1 /* EnumerateMediaDevices.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07492B3A1DF8AE2D00633DE1 /* EnumerateMediaDevices.cpp */; };
                07492B3C1DF8B86600633DE1 /* enumerateMediaDevices.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 07492B391DF8ADA400633DE1 /* enumerateMediaDevices.html */; };
                074994421EA5034B000DA44E /* getUserMedia.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 4A410F4D19AF7BEF002EBAB5 /* getUserMedia.html */; };
                7CCE7EC51A411A7E00447C4C /* MemoryCacheDisableWithinResourceLoadDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1220D9F155B25480013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.mm */; };
                7CCE7EC61A411A7E00447C4C /* MemoryCachePruneWithinResourceLoadDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 517E7DFB15110EA600D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.mm */; };
                7CCE7EC71A411A7E00447C4C /* PageVisibilityStateWithWindowChanges.mm in Sources */ = {isa = PBXBuildFile; fileRef = A57A34EF16AF677200C2501F /* PageVisibilityStateWithWindowChanges.mm */; };
-               7CCE7EC81A411A7E00447C4C /* PublicSuffix.mm in Sources */ = {isa = PBXBuildFile; fileRef = 00BC16851680FE810065F1E5 /* PublicSuffix.mm */; };
                7CCE7EC91A411A7E00447C4C /* RenderedImageFromDOMNode.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37C784DE197C8F2E0010A496 /* RenderedImageFromDOMNode.mm */; };
                7CCE7ECA1A411A7E00447C4C /* RenderedImageFromDOMRange.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3722C8681461E03E00C45D00 /* RenderedImageFromDOMRange.mm */; };
                7CCE7ECB1A411A7E00447C4C /* SetAndUpdateCacheModel.mm in Sources */ = {isa = PBXBuildFile; fileRef = 261516D515B0E60500A2C201 /* SetAndUpdateCacheModel.mm */; };
 /* End PBXCopyFilesBuildPhase section */
 
 /* Begin PBXFileReference section */
-               00BC16851680FE810065F1E5 /* PublicSuffix.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PublicSuffix.mm; sourceTree = "<group>"; };
                00CD9F6215BE312C002DA2CE /* BackForwardList.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BackForwardList.mm; sourceTree = "<group>"; };
+               041A1E33216FFDBC00789E0A /* PublicSuffix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PublicSuffix.cpp; sourceTree = "<group>"; };
                07492B391DF8ADA400633DE1 /* enumerateMediaDevices.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = enumerateMediaDevices.html; sourceTree = "<group>"; };
                07492B3A1DF8AE2D00633DE1 /* EnumerateMediaDevices.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EnumerateMediaDevices.cpp; sourceTree = "<group>"; };
                0766DD1F1A5AD5200023E3BB /* PendingAPIRequestURL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PendingAPIRequestURL.cpp; sourceTree = "<group>"; };
                                CE1866471F72E8F100A0CAB6 /* MarkedText.cpp */,
                                A5B149DD1F5A19DC00C6DAFF /* MIMETypeRegistry.cpp */,
                                CD225C071C45A69200140761 /* ParsedContentRange.cpp */,
+                               041A1E33216FFDBC00789E0A /* PublicSuffix.cpp */,
                                F418BE141F71B7DC001970E6 /* RoundedRectTests.cpp */,
                                CDCFA7A91E45122F00C2433D /* SampleMap.cpp */,
                                CE06DF9A1E1851F200E570C9 /* SecurityOrigin.cpp */,
                                E19DB9781B32137C00DB38D4 /* NavigatorLanguage.mm */,
                                83F22C6320B355EB0034277E /* NoPolicyDelegateResponse.mm */,
                                A57A34EF16AF677200C2501F /* PageVisibilityStateWithWindowChanges.mm */,
-                               00BC16851680FE810065F1E5 /* PublicSuffix.mm */,
                                37C784DE197C8F2E0010A496 /* RenderedImageFromDOMNode.mm */,
                                3722C8681461E03E00C45D00 /* RenderedImageFromDOMRange.mm */,
                                261516D515B0E60500A2C201 /* SetAndUpdateCacheModel.mm */,
                                41882F0321010C0D002FF288 /* ProcessPreWarming.mm in Sources */,
                                518C1153205B0504001FF4AE /* ProcessSwapOnNavigation.mm in Sources */,
                                7C83E0C11D0A652F00FEBCF3 /* ProvisionalURLNotChange.mm in Sources */,
-                               7CCE7EC81A411A7E00447C4C /* PublicSuffix.mm in Sources */,
+                               041A1E34216FFDBC00789E0A /* PublicSuffix.cpp in Sources */,
                                7C83E0C21D0A653500FEBCF3 /* QuickLook.mm in Sources */,
                                7CCE7F0D1A411AE600447C4C /* ReloadPageAfterCrash.cpp in Sources */,
                                7C83E0C31D0A653A00FEBCF3 /* RemoteObjectRegistry.mm in Sources */,
index f87ba63..6069301 100644 (file)
@@ -43,6 +43,8 @@ public:
     }
 };
 
+const char16_t bidirectionalDomain[28] = u"bidirectional\u0786\u07AE\u0782\u07B0\u0795\u07A9\u0793\u07A6\u0783\u07AA.com";
+
 TEST_F(PublicSuffix, IsPublicSuffix)
 {
     EXPECT_TRUE(isPublicSuffix("com"));
@@ -54,10 +56,107 @@ TEST_F(PublicSuffix, IsPublicSuffix)
     EXPECT_FALSE(isPublicSuffix("bl.uk"));
     EXPECT_FALSE(isPublicSuffix("test.co.uk"));
     EXPECT_TRUE(isPublicSuffix("xn--zf0ao64a.tw"));
+    EXPECT_FALSE(isPublicSuffix("r4---asdf.test.com"));
+    EXPECT_FALSE(isPublicSuffix(utf16String(bidirectionalDomain)));
+    EXPECT_TRUE(isPublicSuffix(utf16String(u"\u6803\u6728.jp")));
+    EXPECT_FALSE(isPublicSuffix(""));
+    EXPECT_FALSE(isPublicSuffix("åäö"));
+
+    // UK
+    EXPECT_TRUE(isPublicSuffix("uk"));
+    EXPECT_FALSE(isPublicSuffix("webkit.uk"));
+    EXPECT_TRUE(isPublicSuffix("co.uk"));
+    EXPECT_FALSE(isPublicSuffix("company.co.uk"));
+
+    // Note: These tests are based on the Public Domain TLD test suite
+    // https://raw.githubusercontent.com/publicsuffix/list/master/tests/test_psl.txt
+    //
+    // That file states:
+    //     Any copyright is dedicated to the Public Domain.
+    //     https://creativecommons.org/publicdomain/zero/1.0/
+
+    // null input.
+    EXPECT_FALSE(isPublicSuffix(""));
+    // Mixed case.
+    EXPECT_TRUE(isPublicSuffix("COM"));
+    EXPECT_FALSE(isPublicSuffix("example.COM"));
+    EXPECT_FALSE(isPublicSuffix("WwW.example.COM"));
+    // Unlisted TLD.
+    EXPECT_FALSE(isPublicSuffix("example"));
+    EXPECT_FALSE(isPublicSuffix("example.example"));
+    EXPECT_FALSE(isPublicSuffix("b.example.example"));
+    EXPECT_FALSE(isPublicSuffix("a.b.example.example"));
+    // TLD with only 1 rule.
+    EXPECT_TRUE(isPublicSuffix("biz"));
+    EXPECT_FALSE(isPublicSuffix("domain.biz"));
+    EXPECT_FALSE(isPublicSuffix("b.domain.biz"));
+    EXPECT_FALSE(isPublicSuffix("a.b.domain.biz"));
+    // TLD with some 2-level rules.
+    EXPECT_FALSE(isPublicSuffix("example.com"));
+    EXPECT_FALSE(isPublicSuffix("b.example.com"));
+    EXPECT_FALSE(isPublicSuffix("a.b.example.com"));
+    EXPECT_TRUE(isPublicSuffix("uk.com"));
+    EXPECT_FALSE(isPublicSuffix("example.uk.com"));
+    EXPECT_FALSE(isPublicSuffix("b.example.uk.com"));
+    EXPECT_FALSE(isPublicSuffix("a.b.example.uk.com"));
+    EXPECT_FALSE(isPublicSuffix("test.ac"));
+    // TLD with only 1 (wildcard) rule.
+    EXPECT_TRUE(isPublicSuffix("mm"));
+    EXPECT_TRUE(isPublicSuffix("c.mm"));
+    EXPECT_FALSE(isPublicSuffix("b.c.mm"));
+    EXPECT_FALSE(isPublicSuffix("a.b.c.mm"));
+    // More complex TLD.
+    EXPECT_TRUE(isPublicSuffix("jp"));
+    EXPECT_FALSE(isPublicSuffix("test.jp"));
+    EXPECT_FALSE(isPublicSuffix("www.test.jp"));
+    EXPECT_TRUE(isPublicSuffix("ac.jp"));
+    EXPECT_FALSE(isPublicSuffix("test.ac.jp"));
+    EXPECT_FALSE(isPublicSuffix("www.test.ac.jp"));
+    EXPECT_TRUE(isPublicSuffix("kyoto.jp"));
+    EXPECT_FALSE(isPublicSuffix("test.kyoto.jp"));
+    EXPECT_TRUE(isPublicSuffix("ide.kyoto.jp"));
+    EXPECT_FALSE(isPublicSuffix("b.ide.kyoto.jp"));
+    EXPECT_FALSE(isPublicSuffix("a.b.ide.kyoto.jp"));
+    EXPECT_TRUE(isPublicSuffix("c.kobe.jp"));
+    EXPECT_FALSE(isPublicSuffix("b.c.kobe.jp"));
+    EXPECT_FALSE(isPublicSuffix("a.b.c.kobe.jp"));
+    EXPECT_FALSE(isPublicSuffix("city.kobe.jp"));
+    EXPECT_FALSE(isPublicSuffix("www.city.kobe.jp"));
+    // TLD with a wildcard rule and exceptions.
+    EXPECT_TRUE(isPublicSuffix("ck"));
+    EXPECT_TRUE(isPublicSuffix("test.ck"));
+    EXPECT_FALSE(isPublicSuffix("b.test.ck"));
+    EXPECT_FALSE(isPublicSuffix("a.b.test.ck"));
+    EXPECT_FALSE(isPublicSuffix("www.ck"));
+    EXPECT_FALSE(isPublicSuffix("www.www.ck"));
+    // US K12.
+    EXPECT_TRUE(isPublicSuffix("us"));
+    EXPECT_FALSE(isPublicSuffix("test.us"));
+    EXPECT_FALSE(isPublicSuffix("www.test.us"));
+    EXPECT_TRUE(isPublicSuffix("ak.us"));
+    EXPECT_FALSE(isPublicSuffix("test.ak.us"));
+    EXPECT_FALSE(isPublicSuffix("www.test.ak.us"));
+    EXPECT_TRUE(isPublicSuffix("k12.ak.us"));
+    EXPECT_FALSE(isPublicSuffix("test.k12.ak.us"));
+    EXPECT_FALSE(isPublicSuffix("www.test.k12.ak.us"));
+    // IDN labels (punycoded)
+    EXPECT_FALSE(isPublicSuffix("xn--85x722f.com.cn"));
+    EXPECT_FALSE(isPublicSuffix("xn--85x722f.xn--55qx5d.cn"));
+    EXPECT_FALSE(isPublicSuffix("www.xn--85x722f.xn--55qx5d.cn"));
+    EXPECT_FALSE(isPublicSuffix("shishi.xn--55qx5d.cn"));
+    EXPECT_TRUE(isPublicSuffix("xn--55qx5d.cn"));
+    EXPECT_FALSE(isPublicSuffix("xn--85x722f.xn--fiqs8s"));
+    EXPECT_FALSE(isPublicSuffix("www.xn--85x722f.xn--fiqs8s"));
+    EXPECT_FALSE(isPublicSuffix("shishi.xn--fiqs8s"));
+    EXPECT_TRUE(isPublicSuffix("xn--fiqs8s"));
 }
 
 TEST_F(PublicSuffix, TopPrivatelyControlledDomain)
 {
+    EXPECT_EQ(utf16String(u"\u6803\u6728.jp"), topPrivatelyControlledDomain(utf16String(u"\u6803\u6728.jp")));
+    EXPECT_EQ(String(utf16String(u"example.\u6803\u6728.jp")), topPrivatelyControlledDomain(utf16String(u"example.\u6803\u6728.jp")));
+    EXPECT_EQ(String(), topPrivatelyControlledDomain(String()));
+    EXPECT_EQ(String(), topPrivatelyControlledDomain(""));
     EXPECT_EQ(String("test.com"), topPrivatelyControlledDomain("test.com"));
     EXPECT_EQ(String("test.com"), topPrivatelyControlledDomain("com.test.com"));
     EXPECT_EQ(String("test.com"), topPrivatelyControlledDomain("subdomain.test.com"));
@@ -71,6 +170,16 @@ TEST_F(PublicSuffix, TopPrivatelyControlledDomain)
     EXPECT_EQ(String("127.0.0.1"), topPrivatelyControlledDomain("127.0.0.1"));
     EXPECT_EQ(String(), topPrivatelyControlledDomain("1"));
     EXPECT_EQ(String(), topPrivatelyControlledDomain("com"));
+    EXPECT_EQ(String("test.com"), topPrivatelyControlledDomain("r4---asdf.test.com"));
+    EXPECT_EQ(String("r4---asdf.com"), topPrivatelyControlledDomain("r4---asdf.com"));
+    EXPECT_EQ(String(), topPrivatelyControlledDomain("r4---asdf"));
+    EXPECT_EQ(utf16String(bidirectionalDomain), utf16String(bidirectionalDomain));
+    EXPECT_EQ(String("example.com"), topPrivatelyControlledDomain("ExamPle.com"));
+    EXPECT_EQ(String("example.com"), topPrivatelyControlledDomain("SUB.dOmain.ExamPle.com"));
+    EXPECT_EQ(String("localhost"), topPrivatelyControlledDomain("localhost"));
+    EXPECT_EQ(String("localhost"), topPrivatelyControlledDomain("LocalHost"));
+    EXPECT_EQ(String("åäö"), topPrivatelyControlledDomain("åäö"));
+    EXPECT_EQ(String("ÅÄÖ"), topPrivatelyControlledDomain("ÅÄÖ"));
 }
 
 }
diff --git a/Tools/TestWebKitAPI/Tests/mac/PublicSuffix.mm b/Tools/TestWebKitAPI/Tests/mac/PublicSuffix.mm
deleted file mode 100644 (file)
index f500baa..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(PUBLIC_SUFFIX_LIST)
-
-#include "WTFStringUtilities.h"
-#include <WebCore/PublicSuffix.h>
-#include <wtf/MainThread.h>
-
-using namespace WebCore;
-
-namespace TestWebKitAPI {
-
-class PublicSuffix: public testing::Test {
-public:
-    virtual void SetUp()
-    {
-        WTF::initializeMainThread();
-        [WebView initialize];
-    }
-};
-
-const char16_t bidirectionalDomain[28] = u"bidirectional\u0786\u07AE\u0782\u07B0\u0795\u07A9\u0793\u07A6\u0783\u07AA.com";
-
-TEST_F(PublicSuffix, IsPublicSuffix)
-{
-    EXPECT_TRUE(isPublicSuffix("com"));
-    EXPECT_FALSE(isPublicSuffix("test.com"));
-    EXPECT_FALSE(isPublicSuffix("com.com"));
-    EXPECT_TRUE(isPublicSuffix("net"));
-    EXPECT_TRUE(isPublicSuffix("org"));
-    EXPECT_TRUE(isPublicSuffix("co.uk"));
-    EXPECT_FALSE(isPublicSuffix("bl.uk"));
-    EXPECT_FALSE(isPublicSuffix("test.co.uk"));
-    EXPECT_TRUE(isPublicSuffix("xn--zf0ao64a.tw"));
-    EXPECT_FALSE(isPublicSuffix("r4---asdf.test.com"));
-    EXPECT_FALSE(isPublicSuffix(utf16String(bidirectionalDomain)));
-    EXPECT_TRUE(isPublicSuffix(utf16String(u"\u6803\u6728.jp")));
-    EXPECT_FALSE(isPublicSuffix(""));
-    EXPECT_FALSE(isPublicSuffix("åäö"));
-
-    // UK
-    EXPECT_TRUE(isPublicSuffix("uk"));
-    EXPECT_FALSE(isPublicSuffix("webkit.uk"));
-    EXPECT_TRUE(isPublicSuffix("co.uk"));
-    EXPECT_FALSE(isPublicSuffix("company.co.uk"));
-
-    // Note: These tests are based on the Public Domain TLD test suite
-    // https://raw.githubusercontent.com/publicsuffix/list/master/tests/test_psl.txt
-    //
-    // That file states:
-    //     Any copyright is dedicated to the Public Domain.
-    //     https://creativecommons.org/publicdomain/zero/1.0/
-
-    // null input.
-    EXPECT_FALSE(isPublicSuffix(""));
-    // Mixed case.
-    EXPECT_TRUE(isPublicSuffix("COM"));
-    EXPECT_FALSE(isPublicSuffix("example.COM"));
-    EXPECT_FALSE(isPublicSuffix("WwW.example.COM"));
-    // Unlisted TLD.
-    EXPECT_FALSE(isPublicSuffix("example"));
-    EXPECT_FALSE(isPublicSuffix("example.example"));
-    EXPECT_FALSE(isPublicSuffix("b.example.example"));
-    EXPECT_FALSE(isPublicSuffix("a.b.example.example"));
-    // TLD with only 1 rule.
-    EXPECT_TRUE(isPublicSuffix("biz"));
-    EXPECT_FALSE(isPublicSuffix("domain.biz"));
-    EXPECT_FALSE(isPublicSuffix("b.domain.biz"));
-    EXPECT_FALSE(isPublicSuffix("a.b.domain.biz"));
-    // TLD with some 2-level rules.
-    EXPECT_FALSE(isPublicSuffix("example.com"));
-    EXPECT_FALSE(isPublicSuffix("b.example.com"));
-    EXPECT_FALSE(isPublicSuffix("a.b.example.com"));
-    EXPECT_TRUE(isPublicSuffix("uk.com"));
-    EXPECT_FALSE(isPublicSuffix("example.uk.com"));
-    EXPECT_FALSE(isPublicSuffix("b.example.uk.com"));
-    EXPECT_FALSE(isPublicSuffix("a.b.example.uk.com"));
-    EXPECT_FALSE(isPublicSuffix("test.ac"));
-    // TLD with only 1 (wildcard) rule.
-    EXPECT_TRUE(isPublicSuffix("mm"));
-    EXPECT_TRUE(isPublicSuffix("c.mm"));
-    EXPECT_FALSE(isPublicSuffix("b.c.mm"));
-    EXPECT_FALSE(isPublicSuffix("a.b.c.mm"));
-    // More complex TLD.
-    EXPECT_TRUE(isPublicSuffix("jp"));
-    EXPECT_FALSE(isPublicSuffix("test.jp"));
-    EXPECT_FALSE(isPublicSuffix("www.test.jp"));
-    EXPECT_TRUE(isPublicSuffix("ac.jp"));
-    EXPECT_FALSE(isPublicSuffix("test.ac.jp"));
-    EXPECT_FALSE(isPublicSuffix("www.test.ac.jp"));
-    EXPECT_TRUE(isPublicSuffix("kyoto.jp"));
-    EXPECT_FALSE(isPublicSuffix("test.kyoto.jp"));
-    EXPECT_TRUE(isPublicSuffix("ide.kyoto.jp"));
-    EXPECT_FALSE(isPublicSuffix("b.ide.kyoto.jp"));
-    EXPECT_FALSE(isPublicSuffix("a.b.ide.kyoto.jp"));
-    EXPECT_TRUE(isPublicSuffix("c.kobe.jp"));
-    EXPECT_FALSE(isPublicSuffix("b.c.kobe.jp"));
-    EXPECT_FALSE(isPublicSuffix("a.b.c.kobe.jp"));
-    EXPECT_FALSE(isPublicSuffix("city.kobe.jp"));
-    EXPECT_FALSE(isPublicSuffix("www.city.kobe.jp"));
-    // TLD with a wildcard rule and exceptions.
-    EXPECT_TRUE(isPublicSuffix("ck"));
-    EXPECT_TRUE(isPublicSuffix("test.ck"));
-    EXPECT_FALSE(isPublicSuffix("b.test.ck"));
-    EXPECT_FALSE(isPublicSuffix("a.b.test.ck"));
-    EXPECT_FALSE(isPublicSuffix("www.ck"));
-    EXPECT_FALSE(isPublicSuffix("www.www.ck"));
-    // US K12.
-    EXPECT_TRUE(isPublicSuffix("us"));
-    EXPECT_FALSE(isPublicSuffix("test.us"));
-    EXPECT_FALSE(isPublicSuffix("www.test.us"));
-    EXPECT_TRUE(isPublicSuffix("ak.us"));
-    EXPECT_FALSE(isPublicSuffix("test.ak.us"));
-    EXPECT_FALSE(isPublicSuffix("www.test.ak.us"));
-    EXPECT_TRUE(isPublicSuffix("k12.ak.us"));
-    EXPECT_FALSE(isPublicSuffix("test.k12.ak.us"));
-    EXPECT_FALSE(isPublicSuffix("www.test.k12.ak.us"));
-    // IDN labels (punycoded)
-    EXPECT_FALSE(isPublicSuffix("xn--85x722f.com.cn"));
-    EXPECT_FALSE(isPublicSuffix("xn--85x722f.xn--55qx5d.cn"));
-    EXPECT_FALSE(isPublicSuffix("www.xn--85x722f.xn--55qx5d.cn"));
-    EXPECT_FALSE(isPublicSuffix("shishi.xn--55qx5d.cn"));
-    EXPECT_TRUE(isPublicSuffix("xn--55qx5d.cn"));
-    EXPECT_FALSE(isPublicSuffix("xn--85x722f.xn--fiqs8s"));
-    EXPECT_FALSE(isPublicSuffix("www.xn--85x722f.xn--fiqs8s"));
-    EXPECT_FALSE(isPublicSuffix("shishi.xn--fiqs8s"));
-    EXPECT_TRUE(isPublicSuffix("xn--fiqs8s"));
-}
-
-TEST_F(PublicSuffix, TopPrivatelyControlledDomain)
-{
-    EXPECT_EQ(utf16String(u"\u6803\u6728.jp"), topPrivatelyControlledDomain(utf16String(u"\u6803\u6728.jp")));
-    EXPECT_EQ(String(utf16String(u"example.\u6803\u6728.jp")), topPrivatelyControlledDomain(utf16String(u"example.\u6803\u6728.jp")));
-    EXPECT_EQ(String(), topPrivatelyControlledDomain(String()));
-    EXPECT_EQ(String(), topPrivatelyControlledDomain(""));
-    EXPECT_EQ(String("test.com"), topPrivatelyControlledDomain("test.com"));
-    EXPECT_EQ(String("test.com"), topPrivatelyControlledDomain("com.test.com"));
-    EXPECT_EQ(String("test.com"), topPrivatelyControlledDomain("subdomain.test.com"));
-    EXPECT_EQ(String("com.com"), topPrivatelyControlledDomain("www.com.com"));
-    EXPECT_EQ(String("test.co.uk"), topPrivatelyControlledDomain("test.co.uk"));
-    EXPECT_EQ(String("test.co.uk"), topPrivatelyControlledDomain("subdomain.test.co.uk"));
-    EXPECT_EQ(String("bl.uk"), topPrivatelyControlledDomain("bl.uk"));
-    EXPECT_EQ(String("bl.uk"), topPrivatelyControlledDomain("subdomain.bl.uk"));
-    EXPECT_EQ(String("test.xn--zf0ao64a.tw"), topPrivatelyControlledDomain("test.xn--zf0ao64a.tw"));
-    EXPECT_EQ(String("test.xn--zf0ao64a.tw"), topPrivatelyControlledDomain("www.test.xn--zf0ao64a.tw"));
-    EXPECT_EQ(String("127.0.0.1"), topPrivatelyControlledDomain("127.0.0.1"));
-    EXPECT_EQ(String(), topPrivatelyControlledDomain("1"));
-    EXPECT_EQ(String(), topPrivatelyControlledDomain("com"));
-    EXPECT_EQ(String("test.com"), topPrivatelyControlledDomain("r4---asdf.test.com"));
-    EXPECT_EQ(String("r4---asdf.com"), topPrivatelyControlledDomain("r4---asdf.com"));
-    EXPECT_EQ(String(), topPrivatelyControlledDomain("r4---asdf"));
-    EXPECT_EQ(utf16String(bidirectionalDomain), utf16String(bidirectionalDomain));
-    EXPECT_EQ(String("example.com"), topPrivatelyControlledDomain("ExamPle.com"));
-    EXPECT_EQ(String("example.com"), topPrivatelyControlledDomain("SUB.dOmain.ExamPle.com"));
-    EXPECT_EQ(String("localhost"), topPrivatelyControlledDomain("localhost"));
-    EXPECT_EQ(String("localhost"), topPrivatelyControlledDomain("LocalHost"));
-    EXPECT_EQ(String("åäö"), topPrivatelyControlledDomain("åäö"));
-    EXPECT_EQ(String("ÅÄÖ"), topPrivatelyControlledDomain("ÅÄÖ"));
-}
-
-}
-
-#endif