Move URL tests from TestWebKitAPI to TestWTF
authoryusukesuzuki@slowstart.org <yusukesuzuki@slowstart.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 1 Dec 2018 12:23:25 +0000 (12:23 +0000)
committeryusukesuzuki@slowstart.org <yusukesuzuki@slowstart.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 1 Dec 2018 12:23:25 +0000 (12:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192275

Reviewed by Keith Miller.

Since URL is moved from WebCore to WTF, we also move tests for them from TestWebKitAPI (TestWebCore) to TestWTF.
But we still have some tests in TestWebCore since only WebCore implements TextEncoding. That part is now decoupled
from URLParser tests and new URLParserTextEncoding.cpp is created.

* TestWebKitAPI/CMakeLists.txt:
* TestWebKitAPI/PlatformGTK.cmake:
* TestWebKitAPI/PlatformWPE.cmake:
* TestWebKitAPI/PlatformWin.cmake:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/URL.cpp: Renamed from Tools/TestWebKitAPI/Tests/WebCore/URL.cpp.
(TestWebKitAPI::TEST_F):
* TestWebKitAPI/Tests/WTF/URLParser.cpp: Renamed from Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp.
(TestWebKitAPI::TEST_F):
* TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm: Renamed from Tools/TestWebKitAPI/Tests/WebCore/cocoa/URLExtras.mm.
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebCore/URLParserTextEncoding.cpp: Added.
(TestWebKitAPI::ExpectedParts::isInvalid const):
(TestWebKitAPI::eq):
(TestWebKitAPI::insertTabAtLocation):
(TestWebKitAPI::invalidParts):
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):

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

Tools/ChangeLog
Tools/TestWebKitAPI/CMakeLists.txt
Tools/TestWebKitAPI/PlatformGTK.cmake
Tools/TestWebKitAPI/PlatformWPE.cmake
Tools/TestWebKitAPI/PlatformWin.cmake
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WTF/URL.cpp [moved from Tools/TestWebKitAPI/Tests/WebCore/URL.cpp with 97% similarity]
Tools/TestWebKitAPI/Tests/WTF/URLParser.cpp [moved from Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp with 92% similarity]
Tools/TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm [moved from Tools/TestWebKitAPI/Tests/WebCore/cocoa/URLExtras.mm with 97% similarity]
Tools/TestWebKitAPI/Tests/WebCore/URLParserTextEncoding.cpp [new file with mode: 0644]

index 772e204..0c62cb7 100644 (file)
@@ -1,3 +1,33 @@
+2018-12-01  Yusuke Suzuki  <yusukesuzuki@slowstart.org>
+
+        Move URL tests from TestWebKitAPI to TestWTF
+        https://bugs.webkit.org/show_bug.cgi?id=192275
+
+        Reviewed by Keith Miller.
+
+        Since URL is moved from WebCore to WTF, we also move tests for them from TestWebKitAPI (TestWebCore) to TestWTF.
+        But we still have some tests in TestWebCore since only WebCore implements TextEncoding. That part is now decoupled
+        from URLParser tests and new URLParserTextEncoding.cpp is created.
+
+        * TestWebKitAPI/CMakeLists.txt:
+        * TestWebKitAPI/PlatformGTK.cmake:
+        * TestWebKitAPI/PlatformWPE.cmake:
+        * TestWebKitAPI/PlatformWin.cmake:
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WTF/URL.cpp: Renamed from Tools/TestWebKitAPI/Tests/WebCore/URL.cpp.
+        (TestWebKitAPI::TEST_F):
+        * TestWebKitAPI/Tests/WTF/URLParser.cpp: Renamed from Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp.
+        (TestWebKitAPI::TEST_F):
+        * TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm: Renamed from Tools/TestWebKitAPI/Tests/WebCore/cocoa/URLExtras.mm.
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebCore/URLParserTextEncoding.cpp: Added.
+        (TestWebKitAPI::ExpectedParts::isInvalid const):
+        (TestWebKitAPI::eq):
+        (TestWebKitAPI::insertTabAtLocation):
+        (TestWebKitAPI::invalidParts):
+        (TestWebKitAPI::checkURL):
+        (TestWebKitAPI::TEST_F):
+
 2018-11-30  Zalan Bujtas  <zalan@apple.com>
 
         Unreviewed LFC passing test list update.
index 0f32558..b249008 100644 (file)
@@ -176,6 +176,8 @@ set(TestWTF_SOURCES
     ${TESTWEBKITAPI_DIR}/Tests/WTF/ThreadMessages.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WTF/Threading.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WTF/Time.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WTF/URL.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WTF/URLParser.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WTF/UniqueArray.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WTF/UniqueRef.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WTF/Variant.cpp
index ce94178..84499de 100644 (file)
@@ -87,6 +87,7 @@ add_executable(TestWebCore
     ${test_main_SOURCES}
     ${TESTWEBKITAPI_DIR}/glib/UtilitiesGLib.cpp
     ${TESTWEBKITAPI_DIR}/TestsController.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebCore/AbortableTaskQueue.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/CSSParser.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/ComplexTextController.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/DNS.cpp
@@ -97,14 +98,12 @@ add_executable(TestWebCore
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/LayoutUnit.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/MIMETypeRegistry.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/PublicSuffix.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebCore/SampleMap.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/SecurityOrigin.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/SharedBuffer.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/SharedBufferTest.cpp
-    ${TESTWEBKITAPI_DIR}/Tests/WebCore/URL.cpp
-    ${TESTWEBKITAPI_DIR}/Tests/WebCore/URLParser.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebCore/URLParserTextEncoding.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/UserAgentQuirks.cpp
-    ${TESTWEBKITAPI_DIR}/Tests/WebCore/SampleMap.cpp
-    ${TESTWEBKITAPI_DIR}/Tests/WebCore/AbortableTaskQueue.cpp
 )
 
 target_link_libraries(TestWebCore ${test_webcore_LIBRARIES})
index d405f66..fb1b6b5 100644 (file)
@@ -58,15 +58,15 @@ add_executable(TestWebCore
     ${test_main_SOURCES}
     ${TESTWEBKITAPI_DIR}/glib/UtilitiesGLib.cpp
     ${TESTWEBKITAPI_DIR}/TestsController.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebCore/FileMonitor.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebCore/FileSystem.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/HTMLParserIdioms.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/LayoutUnit.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/MIMETypeRegistry.cpp
-    ${TESTWEBKITAPI_DIR}/Tests/WebCore/URL.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebCore/PublicSuffix.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/SharedBuffer.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/SharedBufferTest.cpp
-    ${TESTWEBKITAPI_DIR}/Tests/WebCore/FileMonitor.cpp
-    ${TESTWEBKITAPI_DIR}/Tests/WebCore/FileSystem.cpp
-    ${TESTWEBKITAPI_DIR}/Tests/WebCore/PublicSuffix.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebCore/URLParserTextEncoding.cpp
 )
 
 target_link_libraries(TestWebCore ${test_webcore_LIBRARIES})
index f63d7a1..4fbcbc4 100644 (file)
@@ -58,8 +58,7 @@ set(TestWebCoreLib_SOURCES
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/SharedBufferTest.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/TimeRanges.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/TransformationMatrix.cpp
-    ${TESTWEBKITAPI_DIR}/Tests/WebCore/URL.cpp
-    ${TESTWEBKITAPI_DIR}/Tests/WebCore/URLParser.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebCore/URLParserTextEncoding.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/win/DIBPixelData.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/win/LinkedFonts.cpp
 )
index 8e2a4e3..010376f 100644 (file)
                5C2936961D5C00ED00DEAB1E /* CookieMessage.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5C2936941D5BFD1900DEAB1E /* CookieMessage.html */; };
                5C4A84951F7EEFFC00ACFC54 /* Configuration.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C4A84941F7EEFD400ACFC54 /* Configuration.mm */; };
                5C69BDD51F82A7EF000F4F4B /* JavaScriptDuringNavigation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C69BDD41F82A7EB000F4F4B /* JavaScriptDuringNavigation.mm */; };
-               5C6E65441D5CEFD400F7862E /* URLParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C6E65411D5CEF8500F7862E /* URLParser.cpp */; };
                5C7148952123A40A00FDE3C5 /* WKWebsiteDatastore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C7148942123A40700FDE3C5 /* WKWebsiteDatastore.mm */; };
                5C726D6F1D3EE06E00C5E1A1 /* InstanceMethodSwizzler.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C726D6E1D3EE06800C5E1A1 /* InstanceMethodSwizzler.mm */; };
                5C7964101EB0278D0075D74C /* EventModifiers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C79640F1EB0269B0075D74C /* EventModifiers.cpp */; };
                7CCE7EAD1A411A3400447C4C /* JavaScriptTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0ADBE7A12FCA4D000D2C129 /* JavaScriptTest.cpp */; };
                7CCE7EAE1A411A3400447C4C /* TestsController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC131AA8117131FC00B69727 /* TestsController.cpp */; };
                7CCE7EAF1A411A3800447C4C /* PlatformUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC575BBF126F5752006F0F12 /* PlatformUtilities.cpp */; };
-               7CCE7EB01A411A4400447C4C /* URLExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93A7EB3C18FA63A4009E7670 /* URLExtras.mm */; };
                7CCE7EB21A411A5100447C4C /* MemoryCacheAddImageToCacheIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7560917719259C59009EF06E /* MemoryCacheAddImageToCacheIOS.mm */; };
                7CCE7EB31A411A7E00447C4C /* AcceptsFirstMouse.mm in Sources */ = {isa = PBXBuildFile; fileRef = 379028B514FABD92007E6B43 /* AcceptsFirstMouse.mm */; };
                7CCE7EB41A411A7E00447C4C /* AttributedString.mm in Sources */ = {isa = PBXBuildFile; fileRef = B55F119F1516834F00915916 /* AttributedString.mm */; };
                7CCE7EDB1A411A9200447C4C /* CSSParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD5451E919E41F9D0016936F /* CSSParser.cpp */; };
                7CCE7EDC1A411A9200447C4C /* CalculationValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93A720E518F1A0E800A848E1 /* CalculationValue.cpp */; };
                7CCE7EDD1A411A9200447C4C /* TimeRanges.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDC2C7141797089D00E627FB /* TimeRanges.cpp */; };
-               7CCE7EDE1A411A9200447C4C /* URL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 440A1D3814A0103A008A66F2 /* URL.cpp */; };
                7CCE7EDF1A411A9200447C4C /* LayoutUnit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14464012167A8305000BD218 /* LayoutUnit.cpp */; };
                7CCE7EE01A411A9A00447C4C /* EditorCommands.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCAA485714A044D40088FAC4 /* EditorCommands.mm */; };
                7CCE7EE11A411A9A00447C4C /* GetBackingScaleFactor.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0C5D3BC14598B6F00A802A6 /* GetBackingScaleFactor.mm */; };
                E324A6F02041C82000A76593 /* UniqueArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E398BC0F2041C76300387136 /* UniqueArray.cpp */; };
                E373D7911F2CF35200C6FAAF /* Signals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3953F951F2CF32100A76A2E /* Signals.cpp */; };
                E38A0D351FD50CC300E98C8B /* Threading.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38A0D341FD50CBC00E98C8B /* Threading.cpp */; };
+               E3A1E77F21B25B39008C6007 /* URLParserTextEncoding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3A1E77E21B25B39008C6007 /* URLParserTextEncoding.cpp */; };
+               E3A1E78221B25B7A008C6007 /* URL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3A1E78021B25B79008C6007 /* URL.cpp */; };
+               E3A1E78521B25B91008C6007 /* URLParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3A1E78421B25B91008C6007 /* URLParser.cpp */; };
+               E3C21A7C21B25CA2003B31A3 /* URLExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = E3C21A7B21B25CA2003B31A3 /* URLExtras.mm */; };
                E3DEA8111F0A589000CBC2E8 /* ThreadGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3DEA8101F0A588000CBC2E8 /* ThreadGroup.cpp */; };
                E5036F78211BC25400BFDBE2 /* color-drop.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E5036F77211BC22800BFDBE2 /* color-drop.html */; };
                ECA680CE1E68CC0900731D20 /* StringUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = ECA680CD1E68CC0900731D20 /* StringUtilities.mm */; };
                41882F0221010A70002FF288 /* ProcessPreWarming.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProcessPreWarming.mm; sourceTree = "<group>"; };
                41973B5A1AF2286A006C7B36 /* FileSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileSystem.cpp; sourceTree = "<group>"; };
                41973B5C1AF22875006C7B36 /* SharedBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedBuffer.cpp; sourceTree = "<group>"; };
-               440A1D3814A0103A008A66F2 /* URL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URL.cpp; sourceTree = "<group>"; };
                442BBF681C91CAD90017087F /* RefLogger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RefLogger.cpp; sourceTree = "<group>"; };
                4433A395208044130091ED57 /* SynchronousTimeoutTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SynchronousTimeoutTests.mm; sourceTree = "<group>"; };
                44817A2E1F0486BF00003810 /* WKRequestActivatedElementInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKRequestActivatedElementInfo.mm; sourceTree = "<group>"; };
                5C4A84941F7EEFD400ACFC54 /* Configuration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Configuration.mm; sourceTree = "<group>"; };
                5C5E633D1D0B67940085A025 /* UniqueRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UniqueRef.cpp; sourceTree = "<group>"; };
                5C69BDD41F82A7EB000F4F4B /* JavaScriptDuringNavigation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = JavaScriptDuringNavigation.mm; sourceTree = "<group>"; };
-               5C6E65411D5CEF8500F7862E /* URLParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URLParser.cpp; sourceTree = "<group>"; };
                5C7148942123A40700FDE3C5 /* WKWebsiteDatastore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebsiteDatastore.mm; sourceTree = "<group>"; };
                5C726D6D1D3EE06800C5E1A1 /* InstanceMethodSwizzler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InstanceMethodSwizzler.h; path = cocoa/InstanceMethodSwizzler.h; sourceTree = "<group>"; };
                5C726D6E1D3EE06800C5E1A1 /* InstanceMethodSwizzler.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = InstanceMethodSwizzler.mm; path = cocoa/InstanceMethodSwizzler.mm; sourceTree = "<group>"; };
                93A427AC180DA60F00CD24D7 /* MoveOnly.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoveOnly.h; sourceTree = "<group>"; };
                93A427AD180DA60F00CD24D7 /* RefLogger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RefLogger.h; sourceTree = "<group>"; };
                93A720E518F1A0E800A848E1 /* CalculationValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CalculationValue.cpp; sourceTree = "<group>"; };
-               93A7EB3C18FA63A4009E7670 /* URLExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = URLExtras.mm; sourceTree = "<group>"; };
                93ABA80816DDAB91002DB2FA /* StringHasher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringHasher.cpp; sourceTree = "<group>"; };
                93AF4ECA1506F035007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewFirstVisuallyNonEmptyLayoutForImages.cpp; sourceTree = "<group>"; };
                93AF4ECD1506F064007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp; sourceTree = "<group>"; };
                E38A0D341FD50CBC00E98C8B /* Threading.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Threading.cpp; sourceTree = "<group>"; };
                E3953F951F2CF32100A76A2E /* Signals.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Signals.cpp; sourceTree = "<group>"; };
                E398BC0F2041C76300387136 /* UniqueArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UniqueArray.cpp; sourceTree = "<group>"; };
+               E3A1E77E21B25B39008C6007 /* URLParserTextEncoding.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URLParserTextEncoding.cpp; sourceTree = "<group>"; };
+               E3A1E78021B25B79008C6007 /* URL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URL.cpp; sourceTree = "<group>"; };
+               E3A1E78421B25B91008C6007 /* URLParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URLParser.cpp; sourceTree = "<group>"; };
+               E3C21A7B21B25CA2003B31A3 /* URLExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = URLExtras.mm; sourceTree = "<group>"; };
                E3DEA8101F0A588000CBC2E8 /* ThreadGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadGroup.cpp; sourceTree = "<group>"; };
                E40019301ACE9B5C001B0A2A /* BloomFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BloomFilter.cpp; sourceTree = "<group>"; };
                E490296714E2E3A4002BEDD1 /* TypingStyleCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TypingStyleCrash.mm; sourceTree = "<group>"; };
                                93A258981F92FF15003E510C /* TextCodec.cpp */,
                                CDC2C7141797089D00E627FB /* TimeRanges.cpp */,
                                7AD3FE8D1D75FB8D00B169A4 /* TransformationMatrix.cpp */,
-                               440A1D3814A0103A008A66F2 /* URL.cpp */,
-                               5C6E65411D5CEF8500F7862E /* URLParser.cpp */,
+                               E3A1E77E21B25B39008C6007 /* URLParserTextEncoding.cpp */,
                                9C64DC311D76198A004B598E /* YouTubePluginReplacement.cpp */,
                        );
                        path = WebCore;
                        isa = PBXGroup;
                        children = (
                                C0991C4F143C7D68007998F2 /* cf */,
+                               E3C21A7821B25C82003B31A3 /* cocoa */,
                                7CBBA07519BB8A0900BBF025 /* darwin */,
                                BC029B1A1486B23800817DA9 /* ns */,
                                26F1B44215CA434F00D1E4BF /* AtomicString.cpp */,
                                0F2C20B71DCD544800542D9E /* Time.cpp */,
                                E398BC0F2041C76300387136 /* UniqueArray.cpp */,
                                5C5E633D1D0B67940085A025 /* UniqueRef.cpp */,
+                               E3A1E78021B25B79008C6007 /* URL.cpp */,
+                               E3A1E78421B25B91008C6007 /* URLParser.cpp */,
                                7CD0D5AA1D5534DE000CC9E1 /* Variant.cpp */,
                                BC55F5F814AD78EE00484BE1 /* Vector.cpp */,
                                1CB9BC371A67482300FE5678 /* WeakPtr.cpp */,
                                751B05D51F8EAC1A0028A09E /* DatabaseTrackerTest.mm */,
                                5769C50A1D9B0001000847FB /* SerializedCryptoKeyWrap.mm */,
                                A17991861E1C994E00A505ED /* SharedBuffer.mm */,
-                               93A7EB3C18FA63A4009E7670 /* URLExtras.mm */,
                                CD89D0381C4EDB2A00040A04 /* WebCoreNSURLSession.mm */,
                        );
                        path = cocoa;
                        name = Resources;
                        sourceTree = "<group>";
                };
+               E3C21A7821B25C82003B31A3 /* cocoa */ = {
+                       isa = PBXGroup;
+                       children = (
+                               E3C21A7B21B25CA2003B31A3 /* URLExtras.mm */,
+                       );
+                       path = cocoa;
+                       sourceTree = "<group>";
+               };
 /* End PBXGroup section */
 
 /* Begin PBXNativeTarget section */
                                5311BD5E1EA9490E00525281 /* ThreadMessages.cpp in Sources */,
                                0F2C20B81DCD545000542D9E /* Time.cpp in Sources */,
                                E324A6F02041C82000A76593 /* UniqueArray.cpp in Sources */,
+                               E3A1E78221B25B7A008C6007 /* URL.cpp in Sources */,
+                               E3C21A7C21B25CA2003B31A3 /* URLExtras.mm in Sources */,
+                               E3A1E78521B25B91008C6007 /* URLParser.cpp in Sources */,
                                7C83E03B1D0A602700FEBCF3 /* UtilitiesCocoa.mm in Sources */,
                                7C83FC711D5535A8001DFBCD /* Variant.cpp in Sources */,
                                7C83DF4C1D0A590C00FEBCF3 /* Vector.cpp in Sources */,
                                7CCE7ED31A411A7E00447C4C /* TypingStyleCrash.mm in Sources */,
                                5CB40B4E1F4B98D3007DC7B9 /* UIDelegate.mm in Sources */,
                                F46849BE1EEF58E400B937FE /* UIPasteboardTests.mm in Sources */,
-                               7CCE7EDE1A411A9200447C4C /* URL.cpp in Sources */,
-                               7CCE7EB01A411A4400447C4C /* URLExtras.mm in Sources */,
-                               5C6E65441D5CEFD400F7862E /* URLParser.cpp in Sources */,
+                               E3A1E77F21B25B39008C6007 /* URLParserTextEncoding.cpp in Sources */,
                                7CCE7F271A411AF600447C4C /* UserContentController.mm in Sources */,
                                7CCE7F2D1A411B1000447C4C /* UserContentTest.mm in Sources */,
                                7C882E0A1C80C764006BF731 /* UserContentWorld.mm in Sources */,
similarity index 97%
rename from Tools/TestWebKitAPI/Tests/WebCore/URL.cpp
rename to Tools/TestWebKitAPI/Tests/WTF/URL.cpp
index dc31b47..937b9f9 100644 (file)
@@ -31,7 +31,7 @@
 
 namespace TestWebKitAPI {
 
-class URLTest : public testing::Test {
+class WTF_URL : public testing::Test {
 public:
     virtual void SetUp()
     {
@@ -39,7 +39,7 @@ public:
     }
 };
 
-TEST_F(URLTest, URLConstructorDefault)
+TEST_F(WTF_URL, URLConstructorDefault)
 {
     URL kurl;
 
@@ -48,7 +48,7 @@ TEST_F(URLTest, URLConstructorDefault)
     EXPECT_FALSE(kurl.isValid());
 }
 
-TEST_F(URLTest, URLConstructorConstChar)
+TEST_F(WTF_URL, URLConstructorConstChar)
 {
     URL kurl({ }, "http://username:password@www.example.com:8080/index.html?var=val#fragment");
 
@@ -74,7 +74,7 @@ static URL createURL(const char* urlAsString)
     return URL({ }, urlAsString);
 };
 
-TEST_F(URLTest, URLProtocolHostAndPort)
+TEST_F(WTF_URL, URLProtocolHostAndPort)
 {
     auto url = createURL("http://username:password@www.example.com:8080/index.html?var=val#fragment");
     EXPECT_EQ(String("http://www.example.com:8080"), url.protocolHostAndPort());
@@ -116,7 +116,7 @@ TEST_F(URLTest, URLProtocolHostAndPort)
     EXPECT_EQ(String("asdf://"), url.protocolHostAndPort());
 }
 
-TEST_F(URLTest, URLDataURIStringSharing)
+TEST_F(WTF_URL, URLDataURIStringSharing)
 {
     URL baseURL({ }, "http://www.webkit.org/");
     String threeApples = "data:text/plain;charset=utf-8;base64,76O/76O/76O/";
@@ -125,7 +125,7 @@ TEST_F(URLTest, URLDataURIStringSharing)
     EXPECT_EQ(threeApples.impl(), url.string().impl());
 }
 
-TEST_F(URLTest, URLSetQuery)
+TEST_F(WTF_URL, URLSetQuery)
 {
     URL url = createURL("http://www.webkit.org/?test");
     URL url1 = createURL("http://www.webkit.org/");
@@ -157,7 +157,7 @@ TEST_F(URLTest, URLSetQuery)
     EXPECT_EQ(urlWithFragmentIdentifier.string(), urlWithFragmentIdentifier3.string());
 }
 
-TEST_F(URLTest, URLSetFragmentIdentifier)
+TEST_F(WTF_URL, URLSetFragmentIdentifier)
 {
     URL url = createURL("http://www.webkit.org/#newFragment%C3%83%C2%A5");
     URL url1 = createURL("http://www.webkit.org/");
@@ -186,7 +186,7 @@ TEST_F(URLTest, URLSetFragmentIdentifier)
     EXPECT_EQ(urlWithQuery.string(), urlWithQuery3.string());
 }
 
-TEST_F(URLTest, URLRemoveQueryAndFragmentIdentifier)
+TEST_F(WTF_URL, URLRemoveQueryAndFragmentIdentifier)
 {
     URL url = createURL("http://www.webkit.org/");
     URL url1 = createURL("http://www.webkit.org/?");
@@ -210,7 +210,7 @@ TEST_F(URLTest, URLRemoveQueryAndFragmentIdentifier)
     EXPECT_EQ(url.string(), url5.string());
 }
 
-TEST_F(URLTest, EqualIgnoringFragmentIdentifier)
+TEST_F(WTF_URL, EqualIgnoringFragmentIdentifier)
 {
     struct TestCase {
         const char* url1;
@@ -261,7 +261,7 @@ TEST_F(URLTest, EqualIgnoringFragmentIdentifier)
     }
 }
 
-TEST_F(URLTest, EqualIgnoringQueryAndFragment)
+TEST_F(WTF_URL, EqualIgnoringQueryAndFragment)
 {
     struct TestCase {
         const char* url1;
@@ -312,7 +312,7 @@ TEST_F(URLTest, EqualIgnoringQueryAndFragment)
     }
 }
 
-TEST_F(URLTest, ProtocolIsInHTTPFamily)
+TEST_F(WTF_URL, ProtocolIsInHTTPFamily)
 {
     EXPECT_FALSE(WTF::protocolIsInHTTPFamily({ }));
     EXPECT_FALSE(WTF::protocolIsInHTTPFamily(""));
@@ -330,7 +330,7 @@ TEST_F(URLTest, ProtocolIsInHTTPFamily)
     EXPECT_TRUE(WTF::protocolIsInHTTPFamily("https://!@#$%^&*()"));
 }
 
-TEST_F(URLTest, HostIsIPAddress)
+TEST_F(WTF_URL, HostIsIPAddress)
 {
     EXPECT_FALSE(URL::hostIsIPAddress({ }));
     EXPECT_FALSE(URL::hostIsIPAddress(""));
@@ -370,7 +370,7 @@ TEST_F(URLTest, HostIsIPAddress)
     EXPECT_TRUE(URL::hostIsIPAddress("::123.45.67.89"));
 }
 
-TEST_F(URLTest, HostIsMatchingDomain)
+TEST_F(WTF_URL, HostIsMatchingDomain)
 {
     URL url = createURL("http://www.webkit.org");
 
 
 #include "config.h"
 #include "WTFStringUtilities.h"
-#include <WebCore/TextEncoding.h>
 #include <wtf/MainThread.h>
 #include <wtf/URLParser.h>
 #include <wtf/text/StringBuilder.h>
 
-using namespace WebCore;
-
 namespace TestWebKitAPI {
 
-class URLParserTest : public testing::Test {
+class WTF_URLParser : public testing::Test {
 public:
-    void SetUp() final {
+    void SetUp() final
+    {
         WTF::initializeMainThread();
     }
 };
@@ -211,55 +209,7 @@ static void shouldFail(const String& urlString, const String& baseString)
     checkRelativeURL(urlString, baseString, {"", "", "", "", 0, "", "", "", urlString});
 }
 
-static void checkURL(const String& urlString, const TextEncoding* encoding, const ExpectedParts& parts, TestTabs testTabs = TestTabs::Yes)
-{
-    auto url = URL({ }, urlString, encoding);
-    EXPECT_TRUE(eq(parts.protocol, url.protocol()));
-    EXPECT_TRUE(eq(parts.user, url.user()));
-    EXPECT_TRUE(eq(parts.password, url.pass()));
-    EXPECT_TRUE(eq(parts.host, url.host()));
-    EXPECT_EQ(parts.port, url.port().value_or(0));
-    EXPECT_TRUE(eq(parts.path, url.path()));
-    EXPECT_TRUE(eq(parts.query, url.query()));
-    EXPECT_TRUE(eq(parts.fragment, url.fragmentIdentifier()));
-    EXPECT_TRUE(eq(parts.string, url.string()));
-    
-    if (testTabs == TestTabs::No)
-        return;
-    
-    for (size_t i = 0; i < urlString.length(); ++i) {
-        String urlStringWithTab = insertTabAtLocation(urlString, i);
-        checkURL(urlStringWithTab, encoding,
-            parts.isInvalid() ? invalidParts(urlStringWithTab) : parts,
-            TestTabs::No);
-    }
-}
-
-static void checkURL(const String& urlString, const String& baseURLString, const TextEncoding* encoding, const ExpectedParts& parts, TestTabs testTabs = TestTabs::Yes)
-{
-    auto url = URL(URL({ }, baseURLString), urlString, encoding);
-    EXPECT_TRUE(eq(parts.protocol, url.protocol()));
-    EXPECT_TRUE(eq(parts.user, url.user()));
-    EXPECT_TRUE(eq(parts.password, url.pass()));
-    EXPECT_TRUE(eq(parts.host, url.host()));
-    EXPECT_EQ(parts.port, url.port().value_or(0));
-    EXPECT_TRUE(eq(parts.path, url.path()));
-    EXPECT_TRUE(eq(parts.query, url.query()));
-    EXPECT_TRUE(eq(parts.fragment, url.fragmentIdentifier()));
-    EXPECT_TRUE(eq(parts.string, url.string()));
-    
-    if (testTabs == TestTabs::No)
-        return;
-    
-    for (size_t i = 0; i < urlString.length(); ++i) {
-        String urlStringWithTab = insertTabAtLocation(urlString, i);
-        checkURL(urlStringWithTab, baseURLString, encoding,
-            parts.isInvalid() ? invalidParts(urlStringWithTab) : parts,
-            TestTabs::No);
-    }
-}
-
-TEST_F(URLParserTest, Basic)
+TEST_F(WTF_URLParser, Basic)
 {
     checkURL("http://user:pass@webkit.org:123/path?query#fragment", {"http", "user", "pass", "webkit.org", 123, "/path", "query", "fragment", "http://user:pass@webkit.org:123/path?query#fragment"});
     checkURL("http://user:pass@webkit.org:123/path?query", {"http", "user", "pass", "webkit.org", 123, "/path", "query", "", "http://user:pass@webkit.org:123/path?query"});
@@ -514,7 +464,7 @@ static void testUserPass(const String& value, const String& encoded)
     testUserPass(value, value, encoded);
 }
 
-TEST_F(URLParserTest, Credentials)
+TEST_F(WTF_URLParser, Credentials)
 {
     auto validSurrogate = utf16String<3>({0xD800, 0xDD55, '\0'});
     auto invalidSurrogate = utf16String<3>({0xD800, 'A', '\0'});
@@ -536,7 +486,7 @@ TEST_F(URLParserTest, Credentials)
     testUserPass(invalidSurrogate, replacementA, "%EF%BF%BDA");
 }
 
-TEST_F(URLParserTest, ParseRelative)
+TEST_F(WTF_URLParser, ParseRelative)
 {
     checkRelativeURL("/index.html", "http://webkit.org/path1/path2/", {"http", "", "", "webkit.org", 0, "/index.html", "", "", "http://webkit.org/index.html"});
     checkRelativeURL("http://whatwg.org/index.html", "http://webkit.org/path1/path2/", {"http", "", "", "whatwg.org", 0, "/index.html", "", "", "http://whatwg.org/index.html"});
@@ -639,7 +589,7 @@ TEST_F(URLParserTest, ParseRelative)
 }
 
 // These are differences between the new URLParser and the old URL::parse which make URLParser more standards compliant.
-TEST_F(URLParserTest, ParserDifferences)
+TEST_F(WTF_URLParser, ParserDifferences)
 {
     checkURLDifferences("http://127.0.1",
         {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"},
@@ -1126,7 +1076,7 @@ TEST_F(URLParserTest, ParserDifferences)
         {"http", "", "", "xn--5mkc", 0, "/", "", "", "http://xn--5mkc/"});
 }
 
-TEST_F(URLParserTest, DefaultPort)
+TEST_F(WTF_URLParser, DefaultPort)
 {
     checkURL("FtP://host:21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"});
     checkURL("ftp://host:21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"});
@@ -1219,7 +1169,7 @@ TEST_F(URLParserTest, DefaultPort)
     checkURL("http://example.com:0000000000000080", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"});
 }
 
-TEST_F(URLParserTest, ParserFailures)
+TEST_F(WTF_URLParser, ParserFailures)
 {
     shouldFail("    ");
     shouldFail("  \a  ");
@@ -1278,7 +1228,7 @@ TEST_F(URLParserTest, ParserFailures)
 }
 
 // These are in the spec but not in the web platform tests.
-TEST_F(URLParserTest, AdditionalTests)
+TEST_F(WTF_URLParser, AdditionalTests)
 {
     checkURL("about:\a\aabc", {"about", "", "", "", 0, "%07%07abc", "", "", "about:%07%07abc"});
     checkURL("notspecial:\t\t\n\t", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"});
@@ -1318,40 +1268,4 @@ TEST_F(URLParserTest, AdditionalTests)
     // FIXME: Write more invalid surrogate pair tests based on feedback from https://bugs.webkit.org/show_bug.cgi?id=162105
 }
 
-TEST_F(URLParserTest, QueryEncoding)
-{
-    checkURL(utf16String(u"http://host?ß😍#ß😍"), nullptr, {"http", "", "", "host", 0, "/", "%C3%9F%F0%9F%98%8D", "%C3%9F%F0%9F%98%8D", utf16String(u"http://host/?%C3%9F%F0%9F%98%8D#%C3%9F%F0%9F%98%8D")}, testTabsValueForSurrogatePairs);
-
-    TextEncoding latin1(String("latin1"));
-    checkURL("http://host/?query with%20spaces", &latin1, {"http", "", "", "host", 0, "/", "query%20with%20spaces", "", "http://host/?query%20with%20spaces"});
-    checkURL("http://host/?query", &latin1, {"http", "", "", "host", 0, "/", "query", "", "http://host/?query"});
-    checkURL("http://host/?\tquery", &latin1, {"http", "", "", "host", 0, "/", "query", "", "http://host/?query"});
-    checkURL("http://host/?q\tuery", &latin1, {"http", "", "", "host", 0, "/", "query", "", "http://host/?query"});
-    checkURL("http://host/?query with SpAcEs#fragment", &latin1, {"http", "", "", "host", 0, "/", "query%20with%20SpAcEs", "fragment", "http://host/?query%20with%20SpAcEs#fragment"});
-    checkURL("http://host/?que\rry\t\r\n#fragment", &latin1, {"http", "", "", "host", 0, "/", "query", "fragment", "http://host/?query#fragment"});
-
-    TextEncoding unrecognized(String("unrecognized invalid encoding name"));
-    checkURL("http://host/?query", &unrecognized, {"http", "", "", "host", 0, "/", "", "", "http://host/?"});
-    checkURL("http://host/?", &unrecognized, {"http", "", "", "host", 0, "/", "", "", "http://host/?"});
-
-    TextEncoding iso88591(String("ISO-8859-1"));
-    String withUmlauts = utf16String<4>({0xDC, 0x430, 0x451, '\0'});
-    checkURL(makeString("ws://host/path?", withUmlauts), &iso88591, {"ws", "", "", "host", 0, "/path", "%C3%9C%D0%B0%D1%91", "", "ws://host/path?%C3%9C%D0%B0%D1%91"});
-    checkURL(makeString("wss://host/path?", withUmlauts), &iso88591, {"wss", "", "", "host", 0, "/path", "%C3%9C%D0%B0%D1%91", "", "wss://host/path?%C3%9C%D0%B0%D1%91"});
-    checkURL(makeString("asdf://host/path?", withUmlauts), &iso88591, {"asdf", "", "", "host", 0, "/path", "%C3%9C%D0%B0%D1%91", "", "asdf://host/path?%C3%9C%D0%B0%D1%91"});
-    checkURL(makeString("https://host/path?", withUmlauts), &iso88591, {"https", "", "", "host", 0, "/path", "%DC%26%231072%3B%26%231105%3B", "", "https://host/path?%DC%26%231072%3B%26%231105%3B"});
-    checkURL(makeString("gopher://host/path?", withUmlauts), &iso88591, {"gopher", "", "", "host", 0, "/path", "%DC%26%231072%3B%26%231105%3B", "", "gopher://host/path?%DC%26%231072%3B%26%231105%3B"});
-    checkURL(makeString("/path?", withUmlauts, "#fragment"), "ws://example.com/", &iso88591, {"ws", "", "", "example.com", 0, "/path", "%C3%9C%D0%B0%D1%91", "fragment", "ws://example.com/path?%C3%9C%D0%B0%D1%91#fragment"});
-    checkURL(makeString("/path?", withUmlauts, "#fragment"), "wss://example.com/", &iso88591, {"wss", "", "", "example.com", 0, "/path", "%C3%9C%D0%B0%D1%91", "fragment", "wss://example.com/path?%C3%9C%D0%B0%D1%91#fragment"});
-    checkURL(makeString("/path?", withUmlauts, "#fragment"), "asdf://example.com/", &iso88591, {"asdf", "", "", "example.com", 0, "/path", "%C3%9C%D0%B0%D1%91", "fragment", "asdf://example.com/path?%C3%9C%D0%B0%D1%91#fragment"});
-    checkURL(makeString("/path?", withUmlauts, "#fragment"), "https://example.com/", &iso88591, {"https", "", "", "example.com", 0, "/path", "%DC%26%231072%3B%26%231105%3B", "fragment", "https://example.com/path?%DC%26%231072%3B%26%231105%3B#fragment"});
-    checkURL(makeString("/path?", withUmlauts, "#fragment"), "gopher://example.com/", &iso88591, {"gopher", "", "", "example.com", 0, "/path", "%DC%26%231072%3B%26%231105%3B", "fragment", "gopher://example.com/path?%DC%26%231072%3B%26%231105%3B#fragment"});
-    checkURL(makeString("gopher://host/path?", withUmlauts, "#fragment"), "asdf://example.com/?doesntmatter", &iso88591, {"gopher", "", "", "host", 0, "/path", "%DC%26%231072%3B%26%231105%3B", "fragment", "gopher://host/path?%DC%26%231072%3B%26%231105%3B#fragment"});
-    checkURL(makeString("asdf://host/path?", withUmlauts, "#fragment"), "http://example.com/?doesntmatter", &iso88591, {"asdf", "", "", "host", 0, "/path", "%C3%9C%D0%B0%D1%91", "fragment", "asdf://host/path?%C3%9C%D0%B0%D1%91#fragment"});
-
-    checkURL("http://host/pa'th?qu'ery#fr'agment", nullptr, {"http", "", "", "host", 0, "/pa'th", "qu%27ery", "fr'agment", "http://host/pa'th?qu%27ery#fr'agment"});
-    checkURL("asdf://host/pa'th?qu'ery#fr'agment", nullptr, {"asdf", "", "", "host", 0, "/pa'th", "qu'ery", "fr'agment", "asdf://host/pa'th?qu'ery#fr'agment"});
-    // FIXME: Add more tests with other encodings and things like non-ascii characters, emoji and unmatched surrogate pairs.
-}
-
 } // namespace TestWebKitAPI
@@ -63,7 +63,7 @@ static NSURL *literalURL(const char* literal)
     return WTF::URLWithData(literalAsData(literal), nil);
 }
 
-TEST(WebCore, URLExtras)
+TEST(WTF_URLExtras, URLExtras)
 {
     EXPECT_STREQ("http://site.com", originalDataAsString(literalURL("http://site.com")));
     EXPECT_STREQ("http://%77ebsite.com", originalDataAsString(literalURL("http://%77ebsite.com")));
@@ -72,7 +72,7 @@ TEST(WebCore, URLExtras)
     EXPECT_STREQ("http://%77ebsite.com", userVisibleString(literalURL("http://%77ebsite.com")));
 }
     
-TEST(WebCore, URLExtras_Spoof)
+TEST(WTF_URLExtras, URLExtras_Spoof)
 {
     Vector<String> punycodedSpoofHosts = {
         "xn--cfa45g", // U+0131, U+0307
@@ -108,7 +108,7 @@ TEST(WebCore, URLExtras_Spoof)
     }
 }
 
-TEST(WebCore, URLExtras_NotSpoofed)
+TEST(WTF_URLExtras, URLExtras_NotSpoofed)
 {
     // Valid mixtures of Armenian and other scripts
     EXPECT_STREQ("https://en.wikipedia.org/wiki/.\u0570\u0561\u0575", userVisibleString(literalURL("https://en.wikipedia.org/wiki/.\u0570\u0561\u0575")));
@@ -122,7 +122,7 @@ TEST(WebCore, URLExtras_NotSpoofed)
     EXPECT_STREQ("https://\u0551\u0535and!$^&*()-~+={}or<>,.?\u0575\u0543.biz", userVisibleString(literalURL("https://\u0551\u0535and!$^&*()-~+={}or<>,.?\u0575\u0543.biz")));
 }
 
-TEST(WebCore, URLExtras_DivisionSign)
+TEST(WTF_URLExtras, URLExtras_DivisionSign)
 {
     // Selected the division sign as an example of a non-ASCII character that is allowed in host names, since it's a lookalike character.
 
@@ -160,7 +160,7 @@ TEST(WTF, URLExtras_Solidus)
     EXPECT_STREQ("site.com/othersite.org", [WTF::decodeHostName(@"site.com\xEF\xBC\x8Fothersite.org") UTF8String]);
 }
 
-TEST(WebCore, URLExtras_Space)
+TEST(WTF_URLExtras, URLExtras_Space)
 {
     // Selected ideographic space, which looks like the ASCII space, which is not allowed unescaped.
 
@@ -179,12 +179,12 @@ TEST(WebCore, URLExtras_Space)
     EXPECT_STREQ("site.com\xE3\x80\x80othersite.org", [WTF::decodeHostName(@"site.com\xE3\x80\x80othersite.org") UTF8String]);
 }
 
-TEST(WebCore, URLExtras_File)
+TEST(WTF_URLExtras, URLExtras_File)
 {
     EXPECT_STREQ("file:///%E2%98%83", [[WTF::URLWithUserTypedString(@"file:///☃", nil) absoluteString] UTF8String]);
 }
 
-TEST(WebCore, URLExtras_ParsingError)
+TEST(WTF_URLExtras, URLExtras_ParsingError)
 {
     // Expect IDN failure.
     NSURL *url = WTF::URLWithUserTypedString(@"http://.com", nil);
@@ -194,7 +194,7 @@ TEST(WebCore, URLExtras_ParsingError)
     EXPECT_TRUE(encodedHostName == nil);
 }
 
-TEST(WebCore, URLExtras_Nil)
+TEST(WTF_URLExtras, URLExtras_Nil)
 {
     NSURL *url1 = WTF::URLWithUserTypedString(nil, nil);
     EXPECT_TRUE(url1 == nil);
diff --git a/Tools/TestWebKitAPI/Tests/WebCore/URLParserTextEncoding.cpp b/Tools/TestWebKitAPI/Tests/WebCore/URLParserTextEncoding.cpp
new file mode 100644 (file)
index 0000000..f892853
--- /dev/null
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2016 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"
+#include "WTFStringUtilities.h"
+#include <WebCore/TextEncoding.h>
+#include <wtf/MainThread.h>
+#include <wtf/URLParser.h>
+#include <wtf/text/StringBuilder.h>
+
+using namespace WebCore;
+
+namespace TestWebKitAPI {
+
+class URLParserTextEncodingTest : public testing::Test {
+public:
+    void SetUp() final
+    {
+        WTF::initializeMainThread();
+    }
+};
+
+struct ExpectedParts {
+    String protocol;
+    String user;
+    String password;
+    String host;
+    unsigned short port;
+    String path;
+    String query;
+    String fragment;
+    String string;
+
+    bool isInvalid() const
+    {
+        return protocol.isEmpty()
+            && user.isEmpty()
+            && password.isEmpty()
+            && host.isEmpty()
+            && !port
+            && path.isEmpty()
+            && query.isEmpty()
+            && fragment.isEmpty();
+    }
+};
+
+template<typename T, typename U>
+bool eq(T&& s1, U&& s2)
+{
+    EXPECT_STREQ(s1.utf8().data(), s2.utf8().data());
+    return s1.utf8() == s2.utf8();
+}
+
+static String insertTabAtLocation(const String& string, size_t location)
+{
+    ASSERT(location <= string.length());
+    return makeString(string.substring(0, location), "\t", string.substring(location));
+}
+
+static ExpectedParts invalidParts(const String& urlStringWithTab)
+{
+    return {"", "", "", "", 0, "" , "", "", urlStringWithTab};
+}
+
+enum class TestTabs { No, Yes };
+
+// Inserting tabs between surrogate pairs changes the encoded value instead of being skipped by the URLParser.
+const TestTabs testTabsValueForSurrogatePairs = TestTabs::No;
+
+static void checkURL(const String& urlString, const TextEncoding* encoding, const ExpectedParts& parts, TestTabs testTabs = TestTabs::Yes)
+{
+    auto url = URL({ }, urlString, encoding);
+    EXPECT_TRUE(eq(parts.protocol, url.protocol()));
+    EXPECT_TRUE(eq(parts.user, url.user()));
+    EXPECT_TRUE(eq(parts.password, url.pass()));
+    EXPECT_TRUE(eq(parts.host, url.host()));
+    EXPECT_EQ(parts.port, url.port().value_or(0));
+    EXPECT_TRUE(eq(parts.path, url.path()));
+    EXPECT_TRUE(eq(parts.query, url.query()));
+    EXPECT_TRUE(eq(parts.fragment, url.fragmentIdentifier()));
+    EXPECT_TRUE(eq(parts.string, url.string()));
+    
+    if (testTabs == TestTabs::No)
+        return;
+    
+    for (size_t i = 0; i < urlString.length(); ++i) {
+        String urlStringWithTab = insertTabAtLocation(urlString, i);
+        checkURL(urlStringWithTab, encoding,
+            parts.isInvalid() ? invalidParts(urlStringWithTab) : parts,
+            TestTabs::No);
+    }
+}
+
+static void checkURL(const String& urlString, const String& baseURLString, const TextEncoding* encoding, const ExpectedParts& parts, TestTabs testTabs = TestTabs::Yes)
+{
+    auto url = URL(URL({ }, baseURLString), urlString, encoding);
+    EXPECT_TRUE(eq(parts.protocol, url.protocol()));
+    EXPECT_TRUE(eq(parts.user, url.user()));
+    EXPECT_TRUE(eq(parts.password, url.pass()));
+    EXPECT_TRUE(eq(parts.host, url.host()));
+    EXPECT_EQ(parts.port, url.port().value_or(0));
+    EXPECT_TRUE(eq(parts.path, url.path()));
+    EXPECT_TRUE(eq(parts.query, url.query()));
+    EXPECT_TRUE(eq(parts.fragment, url.fragmentIdentifier()));
+    EXPECT_TRUE(eq(parts.string, url.string()));
+    
+    if (testTabs == TestTabs::No)
+        return;
+    
+    for (size_t i = 0; i < urlString.length(); ++i) {
+        String urlStringWithTab = insertTabAtLocation(urlString, i);
+        checkURL(urlStringWithTab, baseURLString, encoding,
+            parts.isInvalid() ? invalidParts(urlStringWithTab) : parts,
+            TestTabs::No);
+    }
+}
+
+TEST_F(URLParserTextEncodingTest, QueryEncoding)
+{
+    checkURL(utf16String(u"http://host?ß😍#ß😍"), nullptr, {"http", "", "", "host", 0, "/", "%C3%9F%F0%9F%98%8D", "%C3%9F%F0%9F%98%8D", utf16String(u"http://host/?%C3%9F%F0%9F%98%8D#%C3%9F%F0%9F%98%8D")}, testTabsValueForSurrogatePairs);
+
+    TextEncoding latin1(String("latin1"));
+    checkURL("http://host/?query with%20spaces", &latin1, {"http", "", "", "host", 0, "/", "query%20with%20spaces", "", "http://host/?query%20with%20spaces"});
+    checkURL("http://host/?query", &latin1, {"http", "", "", "host", 0, "/", "query", "", "http://host/?query"});
+    checkURL("http://host/?\tquery", &latin1, {"http", "", "", "host", 0, "/", "query", "", "http://host/?query"});
+    checkURL("http://host/?q\tuery", &latin1, {"http", "", "", "host", 0, "/", "query", "", "http://host/?query"});
+    checkURL("http://host/?query with SpAcEs#fragment", &latin1, {"http", "", "", "host", 0, "/", "query%20with%20SpAcEs", "fragment", "http://host/?query%20with%20SpAcEs#fragment"});
+    checkURL("http://host/?que\rry\t\r\n#fragment", &latin1, {"http", "", "", "host", 0, "/", "query", "fragment", "http://host/?query#fragment"});
+
+    TextEncoding unrecognized(String("unrecognized invalid encoding name"));
+    checkURL("http://host/?query", &unrecognized, {"http", "", "", "host", 0, "/", "", "", "http://host/?"});
+    checkURL("http://host/?", &unrecognized, {"http", "", "", "host", 0, "/", "", "", "http://host/?"});
+
+    TextEncoding iso88591(String("ISO-8859-1"));
+    String withUmlauts = utf16String<4>({0xDC, 0x430, 0x451, '\0'});
+    checkURL(makeString("ws://host/path?", withUmlauts), &iso88591, {"ws", "", "", "host", 0, "/path", "%C3%9C%D0%B0%D1%91", "", "ws://host/path?%C3%9C%D0%B0%D1%91"});
+    checkURL(makeString("wss://host/path?", withUmlauts), &iso88591, {"wss", "", "", "host", 0, "/path", "%C3%9C%D0%B0%D1%91", "", "wss://host/path?%C3%9C%D0%B0%D1%91"});
+    checkURL(makeString("asdf://host/path?", withUmlauts), &iso88591, {"asdf", "", "", "host", 0, "/path", "%C3%9C%D0%B0%D1%91", "", "asdf://host/path?%C3%9C%D0%B0%D1%91"});
+    checkURL(makeString("https://host/path?", withUmlauts), &iso88591, {"https", "", "", "host", 0, "/path", "%DC%26%231072%3B%26%231105%3B", "", "https://host/path?%DC%26%231072%3B%26%231105%3B"});
+    checkURL(makeString("gopher://host/path?", withUmlauts), &iso88591, {"gopher", "", "", "host", 0, "/path", "%DC%26%231072%3B%26%231105%3B", "", "gopher://host/path?%DC%26%231072%3B%26%231105%3B"});
+    checkURL(makeString("/path?", withUmlauts, "#fragment"), "ws://example.com/", &iso88591, {"ws", "", "", "example.com", 0, "/path", "%C3%9C%D0%B0%D1%91", "fragment", "ws://example.com/path?%C3%9C%D0%B0%D1%91#fragment"});
+    checkURL(makeString("/path?", withUmlauts, "#fragment"), "wss://example.com/", &iso88591, {"wss", "", "", "example.com", 0, "/path", "%C3%9C%D0%B0%D1%91", "fragment", "wss://example.com/path?%C3%9C%D0%B0%D1%91#fragment"});
+    checkURL(makeString("/path?", withUmlauts, "#fragment"), "asdf://example.com/", &iso88591, {"asdf", "", "", "example.com", 0, "/path", "%C3%9C%D0%B0%D1%91", "fragment", "asdf://example.com/path?%C3%9C%D0%B0%D1%91#fragment"});
+    checkURL(makeString("/path?", withUmlauts, "#fragment"), "https://example.com/", &iso88591, {"https", "", "", "example.com", 0, "/path", "%DC%26%231072%3B%26%231105%3B", "fragment", "https://example.com/path?%DC%26%231072%3B%26%231105%3B#fragment"});
+    checkURL(makeString("/path?", withUmlauts, "#fragment"), "gopher://example.com/", &iso88591, {"gopher", "", "", "example.com", 0, "/path", "%DC%26%231072%3B%26%231105%3B", "fragment", "gopher://example.com/path?%DC%26%231072%3B%26%231105%3B#fragment"});
+    checkURL(makeString("gopher://host/path?", withUmlauts, "#fragment"), "asdf://example.com/?doesntmatter", &iso88591, {"gopher", "", "", "host", 0, "/path", "%DC%26%231072%3B%26%231105%3B", "fragment", "gopher://host/path?%DC%26%231072%3B%26%231105%3B#fragment"});
+    checkURL(makeString("asdf://host/path?", withUmlauts, "#fragment"), "http://example.com/?doesntmatter", &iso88591, {"asdf", "", "", "host", 0, "/path", "%C3%9C%D0%B0%D1%91", "fragment", "asdf://host/path?%C3%9C%D0%B0%D1%91#fragment"});
+
+    checkURL("http://host/pa'th?qu'ery#fr'agment", nullptr, {"http", "", "", "host", 0, "/pa'th", "qu%27ery", "fr'agment", "http://host/pa'th?qu%27ery#fr'agment"});
+    checkURL("asdf://host/pa'th?qu'ery#fr'agment", nullptr, {"asdf", "", "", "host", 0, "/pa'th", "qu'ery", "fr'agment", "asdf://host/pa'th?qu'ery#fr'agment"});
+    // FIXME: Add more tests with other encodings and things like non-ascii characters, emoji and unmatched surrogate pairs.
+}
+
+} // namespace TestWebKitAPI