WebKit Bugzilla
Attachment 356293 Details for
Bug 192275
: Move URL tests from TestWebKitAPI to TestWTF
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-192275-20181201151328.patch (text/plain), 282.13 KB, created by
Yusuke Suzuki
on 2018-11-30 22:13:29 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2018-11-30 22:13:29 PST
Size:
282.13 KB
patch
obsolete
>Subversion Revision: 238775 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 1e28529899f1da8ec136a49c593671b5b18e1c5c..3812b0be3d0f73cb20c5478534e6efdfc9490814 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,33 @@ >+2018-11-30 Yusuke Suzuki <yusukesuzuki@slowstart.org> >+ >+ Move URL tests from TestWebKitAPI to TestWTF >+ https://bugs.webkit.org/show_bug.cgi?id=192275 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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 Alex Christensen <achristensen@webkit.org> > > Move URL from WebCore to WTF >diff --git a/Tools/TestWebKitAPI/CMakeLists.txt b/Tools/TestWebKitAPI/CMakeLists.txt >index 0f3255824b88a603201793d7b8939a51aa3ee7f3..b24900898b3fc5af89c4903380c3fd7c1dc0d705 100644 >--- a/Tools/TestWebKitAPI/CMakeLists.txt >+++ b/Tools/TestWebKitAPI/CMakeLists.txt >@@ -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 >diff --git a/Tools/TestWebKitAPI/PlatformGTK.cmake b/Tools/TestWebKitAPI/PlatformGTK.cmake >index ce94178eed40879ee5cd68d1c51130db90e75d21..84499de398b25d25ac0c93602aaad1d690d3de8a 100644 >--- a/Tools/TestWebKitAPI/PlatformGTK.cmake >+++ b/Tools/TestWebKitAPI/PlatformGTK.cmake >@@ -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}) >diff --git a/Tools/TestWebKitAPI/PlatformWPE.cmake b/Tools/TestWebKitAPI/PlatformWPE.cmake >index d405f66a5d61a87c4770ab2bc4aff76410e0a96b..fb1b6b52a3563880a52f685588c2e1fbbeabd9e1 100644 >--- a/Tools/TestWebKitAPI/PlatformWPE.cmake >+++ b/Tools/TestWebKitAPI/PlatformWPE.cmake >@@ -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}) >diff --git a/Tools/TestWebKitAPI/PlatformWin.cmake b/Tools/TestWebKitAPI/PlatformWin.cmake >index f63d7a1651e0089553a841dccdeb90515acbb8e6..4fbcbc4b5891e0f1ef4fdd76877836fd8c6526b5 100644 >--- a/Tools/TestWebKitAPI/PlatformWin.cmake >+++ b/Tools/TestWebKitAPI/PlatformWin.cmake >@@ -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 > ) >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index 8e2a4e3ca0f6f1d3595830013db6e09d54533482..010376f9bb44824b78886e0ef76aa00535c6eeb5 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -284,7 +284,6 @@ > 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 */; }; >@@ -455,7 +454,6 @@ > 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 */; }; >@@ -499,7 +497,6 @@ > 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 */; }; >@@ -800,6 +797,10 @@ > 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 */; }; >@@ -1481,7 +1482,6 @@ > 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>"; }; >@@ -1623,7 +1623,6 @@ > 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>"; }; >@@ -1784,7 +1783,6 @@ > 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>"; }; >@@ -2085,6 +2083,10 @@ > 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>"; }; >@@ -2643,8 +2645,7 @@ > 93A258981F92FF15003E510C /* TextCodec.cpp */, > CDC2C7141797089D00E627FB /* TimeRanges.cpp */, > 7AD3FE8D1D75FB8D00B169A4 /* TransformationMatrix.cpp */, >- 440A1D3814A0103A008A66F2 /* URL.cpp */, >- 5C6E65411D5CEF8500F7862E /* URLParser.cpp */, >+ E3A1E77E21B25B39008C6007 /* URLParserTextEncoding.cpp */, > 9C64DC311D76198A004B598E /* YouTubePluginReplacement.cpp */, > ); > path = WebCore; >@@ -3104,6 +3105,7 @@ > isa = PBXGroup; > children = ( > C0991C4F143C7D68007998F2 /* cf */, >+ E3C21A7821B25C82003B31A3 /* cocoa */, > 7CBBA07519BB8A0900BBF025 /* darwin */, > BC029B1A1486B23800817DA9 /* ns */, > 26F1B44215CA434F00D1E4BF /* AtomicString.cpp */, >@@ -3181,6 +3183,8 @@ > 0F2C20B71DCD544800542D9E /* Time.cpp */, > E398BC0F2041C76300387136 /* UniqueArray.cpp */, > 5C5E633D1D0B67940085A025 /* UniqueRef.cpp */, >+ E3A1E78021B25B79008C6007 /* URL.cpp */, >+ E3A1E78421B25B91008C6007 /* URLParser.cpp */, > 7CD0D5AA1D5534DE000CC9E1 /* Variant.cpp */, > BC55F5F814AD78EE00484BE1 /* Vector.cpp */, > 1CB9BC371A67482300FE5678 /* WeakPtr.cpp */, >@@ -3483,7 +3487,6 @@ > 751B05D51F8EAC1A0028A09E /* DatabaseTrackerTest.mm */, > 5769C50A1D9B0001000847FB /* SerializedCryptoKeyWrap.mm */, > A17991861E1C994E00A505ED /* SharedBuffer.mm */, >- 93A7EB3C18FA63A4009E7670 /* URLExtras.mm */, > CD89D0381C4EDB2A00040A04 /* WebCoreNSURLSession.mm */, > ); > path = cocoa; >@@ -3523,6 +3526,14 @@ > name = Resources; > sourceTree = "<group>"; > }; >+ E3C21A7821B25C82003B31A3 /* cocoa */ = { >+ isa = PBXGroup; >+ children = ( >+ E3C21A7B21B25CA2003B31A3 /* URLExtras.mm */, >+ ); >+ path = cocoa; >+ sourceTree = "<group>"; >+ }; > /* End PBXGroup section */ > > /* Begin PBXNativeTarget section */ >@@ -3766,6 +3777,9 @@ > 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 */, >@@ -4139,9 +4153,7 @@ > 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 */, >diff --git a/Tools/TestWebKitAPI/Tests/WTF/URL.cpp b/Tools/TestWebKitAPI/Tests/WTF/URL.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..937b9f940bf9113fce3723faf0c5e5bf6b1c87de >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WTF/URL.cpp >@@ -0,0 +1,401 @@ >+/* >+ * Copyright (C) 2011, 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" >+#include "WTFStringUtilities.h" >+#include <wtf/MainThread.h> >+#include <wtf/URL.h> >+#include <wtf/URLParser.h> >+ >+namespace TestWebKitAPI { >+ >+class WTF_URL : public testing::Test { >+public: >+ virtual void SetUp() >+ { >+ WTF::initializeMainThread(); >+ } >+}; >+ >+TEST_F(WTF_URL, URLConstructorDefault) >+{ >+ URL kurl; >+ >+ EXPECT_TRUE(kurl.isEmpty()); >+ EXPECT_TRUE(kurl.isNull()); >+ EXPECT_FALSE(kurl.isValid()); >+} >+ >+TEST_F(WTF_URL, URLConstructorConstChar) >+{ >+ URL kurl({ }, "http://username:password@www.example.com:8080/index.html?var=val#fragment"); >+ >+ EXPECT_FALSE(kurl.isEmpty()); >+ EXPECT_FALSE(kurl.isNull()); >+ EXPECT_TRUE(kurl.isValid()); >+ >+ EXPECT_EQ(kurl.protocol() == "http", true); >+ EXPECT_EQ(String("www.example.com"), kurl.host().toString()); >+ EXPECT_TRUE(!!kurl.port()); >+ EXPECT_EQ(8080, kurl.port().value()); >+ EXPECT_EQ(String("username"), kurl.user()); >+ EXPECT_EQ(String("password"), kurl.pass()); >+ EXPECT_EQ(String("/index.html"), kurl.path()); >+ EXPECT_EQ(String("index.html"), kurl.lastPathComponent()); >+ EXPECT_EQ(String("var=val"), kurl.query()); >+ EXPECT_TRUE(kurl.hasFragmentIdentifier()); >+ EXPECT_EQ(String("fragment"), kurl.fragmentIdentifier()); >+} >+ >+static URL createURL(const char* urlAsString) >+{ >+ return URL({ }, urlAsString); >+}; >+ >+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()); >+ >+ url = createURL("http://username:@www.example.com:8080/index.html?var=val#fragment"); >+ EXPECT_EQ(String("http://www.example.com:8080"), url.protocolHostAndPort()); >+ >+ url = createURL("http://:password@www.example.com:8080/index.html?var=val#fragment"); >+ EXPECT_EQ(String("http://www.example.com:8080"), url.protocolHostAndPort()); >+ >+ url = createURL("http://username@www.example.com:8080/index.html?var=val#fragment"); >+ EXPECT_EQ(String("http://www.example.com:8080"), url.protocolHostAndPort()); >+ >+ url = createURL("http://www.example.com:8080/index.html?var=val#fragment"); >+ EXPECT_EQ(String("http://www.example.com:8080"), url.protocolHostAndPort()); >+ >+ url = createURL("http://www.example.com:/index.html?var=val#fragment"); >+ EXPECT_EQ(String("http://www.example.com"), url.protocolHostAndPort()); >+ >+ url = createURL("http://www.example.com/index.html?var=val#fragment"); >+ EXPECT_EQ(String("http://www.example.com"), url.protocolHostAndPort()); >+ >+ url = createURL("file:///a/b/c"); >+ EXPECT_EQ(String("file://"), url.protocolHostAndPort()); >+ >+ url = createURL("file:///a/b"); >+ EXPECT_EQ(String("file://"), url.protocolHostAndPort()); >+ >+ url = createURL("file:///a"); >+ EXPECT_EQ(String("file://"), url.protocolHostAndPort()); >+ >+ url = createURL("file:///a"); >+ EXPECT_EQ(String("file://"), url.protocolHostAndPort()); >+ >+ url = createURL("asdf://username:password@www.example.com:8080/index.html?var=val#fragment"); >+ EXPECT_EQ(String("asdf://www.example.com:8080"), url.protocolHostAndPort()); >+ >+ url = createURL("asdf:///a/b/c"); >+ EXPECT_EQ(String("asdf://"), url.protocolHostAndPort()); >+} >+ >+TEST_F(WTF_URL, URLDataURIStringSharing) >+{ >+ URL baseURL({ }, "http://www.webkit.org/"); >+ String threeApples = "data:text/plain;charset=utf-8;base64,76O/76O/76O/"; >+ >+ URL url(baseURL, threeApples); >+ EXPECT_EQ(threeApples.impl(), url.string().impl()); >+} >+ >+TEST_F(WTF_URL, URLSetQuery) >+{ >+ URL url = createURL("http://www.webkit.org/?test"); >+ URL url1 = createURL("http://www.webkit.org/"); >+ URL url2 = createURL("http://www.webkit.org/?"); >+ URL url3 = createURL("http://www.webkit.org/?test"); >+ URL url4 = createURL("http://www.webkit.org/?test1"); >+ >+ url1.setQuery("test"); >+ url2.setQuery("test"); >+ url3.setQuery("test"); >+ url4.setQuery("test"); >+ >+ EXPECT_EQ(url.string(), url1.string()); >+ EXPECT_EQ(url.string(), url2.string()); >+ EXPECT_EQ(url.string(), url3.string()); >+ EXPECT_EQ(url.string(), url4.string()); >+ >+ URL urlWithFragmentIdentifier = createURL("http://www.webkit.org/?test%C3%83%C2%A5#newFragment"); >+ URL urlWithFragmentIdentifier1 = createURL("http://www.webkit.org/#newFragment"); >+ URL urlWithFragmentIdentifier2 = createURL("http://www.webkit.org/?#newFragment"); >+ URL urlWithFragmentIdentifier3 = createURL("http://www.webkit.org/?test1#newFragment"); >+ >+ urlWithFragmentIdentifier1.setQuery("test\xc3\xa5"); >+ urlWithFragmentIdentifier2.setQuery("test\xc3\xa5"); >+ urlWithFragmentIdentifier3.setQuery("test\xc3\xa5"); >+ >+ EXPECT_EQ(urlWithFragmentIdentifier.string(), urlWithFragmentIdentifier1.string()); >+ EXPECT_EQ(urlWithFragmentIdentifier.string(), urlWithFragmentIdentifier2.string()); >+ EXPECT_EQ(urlWithFragmentIdentifier.string(), urlWithFragmentIdentifier3.string()); >+} >+ >+TEST_F(WTF_URL, URLSetFragmentIdentifier) >+{ >+ URL url = createURL("http://www.webkit.org/#newFragment%C3%83%C2%A5"); >+ URL url1 = createURL("http://www.webkit.org/"); >+ URL url2 = createURL("http://www.webkit.org/#test2"); >+ URL url3 = createURL("http://www.webkit.org/#"); >+ >+ url1.setFragmentIdentifier("newFragment\xc3\xa5"); >+ url2.setFragmentIdentifier("newFragment\xc3\xa5"); >+ url3.setFragmentIdentifier("newFragment\xc3\xa5"); >+ >+ EXPECT_EQ(url.string(), url1.string()); >+ EXPECT_EQ(url.string(), url2.string()); >+ EXPECT_EQ(url.string(), url3.string()); >+ >+ URL urlWithQuery = createURL("http://www.webkit.org/?test1#newFragment"); >+ URL urlWithQuery1 = createURL("http://www.webkit.org/?test1"); >+ URL urlWithQuery2 = createURL("http://www.webkit.org/?test1#"); >+ URL urlWithQuery3 = createURL("http://www.webkit.org/?test1#test2"); >+ >+ urlWithQuery1.setFragmentIdentifier("newFragment"); >+ urlWithQuery2.setFragmentIdentifier("newFragment"); >+ urlWithQuery3.setFragmentIdentifier("newFragment"); >+ >+ EXPECT_EQ(urlWithQuery.string(), urlWithQuery1.string()); >+ EXPECT_EQ(urlWithQuery.string(), urlWithQuery2.string()); >+ EXPECT_EQ(urlWithQuery.string(), urlWithQuery3.string()); >+} >+ >+TEST_F(WTF_URL, URLRemoveQueryAndFragmentIdentifier) >+{ >+ URL url = createURL("http://www.webkit.org/"); >+ URL url1 = createURL("http://www.webkit.org/?"); >+ URL url2 = createURL("http://www.webkit.org/?test1"); >+ URL url3 = createURL("http://www.webkit.org/?test1#test2"); >+ URL url4 = createURL("http://www.webkit.org/#test2"); >+ URL url5 = createURL("http://www.webkit.org/#"); >+ >+ url.removeQueryAndFragmentIdentifier(); >+ url1.removeQueryAndFragmentIdentifier(); >+ url2.removeQueryAndFragmentIdentifier(); >+ url3.removeQueryAndFragmentIdentifier(); >+ url4.removeQueryAndFragmentIdentifier(); >+ url5.removeQueryAndFragmentIdentifier(); >+ >+ EXPECT_EQ(url.string(), url.string()); >+ EXPECT_EQ(url.string(), url1.string()); >+ EXPECT_EQ(url.string(), url2.string()); >+ EXPECT_EQ(url.string(), url3.string()); >+ EXPECT_EQ(url.string(), url4.string()); >+ EXPECT_EQ(url.string(), url5.string()); >+} >+ >+TEST_F(WTF_URL, EqualIgnoringFragmentIdentifier) >+{ >+ struct TestCase { >+ const char* url1; >+ const char* url2; >+ bool expected; >+ } cases[] = { >+ {"http://example.com/", "http://example.com/", true}, >+ {"http://example.com/#hash", "http://example.com/", true}, >+ {"http://example.com/path", "http://example.com/", false}, >+ {"http://example.com/path", "http://example.com/path", true}, >+ {"http://example.com/path#hash", "http://example.com/path", true}, >+ {"http://example.com/path?query", "http://example.com/path", false}, >+ {"http://example.com/path?query#hash", "http://example.com/path", false}, >+ {"http://example.com/otherpath", "http://example.com/path", false}, >+ {"http://example.com:80/", "http://example.com/", true}, >+ {"http://example.com:80/#hash", "http://example.com/", true}, >+ {"http://example.com:80/path", "http://example.com/", false}, >+ {"http://example.com:80/path#hash", "http://example.com/path", true}, >+ {"http://example.com:80/path?query", "http://example.com/path", false}, >+ {"http://example.com:80/path?query#hash", "http://example.com/path", false}, >+ {"http://example.com:80/otherpath", "http://example.com/path", false}, >+ {"http://not-example.com:80/", "http://example.com/", false}, >+ {"http://example.com:81/", "http://example.com/", false}, >+ {"http://example.com:81/#hash", "http://example.com:81/", true}, >+ {"http://example.com:81/path", "http://example.com:81", false}, >+ {"http://example.com:81/path#hash", "http://example.com:81/path", true}, >+ {"http://example.com:81/path?query", "http://example.com:81/path", false}, >+ {"http://example.com:81/path?query#hash", "http://example.com:81/path", false}, >+ {"http://example.com:81/otherpath", "http://example.com:81/path", false}, >+ {"file:///path/to/file.html", "file:///path/to/file.html", true}, >+ {"file:///path/to/file.html#hash", "file:///path/to/file.html", true}, >+ {"file:///path/to/file.html?query", "file:///path/to/file.html", false}, >+ {"file:///path/to/file.html?query#hash", "file:///path/to/file.html", false}, >+ {"file:///path/to/other_file.html", "file:///path/to/file.html", false}, >+ {"file:///path/to/other/file.html", "file:///path/to/file.html", false}, >+ {"data:text/plain;charset=utf-8;base64,76O/76O/76O/", "data:text/plain;charset=utf-8;base64,760/760/760/", false}, >+ {"http://example.com", "file://example.com", false}, >+ {"http://example.com/#hash", "file://example.com", false}, >+ {"http://example.com/?query", "file://example.com/", false}, >+ {"http://example.com/?query#hash", "file://example.com/", false}, >+ }; >+ >+ for (const auto& test : cases) { >+ URL url1 = createURL(test.url1); >+ URL url2 = createURL(test.url2); >+ EXPECT_EQ(test.expected, equalIgnoringFragmentIdentifier(url1, url2)) >+ << "Test failed for " << test.url1 << " vs. " << test.url2; >+ } >+} >+ >+TEST_F(WTF_URL, EqualIgnoringQueryAndFragment) >+{ >+ struct TestCase { >+ const char* url1; >+ const char* url2; >+ bool expected; >+ } cases[] = { >+ {"http://example.com/", "http://example.com/", true}, >+ {"http://example.com/#hash", "http://example.com/", true}, >+ {"http://example.com/path", "http://example.com/", false}, >+ {"http://example.com/path", "http://example.com/path", true}, >+ {"http://example.com/path#hash", "http://example.com/path", true}, >+ {"http://example.com/path?query", "http://example.com/path", true}, >+ {"http://example.com/path?query#hash", "http://example.com/path", true}, >+ {"http://example.com/otherpath", "http://example.com/path", false}, >+ {"http://example.com:80/", "http://example.com/", true}, >+ {"http://example.com:80/#hash", "http://example.com/", true}, >+ {"http://example.com:80/path", "http://example.com/", false}, >+ {"http://example.com:80/path#hash", "http://example.com/path", true}, >+ {"http://example.com:80/path?query", "http://example.com/path", true}, >+ {"http://example.com:80/path?query#hash", "http://example.com/path", true}, >+ {"http://example.com:80/otherpath", "http://example.com/path", false}, >+ {"http://not-example.com:80/", "http://example.com:80/", false}, >+ {"http://example.com:81/", "http://example.com/", false}, >+ {"http://example.com:81/#hash", "http://example.com:81/", true}, >+ {"http://example.com:81/path", "http://example.com:81", false}, >+ {"http://example.com:81/path#hash", "http://example.com:81/path", true}, >+ {"http://example.com:81/path?query", "http://example.com:81/path", true}, >+ {"http://example.com:81/path?query#hash", "http://example.com:81/path", true}, >+ {"http://example.com:81/otherpath", "http://example.com:81/path", false}, >+ {"file:///path/to/file.html", "file:///path/to/file.html", true}, >+ {"file:///path/to/file.html#hash", "file:///path/to/file.html", true}, >+ {"file:///path/to/file.html?query", "file:///path/to/file.html", true}, >+ {"file:///path/to/file.html?query#hash", "file:///path/to/file.html", true}, >+ {"file:///path/to/other_file.html", "file:///path/to/file.html", false}, >+ {"file:///path/to/other/file.html", "file:///path/to/file.html", false}, >+ {"data:text/plain;charset=utf-8;base64,76O/76O/76O/", "data:text/plain;charset=utf-8;base64,760/760/760/", false}, >+ {"http://example.com", "file://example.com", false}, >+ {"http://example.com/#hash", "file://example.com", false}, >+ {"http://example.com/?query", "file://example.com/", false}, >+ {"http://example.com/?query#hash", "file://example.com/", false}, >+ }; >+ >+ for (const auto& test : cases) { >+ URL url1 = createURL(test.url1); >+ URL url2 = createURL(test.url2); >+ EXPECT_EQ(test.expected, equalIgnoringQueryAndFragment(url1, url2)) >+ << "Test failed for " << test.url1 << " vs. " << test.url2; >+ } >+} >+ >+TEST_F(WTF_URL, ProtocolIsInHTTPFamily) >+{ >+ EXPECT_FALSE(WTF::protocolIsInHTTPFamily({ })); >+ EXPECT_FALSE(WTF::protocolIsInHTTPFamily("")); >+ EXPECT_FALSE(WTF::protocolIsInHTTPFamily("a")); >+ EXPECT_FALSE(WTF::protocolIsInHTTPFamily("ab")); >+ EXPECT_FALSE(WTF::protocolIsInHTTPFamily("abc")); >+ EXPECT_FALSE(WTF::protocolIsInHTTPFamily("abcd")); >+ EXPECT_FALSE(WTF::protocolIsInHTTPFamily("abcde")); >+ EXPECT_FALSE(WTF::protocolIsInHTTPFamily("abcdef")); >+ EXPECT_FALSE(WTF::protocolIsInHTTPFamily("abcdefg")); >+ EXPECT_TRUE(WTF::protocolIsInHTTPFamily("http:")); >+ EXPECT_FALSE(WTF::protocolIsInHTTPFamily("http")); >+ EXPECT_TRUE(WTF::protocolIsInHTTPFamily("https:")); >+ EXPECT_FALSE(WTF::protocolIsInHTTPFamily("https")); >+ EXPECT_TRUE(WTF::protocolIsInHTTPFamily("https://!@#$%^&*()")); >+} >+ >+TEST_F(WTF_URL, HostIsIPAddress) >+{ >+ EXPECT_FALSE(URL::hostIsIPAddress({ })); >+ EXPECT_FALSE(URL::hostIsIPAddress("")); >+ EXPECT_FALSE(URL::hostIsIPAddress("localhost")); >+ EXPECT_FALSE(URL::hostIsIPAddress("127.localhost")); >+ EXPECT_FALSE(URL::hostIsIPAddress("localhost.127")); >+ EXPECT_FALSE(URL::hostIsIPAddress("127.0.0")); >+ EXPECT_FALSE(URL::hostIsIPAddress("127.0 .0.1")); >+ EXPECT_FALSE(URL::hostIsIPAddress(" 127.0.0.1")); >+ EXPECT_FALSE(URL::hostIsIPAddress("127..0.0.1")); >+ EXPECT_FALSE(URL::hostIsIPAddress("127.0.0.")); >+ EXPECT_FALSE(URL::hostIsIPAddress("256.0.0.1")); >+ EXPECT_FALSE(URL::hostIsIPAddress("0123:4567:89AB:cdef:3210:7654:ba98")); >+ EXPECT_FALSE(URL::hostIsIPAddress("012x:4567:89AB:cdef:3210:7654:ba98:FeDc")); >+#if !PLATFORM(COCOA) >+ // FIXME: This fails in Mac. >+ EXPECT_FALSE(URL::hostIsIPAddress("127.0.0.01")); >+ EXPECT_FALSE(URL::hostIsIPAddress("00123:4567:89AB:cdef:3210:7654:ba98:FeDc")); >+#endif >+ EXPECT_FALSE(URL::hostIsIPAddress("0123:4567:89AB:cdef:3210:123.45.67.89")); >+ EXPECT_FALSE(URL::hostIsIPAddress(":::")); >+ EXPECT_FALSE(URL::hostIsIPAddress("0123::89AB:cdef:3210:7654::FeDc")); >+ EXPECT_FALSE(URL::hostIsIPAddress("0123:4567:89AB:cdef:3210:7654:ba98:")); >+ EXPECT_FALSE(URL::hostIsIPAddress("0123:4567:89AB:cdef:3210:7654:ba98:FeDc:")); >+ EXPECT_FALSE(URL::hostIsIPAddress(":4567:89AB:cdef:3210:7654:ba98:FeDc")); >+ EXPECT_FALSE(URL::hostIsIPAddress(":0123:4567:89AB:cdef:3210:7654:ba98:FeDc")); >+ >+ EXPECT_TRUE(URL::hostIsIPAddress("127.0.0.1")); >+ EXPECT_TRUE(URL::hostIsIPAddress("255.1.10.100")); >+ EXPECT_TRUE(URL::hostIsIPAddress("0.0.0.0")); >+ EXPECT_TRUE(URL::hostIsIPAddress("::1")); >+ EXPECT_TRUE(URL::hostIsIPAddress("::")); >+ EXPECT_TRUE(URL::hostIsIPAddress("0123:4567:89AB:cdef:3210:7654:ba98:FeDc")); >+ EXPECT_TRUE(URL::hostIsIPAddress("0123:4567:89AB:cdef:3210:7654:ba98::")); >+ EXPECT_TRUE(URL::hostIsIPAddress("::4567:89AB:cdef:3210:7654:ba98:FeDc")); >+ EXPECT_TRUE(URL::hostIsIPAddress("0123:4567:89AB:cdef:3210:7654:123.45.67.89")); >+ EXPECT_TRUE(URL::hostIsIPAddress("::123.45.67.89")); >+} >+ >+TEST_F(WTF_URL, HostIsMatchingDomain) >+{ >+ URL url = createURL("http://www.webkit.org"); >+ >+ EXPECT_TRUE(url.isMatchingDomain(String { })); >+ EXPECT_TRUE(url.isMatchingDomain(emptyString())); >+ EXPECT_TRUE(url.isMatchingDomain("org"_s)); >+ EXPECT_TRUE(url.isMatchingDomain("webkit.org"_s)); >+ EXPECT_TRUE(url.isMatchingDomain("www.webkit.org"_s)); >+ >+ EXPECT_FALSE(url.isMatchingDomain("rg"_s)); >+ EXPECT_FALSE(url.isMatchingDomain(".org"_s)); >+ EXPECT_FALSE(url.isMatchingDomain("ww.webkit.org"_s)); >+ EXPECT_FALSE(url.isMatchingDomain("http://www.webkit.org"_s)); >+ >+ url = createURL("file:///www.webkit.org"); >+ >+ EXPECT_TRUE(url.isMatchingDomain(String { })); >+ EXPECT_TRUE(url.isMatchingDomain(emptyString())); >+ EXPECT_FALSE(url.isMatchingDomain("org"_s)); >+ EXPECT_FALSE(url.isMatchingDomain("webkit.org"_s)); >+ EXPECT_FALSE(url.isMatchingDomain("www.webkit.org"_s)); >+ >+ URL emptyURL; >+ EXPECT_FALSE(emptyURL.isMatchingDomain(String { })); >+ EXPECT_FALSE(emptyURL.isMatchingDomain(emptyString())); >+} >+ >+} // namespace TestWebKitAPI >diff --git a/Tools/TestWebKitAPI/Tests/WTF/URLParser.cpp b/Tools/TestWebKitAPI/Tests/WTF/URLParser.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..f8085d02dfe92aededadce5e57b941f6cd71a2d0 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WTF/URLParser.cpp >@@ -0,0 +1,1271 @@ >+/* >+ * 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 <wtf/MainThread.h> >+#include <wtf/URLParser.h> >+#include <wtf/text/StringBuilder.h> >+ >+namespace TestWebKitAPI { >+ >+class WTF_URLParser : 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 ExpectedParts& parts, TestTabs testTabs = TestTabs::Yes) >+{ >+ auto url = URL(URL(), urlString); >+ >+ 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())); >+ >+ EXPECT_TRUE(WTF::URLParser::internalValuesConsistent(url)); >+ >+ if (testTabs == TestTabs::No) >+ return; >+ >+ for (size_t i = 0; i < urlString.length(); ++i) { >+ String urlStringWithTab = insertTabAtLocation(urlString, i); >+ checkURL(urlStringWithTab, >+ parts.isInvalid() ? invalidParts(urlStringWithTab) : parts, >+ TestTabs::No); >+ } >+} >+ >+static void checkRelativeURL(const String& urlString, const String& baseURLString, const ExpectedParts& parts, TestTabs testTabs = TestTabs::Yes) >+{ >+ auto url = URL(URL(URL(), baseURLString), urlString); >+ >+ 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())); >+ >+ EXPECT_TRUE(WTF::URLParser::internalValuesConsistent(url)); >+ >+ if (testTabs == TestTabs::No) >+ return; >+ >+ for (size_t i = 0; i < urlString.length(); ++i) { >+ String urlStringWithTab = insertTabAtLocation(urlString, i); >+ checkRelativeURL(urlStringWithTab, >+ baseURLString, >+ parts.isInvalid() ? invalidParts(urlStringWithTab) : parts, >+ TestTabs::No); >+ } >+} >+ >+static void checkURLDifferences(const String& urlString, const ExpectedParts& partsNew, const ExpectedParts& partsOld, TestTabs testTabs = TestTabs::Yes) >+{ >+ UNUSED_PARAM(partsOld); // FIXME: Remove all the old expected parts. >+ auto url = URL(URL(), urlString); >+ >+ EXPECT_TRUE(eq(partsNew.protocol, url.protocol())); >+ EXPECT_TRUE(eq(partsNew.user, url.user())); >+ EXPECT_TRUE(eq(partsNew.password, url.pass())); >+ EXPECT_TRUE(eq(partsNew.host, url.host())); >+ EXPECT_EQ(partsNew.port, url.port().value_or(0)); >+ EXPECT_TRUE(eq(partsNew.path, url.path())); >+ EXPECT_TRUE(eq(partsNew.query, url.query())); >+ EXPECT_TRUE(eq(partsNew.fragment, url.fragmentIdentifier())); >+ EXPECT_TRUE(eq(partsNew.string, url.string())); >+ >+ EXPECT_TRUE(WTF::URLParser::internalValuesConsistent(url)); >+ >+ if (testTabs == TestTabs::No) >+ return; >+ >+ for (size_t i = 0; i < urlString.length(); ++i) { >+ String urlStringWithTab = insertTabAtLocation(urlString, i); >+ checkURLDifferences(urlStringWithTab, >+ partsNew.isInvalid() ? invalidParts(urlStringWithTab) : partsNew, >+ partsOld.isInvalid() ? invalidParts(urlStringWithTab) : partsOld, >+ TestTabs::No); >+ } >+} >+ >+static void checkRelativeURLDifferences(const String& urlString, const String& baseURLString, const ExpectedParts& partsNew, const ExpectedParts& partsOld, TestTabs testTabs = TestTabs::Yes) >+{ >+ UNUSED_PARAM(partsOld); // FIXME: Remove all the old expected parts. >+ auto url = URL(URL(URL(), baseURLString), urlString); >+ >+ EXPECT_TRUE(eq(partsNew.protocol, url.protocol())); >+ EXPECT_TRUE(eq(partsNew.user, url.user())); >+ EXPECT_TRUE(eq(partsNew.password, url.pass())); >+ EXPECT_TRUE(eq(partsNew.host, url.host())); >+ EXPECT_EQ(partsNew.port, url.port().value_or(0)); >+ EXPECT_TRUE(eq(partsNew.path, url.path())); >+ EXPECT_TRUE(eq(partsNew.query, url.query())); >+ EXPECT_TRUE(eq(partsNew.fragment, url.fragmentIdentifier())); >+ EXPECT_TRUE(eq(partsNew.string, url.string())); >+ >+ EXPECT_TRUE(WTF::URLParser::internalValuesConsistent(url)); >+ >+ if (testTabs == TestTabs::No) >+ return; >+ >+ for (size_t i = 0; i < urlString.length(); ++i) { >+ String urlStringWithTab = insertTabAtLocation(urlString, i); >+ checkRelativeURLDifferences(urlStringWithTab, baseURLString, >+ partsNew.isInvalid() ? invalidParts(urlStringWithTab) : partsNew, >+ partsOld.isInvalid() ? invalidParts(urlStringWithTab) : partsOld, >+ TestTabs::No); >+ } >+} >+ >+static void shouldFail(const String& urlString) >+{ >+ checkURL(urlString, {"", "", "", "", 0, "", "", "", urlString}); >+} >+ >+static void shouldFail(const String& urlString, const String& baseString) >+{ >+ checkRelativeURL(urlString, baseString, {"", "", "", "", 0, "", "", "", urlString}); >+} >+ >+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"}); >+ checkURL("http://user:pass@webkit.org:123/path", {"http", "user", "pass", "webkit.org", 123, "/path", "", "", "http://user:pass@webkit.org:123/path"}); >+ checkURL("http://user:pass@webkit.org:123/", {"http", "user", "pass", "webkit.org", 123, "/", "", "", "http://user:pass@webkit.org:123/"}); >+ checkURL("http://user:pass@webkit.org:123", {"http", "user", "pass", "webkit.org", 123, "/", "", "", "http://user:pass@webkit.org:123/"}); >+ checkURL("http://user:pass@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"}); >+ checkURL("http://user:\t\t\tpass@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"}); >+ checkURL("http://us\ter:pass@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"}); >+ checkURL("http://user:pa\tss@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"}); >+ checkURL("http://user:pass\t@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"}); >+ checkURL("http://\tuser:pass@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"}); >+ checkURL("http://user\t:pass@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"}); >+ checkURL("http://webkit.org", {"http", "", "", "webkit.org", 0, "/", "", "", "http://webkit.org/"}); >+ checkURL("http://127.0.0.1", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}); >+ checkURL("http://webkit.org/", {"http", "", "", "webkit.org", 0, "/", "", "", "http://webkit.org/"}); >+ checkURL("http://webkit.org/path1/path2/index.html", {"http", "", "", "webkit.org", 0, "/path1/path2/index.html", "", "", "http://webkit.org/path1/path2/index.html"}); >+ checkURL("about:blank", {"about", "", "", "", 0, "blank", "", "", "about:blank"}); >+ checkURL("about:blank?query", {"about", "", "", "", 0, "blank", "query", "", "about:blank?query"}); >+ checkURL("about:blank#fragment", {"about", "", "", "", 0, "blank", "", "fragment", "about:blank#fragment"}); >+ checkURL("http://[0:f::f:f:0:0]", {"http", "", "", "[0:f::f:f:0:0]", 0, "/", "", "", "http://[0:f::f:f:0:0]/"}); >+ checkURL("http://[0:f:0:0:f::]", {"http", "", "", "[0:f:0:0:f::]", 0, "/", "", "", "http://[0:f:0:0:f::]/"}); >+ checkURL("http://[::f:0:0:f:0:0]", {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"}); >+ checkURL("http://[0:f:0:0:f::]:", {"http", "", "", "[0:f:0:0:f::]", 0, "/", "", "", "http://[0:f:0:0:f::]/"}); >+ checkURL("http://[0:f:0:0:f::]:\t", {"http", "", "", "[0:f:0:0:f::]", 0, "/", "", "", "http://[0:f:0:0:f::]/"}); >+ checkURL("http://[0:f:0:0:f::]\t:", {"http", "", "", "[0:f:0:0:f::]", 0, "/", "", "", "http://[0:f:0:0:f::]/"}); >+ checkURL("http://\t[::f:0:0:f:0:0]", {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"}); >+ checkURL("http://[\t::f:0:0:f:0:0]", {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"}); >+ checkURL("http://[:\t:f:0:0:f:0:0]", {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"}); >+ checkURL("http://[::\tf:0:0:f:0:0]", {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"}); >+ checkURL("http://[::f\t:0:0:f:0:0]", {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"}); >+ checkURL("http://[::f:\t0:0:f:0:0]", {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"}); >+ checkURL("http://example.com/path1/path2/.", {"http", "", "", "example.com", 0, "/path1/path2/", "", "", "http://example.com/path1/path2/"}); >+ checkURL("http://example.com/path1/path2/..", {"http", "", "", "example.com", 0, "/path1/", "", "", "http://example.com/path1/"}); >+ checkURL("http://example.com/path1/path2/./path3", {"http", "", "", "example.com", 0, "/path1/path2/path3", "", "", "http://example.com/path1/path2/path3"}); >+ checkURL("http://example.com/path1/path2/.\\path3", {"http", "", "", "example.com", 0, "/path1/path2/path3", "", "", "http://example.com/path1/path2/path3"}); >+ checkURL("http://example.com/path1/path2/../path3", {"http", "", "", "example.com", 0, "/path1/path3", "", "", "http://example.com/path1/path3"}); >+ checkURL("http://example.com/path1/path2/..\\path3", {"http", "", "", "example.com", 0, "/path1/path3", "", "", "http://example.com/path1/path3"}); >+ checkURL("http://example.com/.", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >+ checkURL("http://example.com/..", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >+ checkURL("http://example.com/./path1", {"http", "", "", "example.com", 0, "/path1", "", "", "http://example.com/path1"}); >+ checkURL("http://example.com/../path1", {"http", "", "", "example.com", 0, "/path1", "", "", "http://example.com/path1"}); >+ checkURL("http://example.com/../path1/../../path2/path3/../path4", {"http", "", "", "example.com", 0, "/path2/path4", "", "", "http://example.com/path2/path4"}); >+ checkURL("http://example.com/path1/.%2", {"http", "", "", "example.com", 0, "/path1/.%2", "", "", "http://example.com/path1/.%2"}); >+ checkURL("http://example.com/path1/%2", {"http", "", "", "example.com", 0, "/path1/%2", "", "", "http://example.com/path1/%2"}); >+ checkURL("http://example.com/path1/%", {"http", "", "", "example.com", 0, "/path1/%", "", "", "http://example.com/path1/%"}); >+ checkURL("http://example.com/path1/.%", {"http", "", "", "example.com", 0, "/path1/.%", "", "", "http://example.com/path1/.%"}); >+ checkURL("http://example.com//.", {"http", "", "", "example.com", 0, "//", "", "", "http://example.com//"}); >+ checkURL("http://example.com//./", {"http", "", "", "example.com", 0, "//", "", "", "http://example.com//"}); >+ checkURL("http://example.com//.//", {"http", "", "", "example.com", 0, "///", "", "", "http://example.com///"}); >+ checkURL("http://example.com//..", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >+ checkURL("http://example.com//../", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >+ checkURL("http://example.com//..//", {"http", "", "", "example.com", 0, "//", "", "", "http://example.com//"}); >+ checkURL("http://example.com//..", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >+ checkURL("http://example.com/.//", {"http", "", "", "example.com", 0, "//", "", "", "http://example.com//"}); >+ checkURL("http://example.com/..//", {"http", "", "", "example.com", 0, "//", "", "", "http://example.com//"}); >+ checkURL("http://example.com/./", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >+ checkURL("http://example.com/../", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >+ checkURL("http://example.com/path1/.../path3", {"http", "", "", "example.com", 0, "/path1/.../path3", "", "", "http://example.com/path1/.../path3"}); >+ checkURL("http://example.com/path1/...", {"http", "", "", "example.com", 0, "/path1/...", "", "", "http://example.com/path1/..."}); >+ checkURL("http://example.com/path1/.../", {"http", "", "", "example.com", 0, "/path1/.../", "", "", "http://example.com/path1/.../"}); >+ checkURL("http://example.com/.path1/", {"http", "", "", "example.com", 0, "/.path1/", "", "", "http://example.com/.path1/"}); >+ checkURL("http://example.com/..path1/", {"http", "", "", "example.com", 0, "/..path1/", "", "", "http://example.com/..path1/"}); >+ checkURL("http://example.com/path1/.path2", {"http", "", "", "example.com", 0, "/path1/.path2", "", "", "http://example.com/path1/.path2"}); >+ checkURL("http://example.com/path1/..path2", {"http", "", "", "example.com", 0, "/path1/..path2", "", "", "http://example.com/path1/..path2"}); >+ checkURL("http://example.com/path1/path2/.?query", {"http", "", "", "example.com", 0, "/path1/path2/", "query", "", "http://example.com/path1/path2/?query"}); >+ checkURL("http://example.com/path1/path2/..?query", {"http", "", "", "example.com", 0, "/path1/", "query", "", "http://example.com/path1/?query"}); >+ checkURL("http://example.com/path1/path2/.#fragment", {"http", "", "", "example.com", 0, "/path1/path2/", "", "fragment", "http://example.com/path1/path2/#fragment"}); >+ checkURL("http://example.com/path1/path2/..#fragment", {"http", "", "", "example.com", 0, "/path1/", "", "fragment", "http://example.com/path1/#fragment"}); >+ >+ checkURL("file:", {"file", "", "", "", 0, "/", "", "", "file:///"}); >+ checkURL("file:/", {"file", "", "", "", 0, "/", "", "", "file:///"}); >+ checkURL("file://", {"file", "", "", "", 0, "/", "", "", "file:///"}); >+ checkURL("file:///", {"file", "", "", "", 0, "/", "", "", "file:///"}); >+ checkURL("file:////", {"file", "", "", "", 0, "//", "", "", "file:////"}); // This matches Firefox and URL::parse which I believe are correct, but not Chrome. >+ checkURL("file:/path", {"file", "", "", "", 0, "/path", "", "", "file:///path"}); >+ checkURL("file://host/path", {"file", "", "", "host", 0, "/path", "", "", "file://host/path"}); >+ checkURL("file://host", {"file", "", "", "host", 0, "/", "", "", "file://host/"}); >+ checkURL("file://host/", {"file", "", "", "host", 0, "/", "", "", "file://host/"}); >+ checkURL("file:///path", {"file", "", "", "", 0, "/path", "", "", "file:///path"}); >+ checkURL("file:////path", {"file", "", "", "", 0, "//path", "", "", "file:////path"}); >+ checkURL("file://localhost/path", {"file", "", "", "", 0, "/path", "", "", "file:///path"}); >+ checkURL("file://localhost/", {"file", "", "", "", 0, "/", "", "", "file:///"}); >+ checkURL("file://localhost", {"file", "", "", "", 0, "/", "", "", "file:///"}); >+ checkURL("file://lOcAlHoSt", {"file", "", "", "", 0, "/", "", "", "file:///"}); >+ checkURL("file://lOcAlHoSt/", {"file", "", "", "", 0, "/", "", "", "file:///"}); >+ checkURL("file:/pAtH/", {"file", "", "", "", 0, "/pAtH/", "", "", "file:///pAtH/"}); >+ checkURL("file:/pAtH", {"file", "", "", "", 0, "/pAtH", "", "", "file:///pAtH"}); >+ checkURL("file:?query", {"file", "", "", "", 0, "/", "query", "", "file:///?query"}); >+ checkURL("file:#fragment", {"file", "", "", "", 0, "/", "", "fragment", "file:///#fragment"}); >+ checkURL("file:?query#fragment", {"file", "", "", "", 0, "/", "query", "fragment", "file:///?query#fragment"}); >+ checkURL("file:#fragment?notquery", {"file", "", "", "", 0, "/", "", "fragment?notquery", "file:///#fragment?notquery"}); >+ checkURL("file:/?query", {"file", "", "", "", 0, "/", "query", "", "file:///?query"}); >+ checkURL("file:/#fragment", {"file", "", "", "", 0, "/", "", "fragment", "file:///#fragment"}); >+ checkURL("file://?query", {"file", "", "", "", 0, "/", "query", "", "file:///?query"}); >+ checkURL("file://#fragment", {"file", "", "", "", 0, "/", "", "fragment", "file:///#fragment"}); >+ checkURL("file:///?query", {"file", "", "", "", 0, "/", "query", "", "file:///?query"}); >+ checkURL("file:///#fragment", {"file", "", "", "", 0, "/", "", "fragment", "file:///#fragment"}); >+ checkURL("file:////?query", {"file", "", "", "", 0, "//", "query", "", "file:////?query"}); >+ checkURL("file:////#fragment", {"file", "", "", "", 0, "//", "", "fragment", "file:////#fragment"}); >+ checkURL("file://?Q", {"file", "", "", "", 0, "/", "Q", "", "file:///?Q"}); >+ checkURL("file://#F", {"file", "", "", "", 0, "/", "", "F", "file:///#F"}); >+ checkURL("file://host?Q", {"file", "", "", "host", 0, "/", "Q", "", "file://host/?Q"}); >+ checkURL("file://host#F", {"file", "", "", "host", 0, "/", "", "F", "file://host/#F"}); >+ checkURL("file://host\\P", {"file", "", "", "host", 0, "/P", "", "", "file://host/P"}); >+ checkURL("file://host\\?Q", {"file", "", "", "host", 0, "/", "Q", "", "file://host/?Q"}); >+ checkURL("file://host\\../P", {"file", "", "", "host", 0, "/P", "", "", "file://host/P"}); >+ checkURL("file://host\\/../P", {"file", "", "", "host", 0, "/P", "", "", "file://host/P"}); >+ checkURL("file://host\\/P", {"file", "", "", "host", 0, "//P", "", "", "file://host//P"}); >+ checkURL("http://host/A b", {"http", "", "", "host", 0, "/A%20b", "", "", "http://host/A%20b"}); >+ checkURL("http://host/a%20B", {"http", "", "", "host", 0, "/a%20B", "", "", "http://host/a%20B"}); >+ checkURL("http://host?q=@ <>!#fragment", {"http", "", "", "host", 0, "/", "q=@%20%3C%3E!", "fragment", "http://host/?q=@%20%3C%3E!#fragment"}); >+ checkURL("http://user:@host", {"http", "user", "", "host", 0, "/", "", "", "http://user@host/"}); >+ checkURL("http://user:@\thost", {"http", "user", "", "host", 0, "/", "", "", "http://user@host/"}); >+ checkURL("http://user:\t@host", {"http", "user", "", "host", 0, "/", "", "", "http://user@host/"}); >+ checkURL("http://user\t:@host", {"http", "user", "", "host", 0, "/", "", "", "http://user@host/"}); >+ checkURL("http://use\tr:@host", {"http", "user", "", "host", 0, "/", "", "", "http://user@host/"}); >+ checkURL("http://127.0.0.1:10100/path", {"http", "", "", "127.0.0.1", 10100, "/path", "", "", "http://127.0.0.1:10100/path"}); >+ checkURL("http://127.0.0.1:/path", {"http", "", "", "127.0.0.1", 0, "/path", "", "", "http://127.0.0.1/path"}); >+ checkURL("http://127.0.0.1\t:/path", {"http", "", "", "127.0.0.1", 0, "/path", "", "", "http://127.0.0.1/path"}); >+ checkURL("http://127.0.0.1:\t/path", {"http", "", "", "127.0.0.1", 0, "/path", "", "", "http://127.0.0.1/path"}); >+ checkURL("http://127.0.0.1:/\tpath", {"http", "", "", "127.0.0.1", 0, "/path", "", "", "http://127.0.0.1/path"}); >+ checkURL("http://127.0.0.1:123", {"http", "", "", "127.0.0.1", 123, "/", "", "", "http://127.0.0.1:123/"}); >+ checkURL("http://127.0.0.1:", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}); >+ checkURL("http://[0:f::f:f:0:0]:123/path", {"http", "", "", "[0:f::f:f:0:0]", 123, "/path", "", "", "http://[0:f::f:f:0:0]:123/path"}); >+ checkURL("http://[0:f::f:f:0:0]:123", {"http", "", "", "[0:f::f:f:0:0]", 123, "/", "", "", "http://[0:f::f:f:0:0]:123/"}); >+ checkURL("http://[0:f:0:0:f:\t:]:123", {"http", "", "", "[0:f:0:0:f::]", 123, "/", "", "", "http://[0:f:0:0:f::]:123/"}); >+ checkURL("http://[0:f:0:0:f::\t]:123", {"http", "", "", "[0:f:0:0:f::]", 123, "/", "", "", "http://[0:f:0:0:f::]:123/"}); >+ checkURL("http://[0:f:0:0:f::]\t:123", {"http", "", "", "[0:f:0:0:f::]", 123, "/", "", "", "http://[0:f:0:0:f::]:123/"}); >+ checkURL("http://[0:f:0:0:f::]:\t123", {"http", "", "", "[0:f:0:0:f::]", 123, "/", "", "", "http://[0:f:0:0:f::]:123/"}); >+ checkURL("http://[0:f:0:0:f::]:1\t23", {"http", "", "", "[0:f:0:0:f::]", 123, "/", "", "", "http://[0:f:0:0:f::]:123/"}); >+ checkURL("http://[0:f::f:f:0:0]:/path", {"http", "", "", "[0:f::f:f:0:0]", 0, "/path", "", "", "http://[0:f::f:f:0:0]/path"}); >+ checkURL("http://[0:f::f:f:0:0]:", {"http", "", "", "[0:f::f:f:0:0]", 0, "/", "", "", "http://[0:f::f:f:0:0]/"}); >+ checkURL("http://host:10100/path", {"http", "", "", "host", 10100, "/path", "", "", "http://host:10100/path"}); >+ checkURL("http://host:/path", {"http", "", "", "host", 0, "/path", "", "", "http://host/path"}); >+ checkURL("http://host:123", {"http", "", "", "host", 123, "/", "", "", "http://host:123/"}); >+ checkURL("http://host:", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >+ checkURL("http://hos\tt\n:\t1\n2\t3\t/\npath", {"http", "", "", "host", 123, "/path", "", "", "http://host:123/path"}); >+ checkURL("http://user@example.org/path3", {"http", "user", "", "example.org", 0, "/path3", "", "", "http://user@example.org/path3"}); >+ checkURL("sc:/pa/pa", {"sc", "", "", "", 0, "/pa/pa", "", "", "sc:/pa/pa"}); >+ checkURL("sc:/pa", {"sc", "", "", "", 0, "/pa", "", "", "sc:/pa"}); >+ checkURL("sc:/pa/", {"sc", "", "", "", 0, "/pa/", "", "", "sc:/pa/"}); >+ checkURL("notspecial:/notuser:notpassword@nothost", {"notspecial", "", "", "", 0, "/notuser:notpassword@nothost", "", "", "notspecial:/notuser:notpassword@nothost"}); >+ checkURL("sc://pa/", {"sc", "", "", "pa", 0, "/", "", "", "sc://pa/"}); >+ checkURL("sc://\tpa/", {"sc", "", "", "pa", 0, "/", "", "", "sc://pa/"}); >+ checkURL("sc:/\t/pa/", {"sc", "", "", "pa", 0, "/", "", "", "sc://pa/"}); >+ checkURL("sc:\t//pa/", {"sc", "", "", "pa", 0, "/", "", "", "sc://pa/"}); >+ checkURL("http://host \a ", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >+ checkURL("notspecial:/a", {"notspecial", "", "", "", 0, "/a", "", "", "notspecial:/a"}); >+ checkURL("notspecial:", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"}); >+ checkURL("http:/a", {"http", "", "", "a", 0, "/", "", "", "http://a/"}); >+ checkURL("http://256../", {"http", "", "", "256..", 0, "/", "", "", "http://256../"}); >+ checkURL("http://256..", {"http", "", "", "256..", 0, "/", "", "", "http://256../"}); >+ checkURL("http://127..1/", {"http", "", "", "127..1", 0, "/", "", "", "http://127..1/"}); >+ checkURL("http://127.a.0.1/", {"http", "", "", "127.a.0.1", 0, "/", "", "", "http://127.a.0.1/"}); >+ checkURL("http://127.0.0.1/", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}); >+ checkURL("http://12\t7.0.0.1/", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}); >+ checkURL("http://127.\t0.0.1/", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}); >+ checkURL("http://./", {"http", "", "", ".", 0, "/", "", "", "http://./"}); >+ checkURL("http://.", {"http", "", "", ".", 0, "/", "", "", "http://./"}); >+ checkURL("notspecial:/a", {"notspecial", "", "", "", 0, "/a", "", "", "notspecial:/a"}); >+ checkURL("notspecial:", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"}); >+ checkURL("notspecial:/", {"notspecial", "", "", "", 0, "/", "", "", "notspecial:/"}); >+ checkURL("data:image/png;base64,encoded-data-follows-here", {"data", "", "", "", 0, "image/png;base64,encoded-data-follows-here", "", "", "data:image/png;base64,encoded-data-follows-here"}); >+ checkURL("data:image/png;base64,encoded/data-with-slash", {"data", "", "", "", 0, "image/png;base64,encoded/data-with-slash", "", "", "data:image/png;base64,encoded/data-with-slash"}); >+ checkURL("about:~", {"about", "", "", "", 0, "~", "", "", "about:~"}); >+ checkURL("https://@test@test@example:800\\path@end", {"", "", "", "", 0, "", "", "", "https://@test@test@example:800\\path@end"}); >+ checkURL("http://www.example.com/#a\nb\rc\td", {"http", "", "", "www.example.com", 0, "/", "", "abcd", "http://www.example.com/#abcd"}); >+ checkURL("http://[A:b:c:DE:fF:0:1:aC]/", {"http", "", "", "[a:b:c:de:ff:0:1:ac]", 0, "/", "", "", "http://[a:b:c:de:ff:0:1:ac]/"}); >+ checkURL("http:////////user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://user@webkit.org:99/?foo"}); >+ checkURL("http:////////user:@webkit.org:99#foo", {"http", "user", "", "webkit.org", 99, "/", "", "foo", "http://user@webkit.org:99/#foo"}); >+ checkURL("http:////\t////user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://user@webkit.org:99/?foo"}); >+ checkURL("http://\t//\\///user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://user@webkit.org:99/?foo"}); >+ checkURL("http:/\\user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://user@webkit.org:99/?foo"}); >+ checkURL("http://127.0.0.1", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}); >+ checkURLDifferences("http://127.0.0.1.", >+ {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}, >+ {"http", "", "", "127.0.0.1.", 0, "/", "", "", "http://127.0.0.1./"}); >+ checkURLDifferences("http://127.0.0.1./", >+ {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}, >+ {"http", "", "", "127.0.0.1.", 0, "/", "", "", "http://127.0.0.1./"}); >+ checkURL("http://127.0.0.1../", {"http", "", "", "127.0.0.1..", 0, "/", "", "", "http://127.0.0.1../"}); >+ checkURLDifferences("http://0x100.0/", >+ {"", "", "", "", 0, "", "", "", "http://0x100.0/"}, >+ {"http", "", "", "0x100.0", 0, "/", "", "", "http://0x100.0/"}); >+ checkURLDifferences("http://0.0.0x100.0/", >+ {"", "", "", "", 0, "", "", "", "http://0.0.0x100.0/"}, >+ {"http", "", "", "0.0.0x100.0", 0, "/", "", "", "http://0.0.0x100.0/"}); >+ checkURLDifferences("http://0.0.0.0x100/", >+ {"", "", "", "", 0, "", "", "", "http://0.0.0.0x100/"}, >+ {"http", "", "", "0.0.0.0x100", 0, "/", "", "", "http://0.0.0.0x100/"}); >+ checkURL("http://host:123?", {"http", "", "", "host", 123, "/", "", "", "http://host:123/?"}); >+ checkURL("http://host:123?query", {"http", "", "", "host", 123, "/", "query", "", "http://host:123/?query"}); >+ checkURL("http://host:123#", {"http", "", "", "host", 123, "/", "", "", "http://host:123/#"}); >+ checkURL("http://host:123#fragment", {"http", "", "", "host", 123, "/", "", "fragment", "http://host:123/#fragment"}); >+ checkURLDifferences("foo:////", >+ {"foo", "", "", "", 0, "//", "", "", "foo:////"}, >+ {"foo", "", "", "", 0, "////", "", "", "foo:////"}); >+ checkURLDifferences("foo:///?", >+ {"foo", "", "", "", 0, "/", "", "", "foo:///?"}, >+ {"foo", "", "", "", 0, "///", "", "", "foo:///?"}); >+ checkURLDifferences("foo:///#", >+ {"foo", "", "", "", 0, "/", "", "", "foo:///#"}, >+ {"foo", "", "", "", 0, "///", "", "", "foo:///#"}); >+ checkURLDifferences("foo:///", >+ {"foo", "", "", "", 0, "/", "", "", "foo:///"}, >+ {"foo", "", "", "", 0, "///", "", "", "foo:///"}); >+ checkURLDifferences("foo://?", >+ {"foo", "", "", "", 0, "", "", "", "foo://?"}, >+ {"foo", "", "", "", 0, "//", "", "", "foo://?"}); >+ checkURLDifferences("foo://#", >+ {"foo", "", "", "", 0, "", "", "", "foo://#"}, >+ {"foo", "", "", "", 0, "//", "", "", "foo://#"}); >+ checkURLDifferences("foo://", >+ {"foo", "", "", "", 0, "", "", "", "foo://"}, >+ {"foo", "", "", "", 0, "//", "", "", "foo://"}); >+ checkURL("foo:/?", {"foo", "", "", "", 0, "/", "", "", "foo:/?"}); >+ checkURL("foo:/#", {"foo", "", "", "", 0, "/", "", "", "foo:/#"}); >+ checkURL("foo:/", {"foo", "", "", "", 0, "/", "", "", "foo:/"}); >+ checkURL("foo:?", {"foo", "", "", "", 0, "", "", "", "foo:?"}); >+ checkURL("foo:#", {"foo", "", "", "", 0, "", "", "", "foo:#"}); >+ checkURLDifferences("A://", >+ {"a", "", "", "", 0, "", "", "", "a://"}, >+ {"a", "", "", "", 0, "//", "", "", "a://"}); >+ checkURLDifferences("aA://", >+ {"aa", "", "", "", 0, "", "", "", "aa://"}, >+ {"aa", "", "", "", 0, "//", "", "", "aa://"}); >+ checkURL(utf16String(u"foo://host/#ÐÐ\u0007 a</"), {"foo", "", "", "host", 0, "/", "", "%D0%9F%D0%9F%07 a</", "foo://host/#%D0%9F%D0%9F%07 a</"}); >+ checkURL(utf16String(u"foo://host/#\u0007 a</"), {"foo", "", "", "host", 0, "/", "", "%07 a</", "foo://host/#%07 a</"}); >+ checkURL(utf16String(u"http://host?Ãð#Ãð"), {"http", "", "", "host", 0, "/", "%C3%9F%F0%9F%98%8D", "%C3%9F%F0%9F%98%8D", "http://host/?%C3%9F%F0%9F%98%8D#%C3%9F%F0%9F%98%8D"}, testTabsValueForSurrogatePairs); >+ checkURL(utf16String(u"http://host/path#ð©\tð©"), {"http", "", "", "host", 0, "/path", "", "%F0%9F%92%A9%F0%9F%92%A9", "http://host/path#%F0%9F%92%A9%F0%9F%92%A9"}, testTabsValueForSurrogatePairs); >+ checkURL(utf16String(u"http://host/#ÐÐ\u0007 a</"), {"http", "", "", "host", 0, "/", "", "%D0%9F%D0%9F%07 a</", "http://host/#%D0%9F%D0%9F%07 a</"}); >+ checkURL(utf16String(u"http://host/#\u0007 a</"), {"http", "", "", "host", 0, "/", "", "%07 a</", "http://host/#%07 a</"}); >+ >+ // This disagrees with the web platform test for http://:@www.example.com but agrees with Chrome and URL::parse, >+ // and Firefox fails the web platform test differently. Maybe the web platform test ought to be changed. >+ checkURL("http://:@host", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >+} >+ >+static void testUserPass(const String& value, const String& decoded, const String& encoded) >+{ >+ URL userURL(URL(), makeString("http://", value, "@example.com/")); >+ URL passURL(URL(), makeString("http://user:", value, "@example.com/")); >+ EXPECT_EQ(encoded, userURL.encodedUser()); >+ EXPECT_EQ(encoded, passURL.encodedPass()); >+ EXPECT_EQ(decoded, userURL.user()); >+ EXPECT_EQ(decoded, passURL.pass()); >+} >+ >+static void testUserPass(const String& value, const String& encoded) >+{ >+ testUserPass(value, value, encoded); >+} >+ >+TEST_F(WTF_URLParser, Credentials) >+{ >+ auto validSurrogate = utf16String<3>({0xD800, 0xDD55, '\0'}); >+ auto invalidSurrogate = utf16String<3>({0xD800, 'A', '\0'}); >+ auto replacementA = utf16String<3>({0xFFFD, 'A', '\0'}); >+ >+ testUserPass("a", "a"); >+ testUserPass("%", "%"); >+ testUserPass("%25", "%", "%25"); >+ testUserPass("%2525", "%25", "%2525"); >+ testUserPass("%FX", "%FX"); >+ testUserPass("%00", String::fromUTF8("\0", 1), "%00"); >+ testUserPass("%F%25", "%F%", "%F%25"); >+ testUserPass("%X%25", "%X%", "%X%25"); >+ testUserPass("%%25", "%%", "%%25"); >+ testUserPass("ð©", "%C3%B0%C2%9F%C2%92%C2%A9"); >+ testUserPass("%ð©", "%%C3%B0%C2%9F%C2%92%C2%A9"); >+ testUserPass(validSurrogate, "%F0%90%85%95"); >+ testUserPass(replacementA, "%EF%BF%BDA"); >+ testUserPass(invalidSurrogate, replacementA, "%EF%BF%BDA"); >+} >+ >+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"}); >+ checkRelativeURL("index.html", "http://webkit.org/path1/path2/page.html?query#fragment", {"http", "", "", "webkit.org", 0, "/path1/path2/index.html", "", "", "http://webkit.org/path1/path2/index.html"}); >+ checkRelativeURL("//whatwg.org/index.html", "https://www.webkit.org/path", {"https", "", "", "whatwg.org", 0, "/index.html", "", "", "https://whatwg.org/index.html"}); >+ checkRelativeURL("http://example\t.\norg", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/", "", "", "http://example.org/"}); >+ checkRelativeURL("test", "file:///path1/path2", {"file", "", "", "", 0, "/path1/test", "", "", "file:///path1/test"}); >+ checkRelativeURL(utf16String(u"http://www.fooãbar.com"), "http://other.com/", {"http", "", "", "www.foo.bar.com", 0, "/", "", "", "http://www.foo.bar.com/"}); >+ checkRelativeURLDifferences(utf16String(u"sc://ñ.test/"), "about:blank", >+ {"sc", "", "", "%C3%B1.test", 0, "/", "", "", "sc://%C3%B1.test/"}, >+ {"sc", "", "", "xn--ida.test", 0, "/", "", "", "sc://xn--ida.test/"}); >+ checkRelativeURL("#fragment", "http://host/path", {"http", "", "", "host", 0, "/path", "", "fragment", "http://host/path#fragment"}); >+ checkRelativeURL("#fragment", "file:///path", {"file", "", "", "", 0, "/path", "", "fragment", "file:///path#fragment"}); >+ checkRelativeURL("#fragment", "file:///path#old", {"file", "", "", "", 0, "/path", "", "fragment", "file:///path#fragment"}); >+ checkRelativeURL("#", "file:///path#old", {"file", "", "", "", 0, "/path", "", "", "file:///path#"}); >+ checkRelativeURL(" ", "file:///path#old", {"file", "", "", "", 0, "/path", "", "", "file:///path"}); >+ checkRelativeURL("#", "file:///path", {"file", "", "", "", 0, "/path", "", "", "file:///path#"}); >+ checkRelativeURL("#", "file:///path?query", {"file", "", "", "", 0, "/path", "query", "", "file:///path?query#"}); >+ checkRelativeURL("#", "file:///path?query#old", {"file", "", "", "", 0, "/path", "query", "", "file:///path?query#"}); >+ checkRelativeURL("?query", "http://host/path", {"http", "", "", "host", 0, "/path", "query", "", "http://host/path?query"}); >+ checkRelativeURL("?query#fragment", "http://host/path", {"http", "", "", "host", 0, "/path", "query", "fragment", "http://host/path?query#fragment"}); >+ checkRelativeURL("?new", "file:///path?old#fragment", {"file", "", "", "", 0, "/path", "new", "", "file:///path?new"}); >+ checkRelativeURL("?", "file:///path?old#fragment", {"file", "", "", "", 0, "/path", "", "", "file:///path?"}); >+ checkRelativeURL("?", "file:///path", {"file", "", "", "", 0, "/path", "", "", "file:///path?"}); >+ checkRelativeURL("?query", "file:///path", {"file", "", "", "", 0, "/path", "query", "", "file:///path?query"}); >+ checkRelativeURL(utf16String(u"?β"), "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "%CE%B2", "", "http://example.org/foo/bar?%CE%B2"}); >+ checkRelativeURL("?", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar?"}); >+ checkRelativeURL("#", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar#"}); >+ checkRelativeURL("?#", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar?#"}); >+ checkRelativeURL("#?", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "?", "http://example.org/foo/bar#?"}); >+ checkRelativeURL("/", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/", "", "", "http://example.org/"}); >+ checkRelativeURL("http://@host", "about:blank", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >+ checkRelativeURL("http://:@host", "about:blank", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >+ checkRelativeURL("http://foo.com/\\@", "http://example.org/foo/bar", {"http", "", "", "foo.com", 0, "//@", "", "", "http://foo.com//@"}); >+ checkRelativeURL("\\@", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/@", "", "", "http://example.org/@"}); >+ checkRelativeURL("/path3", "http://user@example.org/path1/path2", {"http", "user", "", "example.org", 0, "/path3", "", "", "http://user@example.org/path3"}); >+ checkRelativeURL("", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar"}); >+ checkRelativeURL("\t", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar"}); >+ checkRelativeURL(" ", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar"}); >+ checkRelativeURL(" \a \t\n", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar"}); >+ checkRelativeURL(":foo.com\\", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/:foo.com/", "", "", "http://example.org/foo/:foo.com/"}); >+ checkRelativeURL("http:/example.com/", "about:blank", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >+ checkRelativeURL("http:example.com/", "about:blank", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >+ checkRelativeURL("http:\\\\foo.com\\", "http://example.org/foo/bar", {"http", "", "", "foo.com", 0, "/", "", "", "http://foo.com/"}); >+ checkRelativeURL("http:\\\\foo.com/", "http://example.org/foo/bar", {"http", "", "", "foo.com", 0, "/", "", "", "http://foo.com/"}); >+ checkRelativeURL("http:\\\\foo.com", "http://example.org/foo/bar", {"http", "", "", "foo.com", 0, "/", "", "", "http://foo.com/"}); >+ checkRelativeURL("http://ExAmPlE.CoM", "http://other.com", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >+ checkRelativeURL("http:", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar"}); >+ checkRelativeURL("#x", "data:,", {"data", "", "", "", 0, ",", "", "x", "data:,#x"}); >+ checkRelativeURL("#x", "about:blank", {"about", "", "", "", 0, "blank", "", "x", "about:blank#x"}); >+ checkRelativeURL(" foo.com ", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/foo.com", "", "", "http://example.org/foo/foo.com"}); >+ checkRelativeURL(" \a baz", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/baz", "", "", "http://example.org/foo/baz"}); >+ checkRelativeURL("~", "http://example.org", {"http", "", "", "example.org", 0, "/~", "", "", "http://example.org/~"}); >+ checkRelativeURL("notspecial:", "about:blank", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"}); >+ checkRelativeURL("notspecial:", "http://host", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"}); >+ checkRelativeURL("http:", "http://host", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >+ checkRelativeURL("i", "sc:/pa/po", {"sc", "", "", "", 0, "/pa/i", "", "", "sc:/pa/i"}); >+ checkRelativeURL("i ", "sc:/pa/po", {"sc", "", "", "", 0, "/pa/i", "", "", "sc:/pa/i"}); >+ checkRelativeURL("i\t\n ", "sc:/pa/po", {"sc", "", "", "", 0, "/pa/i", "", "", "sc:/pa/i"}); >+ checkRelativeURL("i", "sc://ho/pa", {"sc", "", "", "ho", 0, "/i", "", "", "sc://ho/i"}); >+ checkRelativeURL("!", "sc://ho/pa", {"sc", "", "", "ho", 0, "/!", "", "", "sc://ho/!"}); >+ checkRelativeURL("!", "sc:/ho/pa", {"sc", "", "", "", 0, "/ho/!", "", "", "sc:/ho/!"}); >+ checkRelativeURL("notspecial:/", "about:blank", {"notspecial", "", "", "", 0, "/", "", "", "notspecial:/"}); >+ checkRelativeURL("notspecial:/", "http://host", {"notspecial", "", "", "", 0, "/", "", "", "notspecial:/"}); >+ checkRelativeURL("foo:/", "http://example.org/foo/bar", {"foo", "", "", "", 0, "/", "", "", "foo:/"}); >+ checkRelativeURL("://:0/", "http://webkit.org/", {"http", "", "", "webkit.org", 0, "/://:0/", "", "", "http://webkit.org/://:0/"}); >+ checkRelativeURL(String(), "http://webkit.org/", {"http", "", "", "webkit.org", 0, "/", "", "", "http://webkit.org/"}); >+ checkRelativeURL("https://@test@test@example:800\\path@end", "http://doesnotmatter/", {"", "", "", "", 0, "", "", "", "https://@test@test@example:800\\path@end"}); >+ checkRelativeURL("http://f:0/c", "http://example.org/foo/bar", {"http", "", "", "f", 0, "/c", "", "", "http://f:0/c"}); >+ checkRelativeURL(String(), "http://host/#fragment", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >+ checkRelativeURL("", "http://host/#fragment", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >+ checkRelativeURL(" ", "http://host/#fragment", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >+ checkRelativeURL(" ", "http://host/path?query#fra#gment", {"http", "", "", "host", 0, "/path", "query", "", "http://host/path?query"}); >+ checkRelativeURL(" \a ", "http://host/#fragment", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >+ checkRelativeURLDifferences("foo://", "http://example.org/foo/bar", >+ {"foo", "", "", "", 0, "", "", "", "foo://"}, >+ {"foo", "", "", "", 0, "//", "", "", "foo://"}); >+ checkRelativeURL(utf16String(u"#β"), "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "%CE%B2", "http://example.org/foo/bar#%CE%B2"}); >+ checkRelativeURL("index.html", "applewebdata://Host/", {"applewebdata", "", "", "Host", 0, "/index.html", "", "", "applewebdata://Host/index.html"}); >+ checkRelativeURL("index.html", "applewebdata://Host", {"applewebdata", "", "", "Host", 0, "/index.html", "", "", "applewebdata://Host/index.html"}); >+ checkRelativeURL("", "applewebdata://Host", {"applewebdata", "", "", "Host", 0, "", "", "", "applewebdata://Host"}); >+ checkRelativeURL("?query", "applewebdata://Host", {"applewebdata", "", "", "Host", 0, "", "query", "", "applewebdata://Host?query"}); >+ checkRelativeURL("#fragment", "applewebdata://Host", {"applewebdata", "", "", "Host", 0, "", "", "fragment", "applewebdata://Host#fragment"}); >+ checkRelativeURL("notspecial://something?", "file:////var//containers//stuff/", {"notspecial", "", "", "something", 0, "", "", "", "notspecial://something?"}, TestTabs::No); >+ checkRelativeURL("notspecial://something#", "file:////var//containers//stuff/", {"notspecial", "", "", "something", 0, "", "", "", "notspecial://something#"}, TestTabs::No); >+ checkRelativeURL("http://something?", "file:////var//containers//stuff/", {"http", "", "", "something", 0, "/", "", "", "http://something/?"}, TestTabs::No); >+ checkRelativeURL("http://something#", "file:////var//containers//stuff/", {"http", "", "", "something", 0, "/", "", "", "http://something/#"}, TestTabs::No); >+ checkRelativeURL("file:", "file:///path?query#fragment", {"file", "", "", "", 0, "/path", "query", "", "file:///path?query"}); >+ checkRelativeURL("/", "file:///C:/a/b", {"file", "", "", "", 0, "/C:/", "", "", "file:///C:/"}); >+ checkRelativeURL("/abc", "file:///C:/a/b", {"file", "", "", "", 0, "/C:/abc", "", "", "file:///C:/abc"}); >+ checkRelativeURL("/abc", "file:///C:", {"file", "", "", "", 0, "/C:/abc", "", "", "file:///C:/abc"}); >+ checkRelativeURL("/abc", "file:///", {"file", "", "", "", 0, "/abc", "", "", "file:///abc"}); >+ checkRelativeURL("//d:", "file:///C:/a/b", {"file", "", "", "", 0, "/d:", "", "", "file:///d:"}, TestTabs::No); >+ checkRelativeURL("//d|", "file:///C:/a/b", {"file", "", "", "", 0, "/d:", "", "", "file:///d:"}, TestTabs::No); >+ checkRelativeURL("//A|", "file:///C:/a/b", {"file", "", "", "", 0, "/A:", "", "", "file:///A:"}, TestTabs::No); >+ >+ // The checking of slashes in SpecialAuthoritySlashes needed to get this to pass contradicts what is in the spec, >+ // but it is included in the web platform tests. >+ checkRelativeURL("http:\\\\host\\foo", "about:blank", {"http", "", "", "host", 0, "/foo", "", "", "http://host/foo"}); >+} >+ >+// These are differences between the new URLParser and the old URL::parse which make URLParser more standards compliant. >+TEST_F(WTF_URLParser, ParserDifferences) >+{ >+ checkURLDifferences("http://127.0.1", >+ {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}, >+ {"http", "", "", "127.0.1", 0, "/", "", "", "http://127.0.1/"}); >+ checkURLDifferences("http://011.11.0X11.0x011", >+ {"http", "", "", "9.11.17.17", 0, "/", "", "", "http://9.11.17.17/"}, >+ {"http", "", "", "011.11.0x11.0x011", 0, "/", "", "", "http://011.11.0x11.0x011/"}); >+ checkURLDifferences("http://[1234:0078:90AB:CdEf:0123:0007:89AB:0000]", >+ {"http", "", "", "[1234:78:90ab:cdef:123:7:89ab:0]", 0, "/", "", "", "http://[1234:78:90ab:cdef:123:7:89ab:0]/"}, >+ {"http", "", "", "[1234:0078:90ab:cdef:0123:0007:89ab:0000]", 0, "/", "", "", "http://[1234:0078:90ab:cdef:0123:0007:89ab:0000]/"}); >+ checkURLDifferences("http://[0:f:0:0:f:f:0:0]", >+ {"http", "", "", "[0:f::f:f:0:0]", 0, "/", "", "", "http://[0:f::f:f:0:0]/"}, >+ {"http", "", "", "[0:f:0:0:f:f:0:0]", 0, "/", "", "", "http://[0:f:0:0:f:f:0:0]/"}); >+ checkURLDifferences("http://[0:f:0:0:f:0:0:0]", >+ {"http", "", "", "[0:f:0:0:f::]", 0, "/", "", "", "http://[0:f:0:0:f::]/"}, >+ {"http", "", "", "[0:f:0:0:f:0:0:0]", 0, "/", "", "", "http://[0:f:0:0:f:0:0:0]/"}); >+ checkURLDifferences("http://[0:0:f:0:0:f:0:0]", >+ {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"}, >+ {"http", "", "", "[0:0:f:0:0:f:0:0]", 0, "/", "", "", "http://[0:0:f:0:0:f:0:0]/"}); >+ checkURLDifferences("http://[a:0:0:0:b:c::d]", >+ {"http", "", "", "[a::b:c:0:d]", 0, "/", "", "", "http://[a::b:c:0:d]/"}, >+ {"http", "", "", "[a:0:0:0:b:c::d]", 0, "/", "", "", "http://[a:0:0:0:b:c::d]/"}); >+ checkURLDifferences("http://[::7f00:0001]/", >+ {"http", "", "", "[::7f00:1]", 0, "/", "", "", "http://[::7f00:1]/"}, >+ {"http", "", "", "[::7f00:0001]", 0, "/", "", "", "http://[::7f00:0001]/"}); >+ checkURLDifferences("http://[::7f00:00]/", >+ {"http", "", "", "[::7f00:0]", 0, "/", "", "", "http://[::7f00:0]/"}, >+ {"http", "", "", "[::7f00:00]", 0, "/", "", "", "http://[::7f00:00]/"}); >+ checkURLDifferences("http://[::0:7f00:0001]/", >+ {"http", "", "", "[::7f00:1]", 0, "/", "", "", "http://[::7f00:1]/"}, >+ {"http", "", "", "[::0:7f00:0001]", 0, "/", "", "", "http://[::0:7f00:0001]/"}); >+ checkURLDifferences("http://127.00.0.1/", >+ {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}, >+ {"http", "", "", "127.00.0.1", 0, "/", "", "", "http://127.00.0.1/"}); >+ checkURLDifferences("http://127.0.0.01/", >+ {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}, >+ {"http", "", "", "127.0.0.01", 0, "/", "", "", "http://127.0.0.01/"}); >+ checkURLDifferences("http://example.com/path1/.%2e", >+ {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}, >+ {"http", "", "", "example.com", 0, "/path1/.%2e", "", "", "http://example.com/path1/.%2e"}); >+ checkURLDifferences("http://example.com/path1/.%2E", >+ {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}, >+ {"http", "", "", "example.com", 0, "/path1/.%2E", "", "", "http://example.com/path1/.%2E"}); >+ checkURLDifferences("http://example.com/path1/.%2E/", >+ {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}, >+ {"http", "", "", "example.com", 0, "/path1/.%2E/", "", "", "http://example.com/path1/.%2E/"}); >+ checkURLDifferences("http://example.com/path1/%2e.", >+ {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}, >+ {"http", "", "", "example.com", 0, "/path1/%2e.", "", "", "http://example.com/path1/%2e."}); >+ checkURLDifferences("http://example.com/path1/%2E%2e", >+ {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}, >+ {"http", "", "", "example.com", 0, "/path1/%2E%2e", "", "", "http://example.com/path1/%2E%2e"}); >+ checkURLDifferences("http://example.com/path1/%2e", >+ {"http", "", "", "example.com", 0, "/path1/", "", "", "http://example.com/path1/"}, >+ {"http", "", "", "example.com", 0, "/path1/%2e", "", "", "http://example.com/path1/%2e"}); >+ checkURLDifferences("http://example.com/path1/%2E", >+ {"http", "", "", "example.com", 0, "/path1/", "", "", "http://example.com/path1/"}, >+ {"http", "", "", "example.com", 0, "/path1/%2E", "", "", "http://example.com/path1/%2E"}); >+ checkURLDifferences("http://example.com/path1/%2E/", >+ {"http", "", "", "example.com", 0, "/path1/", "", "", "http://example.com/path1/"}, >+ {"http", "", "", "example.com", 0, "/path1/%2E/", "", "", "http://example.com/path1/%2E/"}); >+ checkURLDifferences("http://example.com/path1/path2/%2e?query", >+ {"http", "", "", "example.com", 0, "/path1/path2/", "query", "", "http://example.com/path1/path2/?query"}, >+ {"http", "", "", "example.com", 0, "/path1/path2/%2e", "query", "", "http://example.com/path1/path2/%2e?query"}); >+ checkURLDifferences("http://example.com/path1/path2/%2e%2e?query", >+ {"http", "", "", "example.com", 0, "/path1/", "query", "", "http://example.com/path1/?query"}, >+ {"http", "", "", "example.com", 0, "/path1/path2/%2e%2e", "query", "", "http://example.com/path1/path2/%2e%2e?query"}); >+ checkURLDifferences("http://example.com/path1/path2/%2e#fragment", >+ {"http", "", "", "example.com", 0, "/path1/path2/", "", "fragment", "http://example.com/path1/path2/#fragment"}, >+ {"http", "", "", "example.com", 0, "/path1/path2/%2e", "", "fragment", "http://example.com/path1/path2/%2e#fragment"}); >+ checkURLDifferences("http://example.com/path1/path2/%2e%2e#fragment", >+ {"http", "", "", "example.com", 0, "/path1/", "", "fragment", "http://example.com/path1/#fragment"}, >+ {"http", "", "", "example.com", 0, "/path1/path2/%2e%2e", "", "fragment", "http://example.com/path1/path2/%2e%2e#fragment"}); >+ checkURL("http://example.com/path1/path2/A%2e%2e#fragment", {"http", "", "", "example.com", 0, "/path1/path2/A%2e%2e", "", "fragment", "http://example.com/path1/path2/A%2e%2e#fragment"}); >+ checkURLDifferences("file://[0:a:0:0:b:c:0:0]/path", >+ {"file", "", "", "[0:a::b:c:0:0]", 0, "/path", "", "", "file://[0:a::b:c:0:0]/path"}, >+ {"file", "", "", "[0:a:0:0:b:c:0:0]", 0, "/path", "", "", "file://[0:a:0:0:b:c:0:0]/path"}); >+ checkURLDifferences("http://", >+ {"", "", "", "", 0, "", "", "", "http://"}, >+ {"http", "", "", "", 0, "/", "", "", "http:/"}); >+ checkRelativeURLDifferences("//", "https://www.webkit.org/path", >+ {"", "", "", "", 0, "", "", "", "//"}, >+ {"https", "", "", "", 0, "/", "", "", "https:/"}); >+ checkURLDifferences("http://127.0.0.1:65536/path", >+ {"", "", "", "", 0, "", "", "", "http://127.0.0.1:65536/path"}, >+ {"http", "", "", "127.0.0.1", 0, "/path", "", "", "http://127.0.0.1:65536/path"}); >+ checkURLDifferences("http://host:65536", >+ {"", "", "", "", 0, "", "", "", "http://host:65536"}, >+ {"http", "", "", "host", 0, "/", "", "", "http://host:65536/"}); >+ checkURLDifferences("http://127.0.0.1:65536", >+ {"", "", "", "", 0, "", "", "", "http://127.0.0.1:65536"}, >+ {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1:65536/"}); >+ checkURLDifferences("http://[0:f::f:f:0:0]:65536", >+ {"", "", "", "", 0, "", "", "", "http://[0:f::f:f:0:0]:65536"}, >+ {"http", "", "", "[0:f::f:f:0:0]", 0, "/", "", "", "http://[0:f::f:f:0:0]:65536/"}); >+ checkRelativeURLDifferences(":foo.com\\", "notspecial://example.org/foo/bar", >+ {"notspecial", "", "", "example.org", 0, "/foo/:foo.com\\", "", "", "notspecial://example.org/foo/:foo.com\\"}, >+ {"notspecial", "", "", "example.org", 0, "/foo/:foo.com/", "", "", "notspecial://example.org/foo/:foo.com/"}); >+ checkURL("sc://pa", {"sc", "", "", "pa", 0, "", "", "", "sc://pa"}); >+ checkRelativeURLDifferences("notspecial:\\\\foo.com\\", "http://example.org/foo/bar", >+ {"notspecial", "", "", "", 0, "\\\\foo.com\\", "", "", "notspecial:\\\\foo.com\\"}, >+ {"notspecial", "", "", "foo.com", 0, "/", "", "", "notspecial://foo.com/"}); >+ checkRelativeURLDifferences("notspecial:\\\\foo.com/", "http://example.org/foo/bar", >+ {"notspecial", "", "", "", 0, "\\\\foo.com/", "", "", "notspecial:\\\\foo.com/"}, >+ {"notspecial", "", "", "foo.com", 0, "/", "", "", "notspecial://foo.com/"}); >+ checkRelativeURLDifferences("notspecial:\\\\foo.com", "http://example.org/foo/bar", >+ {"notspecial", "", "", "", 0, "\\\\foo.com", "", "", "notspecial:\\\\foo.com"}, >+ {"notspecial", "", "", "foo.com", 0, "", "", "", "notspecial://foo.com"}); >+ checkURLDifferences("file://notuser:notpassword@test", >+ {"", "", "", "", 0, "", "", "", "file://notuser:notpassword@test"}, >+ {"file", "notuser", "notpassword", "test", 0, "/", "", "", "file://notuser:notpassword@test/"}); >+ checkURLDifferences("file://notuser:notpassword@test/", >+ {"", "", "", "", 0, "", "", "", "file://notuser:notpassword@test/"}, >+ {"file", "notuser", "notpassword", "test", 0, "/", "", "", "file://notuser:notpassword@test/"}); >+ checkRelativeURLDifferences("http:/", "about:blank", >+ {"", "", "", "", 0, "", "", "", "http:/"}, >+ {"http", "", "", "", 0, "/", "", "", "http:/"}); >+ checkRelativeURLDifferences("http:", "about:blank", >+ {"http", "", "", "", 0, "", "", "", "http:"}, >+ {"http", "", "", "", 0, "/", "", "", "http:/"}); >+ checkRelativeURLDifferences("http:/", "http://host", >+ {"", "", "", "", 0, "", "", "", "http:/"}, >+ {"http", "", "", "", 0, "/", "", "", "http:/"}); >+ checkURLDifferences("http:/", >+ {"", "", "", "", 0, "", "", "", "http:/"}, >+ {"http", "", "", "", 0, "/", "", "", "http:/"}); >+ checkURLDifferences("http:", >+ {"http", "", "", "", 0, "", "", "", "http:"}, >+ {"http", "", "", "", 0, "/", "", "", "http:/"}); >+ checkRelativeURLDifferences("http:/example.com/", "http://example.org/foo/bar", >+ {"http", "", "", "example.org", 0, "/example.com/", "", "", "http://example.org/example.com/"}, >+ {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >+ >+ // This behavior matches Chrome and Firefox, but not WebKit using URL::parse. >+ // The behavior of URL::parse is clearly wrong because reparsing file://path would make path the host. >+ // The spec is unclear. >+ checkURLDifferences("file:path", >+ {"file", "", "", "", 0, "/path", "", "", "file:///path"}, >+ {"file", "", "", "", 0, "path", "", "", "file://path"}); >+ checkURLDifferences("file:pAtH", >+ {"file", "", "", "", 0, "/pAtH", "", "", "file:///pAtH"}, >+ {"file", "", "", "", 0, "pAtH", "", "", "file://pAtH"}); >+ checkURLDifferences("file:pAtH/", >+ {"file", "", "", "", 0, "/pAtH/", "", "", "file:///pAtH/"}, >+ {"file", "", "", "", 0, "pAtH/", "", "", "file://pAtH/"}); >+ checkURLDifferences("http://example.com%A0", >+ {"", "", "", "", 0, "", "", "", "http://example.com%A0"}, >+ {"http", "", "", "example.com%a0", 0, "/", "", "", "http://example.com%a0/"}); >+ checkURLDifferences("http://%E2%98%83", >+ {"http", "", "", "xn--n3h", 0, "/", "", "", "http://xn--n3h/"}, >+ {"http", "", "", "%e2%98%83", 0, "/", "", "", "http://%e2%98%83/"}); >+ checkURLDifferences("http://host%73", >+ {"http", "", "", "hosts", 0, "/", "", "", "http://hosts/"}, >+ {"http", "", "", "host%73", 0, "/", "", "", "http://host%73/"}); >+ checkURLDifferences("http://host%53", >+ {"http", "", "", "hosts", 0, "/", "", "", "http://hosts/"}, >+ {"http", "", "", "host%53", 0, "/", "", "", "http://host%53/"}); >+ checkURLDifferences("http://%", >+ {"", "", "", "", 0, "", "", "", "http://%"}, >+ {"http", "", "", "%", 0, "/", "", "", "http://%/"}); >+ checkURLDifferences("http://%7", >+ {"", "", "", "", 0, "", "", "", "http://%7"}, >+ {"http", "", "", "%7", 0, "/", "", "", "http://%7/"}); >+ checkURLDifferences("http://%7s", >+ {"", "", "", "", 0, "", "", "", "http://%7s"}, >+ {"http", "", "", "%7s", 0, "/", "", "", "http://%7s/"}); >+ checkURLDifferences("http://%73", >+ {"http", "", "", "s", 0, "/", "", "", "http://s/"}, >+ {"http", "", "", "%73", 0, "/", "", "", "http://%73/"}); >+ checkURLDifferences("http://abcdefg%", >+ {"", "", "", "", 0, "", "", "", "http://abcdefg%"}, >+ {"http", "", "", "abcdefg%", 0, "/", "", "", "http://abcdefg%/"}); >+ checkURLDifferences("http://abcd%7Xefg", >+ {"", "", "", "", 0, "", "", "", "http://abcd%7Xefg"}, >+ {"http", "", "", "abcd%7xefg", 0, "/", "", "", "http://abcd%7xefg/"}); >+ >+ >+ // URLParser matches Chrome and the spec, but not URL::parse or Firefox. >+ checkURLDifferences(utf16String(u"http://ï¼ï¼¸ï½ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼"), >+ {"http", "", "", "192.168.0.1", 0, "/", "", "", "http://192.168.0.1/"}, >+ {"http", "", "", "0xc0.0250.01", 0, "/", "", "", "http://0xc0.0250.01/"}); >+ >+ checkURL("http://host/path%2e.%2E", {"http", "", "", "host", 0, "/path%2e.%2E", "", "", "http://host/path%2e.%2E"}); >+ >+ checkRelativeURLDifferences(utf16String(u"http://foo:ð©@example.com/bar"), "http://other.com/", >+ {"http", "foo", utf16String(u"ð©"), "example.com", 0, "/bar", "", "", "http://foo:%F0%9F%92%A9@example.com/bar"}, >+ {"", "", "", "", 0, "", "", "", utf16String(u"http://foo:ð©@example.com/bar")}, testTabsValueForSurrogatePairs); >+ checkRelativeURLDifferences("http://&a:foo(b]c@d:2/", "http://example.org/foo/bar", >+ {"http", "&a", "foo(b]c", "d", 2, "/", "", "", "http://&a:foo(b%5Dc@d:2/"}, >+ {"", "", "", "", 0, "", "", "", "http://&a:foo(b]c@d:2/"}); >+ checkRelativeURLDifferences("http://`{}:`{}@h/`{}?`{}", "http://doesnotmatter/", >+ {"http", "`{}", "`{}", "h", 0, "/%60%7B%7D", "`{}", "", "http://%60%7B%7D:%60%7B%7D@h/%60%7B%7D?`{}"}, >+ {"", "", "", "", 0, "", "", "", "http://`{}:`{}@h/`{}?`{}"}); >+ checkURLDifferences("http://[0:f::f::f]", >+ {"", "", "", "", 0, "" , "", "", "http://[0:f::f::f]"}, >+ {"http", "", "", "[0:f::f::f]", 0, "/" , "", "", "http://[0:f::f::f]/"}); >+ checkURLDifferences("http://123", >+ {"http", "", "", "0.0.0.123", 0, "/", "", "", "http://0.0.0.123/"}, >+ {"http", "", "", "123", 0, "/", "", "", "http://123/"}); >+ checkURLDifferences("http://123.234/", >+ {"http", "", "", "123.0.0.234", 0, "/", "", "", "http://123.0.0.234/"}, >+ {"http", "", "", "123.234", 0, "/", "", "", "http://123.234/"}); >+ checkURLDifferences("http://123.234.012", >+ {"http", "", "", "123.234.0.10", 0, "/", "", "", "http://123.234.0.10/"}, >+ {"http", "", "", "123.234.012", 0, "/", "", "", "http://123.234.012/"}); >+ checkURLDifferences("http://123.234.12", >+ {"http", "", "", "123.234.0.12", 0, "/", "", "", "http://123.234.0.12/"}, >+ {"http", "", "", "123.234.12", 0, "/", "", "", "http://123.234.12/"}); >+ checkRelativeURLDifferences("file:c:\\foo\\bar.html", "file:///tmp/mock/path", >+ {"file", "", "", "", 0, "/c:/foo/bar.html", "", "", "file:///c:/foo/bar.html"}, >+ {"file", "", "", "", 0, "/tmp/mock/c:/foo/bar.html", "", "", "file:///tmp/mock/c:/foo/bar.html"}); >+ checkRelativeURLDifferences(" File:c|////foo\\bar.html", "file:///tmp/mock/path", >+ {"file", "", "", "", 0, "/c:////foo/bar.html", "", "", "file:///c:////foo/bar.html"}, >+ {"file", "", "", "", 0, "/tmp/mock/c|////foo/bar.html", "", "", "file:///tmp/mock/c|////foo/bar.html"}); >+ checkRelativeURLDifferences(" Fil\t\n\te\n\t\n:\t\n\tc\t\n\t|\n\t\n/\t\n\t/\n\t\n//foo\\bar.html", "file:///tmp/mock/path", >+ {"file", "", "", "", 0, "/c:////foo/bar.html", "", "", "file:///c:////foo/bar.html"}, >+ {"file", "", "", "", 0, "/tmp/mock/c|////foo/bar.html", "", "", "file:///tmp/mock/c|////foo/bar.html"}); >+ checkRelativeURLDifferences("C|/foo/bar", "file:///tmp/mock/path", >+ {"file", "", "", "", 0, "/C:/foo/bar", "", "", "file:///C:/foo/bar"}, >+ {"file", "", "", "", 0, "/tmp/mock/C|/foo/bar", "", "", "file:///tmp/mock/C|/foo/bar"}); >+ checkRelativeURLDifferences("/C|/foo/bar", "file:///tmp/mock/path", >+ {"file", "", "", "", 0, "/C:/foo/bar", "", "", "file:///C:/foo/bar"}, >+ {"file", "", "", "", 0, "/C|/foo/bar", "", "", "file:///C|/foo/bar"}); >+ checkRelativeURLDifferences("https://@test@test@example:800/", "http://doesnotmatter/", >+ {"https", "@test@test", "", "example", 800, "/", "", "", "https://%40test%40test@example:800/"}, >+ {"", "", "", "", 0, "", "", "", "https://@test@test@example:800/"}); >+ checkRelativeURLDifferences("https://@test@test@example:800/path@end", "http://doesnotmatter/", >+ {"https", "@test@test", "", "example", 800, "/path@end", "", "", "https://%40test%40test@example:800/path@end"}, >+ {"", "", "", "", 0, "", "", "", "https://@test@test@example:800/path@end"}); >+ checkURLDifferences("notspecial://@test@test@example:800/path@end", >+ {"notspecial", "@test@test", "", "example", 800, "/path@end", "", "", "notspecial://%40test%40test@example:800/path@end"}, >+ {"", "", "", "", 0, "", "", "", "notspecial://@test@test@example:800/path@end"}); >+ checkURLDifferences("notspecial://@test@test@example:800\\path@end", >+ {"notspecial", "@test@test@example", "800\\path", "end", 0, "", "", "", "notspecial://%40test%40test%40example:800%5Cpath@end"}, >+ {"", "", "", "", 0, "", "", "", "notspecial://@test@test@example:800\\path@end"}); >+ checkURLDifferences("http://%48OsT", >+ {"http", "", "", "host", 0, "/", "", "", "http://host/"}, >+ {"http", "", "", "%48ost", 0, "/", "", "", "http://%48ost/"}); >+ checkURLDifferences("http://h%4FsT", >+ {"http", "", "", "host", 0, "/", "", "", "http://host/"}, >+ {"http", "", "", "h%4fst", 0, "/", "", "", "http://h%4fst/"}); >+ checkURLDifferences("http://h%4fsT", >+ {"http", "", "", "host", 0, "/", "", "", "http://host/"}, >+ {"http", "", "", "h%4fst", 0, "/", "", "", "http://h%4fst/"}); >+ checkURLDifferences("http://h%6fsT", >+ {"http", "", "", "host", 0, "/", "", "", "http://host/"}, >+ {"http", "", "", "h%6fst", 0, "/", "", "", "http://h%6fst/"}); >+ checkURLDifferences("http://host/`", >+ {"http", "", "", "host", 0, "/%60", "", "", "http://host/%60"}, >+ {"http", "", "", "host", 0, "/`", "", "", "http://host/`"}); >+ checkURLDifferences("http://://", >+ {"", "", "", "", 0, "", "", "", "http://://"}, >+ {"http", "", "", "", 0, "//", "", "", "http://://"}); >+ checkURLDifferences("http://:123?", >+ {"", "", "", "", 0, "", "", "", "http://:123?"}, >+ {"http", "", "", "", 123, "/", "", "", "http://:123/?"}); >+ checkURLDifferences("http:/:", >+ {"", "", "", "", 0, "", "", "", "http:/:"}, >+ {"http", "", "", "", 0, "/", "", "", "http://:/"}); >+ checkURLDifferences("asdf://:", >+ {"", "", "", "", 0, "", "", "", "asdf://:"}, >+ {"asdf", "", "", "", 0, "", "", "", "asdf://:"}); >+ checkURLDifferences("http://:", >+ {"", "", "", "", 0, "", "", "", "http://:"}, >+ {"http", "", "", "", 0, "/", "", "", "http://:/"}); >+ checkURLDifferences("http:##foo", >+ {"", "", "", "", 0, "", "", "", "http:##foo"}, >+ {"http", "", "", "", 0, "/", "", "#foo", "http:/##foo"}); >+ checkURLDifferences("http:??bar", >+ {"", "", "", "", 0, "", "", "", "http:??bar"}, >+ {"http", "", "", "", 0, "/", "?bar", "", "http:/??bar"}); >+ checkURL("asdf:##foo", {"asdf", "", "", "", 0, "", "", "#foo", "asdf:##foo"}); >+ checkURL("asdf:??bar", {"asdf", "", "", "", 0, "", "?bar", "", "asdf:??bar"}); >+ checkRelativeURLDifferences("//C|/foo/bar", "file:///tmp/mock/path", >+ {"file", "", "", "", 0, "/C:/foo/bar", "", "", "file:///C:/foo/bar"}, >+ {"", "", "", "", 0, "", "", "", "//C|/foo/bar"}); >+ checkRelativeURLDifferences("//C:/foo/bar", "file:///tmp/mock/path", >+ {"file", "", "", "", 0, "/C:/foo/bar", "", "", "file:///C:/foo/bar"}, >+ {"file", "", "", "c", 0, "/foo/bar", "", "", "file://c/foo/bar"}); >+ checkRelativeURLDifferences("//C|?foo/bar", "file:///tmp/mock/path", >+ {"file", "", "", "", 0, "/C:/", "foo/bar", "", "file:///C:/?foo/bar"}, >+ {"", "", "", "", 0, "", "", "", "//C|?foo/bar"}); >+ checkRelativeURLDifferences("//C|#foo/bar", "file:///tmp/mock/path", >+ {"file", "", "", "", 0, "/C:/", "", "foo/bar", "file:///C:/#foo/bar"}, >+ {"", "", "", "", 0, "", "", "", "//C|#foo/bar"}); >+ checkURLDifferences("http://0xFFFFFfFF/", >+ {"http", "", "", "255.255.255.255", 0, "/", "", "", "http://255.255.255.255/"}, >+ {"http", "", "", "0xffffffff", 0, "/", "", "", "http://0xffffffff/"}); >+ checkURLDifferences("http://0000000000000000037777777777/", >+ {"http", "", "", "255.255.255.255", 0, "/", "", "", "http://255.255.255.255/"}, >+ {"http", "", "", "0000000000000000037777777777", 0, "/", "", "", "http://0000000000000000037777777777/"}); >+ checkURLDifferences("http://4294967295/", >+ {"http", "", "", "255.255.255.255", 0, "/", "", "", "http://255.255.255.255/"}, >+ {"http", "", "", "4294967295", 0, "/", "", "", "http://4294967295/"}); >+ checkURLDifferences("http://256/", >+ {"http", "", "", "0.0.1.0", 0, "/", "", "", "http://0.0.1.0/"}, >+ {"http", "", "", "256", 0, "/", "", "", "http://256/"}); >+ checkURLDifferences("http://256./", >+ {"http", "", "", "0.0.1.0", 0, "/", "", "", "http://0.0.1.0/"}, >+ {"http", "", "", "256.", 0, "/", "", "", "http://256./"}); >+ checkURLDifferences("http://123.256/", >+ {"http", "", "", "123.0.1.0", 0, "/", "", "", "http://123.0.1.0/"}, >+ {"http", "", "", "123.256", 0, "/", "", "", "http://123.256/"}); >+ checkURLDifferences("http://127.%.0.1/", >+ {"", "", "", "", 0, "", "", "", "http://127.%.0.1/"}, >+ {"http", "", "", "127.%.0.1", 0, "/", "", "", "http://127.%.0.1/"}); >+ checkURLDifferences("http://[1:2:3:4:5:6:7:8:]/", >+ {"", "", "", "", 0, "", "", "", "http://[1:2:3:4:5:6:7:8:]/"}, >+ {"http", "", "", "[1:2:3:4:5:6:7:8:]", 0, "/", "", "", "http://[1:2:3:4:5:6:7:8:]/"}); >+ checkURLDifferences("http://[:2:3:4:5:6:7:8:]/", >+ {"", "", "", "", 0, "", "", "", "http://[:2:3:4:5:6:7:8:]/"}, >+ {"http", "", "", "[:2:3:4:5:6:7:8:]", 0, "/", "", "", "http://[:2:3:4:5:6:7:8:]/"}); >+ checkURLDifferences("http://[1:2:3:4:5:6:7::]/", >+ {"http", "", "", "[1:2:3:4:5:6:7:0]", 0, "/", "", "", "http://[1:2:3:4:5:6:7:0]/"}, >+ {"http", "", "", "[1:2:3:4:5:6:7::]", 0, "/", "", "", "http://[1:2:3:4:5:6:7::]/"}); >+ checkURLDifferences("http://[1:2:3:4:5:6:7:::]/", >+ {"", "", "", "", 0, "", "", "", "http://[1:2:3:4:5:6:7:::]/"}, >+ {"http", "", "", "[1:2:3:4:5:6:7:::]", 0, "/", "", "", "http://[1:2:3:4:5:6:7:::]/"}); >+ checkURLDifferences("http://127.0.0.1~/", >+ {"http", "", "", "127.0.0.1~", 0, "/", "", "", "http://127.0.0.1~/"}, >+ {"", "", "", "", 0, "", "", "", "http://127.0.0.1~/"}); >+ checkURLDifferences("http://127.0.1~/", >+ {"http", "", "", "127.0.1~", 0, "/", "", "", "http://127.0.1~/"}, >+ {"", "", "", "", 0, "", "", "", "http://127.0.1~/"}); >+ checkURLDifferences("http://127.0.1./", >+ {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}, >+ {"http", "", "", "127.0.1.", 0, "/", "", "", "http://127.0.1./"}); >+ checkURLDifferences("http://127.0.1.~/", >+ {"http", "", "", "127.0.1.~", 0, "/", "", "", "http://127.0.1.~/"}, >+ {"", "", "", "", 0, "", "", "", "http://127.0.1.~/"}); >+ checkURLDifferences("http://127.0.1.~", >+ {"http", "", "", "127.0.1.~", 0, "/", "", "", "http://127.0.1.~/"}, >+ {"", "", "", "", 0, "", "", "", "http://127.0.1.~"}); >+ checkRelativeURLDifferences("http://f:000/c", "http://example.org/foo/bar", >+ {"http", "", "", "f", 0, "/c", "", "", "http://f:0/c"}, >+ {"http", "", "", "f", 0, "/c", "", "", "http://f:000/c"}); >+ checkRelativeURLDifferences("http://f:010/c", "http://example.org/foo/bar", >+ {"http", "", "", "f", 10, "/c", "", "", "http://f:10/c"}, >+ {"http", "", "", "f", 10, "/c", "", "", "http://f:010/c"}); >+ checkURL("notspecial://HoSt", {"notspecial", "", "", "HoSt", 0, "", "", "", "notspecial://HoSt"}); >+ checkURL("notspecial://H%6FSt", {"notspecial", "", "", "H%6FSt", 0, "", "", "", "notspecial://H%6FSt"}); >+ checkURL("notspecial://H%4fSt", {"notspecial", "", "", "H%4fSt", 0, "", "", "", "notspecial://H%4fSt"}); >+ checkURLDifferences(utf16String(u"notspecial://HðÃt"), >+ {"notspecial", "", "", "H%F0%9F%98%8D%C3%9Ft", 0, "", "", "", "notspecial://H%F0%9F%98%8D%C3%9Ft"}, >+ {"notspecial", "", "", "xn--hsst-qc83c", 0, "", "", "", "notspecial://xn--hsst-qc83c"}, testTabsValueForSurrogatePairs); >+ checkURLDifferences("http://[ffff:aaaa:cccc:eeee:bbbb:dddd:255.255.255.255]/", >+ {"http", "", "", "[ffff:aaaa:cccc:eeee:bbbb:dddd:ffff:ffff]", 0, "/", "", "", "http://[ffff:aaaa:cccc:eeee:bbbb:dddd:ffff:ffff]/"}, >+ {"http", "", "", "[ffff:aaaa:cccc:eeee:bbbb:dddd:255.255.255.255]", 0, "/", "", "", "http://[ffff:aaaa:cccc:eeee:bbbb:dddd:255.255.255.255]/"}, TestTabs::No); >+ checkURLDifferences("http://[::123.234.12.210]/", >+ {"http", "", "", "[::7bea:cd2]", 0, "/", "", "", "http://[::7bea:cd2]/"}, >+ {"http", "", "", "[::123.234.12.210]", 0, "/", "", "", "http://[::123.234.12.210]/"}); >+ checkURLDifferences("http://[::a:255.255.255.255]/", >+ {"http", "", "", "[::a:ffff:ffff]", 0, "/", "", "", "http://[::a:ffff:ffff]/"}, >+ {"http", "", "", "[::a:255.255.255.255]", 0, "/", "", "", "http://[::a:255.255.255.255]/"}); >+ checkURLDifferences("http://[::0.00.255.255]/", >+ {"", "", "", "", 0, "", "", "", "http://[::0.00.255.255]/"}, >+ {"http", "", "", "[::0.00.255.255]", 0, "/", "", "", "http://[::0.00.255.255]/"}); >+ checkURLDifferences("http://[::0.0.255.255]/", >+ {"http", "", "", "[::ffff]", 0, "/", "", "", "http://[::ffff]/"}, >+ {"http", "", "", "[::0.0.255.255]", 0, "/", "", "", "http://[::0.0.255.255]/"}); >+ checkURLDifferences("http://[::0:1.0.255.255]/", >+ {"http", "", "", "[::100:ffff]", 0, "/", "", "", "http://[::100:ffff]/"}, >+ {"http", "", "", "[::0:1.0.255.255]", 0, "/", "", "", "http://[::0:1.0.255.255]/"}); >+ checkURLDifferences("http://[::A:1.0.255.255]/", >+ {"http", "", "", "[::a:100:ffff]", 0, "/", "", "", "http://[::a:100:ffff]/"}, >+ {"http", "", "", "[::a:1.0.255.255]", 0, "/", "", "", "http://[::a:1.0.255.255]/"}); >+ checkURLDifferences("http://[:127.0.0.1]", >+ {"", "", "", "", 0, "", "", "", "http://[:127.0.0.1]"}, >+ {"http", "", "", "[:127.0.0.1]", 0, "/", "", "", "http://[:127.0.0.1]/"}); >+ checkURLDifferences("http://[127.0.0.1]", >+ {"", "", "", "", 0, "", "", "", "http://[127.0.0.1]"}, >+ {"http", "", "", "[127.0.0.1]", 0, "/", "", "", "http://[127.0.0.1]/"}); >+ checkURLDifferences("http://[a:b:c:d:e:f:127.0.0.1]", >+ {"http", "", "", "[a:b:c:d:e:f:7f00:1]", 0, "/", "", "", "http://[a:b:c:d:e:f:7f00:1]/"}, >+ {"http", "", "", "[a:b:c:d:e:f:127.0.0.1]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0.0.1]/"}); >+ checkURLDifferences("http://[a:b:c:d:e:f:127.0.0.101]", >+ {"http", "", "", "[a:b:c:d:e:f:7f00:65]", 0, "/", "", "", "http://[a:b:c:d:e:f:7f00:65]/"}, >+ {"http", "", "", "[a:b:c:d:e:f:127.0.0.101]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0.0.101]/"}); >+ checkURLDifferences("http://[::a:b:c:d:e:f:127.0.0.1]", >+ {"", "", "", "", 0, "", "", "", "http://[::a:b:c:d:e:f:127.0.0.1]"}, >+ {"http", "", "", "[::a:b:c:d:e:f:127.0.0.1]", 0, "/", "", "", "http://[::a:b:c:d:e:f:127.0.0.1]/"}); >+ checkURLDifferences("http://[a:b::c:d:e:f:127.0.0.1]", >+ {"", "", "", "", 0, "", "", "", "http://[a:b::c:d:e:f:127.0.0.1]"}, >+ {"http", "", "", "[a:b::c:d:e:f:127.0.0.1]", 0, "/", "", "", "http://[a:b::c:d:e:f:127.0.0.1]/"}); >+ checkURLDifferences("http://[a:b:c:d:e:127.0.0.1]", >+ {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:127.0.0.1]"}, >+ {"http", "", "", "[a:b:c:d:e:127.0.0.1]", 0, "/", "", "", "http://[a:b:c:d:e:127.0.0.1]/"}); >+ checkURLDifferences("http://[a:b:c:d:e:f:127.0.0.0.1]", >+ {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f:127.0.0.0.1]"}, >+ {"http", "", "", "[a:b:c:d:e:f:127.0.0.0.1]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0.0.0.1]/"}); >+ checkURLDifferences("http://[a:b:c:d:e:f:127.0.1]", >+ {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f:127.0.1]"}, >+ {"http", "", "", "[a:b:c:d:e:f:127.0.1]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0.1]/"}); >+ checkURLDifferences("http://[a:b:c:d:e:f:127.0.0.011]", // Chrome treats this as octal, Firefox and the spec fail >+ {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f:127.0.0.011]"}, >+ {"http", "", "", "[a:b:c:d:e:f:127.0.0.011]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0.0.011]/"}); >+ checkURLDifferences("http://[a:b:c:d:e:f:127.0.00.1]", >+ {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f:127.0.00.1]"}, >+ {"http", "", "", "[a:b:c:d:e:f:127.0.00.1]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0.00.1]/"}); >+ checkURLDifferences("http://[a:b:c:d:e:f:127.0.0.1.]", >+ {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f:127.0.0.1.]"}, >+ {"http", "", "", "[a:b:c:d:e:f:127.0.0.1.]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0.0.1.]/"}); >+ checkURLDifferences("http://[a:b:c:d:e:f:127.0..0.1]", >+ {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f:127.0..0.1]"}, >+ {"http", "", "", "[a:b:c:d:e:f:127.0..0.1]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0..0.1]/"}); >+ checkURLDifferences("http://[a:b:c:d:e:f::127.0.0.1]", >+ {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f::127.0.0.1]"}, >+ {"http", "", "", "[a:b:c:d:e:f::127.0.0.1]", 0, "/", "", "", "http://[a:b:c:d:e:f::127.0.0.1]/"}); >+ checkURLDifferences("http://[a:b:c:d:e::127.0.0.1]", >+ {"http", "", "", "[a:b:c:d:e:0:7f00:1]", 0, "/", "", "", "http://[a:b:c:d:e:0:7f00:1]/"}, >+ {"http", "", "", "[a:b:c:d:e::127.0.0.1]", 0, "/", "", "", "http://[a:b:c:d:e::127.0.0.1]/"}); >+ checkURLDifferences("http://[a:b:c:d::e:127.0.0.1]", >+ {"http", "", "", "[a:b:c:d:0:e:7f00:1]", 0, "/", "", "", "http://[a:b:c:d:0:e:7f00:1]/"}, >+ {"http", "", "", "[a:b:c:d::e:127.0.0.1]", 0, "/", "", "", "http://[a:b:c:d::e:127.0.0.1]/"}); >+ checkURLDifferences("http://[a:b:c:d:e:f::127.0.0.]", >+ {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f::127.0.0.]"}, >+ {"http", "", "", "[a:b:c:d:e:f::127.0.0.]", 0, "/", "", "", "http://[a:b:c:d:e:f::127.0.0.]/"}); >+ checkURLDifferences("http://[a:b:c:d:e:f::127.0.0.256]", >+ {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f::127.0.0.256]"}, >+ {"http", "", "", "[a:b:c:d:e:f::127.0.0.256]", 0, "/", "", "", "http://[a:b:c:d:e:f::127.0.0.256]/"}); >+ checkURLDifferences("http://123456", {"http", "", "", "0.1.226.64", 0, "/", "", "", "http://0.1.226.64/"}, {"http", "", "", "123456", 0, "/", "", "", "http://123456/"}); >+ checkURL("asdf://123456", {"asdf", "", "", "123456", 0, "", "", "", "asdf://123456"}); >+ checkURLDifferences("http://[0:0:0:0:a:b:c:d]", >+ {"http", "", "", "[::a:b:c:d]", 0, "/", "", "", "http://[::a:b:c:d]/"}, >+ {"http", "", "", "[0:0:0:0:a:b:c:d]", 0, "/", "", "", "http://[0:0:0:0:a:b:c:d]/"}); >+ checkURLDifferences("asdf://[0:0:0:0:a:b:c:d]", >+ {"asdf", "", "", "[::a:b:c:d]", 0, "", "", "", "asdf://[::a:b:c:d]"}, >+ {"asdf", "", "", "[0:0:0:0:a:b:c:d]", 0, "", "", "", "asdf://[0:0:0:0:a:b:c:d]"}, TestTabs::No); >+ shouldFail("a://%:a"); >+ checkURL("a://%:/", {"a", "", "", "%", 0, "/", "", "", "a://%/"}); >+ checkURL("a://%:", {"a", "", "", "%", 0, "", "", "", "a://%"}); >+ checkURL("a://%:1/", {"a", "", "", "%", 1, "/", "", "", "a://%:1/"}); >+ checkURLDifferences("http://%:", >+ {"", "", "", "", 0, "", "", "", "http://%:"}, >+ {"http", "", "", "%", 0, "/", "", "", "http://%/"}); >+ checkURL("a://123456", {"a", "", "", "123456", 0, "", "", "", "a://123456"}); >+ checkURL("a://123456:7", {"a", "", "", "123456", 7, "", "", "", "a://123456:7"}); >+ checkURL("a://123456:7/", {"a", "", "", "123456", 7, "/", "", "", "a://123456:7/"}); >+ checkURL("a://A", {"a", "", "", "A", 0, "", "", "", "a://A"}); >+ checkURL("a://A:2", {"a", "", "", "A", 2, "", "", "", "a://A:2"}); >+ checkURL("a://A:2/", {"a", "", "", "A", 2, "/", "", "", "a://A:2/"}); >+ checkURLDifferences(u8"asd://Ã", >+ {"asd", "", "", "%C3%83%C2%9F", 0, "", "", "", "asd://%C3%83%C2%9F"}, >+ {"", "", "", "", 0, "", "", "", "about:blank"}, TestTabs::No); >+ checkURLDifferences(u8"asd://Ã:4", >+ {"asd", "", "", "%C3%83%C2%9F", 4, "", "", "", "asd://%C3%83%C2%9F:4"}, >+ {"", "", "", "", 0, "", "", "", "about:blank"}, TestTabs::No); >+ checkURLDifferences(u8"asd://Ã:4/", >+ {"asd", "", "", "%C3%83%C2%9F", 4, "/", "", "", "asd://%C3%83%C2%9F:4/"}, >+ {"", "", "", "", 0, "", "", "", "about:blank"}, TestTabs::No); >+ checkURLDifferences("a://[A::b]:4", >+ {"a", "", "", "[a::b]", 4, "", "", "", "a://[a::b]:4"}, >+ {"a", "", "", "[A::b]", 4, "", "", "", "a://[A::b]:4"}); >+ shouldFail("http://[~]"); >+ shouldFail("a://[~]"); >+ checkRelativeURLDifferences("a://b", "//[aBc]", >+ {"a", "", "", "b", 0, "", "", "", "a://b"}, >+ {"", "", "", "", 0, "", "", "", "a://b"}); >+ checkURL(utf16String(u"http://öbb.at"), {"http", "", "", "xn--bb-eka.at", 0, "/", "", "", "http://xn--bb-eka.at/"}); >+ checkURL(utf16String(u"http://ÃBB.at"), {"http", "", "", "xn--bb-eka.at", 0, "/", "", "", "http://xn--bb-eka.at/"}); >+ checkURL(utf16String(u"http://â.com"), {"http", "", "", "xn--19g.com", 0, "/", "", "", "http://xn--19g.com/"}); >+ checkURLDifferences(utf16String(u"http://faÃ.de"), >+ {"http", "", "", "xn--fa-hia.de", 0, "/", "", "", "http://xn--fa-hia.de/"}, >+ {"http", "", "", "fass.de", 0, "/", "", "", "http://fass.de/"}); >+ checkURL(utf16String(u"http://ÔÓлп.com"), {"http", "", "", "xn--k1ai47bhi.com", 0, "/", "", "", "http://xn--k1ai47bhi.com/"}); >+ checkURLDifferences(utf16String(u"http://Ⱥbby.com"), >+ {"http", "", "", "xn--bby-iy0b.com", 0, "/", "", "", "http://xn--bby-iy0b.com/"}, >+ {"http", "", "", "xn--bby-spb.com", 0, "/", "", "", "http://xn--bby-spb.com/"}); >+ checkURLDifferences(utf16String(u"http://\u2132"), >+ {"", "", "", "", 0, "", "", "", utf16String(u"http://â²")}, >+ {"http", "", "", "xn--f3g", 0, "/", "", "", "http://xn--f3g/"}); >+ checkURLDifferences(utf16String(u"http://\u05D9\u05B4\u05D5\u05D0\u05B8/"), >+ {"http", "", "", "xn--cdbi5etas", 0, "/", "", "", "http://xn--cdbi5etas/"}, >+ {"", "", "", "", 0, "", "", "", "about:blank"}, TestTabs::No); >+ checkURLDifferences(utf16String(u"http://bidirectional\u0786\u07AE\u0782\u07B0\u0795\u07A9\u0793\u07A6\u0783\u07AA/"), >+ {"", "", "", "", 0, "", "", "", utf16String(u"http://bidirectionalÞÞ®ÞÞ°ÞÞ©ÞÞ¦ÞÞª/")}, >+ {"", "", "", "", 0, "", "", "", "about:blank"}, TestTabs::No); >+ checkURLDifferences(utf16String(u"http://contextj\u200D"), >+ {"", "", "", "", 0, "", "", "", utf16String(u"http://contextj\u200D")}, >+ {"http", "", "", "contextj", 0, "/", "", "", "http://contextj/"}); >+ checkURL(utf16String(u"http://contexto\u30FB"), {"http", "", "", "xn--contexto-wg5g", 0, "/", "", "", "http://xn--contexto-wg5g/"}); >+ checkURLDifferences(utf16String(u"http://\u321D\u321E/"), >+ {"http", "", "", "xn--()()-bs0sc174agx4b", 0, "/", "", "", "http://xn--()()-bs0sc174agx4b/"}, >+ {"http", "", "", "xn--5mkc", 0, "/", "", "", "http://xn--5mkc/"}); >+} >+ >+TEST_F(WTF_URLParser, DefaultPort) >+{ >+ checkURL("FtP://host:21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}); >+ checkURL("ftp://host:21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}); >+ checkURL("f\ttp://host:21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}); >+ checkURL("f\ttp://host\t:21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}); >+ checkURL("f\ttp://host:\t21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}); >+ checkURL("f\ttp://host:2\t1/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}); >+ checkURL("f\ttp://host:21\t/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}); >+ checkURL("ftp://host\t:21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}); >+ checkURL("ftp://host:\t21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}); >+ checkURL("ftp://host:2\t1/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}); >+ checkURL("ftp://host:21\t/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}); >+ checkURL("ftp://host:22/", {"ftp", "", "", "host", 22, "/", "", "", "ftp://host:22/"}); >+ checkURLDifferences("ftp://host:21", >+ {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}, >+ {"ftp", "", "", "host", 0, "", "", "", "ftp://host"}); >+ checkURLDifferences("ftp://host:22", >+ {"ftp", "", "", "host", 22, "/", "", "", "ftp://host:22/"}, >+ {"ftp", "", "", "host", 22, "", "", "", "ftp://host:22"}); >+ >+ checkURL("gOpHeR://host:70/", {"gopher", "", "", "host", 0, "/", "", "", "gopher://host/"}); >+ checkURL("gopher://host:70/", {"gopher", "", "", "host", 0, "/", "", "", "gopher://host/"}); >+ checkURL("gopher://host:71/", {"gopher", "", "", "host", 71, "/", "", "", "gopher://host:71/"}); >+ // Spec, Chrome, Firefox, and URLParser have "/", URL::parse does not. >+ // Spec, Chrome, URLParser, URL::parse recognize gopher default port, Firefox does not. >+ checkURLDifferences("gopher://host:70", >+ {"gopher", "", "", "host", 0, "/", "", "", "gopher://host/"}, >+ {"gopher", "", "", "host", 0, "", "", "", "gopher://host"}); >+ checkURLDifferences("gopher://host:71", >+ {"gopher", "", "", "host", 71, "/", "", "", "gopher://host:71/"}, >+ {"gopher", "", "", "host", 71, "", "", "", "gopher://host:71"}); >+ >+ checkURL("hTtP://host:80", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >+ checkURL("http://host:80", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >+ checkURL("http://host:80/", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >+ checkURL("http://host:81", {"http", "", "", "host", 81, "/", "", "", "http://host:81/"}); >+ checkURL("http://host:81/", {"http", "", "", "host", 81, "/", "", "", "http://host:81/"}); >+ >+ checkURL("hTtPs://host:443", {"https", "", "", "host", 0, "/", "", "", "https://host/"}); >+ checkURL("https://host:443", {"https", "", "", "host", 0, "/", "", "", "https://host/"}); >+ checkURL("https://host:443/", {"https", "", "", "host", 0, "/", "", "", "https://host/"}); >+ checkURL("https://host:444", {"https", "", "", "host", 444, "/", "", "", "https://host:444/"}); >+ checkURL("https://host:444/", {"https", "", "", "host", 444, "/", "", "", "https://host:444/"}); >+ >+ checkURL("wS://host:80/", {"ws", "", "", "host", 0, "/", "", "", "ws://host/"}); >+ checkURL("ws://host:80/", {"ws", "", "", "host", 0, "/", "", "", "ws://host/"}); >+ checkURL("ws://host:81/", {"ws", "", "", "host", 81, "/", "", "", "ws://host:81/"}); >+ // URLParser matches Chrome and Firefox, but not URL::parse >+ checkURLDifferences("ws://host:80", >+ {"ws", "", "", "host", 0, "/", "", "", "ws://host/"}, >+ {"ws", "", "", "host", 0, "", "", "", "ws://host"}); >+ checkURLDifferences("ws://host:81", >+ {"ws", "", "", "host", 81, "/", "", "", "ws://host:81/"}, >+ {"ws", "", "", "host", 81, "", "", "", "ws://host:81"}); >+ >+ checkURL("WsS://host:443/", {"wss", "", "", "host", 0, "/", "", "", "wss://host/"}); >+ checkURL("wss://host:443/", {"wss", "", "", "host", 0, "/", "", "", "wss://host/"}); >+ checkURL("wss://host:444/", {"wss", "", "", "host", 444, "/", "", "", "wss://host:444/"}); >+ // URLParser matches Chrome and Firefox, but not URL::parse >+ checkURLDifferences("wss://host:443", >+ {"wss", "", "", "host", 0, "/", "", "", "wss://host/"}, >+ {"wss", "", "", "host", 0, "", "", "", "wss://host"}); >+ checkURLDifferences("wss://host:444", >+ {"wss", "", "", "host", 444, "/", "", "", "wss://host:444/"}, >+ {"wss", "", "", "host", 444, "", "", "", "wss://host:444"}); >+ >+ checkURL("fTpS://host:990/", {"ftps", "", "", "host", 990, "/", "", "", "ftps://host:990/"}); >+ checkURL("ftps://host:990/", {"ftps", "", "", "host", 990, "/", "", "", "ftps://host:990/"}); >+ checkURL("ftps://host:991/", {"ftps", "", "", "host", 991, "/", "", "", "ftps://host:991/"}); >+ checkURL("ftps://host:990", {"ftps", "", "", "host", 990, "", "", "", "ftps://host:990"}); >+ checkURL("ftps://host:991", {"ftps", "", "", "host", 991, "", "", "", "ftps://host:991"}); >+ >+ checkURL("uNkNoWn://host:80/", {"unknown", "", "", "host", 80, "/", "", "", "unknown://host:80/"}); >+ checkURL("unknown://host:80/", {"unknown", "", "", "host", 80, "/", "", "", "unknown://host:80/"}); >+ checkURL("unknown://host:81/", {"unknown", "", "", "host", 81, "/", "", "", "unknown://host:81/"}); >+ checkURL("unknown://host:80", {"unknown", "", "", "host", 80, "", "", "", "unknown://host:80"}); >+ checkURL("unknown://host:81", {"unknown", "", "", "host", 81, "", "", "", "unknown://host:81"}); >+ >+ checkURL("file://host:0", {"file", "", "", "host", 0, "/", "", "", "file://host:0/"}); >+ checkURL("file://host:80", {"file", "", "", "host", 80, "/", "", "", "file://host:80/"}); >+ checkURL("file://host:80/path", {"file", "", "", "host", 80, "/path", "", "", "file://host:80/path"}); >+ checkURLDifferences("file://:80/path", >+ {"", "", "", "", 0, "", "", "", "file://:80/path"}, >+ {"file", "", "", "", 80, "/path", "", "", "file://:80/path"}); >+ checkURLDifferences("file://:0/path", >+ {"", "", "", "", 0, "", "", "", "file://:0/path"}, >+ {"file", "", "", "", 0, "/path", "", "", "file://:0/path"}); >+ >+ checkURL("http://example.com:0000000000000077", {"http", "", "", "example.com", 77, "/", "", "", "http://example.com:77/"}); >+ checkURL("http://example.com:0000000000000080", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >+} >+ >+TEST_F(WTF_URLParser, ParserFailures) >+{ >+ shouldFail(" "); >+ shouldFail(" \a "); >+ shouldFail(""); >+ shouldFail(String()); >+ shouldFail("", "about:blank"); >+ shouldFail(String(), "about:blank"); >+ shouldFail("http://127.0.0.1:abc"); >+ shouldFail("http://host:abc"); >+ shouldFail("http://:abc"); >+ shouldFail("http://a:@", "about:blank"); >+ shouldFail("http://:b@", "about:blank"); >+ shouldFail("http://:@", "about:blank"); >+ shouldFail("http://a:@"); >+ shouldFail("http://:b@"); >+ shouldFail("http://@"); >+ shouldFail("http://[0:f::f:f:0:0]:abc"); >+ shouldFail("../i", "sc:sd"); >+ shouldFail("../i", "sc:sd/sd"); >+ shouldFail("/i", "sc:sd"); >+ shouldFail("/i", "sc:sd/sd"); >+ shouldFail("?i", "sc:sd"); >+ shouldFail("?i", "sc:sd/sd"); >+ shouldFail("http://example example.com", "http://other.com/"); >+ shouldFail("http://[www.example.com]/", "about:blank"); >+ shouldFail("http://192.168.0.1 hello", "http://other.com/"); >+ shouldFail("http://[example.com]", "http://other.com/"); >+ shouldFail("i", "sc:sd"); >+ shouldFail("i", "sc:sd/sd"); >+ shouldFail("i"); >+ shouldFail("asdf"); >+ shouldFail("~"); >+ shouldFail("%"); >+ shouldFail("//%"); >+ shouldFail("~", "about:blank"); >+ shouldFail("~~~"); >+ shouldFail("://:0/"); >+ shouldFail("://:0/", ""); >+ shouldFail("://:0/", "about:blank"); >+ shouldFail("about~"); >+ shouldFail("//C:asdf/foo/bar", "file:///tmp/mock/path"); >+ shouldFail("http://[1234::ab#]"); >+ shouldFail("http://[1234::ab/]"); >+ shouldFail("http://[1234::ab?]"); >+ shouldFail("http://[1234::ab@]"); >+ shouldFail("http://[1234::ab~]"); >+ shouldFail("http://[2001::1"); >+ shouldFail("http://4:b\xE1"); >+ shouldFail("http://[1:2:3:4:5:6:7:8~]/"); >+ shouldFail("http://[a:b:c:d:e:f:g:127.0.0.1]"); >+ shouldFail("http://[a:b:c:d:e:f:g:h:127.0.0.1]"); >+ shouldFail("http://[a:b:c:d:e:f:127.0.0.0x11]"); // Chrome treats this as hex, Firefox and the spec fail >+ shouldFail("http://[a:b:c:d:e:f:127.0.-0.1]"); >+ shouldFail("asdf://space In\aHost"); >+ shouldFail("asdf://[0:0:0:0:a:b:c:d"); >+} >+ >+// These are in the spec but not in the web platform tests. >+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:"}); >+ checkURL("notspecial\t\t\n\t:\t\t\n\t/\t\t\n\t/\t\t\n\thost", {"notspecial", "", "", "host", 0, "", "", "", "notspecial://host"}); >+ checkRelativeURL("http:", "http://example.org/foo/bar?query#fragment", {"http", "", "", "example.org", 0, "/foo/bar", "query", "", "http://example.org/foo/bar?query"}); >+ checkRelativeURLDifferences("ws:", "http://example.org/foo/bar", >+ {"ws", "", "", "", 0, "", "", "", "ws:"}, >+ {"ws", "", "", "", 0, "s:", "", "", "ws:s:"}); >+ checkRelativeURL("notspecial:", "http://example.org/foo/bar", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"}); >+ >+ const wchar_t surrogateBegin = 0xD800; >+ const wchar_t validSurrogateEnd = 0xDD55; >+ const wchar_t invalidSurrogateEnd = 'A'; >+ const wchar_t replacementCharacter = 0xFFFD; >+ checkURL(utf16String<12>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', surrogateBegin, validSurrogateEnd, '\0'}), >+ {"http", "", "", "w", 0, "/%F0%90%85%95", "", "", "http://w/%F0%90%85%95"}, testTabsValueForSurrogatePairs); >+ shouldFail(utf16String<10>({'h', 't', 't', 'p', ':', '/', surrogateBegin, invalidSurrogateEnd, '/', '\0'})); >+ shouldFail(utf16String<9>({'h', 't', 't', 'p', ':', '/', replacementCharacter, '/', '\0'})); >+ >+ // URLParser matches Chrome and Firefox but not URL::parse. >+ checkURLDifferences(utf16String<12>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', surrogateBegin, invalidSurrogateEnd}), >+ {"http", "", "", "w", 0, "/%EF%BF%BDA", "", "", "http://w/%EF%BF%BDA"}, >+ {"http", "", "", "w", 0, "/%ED%A0%80A", "", "", "http://w/%ED%A0%80A"}); >+ checkURLDifferences(utf16String<13>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', '?', surrogateBegin, invalidSurrogateEnd, '\0'}), >+ {"http", "", "", "w", 0, "/", "%EF%BF%BDA", "", "http://w/?%EF%BF%BDA"}, >+ {"http", "", "", "w", 0, "/", "%ED%A0%80A", "", "http://w/?%ED%A0%80A"}); >+ checkURLDifferences(utf16String<11>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', surrogateBegin, '\0'}), >+ {"http", "", "", "w", 0, "/%EF%BF%BD", "", "", "http://w/%EF%BF%BD"}, >+ {"http", "", "", "w", 0, "/%ED%A0%80", "", "", "http://w/%ED%A0%80"}); >+ checkURLDifferences(utf16String<12>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', '?', surrogateBegin, '\0'}), >+ {"http", "", "", "w", 0, "/", "%EF%BF%BD", "", "http://w/?%EF%BF%BD"}, >+ {"http", "", "", "w", 0, "/", "%ED%A0%80", "", "http://w/?%ED%A0%80"}); >+ checkURLDifferences(utf16String<13>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', '?', surrogateBegin, ' ', '\0'}), >+ {"http", "", "", "w", 0, "/", "%EF%BF%BD", "", "http://w/?%EF%BF%BD"}, >+ {"http", "", "", "w", 0, "/", "%ED%A0%80", "", "http://w/?%ED%A0%80"}); >+ >+ // FIXME: Write more invalid surrogate pair tests based on feedback from https://bugs.webkit.org/show_bug.cgi?id=162105 >+} >+ >+} // namespace TestWebKitAPI >diff --git a/Tools/TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm b/Tools/TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..28076f4ba06dbed7b7debfcc0db599cf7876b1b9 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm >@@ -0,0 +1,207 @@ >+/* >+ * Copyright (C) 2014 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. >+ */ >+ >+#import "config.h" >+ >+#import <wtf/Vector.h> >+#import <wtf/cocoa/NSURLExtras.h> >+#import <wtf/text/WTFString.h> >+ >+namespace TestWebKitAPI { >+ >+static NSData *literalAsData(const char* literal) >+{ >+ return [NSData dataWithBytes:literal length:strlen(literal)]; >+} >+ >+static const char* dataAsString(NSData *data) >+{ >+ static char buffer[1000]; >+ if ([data length] > sizeof(buffer) - 1) >+ return "ERROR"; >+ if (memchr([data bytes], 0, [data length])) >+ return "ERROR"; >+ memcpy(buffer, [data bytes], [data length]); >+ buffer[[data length]] = '\0'; >+ return buffer; >+} >+ >+static const char* originalDataAsString(NSURL *URL) >+{ >+ return dataAsString(WTF::originalURLData(URL)); >+} >+ >+static const char* userVisibleString(NSURL *URL) >+{ >+ return [WTF::userVisibleString(URL) UTF8String]; >+} >+ >+static NSURL *literalURL(const char* literal) >+{ >+ return WTF::URLWithData(literalAsData(literal), nil); >+} >+ >+TEST(WTF_URLExtras, URLExtras) >+{ >+ EXPECT_STREQ("http://site.com", originalDataAsString(literalURL("http://site.com"))); >+ EXPECT_STREQ("http://%77ebsite.com", originalDataAsString(literalURL("http://%77ebsite.com"))); >+ >+ EXPECT_STREQ("http://site.com", userVisibleString(literalURL("http://site.com"))); >+ EXPECT_STREQ("http://%77ebsite.com", userVisibleString(literalURL("http://%77ebsite.com"))); >+} >+ >+TEST(WTF_URLExtras, URLExtras_Spoof) >+{ >+ Vector<String> punycodedSpoofHosts = { >+ "xn--cfa45g", // U+0131, U+0307 >+ "xn--tma03b", // U+0237, U+0307 >+ "xn--tma03bxga", // U+0237, U+034F, U+034F, U+0307 >+ "xn--tma03bl01e", // U+0237, U+200B, U+0307 >+ "xn--a-egb", // a, U+034F >+ "xn--a-qgn", // a, U+200B >+ "xn--a-mgn", // a, U+2009 >+ "xn--u7f", // U+1D04 >+ "xn--57f", // U+1D0F >+ "xn--i38a", // U+A731 >+ "xn--j8f", // U+1D1C >+ "xn--n8f", // U+1D20 >+ "xn--o8f", // U+1D21 >+ "xn--p8f", // U+1D22 >+ "xn--0na", // U+0261 >+ "xn--cn-ded", // U+054D >+ "xn--ews-nfe.org", // U+054D >+ "xn--yotube-qkh", // U+0578 >+ "xn--cla-7fe.edu", // U+0578 >+ "xn--rsa94l", // U+05D5 U+0307 >+ "xn--hdb9c", // U+05D5 U+05B9 >+ "xn--idb7c", // U+05D5 U+05BA >+ "xn--pdb3b", // U+05D5 U+05C1 >+ "xn--qdb1b", // U+05D5 U+05C2 >+ "xn--sdb7a", // U+05D5 U+05C4 >+ "xn--2-zic", // U+0032 U+05E1 >+ }; >+ for (const String& host : punycodedSpoofHosts) { >+ auto url = makeString("http://", host, "/").utf8(); >+ EXPECT_STREQ(url.data(), userVisibleString(literalURL(url.data()))); >+ } >+} >+ >+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"))); >+ EXPECT_STREQ("https://\u0573\u0574\u0578.\u0570\u0561\u0575", userVisibleString(literalURL("https://\u0573\u0574\u0578.\u0570\u0561\u0575"))); >+ EXPECT_STREQ("https://\u0573-1-\u0574\u0578.\u0570\u0561\u0575", userVisibleString(literalURL("https://\u0573-1-\u0574\u0578.\u0570\u0561\u0575"))); >+ EXPECT_STREQ("https://2\u0573_\u0574\u0578.\u0570\u0561\u0575", userVisibleString(literalURL("https://2\u0573_\u0574\u0578.\u0570\u0561\u0575"))); >+ EXPECT_STREQ("https://\u0573_\u0574\u05783.\u0570\u0561\u0575", userVisibleString(literalURL("https://\u0573_\u0574\u05783.\u0570\u0561\u0575"))); >+ EXPECT_STREQ("https://got\u0551\u0535\u0543.com", userVisibleString(literalURL("https://got\u0551\u0535\u0543.com"))); >+ EXPECT_STREQ("https://\u0551\u0535\u0543fans.net", userVisibleString(literalURL("https://\u0551\u0535\u0543fans.net"))); >+ EXPECT_STREQ("https://\u0551\u0535or\u0575\u0543.biz", userVisibleString(literalURL("https://\u0551\u0535or\u0575\u0543.biz"))); >+ EXPECT_STREQ("https://\u0551\u0535and!$^&*()-~+={}or<>,.?\u0575\u0543.biz", userVisibleString(literalURL("https://\u0551\u0535and!$^&*()-~+={}or<>,.?\u0575\u0543.biz"))); >+} >+ >+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. >+ >+ // Code path similar to the one used when typing in a URL. >+ EXPECT_STREQ("http://site.xn--comothersite-kjb.org", originalDataAsString(WTF::URLWithUserTypedString(@"http://site.com\xC3\xB7othersite.org", nil))); >+ EXPECT_STREQ("http://site.com\xC3\xB7othersite.org", userVisibleString(WTF::URLWithUserTypedString(@"http://site.com\xC3\xB7othersite.org", nil))); >+ >+ // Code paths similar to the ones used for URLs found in webpages or HTTP responses. >+ EXPECT_STREQ("http://site.com\xC3\xB7othersite.org", originalDataAsString(literalURL("http://site.com\xC3\xB7othersite.org"))); >+ EXPECT_STREQ("http://site.com\xC3\xB7othersite.org", userVisibleString(literalURL("http://site.com\xC3\xB7othersite.org"))); >+ EXPECT_STREQ("http://site.com%C3%B7othersite.org", originalDataAsString(literalURL("http://site.com%C3%B7othersite.org"))); >+ EXPECT_STREQ("http://site.com\xC3\xB7othersite.org", userVisibleString(literalURL("http://site.com%C3%B7othersite.org"))); >+ >+ // Separate functions that deal with just a host name on its own. >+ EXPECT_STREQ("site.xn--comothersite-kjb.org", [WTF::encodeHostName(@"site.com\xC3\xB7othersite.org") UTF8String]); >+ EXPECT_STREQ("site.com\xC3\xB7othersite.org", [WTF::decodeHostName(@"site.com\xC3\xB7othersite.org") UTF8String]); >+} >+ >+TEST(WTF, URLExtras_Solidus) >+{ >+ // Selected full width solidus, which looks like the solidus, which is the character that indicates the end of the host name. >+ >+ // Code path similar to the one used when typing in a URL. >+ EXPECT_STREQ("http://site.com/othersite.org", originalDataAsString(WTF::URLWithUserTypedString(@"http://site.com\xEF\xBC\x8Fothersite.org", nil))); >+ EXPECT_STREQ("http://site.com/othersite.org", userVisibleString(WTF::URLWithUserTypedString(@"http://site.com\xEF\xBC\x8Fothersite.org", nil))); >+ >+ // Code paths similar to the ones used for URLs found in webpages or HTTP responses. >+ EXPECT_STREQ("http://site.com\xEF\xBC\x8Fothersite.org", originalDataAsString(literalURL("http://site.com\xEF\xBC\x8Fothersite.org"))); >+ EXPECT_STREQ("http://site.com%EF%BC%8Fothersite.org", userVisibleString(literalURL("http://site.com\xEF\xBC\x8Fothersite.org"))); >+ EXPECT_STREQ("http://site.com%EF%BC%8Fothersite.org", originalDataAsString(literalURL("http://site.com%EF%BC%8Fothersite.org"))); >+ EXPECT_STREQ("http://site.com%EF%BC%8Fothersite.org", userVisibleString(literalURL("http://site.com%EF%BC%8Fothersite.org"))); >+ >+ // Separate functions that deal with just a host name on its own. >+ EXPECT_STREQ("site.com/othersite.org", [WTF::encodeHostName(@"site.com\xEF\xBC\x8Fothersite.org") UTF8String]); >+ EXPECT_STREQ("site.com/othersite.org", [WTF::decodeHostName(@"site.com\xEF\xBC\x8Fothersite.org") UTF8String]); >+} >+ >+TEST(WTF_URLExtras, URLExtras_Space) >+{ >+ // Selected ideographic space, which looks like the ASCII space, which is not allowed unescaped. >+ >+ // Code path similar to the one used when typing in a URL. >+ EXPECT_STREQ("http://site.com%20othersite.org", originalDataAsString(WTF::URLWithUserTypedString(@"http://site.com\xE3\x80\x80othersite.org", nil))); >+ EXPECT_STREQ("http://site.com%20othersite.org", userVisibleString(WTF::URLWithUserTypedString(@"http://site.com\xE3\x80\x80othersite.org", nil))); >+ >+ // Code paths similar to the ones used for URLs found in webpages or HTTP responses. >+ EXPECT_STREQ("http://site.com\xE3\x80\x80othersite.org", originalDataAsString(literalURL("http://site.com\xE3\x80\x80othersite.org"))); >+ EXPECT_STREQ("http://site.com%E3%80%80othersite.org", userVisibleString(literalURL("http://site.com\xE3\x80\x80othersite.org"))); >+ EXPECT_STREQ("http://site.com%E3%80%80othersite.org", originalDataAsString(literalURL("http://site.com%E3%80%80othersite.org"))); >+ EXPECT_STREQ("http://site.com%E3%80%80othersite.org", userVisibleString(literalURL("http://site.com%E3%80%80othersite.org"))); >+ >+ // Separate functions that deal with just a host name on its own. >+ EXPECT_STREQ("site.com othersite.org", [WTF::encodeHostName(@"site.com\xE3\x80\x80othersite.org") UTF8String]); >+ EXPECT_STREQ("site.com\xE3\x80\x80othersite.org", [WTF::decodeHostName(@"site.com\xE3\x80\x80othersite.org") UTF8String]); >+} >+ >+TEST(WTF_URLExtras, URLExtras_File) >+{ >+ EXPECT_STREQ("file:///%E2%98%83", [[WTF::URLWithUserTypedString(@"file:///â", nil) absoluteString] UTF8String]); >+} >+ >+TEST(WTF_URLExtras, URLExtras_ParsingError) >+{ >+ // Expect IDN failure. >+ NSURL *url = WTF::URLWithUserTypedString(@"http://.com", nil); >+ EXPECT_TRUE(url == nil); >+ >+ NSString *encodedHostName = WTF::encodeHostName(@"http://.com"); >+ EXPECT_TRUE(encodedHostName == nil); >+} >+ >+TEST(WTF_URLExtras, URLExtras_Nil) >+{ >+ NSURL *url1 = WTF::URLWithUserTypedString(nil, nil); >+ EXPECT_TRUE(url1 == nil); >+ >+ NSURL *url2 = WTF::URLWithUserTypedStringDeprecated(nil, nil); >+ EXPECT_TRUE(url2 == nil); >+} >+ >+} // namespace TestWebKitAPI >+ >diff --git a/Tools/TestWebKitAPI/Tests/WebCore/URL.cpp b/Tools/TestWebKitAPI/Tests/WebCore/URL.cpp >deleted file mode 100644 >index dc31b47bd07868aedcaff97f5656d83f789d8321..0000000000000000000000000000000000000000 >--- a/Tools/TestWebKitAPI/Tests/WebCore/URL.cpp >+++ /dev/null >@@ -1,401 +0,0 @@ >-/* >- * Copyright (C) 2011, 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" >-#include "WTFStringUtilities.h" >-#include <wtf/MainThread.h> >-#include <wtf/URL.h> >-#include <wtf/URLParser.h> >- >-namespace TestWebKitAPI { >- >-class URLTest : public testing::Test { >-public: >- virtual void SetUp() >- { >- WTF::initializeMainThread(); >- } >-}; >- >-TEST_F(URLTest, URLConstructorDefault) >-{ >- URL kurl; >- >- EXPECT_TRUE(kurl.isEmpty()); >- EXPECT_TRUE(kurl.isNull()); >- EXPECT_FALSE(kurl.isValid()); >-} >- >-TEST_F(URLTest, URLConstructorConstChar) >-{ >- URL kurl({ }, "http://username:password@www.example.com:8080/index.html?var=val#fragment"); >- >- EXPECT_FALSE(kurl.isEmpty()); >- EXPECT_FALSE(kurl.isNull()); >- EXPECT_TRUE(kurl.isValid()); >- >- EXPECT_EQ(kurl.protocol() == "http", true); >- EXPECT_EQ(String("www.example.com"), kurl.host().toString()); >- EXPECT_TRUE(!!kurl.port()); >- EXPECT_EQ(8080, kurl.port().value()); >- EXPECT_EQ(String("username"), kurl.user()); >- EXPECT_EQ(String("password"), kurl.pass()); >- EXPECT_EQ(String("/index.html"), kurl.path()); >- EXPECT_EQ(String("index.html"), kurl.lastPathComponent()); >- EXPECT_EQ(String("var=val"), kurl.query()); >- EXPECT_TRUE(kurl.hasFragmentIdentifier()); >- EXPECT_EQ(String("fragment"), kurl.fragmentIdentifier()); >-} >- >-static URL createURL(const char* urlAsString) >-{ >- return URL({ }, urlAsString); >-}; >- >-TEST_F(URLTest, 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()); >- >- url = createURL("http://username:@www.example.com:8080/index.html?var=val#fragment"); >- EXPECT_EQ(String("http://www.example.com:8080"), url.protocolHostAndPort()); >- >- url = createURL("http://:password@www.example.com:8080/index.html?var=val#fragment"); >- EXPECT_EQ(String("http://www.example.com:8080"), url.protocolHostAndPort()); >- >- url = createURL("http://username@www.example.com:8080/index.html?var=val#fragment"); >- EXPECT_EQ(String("http://www.example.com:8080"), url.protocolHostAndPort()); >- >- url = createURL("http://www.example.com:8080/index.html?var=val#fragment"); >- EXPECT_EQ(String("http://www.example.com:8080"), url.protocolHostAndPort()); >- >- url = createURL("http://www.example.com:/index.html?var=val#fragment"); >- EXPECT_EQ(String("http://www.example.com"), url.protocolHostAndPort()); >- >- url = createURL("http://www.example.com/index.html?var=val#fragment"); >- EXPECT_EQ(String("http://www.example.com"), url.protocolHostAndPort()); >- >- url = createURL("file:///a/b/c"); >- EXPECT_EQ(String("file://"), url.protocolHostAndPort()); >- >- url = createURL("file:///a/b"); >- EXPECT_EQ(String("file://"), url.protocolHostAndPort()); >- >- url = createURL("file:///a"); >- EXPECT_EQ(String("file://"), url.protocolHostAndPort()); >- >- url = createURL("file:///a"); >- EXPECT_EQ(String("file://"), url.protocolHostAndPort()); >- >- url = createURL("asdf://username:password@www.example.com:8080/index.html?var=val#fragment"); >- EXPECT_EQ(String("asdf://www.example.com:8080"), url.protocolHostAndPort()); >- >- url = createURL("asdf:///a/b/c"); >- EXPECT_EQ(String("asdf://"), url.protocolHostAndPort()); >-} >- >-TEST_F(URLTest, URLDataURIStringSharing) >-{ >- URL baseURL({ }, "http://www.webkit.org/"); >- String threeApples = "data:text/plain;charset=utf-8;base64,76O/76O/76O/"; >- >- URL url(baseURL, threeApples); >- EXPECT_EQ(threeApples.impl(), url.string().impl()); >-} >- >-TEST_F(URLTest, URLSetQuery) >-{ >- URL url = createURL("http://www.webkit.org/?test"); >- URL url1 = createURL("http://www.webkit.org/"); >- URL url2 = createURL("http://www.webkit.org/?"); >- URL url3 = createURL("http://www.webkit.org/?test"); >- URL url4 = createURL("http://www.webkit.org/?test1"); >- >- url1.setQuery("test"); >- url2.setQuery("test"); >- url3.setQuery("test"); >- url4.setQuery("test"); >- >- EXPECT_EQ(url.string(), url1.string()); >- EXPECT_EQ(url.string(), url2.string()); >- EXPECT_EQ(url.string(), url3.string()); >- EXPECT_EQ(url.string(), url4.string()); >- >- URL urlWithFragmentIdentifier = createURL("http://www.webkit.org/?test%C3%83%C2%A5#newFragment"); >- URL urlWithFragmentIdentifier1 = createURL("http://www.webkit.org/#newFragment"); >- URL urlWithFragmentIdentifier2 = createURL("http://www.webkit.org/?#newFragment"); >- URL urlWithFragmentIdentifier3 = createURL("http://www.webkit.org/?test1#newFragment"); >- >- urlWithFragmentIdentifier1.setQuery("test\xc3\xa5"); >- urlWithFragmentIdentifier2.setQuery("test\xc3\xa5"); >- urlWithFragmentIdentifier3.setQuery("test\xc3\xa5"); >- >- EXPECT_EQ(urlWithFragmentIdentifier.string(), urlWithFragmentIdentifier1.string()); >- EXPECT_EQ(urlWithFragmentIdentifier.string(), urlWithFragmentIdentifier2.string()); >- EXPECT_EQ(urlWithFragmentIdentifier.string(), urlWithFragmentIdentifier3.string()); >-} >- >-TEST_F(URLTest, URLSetFragmentIdentifier) >-{ >- URL url = createURL("http://www.webkit.org/#newFragment%C3%83%C2%A5"); >- URL url1 = createURL("http://www.webkit.org/"); >- URL url2 = createURL("http://www.webkit.org/#test2"); >- URL url3 = createURL("http://www.webkit.org/#"); >- >- url1.setFragmentIdentifier("newFragment\xc3\xa5"); >- url2.setFragmentIdentifier("newFragment\xc3\xa5"); >- url3.setFragmentIdentifier("newFragment\xc3\xa5"); >- >- EXPECT_EQ(url.string(), url1.string()); >- EXPECT_EQ(url.string(), url2.string()); >- EXPECT_EQ(url.string(), url3.string()); >- >- URL urlWithQuery = createURL("http://www.webkit.org/?test1#newFragment"); >- URL urlWithQuery1 = createURL("http://www.webkit.org/?test1"); >- URL urlWithQuery2 = createURL("http://www.webkit.org/?test1#"); >- URL urlWithQuery3 = createURL("http://www.webkit.org/?test1#test2"); >- >- urlWithQuery1.setFragmentIdentifier("newFragment"); >- urlWithQuery2.setFragmentIdentifier("newFragment"); >- urlWithQuery3.setFragmentIdentifier("newFragment"); >- >- EXPECT_EQ(urlWithQuery.string(), urlWithQuery1.string()); >- EXPECT_EQ(urlWithQuery.string(), urlWithQuery2.string()); >- EXPECT_EQ(urlWithQuery.string(), urlWithQuery3.string()); >-} >- >-TEST_F(URLTest, URLRemoveQueryAndFragmentIdentifier) >-{ >- URL url = createURL("http://www.webkit.org/"); >- URL url1 = createURL("http://www.webkit.org/?"); >- URL url2 = createURL("http://www.webkit.org/?test1"); >- URL url3 = createURL("http://www.webkit.org/?test1#test2"); >- URL url4 = createURL("http://www.webkit.org/#test2"); >- URL url5 = createURL("http://www.webkit.org/#"); >- >- url.removeQueryAndFragmentIdentifier(); >- url1.removeQueryAndFragmentIdentifier(); >- url2.removeQueryAndFragmentIdentifier(); >- url3.removeQueryAndFragmentIdentifier(); >- url4.removeQueryAndFragmentIdentifier(); >- url5.removeQueryAndFragmentIdentifier(); >- >- EXPECT_EQ(url.string(), url.string()); >- EXPECT_EQ(url.string(), url1.string()); >- EXPECT_EQ(url.string(), url2.string()); >- EXPECT_EQ(url.string(), url3.string()); >- EXPECT_EQ(url.string(), url4.string()); >- EXPECT_EQ(url.string(), url5.string()); >-} >- >-TEST_F(URLTest, EqualIgnoringFragmentIdentifier) >-{ >- struct TestCase { >- const char* url1; >- const char* url2; >- bool expected; >- } cases[] = { >- {"http://example.com/", "http://example.com/", true}, >- {"http://example.com/#hash", "http://example.com/", true}, >- {"http://example.com/path", "http://example.com/", false}, >- {"http://example.com/path", "http://example.com/path", true}, >- {"http://example.com/path#hash", "http://example.com/path", true}, >- {"http://example.com/path?query", "http://example.com/path", false}, >- {"http://example.com/path?query#hash", "http://example.com/path", false}, >- {"http://example.com/otherpath", "http://example.com/path", false}, >- {"http://example.com:80/", "http://example.com/", true}, >- {"http://example.com:80/#hash", "http://example.com/", true}, >- {"http://example.com:80/path", "http://example.com/", false}, >- {"http://example.com:80/path#hash", "http://example.com/path", true}, >- {"http://example.com:80/path?query", "http://example.com/path", false}, >- {"http://example.com:80/path?query#hash", "http://example.com/path", false}, >- {"http://example.com:80/otherpath", "http://example.com/path", false}, >- {"http://not-example.com:80/", "http://example.com/", false}, >- {"http://example.com:81/", "http://example.com/", false}, >- {"http://example.com:81/#hash", "http://example.com:81/", true}, >- {"http://example.com:81/path", "http://example.com:81", false}, >- {"http://example.com:81/path#hash", "http://example.com:81/path", true}, >- {"http://example.com:81/path?query", "http://example.com:81/path", false}, >- {"http://example.com:81/path?query#hash", "http://example.com:81/path", false}, >- {"http://example.com:81/otherpath", "http://example.com:81/path", false}, >- {"file:///path/to/file.html", "file:///path/to/file.html", true}, >- {"file:///path/to/file.html#hash", "file:///path/to/file.html", true}, >- {"file:///path/to/file.html?query", "file:///path/to/file.html", false}, >- {"file:///path/to/file.html?query#hash", "file:///path/to/file.html", false}, >- {"file:///path/to/other_file.html", "file:///path/to/file.html", false}, >- {"file:///path/to/other/file.html", "file:///path/to/file.html", false}, >- {"data:text/plain;charset=utf-8;base64,76O/76O/76O/", "data:text/plain;charset=utf-8;base64,760/760/760/", false}, >- {"http://example.com", "file://example.com", false}, >- {"http://example.com/#hash", "file://example.com", false}, >- {"http://example.com/?query", "file://example.com/", false}, >- {"http://example.com/?query#hash", "file://example.com/", false}, >- }; >- >- for (const auto& test : cases) { >- URL url1 = createURL(test.url1); >- URL url2 = createURL(test.url2); >- EXPECT_EQ(test.expected, equalIgnoringFragmentIdentifier(url1, url2)) >- << "Test failed for " << test.url1 << " vs. " << test.url2; >- } >-} >- >-TEST_F(URLTest, EqualIgnoringQueryAndFragment) >-{ >- struct TestCase { >- const char* url1; >- const char* url2; >- bool expected; >- } cases[] = { >- {"http://example.com/", "http://example.com/", true}, >- {"http://example.com/#hash", "http://example.com/", true}, >- {"http://example.com/path", "http://example.com/", false}, >- {"http://example.com/path", "http://example.com/path", true}, >- {"http://example.com/path#hash", "http://example.com/path", true}, >- {"http://example.com/path?query", "http://example.com/path", true}, >- {"http://example.com/path?query#hash", "http://example.com/path", true}, >- {"http://example.com/otherpath", "http://example.com/path", false}, >- {"http://example.com:80/", "http://example.com/", true}, >- {"http://example.com:80/#hash", "http://example.com/", true}, >- {"http://example.com:80/path", "http://example.com/", false}, >- {"http://example.com:80/path#hash", "http://example.com/path", true}, >- {"http://example.com:80/path?query", "http://example.com/path", true}, >- {"http://example.com:80/path?query#hash", "http://example.com/path", true}, >- {"http://example.com:80/otherpath", "http://example.com/path", false}, >- {"http://not-example.com:80/", "http://example.com:80/", false}, >- {"http://example.com:81/", "http://example.com/", false}, >- {"http://example.com:81/#hash", "http://example.com:81/", true}, >- {"http://example.com:81/path", "http://example.com:81", false}, >- {"http://example.com:81/path#hash", "http://example.com:81/path", true}, >- {"http://example.com:81/path?query", "http://example.com:81/path", true}, >- {"http://example.com:81/path?query#hash", "http://example.com:81/path", true}, >- {"http://example.com:81/otherpath", "http://example.com:81/path", false}, >- {"file:///path/to/file.html", "file:///path/to/file.html", true}, >- {"file:///path/to/file.html#hash", "file:///path/to/file.html", true}, >- {"file:///path/to/file.html?query", "file:///path/to/file.html", true}, >- {"file:///path/to/file.html?query#hash", "file:///path/to/file.html", true}, >- {"file:///path/to/other_file.html", "file:///path/to/file.html", false}, >- {"file:///path/to/other/file.html", "file:///path/to/file.html", false}, >- {"data:text/plain;charset=utf-8;base64,76O/76O/76O/", "data:text/plain;charset=utf-8;base64,760/760/760/", false}, >- {"http://example.com", "file://example.com", false}, >- {"http://example.com/#hash", "file://example.com", false}, >- {"http://example.com/?query", "file://example.com/", false}, >- {"http://example.com/?query#hash", "file://example.com/", false}, >- }; >- >- for (const auto& test : cases) { >- URL url1 = createURL(test.url1); >- URL url2 = createURL(test.url2); >- EXPECT_EQ(test.expected, equalIgnoringQueryAndFragment(url1, url2)) >- << "Test failed for " << test.url1 << " vs. " << test.url2; >- } >-} >- >-TEST_F(URLTest, ProtocolIsInHTTPFamily) >-{ >- EXPECT_FALSE(WTF::protocolIsInHTTPFamily({ })); >- EXPECT_FALSE(WTF::protocolIsInHTTPFamily("")); >- EXPECT_FALSE(WTF::protocolIsInHTTPFamily("a")); >- EXPECT_FALSE(WTF::protocolIsInHTTPFamily("ab")); >- EXPECT_FALSE(WTF::protocolIsInHTTPFamily("abc")); >- EXPECT_FALSE(WTF::protocolIsInHTTPFamily("abcd")); >- EXPECT_FALSE(WTF::protocolIsInHTTPFamily("abcde")); >- EXPECT_FALSE(WTF::protocolIsInHTTPFamily("abcdef")); >- EXPECT_FALSE(WTF::protocolIsInHTTPFamily("abcdefg")); >- EXPECT_TRUE(WTF::protocolIsInHTTPFamily("http:")); >- EXPECT_FALSE(WTF::protocolIsInHTTPFamily("http")); >- EXPECT_TRUE(WTF::protocolIsInHTTPFamily("https:")); >- EXPECT_FALSE(WTF::protocolIsInHTTPFamily("https")); >- EXPECT_TRUE(WTF::protocolIsInHTTPFamily("https://!@#$%^&*()")); >-} >- >-TEST_F(URLTest, HostIsIPAddress) >-{ >- EXPECT_FALSE(URL::hostIsIPAddress({ })); >- EXPECT_FALSE(URL::hostIsIPAddress("")); >- EXPECT_FALSE(URL::hostIsIPAddress("localhost")); >- EXPECT_FALSE(URL::hostIsIPAddress("127.localhost")); >- EXPECT_FALSE(URL::hostIsIPAddress("localhost.127")); >- EXPECT_FALSE(URL::hostIsIPAddress("127.0.0")); >- EXPECT_FALSE(URL::hostIsIPAddress("127.0 .0.1")); >- EXPECT_FALSE(URL::hostIsIPAddress(" 127.0.0.1")); >- EXPECT_FALSE(URL::hostIsIPAddress("127..0.0.1")); >- EXPECT_FALSE(URL::hostIsIPAddress("127.0.0.")); >- EXPECT_FALSE(URL::hostIsIPAddress("256.0.0.1")); >- EXPECT_FALSE(URL::hostIsIPAddress("0123:4567:89AB:cdef:3210:7654:ba98")); >- EXPECT_FALSE(URL::hostIsIPAddress("012x:4567:89AB:cdef:3210:7654:ba98:FeDc")); >-#if !PLATFORM(COCOA) >- // FIXME: This fails in Mac. >- EXPECT_FALSE(URL::hostIsIPAddress("127.0.0.01")); >- EXPECT_FALSE(URL::hostIsIPAddress("00123:4567:89AB:cdef:3210:7654:ba98:FeDc")); >-#endif >- EXPECT_FALSE(URL::hostIsIPAddress("0123:4567:89AB:cdef:3210:123.45.67.89")); >- EXPECT_FALSE(URL::hostIsIPAddress(":::")); >- EXPECT_FALSE(URL::hostIsIPAddress("0123::89AB:cdef:3210:7654::FeDc")); >- EXPECT_FALSE(URL::hostIsIPAddress("0123:4567:89AB:cdef:3210:7654:ba98:")); >- EXPECT_FALSE(URL::hostIsIPAddress("0123:4567:89AB:cdef:3210:7654:ba98:FeDc:")); >- EXPECT_FALSE(URL::hostIsIPAddress(":4567:89AB:cdef:3210:7654:ba98:FeDc")); >- EXPECT_FALSE(URL::hostIsIPAddress(":0123:4567:89AB:cdef:3210:7654:ba98:FeDc")); >- >- EXPECT_TRUE(URL::hostIsIPAddress("127.0.0.1")); >- EXPECT_TRUE(URL::hostIsIPAddress("255.1.10.100")); >- EXPECT_TRUE(URL::hostIsIPAddress("0.0.0.0")); >- EXPECT_TRUE(URL::hostIsIPAddress("::1")); >- EXPECT_TRUE(URL::hostIsIPAddress("::")); >- EXPECT_TRUE(URL::hostIsIPAddress("0123:4567:89AB:cdef:3210:7654:ba98:FeDc")); >- EXPECT_TRUE(URL::hostIsIPAddress("0123:4567:89AB:cdef:3210:7654:ba98::")); >- EXPECT_TRUE(URL::hostIsIPAddress("::4567:89AB:cdef:3210:7654:ba98:FeDc")); >- EXPECT_TRUE(URL::hostIsIPAddress("0123:4567:89AB:cdef:3210:7654:123.45.67.89")); >- EXPECT_TRUE(URL::hostIsIPAddress("::123.45.67.89")); >-} >- >-TEST_F(URLTest, HostIsMatchingDomain) >-{ >- URL url = createURL("http://www.webkit.org"); >- >- EXPECT_TRUE(url.isMatchingDomain(String { })); >- EXPECT_TRUE(url.isMatchingDomain(emptyString())); >- EXPECT_TRUE(url.isMatchingDomain("org"_s)); >- EXPECT_TRUE(url.isMatchingDomain("webkit.org"_s)); >- EXPECT_TRUE(url.isMatchingDomain("www.webkit.org"_s)); >- >- EXPECT_FALSE(url.isMatchingDomain("rg"_s)); >- EXPECT_FALSE(url.isMatchingDomain(".org"_s)); >- EXPECT_FALSE(url.isMatchingDomain("ww.webkit.org"_s)); >- EXPECT_FALSE(url.isMatchingDomain("http://www.webkit.org"_s)); >- >- url = createURL("file:///www.webkit.org"); >- >- EXPECT_TRUE(url.isMatchingDomain(String { })); >- EXPECT_TRUE(url.isMatchingDomain(emptyString())); >- EXPECT_FALSE(url.isMatchingDomain("org"_s)); >- EXPECT_FALSE(url.isMatchingDomain("webkit.org"_s)); >- EXPECT_FALSE(url.isMatchingDomain("www.webkit.org"_s)); >- >- URL emptyURL; >- EXPECT_FALSE(emptyURL.isMatchingDomain(String { })); >- EXPECT_FALSE(emptyURL.isMatchingDomain(emptyString())); >-} >- >-} // namespace TestWebKitAPI >diff --git a/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp b/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp >deleted file mode 100644 >index 1c4dcdd05e21d7b5fd7ab7dfe85d8f05c1ac8a7a..0000000000000000000000000000000000000000 >--- a/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp >+++ /dev/null >@@ -1,1357 +0,0 @@ >-/* >- * 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 URLParserTest : 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 ExpectedParts& parts, TestTabs testTabs = TestTabs::Yes) >-{ >- auto url = URL(URL(), urlString); >- >- 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())); >- >- EXPECT_TRUE(WTF::URLParser::internalValuesConsistent(url)); >- >- if (testTabs == TestTabs::No) >- return; >- >- for (size_t i = 0; i < urlString.length(); ++i) { >- String urlStringWithTab = insertTabAtLocation(urlString, i); >- checkURL(urlStringWithTab, >- parts.isInvalid() ? invalidParts(urlStringWithTab) : parts, >- TestTabs::No); >- } >-} >- >-static void checkRelativeURL(const String& urlString, const String& baseURLString, const ExpectedParts& parts, TestTabs testTabs = TestTabs::Yes) >-{ >- auto url = URL(URL(URL(), baseURLString), urlString); >- >- 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())); >- >- EXPECT_TRUE(WTF::URLParser::internalValuesConsistent(url)); >- >- if (testTabs == TestTabs::No) >- return; >- >- for (size_t i = 0; i < urlString.length(); ++i) { >- String urlStringWithTab = insertTabAtLocation(urlString, i); >- checkRelativeURL(urlStringWithTab, >- baseURLString, >- parts.isInvalid() ? invalidParts(urlStringWithTab) : parts, >- TestTabs::No); >- } >-} >- >-static void checkURLDifferences(const String& urlString, const ExpectedParts& partsNew, const ExpectedParts& partsOld, TestTabs testTabs = TestTabs::Yes) >-{ >- UNUSED_PARAM(partsOld); // FIXME: Remove all the old expected parts. >- auto url = URL(URL(), urlString); >- >- EXPECT_TRUE(eq(partsNew.protocol, url.protocol())); >- EXPECT_TRUE(eq(partsNew.user, url.user())); >- EXPECT_TRUE(eq(partsNew.password, url.pass())); >- EXPECT_TRUE(eq(partsNew.host, url.host())); >- EXPECT_EQ(partsNew.port, url.port().value_or(0)); >- EXPECT_TRUE(eq(partsNew.path, url.path())); >- EXPECT_TRUE(eq(partsNew.query, url.query())); >- EXPECT_TRUE(eq(partsNew.fragment, url.fragmentIdentifier())); >- EXPECT_TRUE(eq(partsNew.string, url.string())); >- >- EXPECT_TRUE(WTF::URLParser::internalValuesConsistent(url)); >- >- if (testTabs == TestTabs::No) >- return; >- >- for (size_t i = 0; i < urlString.length(); ++i) { >- String urlStringWithTab = insertTabAtLocation(urlString, i); >- checkURLDifferences(urlStringWithTab, >- partsNew.isInvalid() ? invalidParts(urlStringWithTab) : partsNew, >- partsOld.isInvalid() ? invalidParts(urlStringWithTab) : partsOld, >- TestTabs::No); >- } >-} >- >-static void checkRelativeURLDifferences(const String& urlString, const String& baseURLString, const ExpectedParts& partsNew, const ExpectedParts& partsOld, TestTabs testTabs = TestTabs::Yes) >-{ >- UNUSED_PARAM(partsOld); // FIXME: Remove all the old expected parts. >- auto url = URL(URL(URL(), baseURLString), urlString); >- >- EXPECT_TRUE(eq(partsNew.protocol, url.protocol())); >- EXPECT_TRUE(eq(partsNew.user, url.user())); >- EXPECT_TRUE(eq(partsNew.password, url.pass())); >- EXPECT_TRUE(eq(partsNew.host, url.host())); >- EXPECT_EQ(partsNew.port, url.port().value_or(0)); >- EXPECT_TRUE(eq(partsNew.path, url.path())); >- EXPECT_TRUE(eq(partsNew.query, url.query())); >- EXPECT_TRUE(eq(partsNew.fragment, url.fragmentIdentifier())); >- EXPECT_TRUE(eq(partsNew.string, url.string())); >- >- EXPECT_TRUE(WTF::URLParser::internalValuesConsistent(url)); >- >- if (testTabs == TestTabs::No) >- return; >- >- for (size_t i = 0; i < urlString.length(); ++i) { >- String urlStringWithTab = insertTabAtLocation(urlString, i); >- checkRelativeURLDifferences(urlStringWithTab, baseURLString, >- partsNew.isInvalid() ? invalidParts(urlStringWithTab) : partsNew, >- partsOld.isInvalid() ? invalidParts(urlStringWithTab) : partsOld, >- TestTabs::No); >- } >-} >- >-static void shouldFail(const String& urlString) >-{ >- checkURL(urlString, {"", "", "", "", 0, "", "", "", urlString}); >-} >- >-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) >-{ >- 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"}); >- checkURL("http://user:pass@webkit.org:123/path", {"http", "user", "pass", "webkit.org", 123, "/path", "", "", "http://user:pass@webkit.org:123/path"}); >- checkURL("http://user:pass@webkit.org:123/", {"http", "user", "pass", "webkit.org", 123, "/", "", "", "http://user:pass@webkit.org:123/"}); >- checkURL("http://user:pass@webkit.org:123", {"http", "user", "pass", "webkit.org", 123, "/", "", "", "http://user:pass@webkit.org:123/"}); >- checkURL("http://user:pass@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"}); >- checkURL("http://user:\t\t\tpass@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"}); >- checkURL("http://us\ter:pass@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"}); >- checkURL("http://user:pa\tss@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"}); >- checkURL("http://user:pass\t@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"}); >- checkURL("http://\tuser:pass@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"}); >- checkURL("http://user\t:pass@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"}); >- checkURL("http://webkit.org", {"http", "", "", "webkit.org", 0, "/", "", "", "http://webkit.org/"}); >- checkURL("http://127.0.0.1", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}); >- checkURL("http://webkit.org/", {"http", "", "", "webkit.org", 0, "/", "", "", "http://webkit.org/"}); >- checkURL("http://webkit.org/path1/path2/index.html", {"http", "", "", "webkit.org", 0, "/path1/path2/index.html", "", "", "http://webkit.org/path1/path2/index.html"}); >- checkURL("about:blank", {"about", "", "", "", 0, "blank", "", "", "about:blank"}); >- checkURL("about:blank?query", {"about", "", "", "", 0, "blank", "query", "", "about:blank?query"}); >- checkURL("about:blank#fragment", {"about", "", "", "", 0, "blank", "", "fragment", "about:blank#fragment"}); >- checkURL("http://[0:f::f:f:0:0]", {"http", "", "", "[0:f::f:f:0:0]", 0, "/", "", "", "http://[0:f::f:f:0:0]/"}); >- checkURL("http://[0:f:0:0:f::]", {"http", "", "", "[0:f:0:0:f::]", 0, "/", "", "", "http://[0:f:0:0:f::]/"}); >- checkURL("http://[::f:0:0:f:0:0]", {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"}); >- checkURL("http://[0:f:0:0:f::]:", {"http", "", "", "[0:f:0:0:f::]", 0, "/", "", "", "http://[0:f:0:0:f::]/"}); >- checkURL("http://[0:f:0:0:f::]:\t", {"http", "", "", "[0:f:0:0:f::]", 0, "/", "", "", "http://[0:f:0:0:f::]/"}); >- checkURL("http://[0:f:0:0:f::]\t:", {"http", "", "", "[0:f:0:0:f::]", 0, "/", "", "", "http://[0:f:0:0:f::]/"}); >- checkURL("http://\t[::f:0:0:f:0:0]", {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"}); >- checkURL("http://[\t::f:0:0:f:0:0]", {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"}); >- checkURL("http://[:\t:f:0:0:f:0:0]", {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"}); >- checkURL("http://[::\tf:0:0:f:0:0]", {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"}); >- checkURL("http://[::f\t:0:0:f:0:0]", {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"}); >- checkURL("http://[::f:\t0:0:f:0:0]", {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"}); >- checkURL("http://example.com/path1/path2/.", {"http", "", "", "example.com", 0, "/path1/path2/", "", "", "http://example.com/path1/path2/"}); >- checkURL("http://example.com/path1/path2/..", {"http", "", "", "example.com", 0, "/path1/", "", "", "http://example.com/path1/"}); >- checkURL("http://example.com/path1/path2/./path3", {"http", "", "", "example.com", 0, "/path1/path2/path3", "", "", "http://example.com/path1/path2/path3"}); >- checkURL("http://example.com/path1/path2/.\\path3", {"http", "", "", "example.com", 0, "/path1/path2/path3", "", "", "http://example.com/path1/path2/path3"}); >- checkURL("http://example.com/path1/path2/../path3", {"http", "", "", "example.com", 0, "/path1/path3", "", "", "http://example.com/path1/path3"}); >- checkURL("http://example.com/path1/path2/..\\path3", {"http", "", "", "example.com", 0, "/path1/path3", "", "", "http://example.com/path1/path3"}); >- checkURL("http://example.com/.", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >- checkURL("http://example.com/..", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >- checkURL("http://example.com/./path1", {"http", "", "", "example.com", 0, "/path1", "", "", "http://example.com/path1"}); >- checkURL("http://example.com/../path1", {"http", "", "", "example.com", 0, "/path1", "", "", "http://example.com/path1"}); >- checkURL("http://example.com/../path1/../../path2/path3/../path4", {"http", "", "", "example.com", 0, "/path2/path4", "", "", "http://example.com/path2/path4"}); >- checkURL("http://example.com/path1/.%2", {"http", "", "", "example.com", 0, "/path1/.%2", "", "", "http://example.com/path1/.%2"}); >- checkURL("http://example.com/path1/%2", {"http", "", "", "example.com", 0, "/path1/%2", "", "", "http://example.com/path1/%2"}); >- checkURL("http://example.com/path1/%", {"http", "", "", "example.com", 0, "/path1/%", "", "", "http://example.com/path1/%"}); >- checkURL("http://example.com/path1/.%", {"http", "", "", "example.com", 0, "/path1/.%", "", "", "http://example.com/path1/.%"}); >- checkURL("http://example.com//.", {"http", "", "", "example.com", 0, "//", "", "", "http://example.com//"}); >- checkURL("http://example.com//./", {"http", "", "", "example.com", 0, "//", "", "", "http://example.com//"}); >- checkURL("http://example.com//.//", {"http", "", "", "example.com", 0, "///", "", "", "http://example.com///"}); >- checkURL("http://example.com//..", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >- checkURL("http://example.com//../", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >- checkURL("http://example.com//..//", {"http", "", "", "example.com", 0, "//", "", "", "http://example.com//"}); >- checkURL("http://example.com//..", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >- checkURL("http://example.com/.//", {"http", "", "", "example.com", 0, "//", "", "", "http://example.com//"}); >- checkURL("http://example.com/..//", {"http", "", "", "example.com", 0, "//", "", "", "http://example.com//"}); >- checkURL("http://example.com/./", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >- checkURL("http://example.com/../", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >- checkURL("http://example.com/path1/.../path3", {"http", "", "", "example.com", 0, "/path1/.../path3", "", "", "http://example.com/path1/.../path3"}); >- checkURL("http://example.com/path1/...", {"http", "", "", "example.com", 0, "/path1/...", "", "", "http://example.com/path1/..."}); >- checkURL("http://example.com/path1/.../", {"http", "", "", "example.com", 0, "/path1/.../", "", "", "http://example.com/path1/.../"}); >- checkURL("http://example.com/.path1/", {"http", "", "", "example.com", 0, "/.path1/", "", "", "http://example.com/.path1/"}); >- checkURL("http://example.com/..path1/", {"http", "", "", "example.com", 0, "/..path1/", "", "", "http://example.com/..path1/"}); >- checkURL("http://example.com/path1/.path2", {"http", "", "", "example.com", 0, "/path1/.path2", "", "", "http://example.com/path1/.path2"}); >- checkURL("http://example.com/path1/..path2", {"http", "", "", "example.com", 0, "/path1/..path2", "", "", "http://example.com/path1/..path2"}); >- checkURL("http://example.com/path1/path2/.?query", {"http", "", "", "example.com", 0, "/path1/path2/", "query", "", "http://example.com/path1/path2/?query"}); >- checkURL("http://example.com/path1/path2/..?query", {"http", "", "", "example.com", 0, "/path1/", "query", "", "http://example.com/path1/?query"}); >- checkURL("http://example.com/path1/path2/.#fragment", {"http", "", "", "example.com", 0, "/path1/path2/", "", "fragment", "http://example.com/path1/path2/#fragment"}); >- checkURL("http://example.com/path1/path2/..#fragment", {"http", "", "", "example.com", 0, "/path1/", "", "fragment", "http://example.com/path1/#fragment"}); >- >- checkURL("file:", {"file", "", "", "", 0, "/", "", "", "file:///"}); >- checkURL("file:/", {"file", "", "", "", 0, "/", "", "", "file:///"}); >- checkURL("file://", {"file", "", "", "", 0, "/", "", "", "file:///"}); >- checkURL("file:///", {"file", "", "", "", 0, "/", "", "", "file:///"}); >- checkURL("file:////", {"file", "", "", "", 0, "//", "", "", "file:////"}); // This matches Firefox and URL::parse which I believe are correct, but not Chrome. >- checkURL("file:/path", {"file", "", "", "", 0, "/path", "", "", "file:///path"}); >- checkURL("file://host/path", {"file", "", "", "host", 0, "/path", "", "", "file://host/path"}); >- checkURL("file://host", {"file", "", "", "host", 0, "/", "", "", "file://host/"}); >- checkURL("file://host/", {"file", "", "", "host", 0, "/", "", "", "file://host/"}); >- checkURL("file:///path", {"file", "", "", "", 0, "/path", "", "", "file:///path"}); >- checkURL("file:////path", {"file", "", "", "", 0, "//path", "", "", "file:////path"}); >- checkURL("file://localhost/path", {"file", "", "", "", 0, "/path", "", "", "file:///path"}); >- checkURL("file://localhost/", {"file", "", "", "", 0, "/", "", "", "file:///"}); >- checkURL("file://localhost", {"file", "", "", "", 0, "/", "", "", "file:///"}); >- checkURL("file://lOcAlHoSt", {"file", "", "", "", 0, "/", "", "", "file:///"}); >- checkURL("file://lOcAlHoSt/", {"file", "", "", "", 0, "/", "", "", "file:///"}); >- checkURL("file:/pAtH/", {"file", "", "", "", 0, "/pAtH/", "", "", "file:///pAtH/"}); >- checkURL("file:/pAtH", {"file", "", "", "", 0, "/pAtH", "", "", "file:///pAtH"}); >- checkURL("file:?query", {"file", "", "", "", 0, "/", "query", "", "file:///?query"}); >- checkURL("file:#fragment", {"file", "", "", "", 0, "/", "", "fragment", "file:///#fragment"}); >- checkURL("file:?query#fragment", {"file", "", "", "", 0, "/", "query", "fragment", "file:///?query#fragment"}); >- checkURL("file:#fragment?notquery", {"file", "", "", "", 0, "/", "", "fragment?notquery", "file:///#fragment?notquery"}); >- checkURL("file:/?query", {"file", "", "", "", 0, "/", "query", "", "file:///?query"}); >- checkURL("file:/#fragment", {"file", "", "", "", 0, "/", "", "fragment", "file:///#fragment"}); >- checkURL("file://?query", {"file", "", "", "", 0, "/", "query", "", "file:///?query"}); >- checkURL("file://#fragment", {"file", "", "", "", 0, "/", "", "fragment", "file:///#fragment"}); >- checkURL("file:///?query", {"file", "", "", "", 0, "/", "query", "", "file:///?query"}); >- checkURL("file:///#fragment", {"file", "", "", "", 0, "/", "", "fragment", "file:///#fragment"}); >- checkURL("file:////?query", {"file", "", "", "", 0, "//", "query", "", "file:////?query"}); >- checkURL("file:////#fragment", {"file", "", "", "", 0, "//", "", "fragment", "file:////#fragment"}); >- checkURL("file://?Q", {"file", "", "", "", 0, "/", "Q", "", "file:///?Q"}); >- checkURL("file://#F", {"file", "", "", "", 0, "/", "", "F", "file:///#F"}); >- checkURL("file://host?Q", {"file", "", "", "host", 0, "/", "Q", "", "file://host/?Q"}); >- checkURL("file://host#F", {"file", "", "", "host", 0, "/", "", "F", "file://host/#F"}); >- checkURL("file://host\\P", {"file", "", "", "host", 0, "/P", "", "", "file://host/P"}); >- checkURL("file://host\\?Q", {"file", "", "", "host", 0, "/", "Q", "", "file://host/?Q"}); >- checkURL("file://host\\../P", {"file", "", "", "host", 0, "/P", "", "", "file://host/P"}); >- checkURL("file://host\\/../P", {"file", "", "", "host", 0, "/P", "", "", "file://host/P"}); >- checkURL("file://host\\/P", {"file", "", "", "host", 0, "//P", "", "", "file://host//P"}); >- checkURL("http://host/A b", {"http", "", "", "host", 0, "/A%20b", "", "", "http://host/A%20b"}); >- checkURL("http://host/a%20B", {"http", "", "", "host", 0, "/a%20B", "", "", "http://host/a%20B"}); >- checkURL("http://host?q=@ <>!#fragment", {"http", "", "", "host", 0, "/", "q=@%20%3C%3E!", "fragment", "http://host/?q=@%20%3C%3E!#fragment"}); >- checkURL("http://user:@host", {"http", "user", "", "host", 0, "/", "", "", "http://user@host/"}); >- checkURL("http://user:@\thost", {"http", "user", "", "host", 0, "/", "", "", "http://user@host/"}); >- checkURL("http://user:\t@host", {"http", "user", "", "host", 0, "/", "", "", "http://user@host/"}); >- checkURL("http://user\t:@host", {"http", "user", "", "host", 0, "/", "", "", "http://user@host/"}); >- checkURL("http://use\tr:@host", {"http", "user", "", "host", 0, "/", "", "", "http://user@host/"}); >- checkURL("http://127.0.0.1:10100/path", {"http", "", "", "127.0.0.1", 10100, "/path", "", "", "http://127.0.0.1:10100/path"}); >- checkURL("http://127.0.0.1:/path", {"http", "", "", "127.0.0.1", 0, "/path", "", "", "http://127.0.0.1/path"}); >- checkURL("http://127.0.0.1\t:/path", {"http", "", "", "127.0.0.1", 0, "/path", "", "", "http://127.0.0.1/path"}); >- checkURL("http://127.0.0.1:\t/path", {"http", "", "", "127.0.0.1", 0, "/path", "", "", "http://127.0.0.1/path"}); >- checkURL("http://127.0.0.1:/\tpath", {"http", "", "", "127.0.0.1", 0, "/path", "", "", "http://127.0.0.1/path"}); >- checkURL("http://127.0.0.1:123", {"http", "", "", "127.0.0.1", 123, "/", "", "", "http://127.0.0.1:123/"}); >- checkURL("http://127.0.0.1:", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}); >- checkURL("http://[0:f::f:f:0:0]:123/path", {"http", "", "", "[0:f::f:f:0:0]", 123, "/path", "", "", "http://[0:f::f:f:0:0]:123/path"}); >- checkURL("http://[0:f::f:f:0:0]:123", {"http", "", "", "[0:f::f:f:0:0]", 123, "/", "", "", "http://[0:f::f:f:0:0]:123/"}); >- checkURL("http://[0:f:0:0:f:\t:]:123", {"http", "", "", "[0:f:0:0:f::]", 123, "/", "", "", "http://[0:f:0:0:f::]:123/"}); >- checkURL("http://[0:f:0:0:f::\t]:123", {"http", "", "", "[0:f:0:0:f::]", 123, "/", "", "", "http://[0:f:0:0:f::]:123/"}); >- checkURL("http://[0:f:0:0:f::]\t:123", {"http", "", "", "[0:f:0:0:f::]", 123, "/", "", "", "http://[0:f:0:0:f::]:123/"}); >- checkURL("http://[0:f:0:0:f::]:\t123", {"http", "", "", "[0:f:0:0:f::]", 123, "/", "", "", "http://[0:f:0:0:f::]:123/"}); >- checkURL("http://[0:f:0:0:f::]:1\t23", {"http", "", "", "[0:f:0:0:f::]", 123, "/", "", "", "http://[0:f:0:0:f::]:123/"}); >- checkURL("http://[0:f::f:f:0:0]:/path", {"http", "", "", "[0:f::f:f:0:0]", 0, "/path", "", "", "http://[0:f::f:f:0:0]/path"}); >- checkURL("http://[0:f::f:f:0:0]:", {"http", "", "", "[0:f::f:f:0:0]", 0, "/", "", "", "http://[0:f::f:f:0:0]/"}); >- checkURL("http://host:10100/path", {"http", "", "", "host", 10100, "/path", "", "", "http://host:10100/path"}); >- checkURL("http://host:/path", {"http", "", "", "host", 0, "/path", "", "", "http://host/path"}); >- checkURL("http://host:123", {"http", "", "", "host", 123, "/", "", "", "http://host:123/"}); >- checkURL("http://host:", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >- checkURL("http://hos\tt\n:\t1\n2\t3\t/\npath", {"http", "", "", "host", 123, "/path", "", "", "http://host:123/path"}); >- checkURL("http://user@example.org/path3", {"http", "user", "", "example.org", 0, "/path3", "", "", "http://user@example.org/path3"}); >- checkURL("sc:/pa/pa", {"sc", "", "", "", 0, "/pa/pa", "", "", "sc:/pa/pa"}); >- checkURL("sc:/pa", {"sc", "", "", "", 0, "/pa", "", "", "sc:/pa"}); >- checkURL("sc:/pa/", {"sc", "", "", "", 0, "/pa/", "", "", "sc:/pa/"}); >- checkURL("notspecial:/notuser:notpassword@nothost", {"notspecial", "", "", "", 0, "/notuser:notpassword@nothost", "", "", "notspecial:/notuser:notpassword@nothost"}); >- checkURL("sc://pa/", {"sc", "", "", "pa", 0, "/", "", "", "sc://pa/"}); >- checkURL("sc://\tpa/", {"sc", "", "", "pa", 0, "/", "", "", "sc://pa/"}); >- checkURL("sc:/\t/pa/", {"sc", "", "", "pa", 0, "/", "", "", "sc://pa/"}); >- checkURL("sc:\t//pa/", {"sc", "", "", "pa", 0, "/", "", "", "sc://pa/"}); >- checkURL("http://host \a ", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >- checkURL("notspecial:/a", {"notspecial", "", "", "", 0, "/a", "", "", "notspecial:/a"}); >- checkURL("notspecial:", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"}); >- checkURL("http:/a", {"http", "", "", "a", 0, "/", "", "", "http://a/"}); >- checkURL("http://256../", {"http", "", "", "256..", 0, "/", "", "", "http://256../"}); >- checkURL("http://256..", {"http", "", "", "256..", 0, "/", "", "", "http://256../"}); >- checkURL("http://127..1/", {"http", "", "", "127..1", 0, "/", "", "", "http://127..1/"}); >- checkURL("http://127.a.0.1/", {"http", "", "", "127.a.0.1", 0, "/", "", "", "http://127.a.0.1/"}); >- checkURL("http://127.0.0.1/", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}); >- checkURL("http://12\t7.0.0.1/", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}); >- checkURL("http://127.\t0.0.1/", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}); >- checkURL("http://./", {"http", "", "", ".", 0, "/", "", "", "http://./"}); >- checkURL("http://.", {"http", "", "", ".", 0, "/", "", "", "http://./"}); >- checkURL("notspecial:/a", {"notspecial", "", "", "", 0, "/a", "", "", "notspecial:/a"}); >- checkURL("notspecial:", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"}); >- checkURL("notspecial:/", {"notspecial", "", "", "", 0, "/", "", "", "notspecial:/"}); >- checkURL("data:image/png;base64,encoded-data-follows-here", {"data", "", "", "", 0, "image/png;base64,encoded-data-follows-here", "", "", "data:image/png;base64,encoded-data-follows-here"}); >- checkURL("data:image/png;base64,encoded/data-with-slash", {"data", "", "", "", 0, "image/png;base64,encoded/data-with-slash", "", "", "data:image/png;base64,encoded/data-with-slash"}); >- checkURL("about:~", {"about", "", "", "", 0, "~", "", "", "about:~"}); >- checkURL("https://@test@test@example:800\\path@end", {"", "", "", "", 0, "", "", "", "https://@test@test@example:800\\path@end"}); >- checkURL("http://www.example.com/#a\nb\rc\td", {"http", "", "", "www.example.com", 0, "/", "", "abcd", "http://www.example.com/#abcd"}); >- checkURL("http://[A:b:c:DE:fF:0:1:aC]/", {"http", "", "", "[a:b:c:de:ff:0:1:ac]", 0, "/", "", "", "http://[a:b:c:de:ff:0:1:ac]/"}); >- checkURL("http:////////user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://user@webkit.org:99/?foo"}); >- checkURL("http:////////user:@webkit.org:99#foo", {"http", "user", "", "webkit.org", 99, "/", "", "foo", "http://user@webkit.org:99/#foo"}); >- checkURL("http:////\t////user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://user@webkit.org:99/?foo"}); >- checkURL("http://\t//\\///user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://user@webkit.org:99/?foo"}); >- checkURL("http:/\\user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://user@webkit.org:99/?foo"}); >- checkURL("http://127.0.0.1", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}); >- checkURLDifferences("http://127.0.0.1.", >- {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}, >- {"http", "", "", "127.0.0.1.", 0, "/", "", "", "http://127.0.0.1./"}); >- checkURLDifferences("http://127.0.0.1./", >- {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}, >- {"http", "", "", "127.0.0.1.", 0, "/", "", "", "http://127.0.0.1./"}); >- checkURL("http://127.0.0.1../", {"http", "", "", "127.0.0.1..", 0, "/", "", "", "http://127.0.0.1../"}); >- checkURLDifferences("http://0x100.0/", >- {"", "", "", "", 0, "", "", "", "http://0x100.0/"}, >- {"http", "", "", "0x100.0", 0, "/", "", "", "http://0x100.0/"}); >- checkURLDifferences("http://0.0.0x100.0/", >- {"", "", "", "", 0, "", "", "", "http://0.0.0x100.0/"}, >- {"http", "", "", "0.0.0x100.0", 0, "/", "", "", "http://0.0.0x100.0/"}); >- checkURLDifferences("http://0.0.0.0x100/", >- {"", "", "", "", 0, "", "", "", "http://0.0.0.0x100/"}, >- {"http", "", "", "0.0.0.0x100", 0, "/", "", "", "http://0.0.0.0x100/"}); >- checkURL("http://host:123?", {"http", "", "", "host", 123, "/", "", "", "http://host:123/?"}); >- checkURL("http://host:123?query", {"http", "", "", "host", 123, "/", "query", "", "http://host:123/?query"}); >- checkURL("http://host:123#", {"http", "", "", "host", 123, "/", "", "", "http://host:123/#"}); >- checkURL("http://host:123#fragment", {"http", "", "", "host", 123, "/", "", "fragment", "http://host:123/#fragment"}); >- checkURLDifferences("foo:////", >- {"foo", "", "", "", 0, "//", "", "", "foo:////"}, >- {"foo", "", "", "", 0, "////", "", "", "foo:////"}); >- checkURLDifferences("foo:///?", >- {"foo", "", "", "", 0, "/", "", "", "foo:///?"}, >- {"foo", "", "", "", 0, "///", "", "", "foo:///?"}); >- checkURLDifferences("foo:///#", >- {"foo", "", "", "", 0, "/", "", "", "foo:///#"}, >- {"foo", "", "", "", 0, "///", "", "", "foo:///#"}); >- checkURLDifferences("foo:///", >- {"foo", "", "", "", 0, "/", "", "", "foo:///"}, >- {"foo", "", "", "", 0, "///", "", "", "foo:///"}); >- checkURLDifferences("foo://?", >- {"foo", "", "", "", 0, "", "", "", "foo://?"}, >- {"foo", "", "", "", 0, "//", "", "", "foo://?"}); >- checkURLDifferences("foo://#", >- {"foo", "", "", "", 0, "", "", "", "foo://#"}, >- {"foo", "", "", "", 0, "//", "", "", "foo://#"}); >- checkURLDifferences("foo://", >- {"foo", "", "", "", 0, "", "", "", "foo://"}, >- {"foo", "", "", "", 0, "//", "", "", "foo://"}); >- checkURL("foo:/?", {"foo", "", "", "", 0, "/", "", "", "foo:/?"}); >- checkURL("foo:/#", {"foo", "", "", "", 0, "/", "", "", "foo:/#"}); >- checkURL("foo:/", {"foo", "", "", "", 0, "/", "", "", "foo:/"}); >- checkURL("foo:?", {"foo", "", "", "", 0, "", "", "", "foo:?"}); >- checkURL("foo:#", {"foo", "", "", "", 0, "", "", "", "foo:#"}); >- checkURLDifferences("A://", >- {"a", "", "", "", 0, "", "", "", "a://"}, >- {"a", "", "", "", 0, "//", "", "", "a://"}); >- checkURLDifferences("aA://", >- {"aa", "", "", "", 0, "", "", "", "aa://"}, >- {"aa", "", "", "", 0, "//", "", "", "aa://"}); >- checkURL(utf16String(u"foo://host/#ÐÐ\u0007 a</"), {"foo", "", "", "host", 0, "/", "", "%D0%9F%D0%9F%07 a</", "foo://host/#%D0%9F%D0%9F%07 a</"}); >- checkURL(utf16String(u"foo://host/#\u0007 a</"), {"foo", "", "", "host", 0, "/", "", "%07 a</", "foo://host/#%07 a</"}); >- checkURL(utf16String(u"http://host?Ãð#Ãð"), {"http", "", "", "host", 0, "/", "%C3%9F%F0%9F%98%8D", "%C3%9F%F0%9F%98%8D", "http://host/?%C3%9F%F0%9F%98%8D#%C3%9F%F0%9F%98%8D"}, testTabsValueForSurrogatePairs); >- checkURL(utf16String(u"http://host/path#ð©\tð©"), {"http", "", "", "host", 0, "/path", "", "%F0%9F%92%A9%F0%9F%92%A9", "http://host/path#%F0%9F%92%A9%F0%9F%92%A9"}, testTabsValueForSurrogatePairs); >- checkURL(utf16String(u"http://host/#ÐÐ\u0007 a</"), {"http", "", "", "host", 0, "/", "", "%D0%9F%D0%9F%07 a</", "http://host/#%D0%9F%D0%9F%07 a</"}); >- checkURL(utf16String(u"http://host/#\u0007 a</"), {"http", "", "", "host", 0, "/", "", "%07 a</", "http://host/#%07 a</"}); >- >- // This disagrees with the web platform test for http://:@www.example.com but agrees with Chrome and URL::parse, >- // and Firefox fails the web platform test differently. Maybe the web platform test ought to be changed. >- checkURL("http://:@host", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >-} >- >-static void testUserPass(const String& value, const String& decoded, const String& encoded) >-{ >- URL userURL(URL(), makeString("http://", value, "@example.com/")); >- URL passURL(URL(), makeString("http://user:", value, "@example.com/")); >- EXPECT_EQ(encoded, userURL.encodedUser()); >- EXPECT_EQ(encoded, passURL.encodedPass()); >- EXPECT_EQ(decoded, userURL.user()); >- EXPECT_EQ(decoded, passURL.pass()); >-} >- >-static void testUserPass(const String& value, const String& encoded) >-{ >- testUserPass(value, value, encoded); >-} >- >-TEST_F(URLParserTest, Credentials) >-{ >- auto validSurrogate = utf16String<3>({0xD800, 0xDD55, '\0'}); >- auto invalidSurrogate = utf16String<3>({0xD800, 'A', '\0'}); >- auto replacementA = utf16String<3>({0xFFFD, 'A', '\0'}); >- >- testUserPass("a", "a"); >- testUserPass("%", "%"); >- testUserPass("%25", "%", "%25"); >- testUserPass("%2525", "%25", "%2525"); >- testUserPass("%FX", "%FX"); >- testUserPass("%00", String::fromUTF8("\0", 1), "%00"); >- testUserPass("%F%25", "%F%", "%F%25"); >- testUserPass("%X%25", "%X%", "%X%25"); >- testUserPass("%%25", "%%", "%%25"); >- testUserPass("ð©", "%C3%B0%C2%9F%C2%92%C2%A9"); >- testUserPass("%ð©", "%%C3%B0%C2%9F%C2%92%C2%A9"); >- testUserPass(validSurrogate, "%F0%90%85%95"); >- testUserPass(replacementA, "%EF%BF%BDA"); >- testUserPass(invalidSurrogate, replacementA, "%EF%BF%BDA"); >-} >- >-TEST_F(URLParserTest, 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"}); >- checkRelativeURL("index.html", "http://webkit.org/path1/path2/page.html?query#fragment", {"http", "", "", "webkit.org", 0, "/path1/path2/index.html", "", "", "http://webkit.org/path1/path2/index.html"}); >- checkRelativeURL("//whatwg.org/index.html", "https://www.webkit.org/path", {"https", "", "", "whatwg.org", 0, "/index.html", "", "", "https://whatwg.org/index.html"}); >- checkRelativeURL("http://example\t.\norg", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/", "", "", "http://example.org/"}); >- checkRelativeURL("test", "file:///path1/path2", {"file", "", "", "", 0, "/path1/test", "", "", "file:///path1/test"}); >- checkRelativeURL(utf16String(u"http://www.fooãbar.com"), "http://other.com/", {"http", "", "", "www.foo.bar.com", 0, "/", "", "", "http://www.foo.bar.com/"}); >- checkRelativeURLDifferences(utf16String(u"sc://ñ.test/"), "about:blank", >- {"sc", "", "", "%C3%B1.test", 0, "/", "", "", "sc://%C3%B1.test/"}, >- {"sc", "", "", "xn--ida.test", 0, "/", "", "", "sc://xn--ida.test/"}); >- checkRelativeURL("#fragment", "http://host/path", {"http", "", "", "host", 0, "/path", "", "fragment", "http://host/path#fragment"}); >- checkRelativeURL("#fragment", "file:///path", {"file", "", "", "", 0, "/path", "", "fragment", "file:///path#fragment"}); >- checkRelativeURL("#fragment", "file:///path#old", {"file", "", "", "", 0, "/path", "", "fragment", "file:///path#fragment"}); >- checkRelativeURL("#", "file:///path#old", {"file", "", "", "", 0, "/path", "", "", "file:///path#"}); >- checkRelativeURL(" ", "file:///path#old", {"file", "", "", "", 0, "/path", "", "", "file:///path"}); >- checkRelativeURL("#", "file:///path", {"file", "", "", "", 0, "/path", "", "", "file:///path#"}); >- checkRelativeURL("#", "file:///path?query", {"file", "", "", "", 0, "/path", "query", "", "file:///path?query#"}); >- checkRelativeURL("#", "file:///path?query#old", {"file", "", "", "", 0, "/path", "query", "", "file:///path?query#"}); >- checkRelativeURL("?query", "http://host/path", {"http", "", "", "host", 0, "/path", "query", "", "http://host/path?query"}); >- checkRelativeURL("?query#fragment", "http://host/path", {"http", "", "", "host", 0, "/path", "query", "fragment", "http://host/path?query#fragment"}); >- checkRelativeURL("?new", "file:///path?old#fragment", {"file", "", "", "", 0, "/path", "new", "", "file:///path?new"}); >- checkRelativeURL("?", "file:///path?old#fragment", {"file", "", "", "", 0, "/path", "", "", "file:///path?"}); >- checkRelativeURL("?", "file:///path", {"file", "", "", "", 0, "/path", "", "", "file:///path?"}); >- checkRelativeURL("?query", "file:///path", {"file", "", "", "", 0, "/path", "query", "", "file:///path?query"}); >- checkRelativeURL(utf16String(u"?β"), "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "%CE%B2", "", "http://example.org/foo/bar?%CE%B2"}); >- checkRelativeURL("?", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar?"}); >- checkRelativeURL("#", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar#"}); >- checkRelativeURL("?#", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar?#"}); >- checkRelativeURL("#?", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "?", "http://example.org/foo/bar#?"}); >- checkRelativeURL("/", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/", "", "", "http://example.org/"}); >- checkRelativeURL("http://@host", "about:blank", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >- checkRelativeURL("http://:@host", "about:blank", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >- checkRelativeURL("http://foo.com/\\@", "http://example.org/foo/bar", {"http", "", "", "foo.com", 0, "//@", "", "", "http://foo.com//@"}); >- checkRelativeURL("\\@", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/@", "", "", "http://example.org/@"}); >- checkRelativeURL("/path3", "http://user@example.org/path1/path2", {"http", "user", "", "example.org", 0, "/path3", "", "", "http://user@example.org/path3"}); >- checkRelativeURL("", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar"}); >- checkRelativeURL("\t", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar"}); >- checkRelativeURL(" ", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar"}); >- checkRelativeURL(" \a \t\n", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar"}); >- checkRelativeURL(":foo.com\\", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/:foo.com/", "", "", "http://example.org/foo/:foo.com/"}); >- checkRelativeURL("http:/example.com/", "about:blank", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >- checkRelativeURL("http:example.com/", "about:blank", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >- checkRelativeURL("http:\\\\foo.com\\", "http://example.org/foo/bar", {"http", "", "", "foo.com", 0, "/", "", "", "http://foo.com/"}); >- checkRelativeURL("http:\\\\foo.com/", "http://example.org/foo/bar", {"http", "", "", "foo.com", 0, "/", "", "", "http://foo.com/"}); >- checkRelativeURL("http:\\\\foo.com", "http://example.org/foo/bar", {"http", "", "", "foo.com", 0, "/", "", "", "http://foo.com/"}); >- checkRelativeURL("http://ExAmPlE.CoM", "http://other.com", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >- checkRelativeURL("http:", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar"}); >- checkRelativeURL("#x", "data:,", {"data", "", "", "", 0, ",", "", "x", "data:,#x"}); >- checkRelativeURL("#x", "about:blank", {"about", "", "", "", 0, "blank", "", "x", "about:blank#x"}); >- checkRelativeURL(" foo.com ", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/foo.com", "", "", "http://example.org/foo/foo.com"}); >- checkRelativeURL(" \a baz", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/baz", "", "", "http://example.org/foo/baz"}); >- checkRelativeURL("~", "http://example.org", {"http", "", "", "example.org", 0, "/~", "", "", "http://example.org/~"}); >- checkRelativeURL("notspecial:", "about:blank", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"}); >- checkRelativeURL("notspecial:", "http://host", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"}); >- checkRelativeURL("http:", "http://host", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >- checkRelativeURL("i", "sc:/pa/po", {"sc", "", "", "", 0, "/pa/i", "", "", "sc:/pa/i"}); >- checkRelativeURL("i ", "sc:/pa/po", {"sc", "", "", "", 0, "/pa/i", "", "", "sc:/pa/i"}); >- checkRelativeURL("i\t\n ", "sc:/pa/po", {"sc", "", "", "", 0, "/pa/i", "", "", "sc:/pa/i"}); >- checkRelativeURL("i", "sc://ho/pa", {"sc", "", "", "ho", 0, "/i", "", "", "sc://ho/i"}); >- checkRelativeURL("!", "sc://ho/pa", {"sc", "", "", "ho", 0, "/!", "", "", "sc://ho/!"}); >- checkRelativeURL("!", "sc:/ho/pa", {"sc", "", "", "", 0, "/ho/!", "", "", "sc:/ho/!"}); >- checkRelativeURL("notspecial:/", "about:blank", {"notspecial", "", "", "", 0, "/", "", "", "notspecial:/"}); >- checkRelativeURL("notspecial:/", "http://host", {"notspecial", "", "", "", 0, "/", "", "", "notspecial:/"}); >- checkRelativeURL("foo:/", "http://example.org/foo/bar", {"foo", "", "", "", 0, "/", "", "", "foo:/"}); >- checkRelativeURL("://:0/", "http://webkit.org/", {"http", "", "", "webkit.org", 0, "/://:0/", "", "", "http://webkit.org/://:0/"}); >- checkRelativeURL(String(), "http://webkit.org/", {"http", "", "", "webkit.org", 0, "/", "", "", "http://webkit.org/"}); >- checkRelativeURL("https://@test@test@example:800\\path@end", "http://doesnotmatter/", {"", "", "", "", 0, "", "", "", "https://@test@test@example:800\\path@end"}); >- checkRelativeURL("http://f:0/c", "http://example.org/foo/bar", {"http", "", "", "f", 0, "/c", "", "", "http://f:0/c"}); >- checkRelativeURL(String(), "http://host/#fragment", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >- checkRelativeURL("", "http://host/#fragment", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >- checkRelativeURL(" ", "http://host/#fragment", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >- checkRelativeURL(" ", "http://host/path?query#fra#gment", {"http", "", "", "host", 0, "/path", "query", "", "http://host/path?query"}); >- checkRelativeURL(" \a ", "http://host/#fragment", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >- checkRelativeURLDifferences("foo://", "http://example.org/foo/bar", >- {"foo", "", "", "", 0, "", "", "", "foo://"}, >- {"foo", "", "", "", 0, "//", "", "", "foo://"}); >- checkRelativeURL(utf16String(u"#β"), "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "%CE%B2", "http://example.org/foo/bar#%CE%B2"}); >- checkRelativeURL("index.html", "applewebdata://Host/", {"applewebdata", "", "", "Host", 0, "/index.html", "", "", "applewebdata://Host/index.html"}); >- checkRelativeURL("index.html", "applewebdata://Host", {"applewebdata", "", "", "Host", 0, "/index.html", "", "", "applewebdata://Host/index.html"}); >- checkRelativeURL("", "applewebdata://Host", {"applewebdata", "", "", "Host", 0, "", "", "", "applewebdata://Host"}); >- checkRelativeURL("?query", "applewebdata://Host", {"applewebdata", "", "", "Host", 0, "", "query", "", "applewebdata://Host?query"}); >- checkRelativeURL("#fragment", "applewebdata://Host", {"applewebdata", "", "", "Host", 0, "", "", "fragment", "applewebdata://Host#fragment"}); >- checkRelativeURL("notspecial://something?", "file:////var//containers//stuff/", {"notspecial", "", "", "something", 0, "", "", "", "notspecial://something?"}, TestTabs::No); >- checkRelativeURL("notspecial://something#", "file:////var//containers//stuff/", {"notspecial", "", "", "something", 0, "", "", "", "notspecial://something#"}, TestTabs::No); >- checkRelativeURL("http://something?", "file:////var//containers//stuff/", {"http", "", "", "something", 0, "/", "", "", "http://something/?"}, TestTabs::No); >- checkRelativeURL("http://something#", "file:////var//containers//stuff/", {"http", "", "", "something", 0, "/", "", "", "http://something/#"}, TestTabs::No); >- checkRelativeURL("file:", "file:///path?query#fragment", {"file", "", "", "", 0, "/path", "query", "", "file:///path?query"}); >- checkRelativeURL("/", "file:///C:/a/b", {"file", "", "", "", 0, "/C:/", "", "", "file:///C:/"}); >- checkRelativeURL("/abc", "file:///C:/a/b", {"file", "", "", "", 0, "/C:/abc", "", "", "file:///C:/abc"}); >- checkRelativeURL("/abc", "file:///C:", {"file", "", "", "", 0, "/C:/abc", "", "", "file:///C:/abc"}); >- checkRelativeURL("/abc", "file:///", {"file", "", "", "", 0, "/abc", "", "", "file:///abc"}); >- checkRelativeURL("//d:", "file:///C:/a/b", {"file", "", "", "", 0, "/d:", "", "", "file:///d:"}, TestTabs::No); >- checkRelativeURL("//d|", "file:///C:/a/b", {"file", "", "", "", 0, "/d:", "", "", "file:///d:"}, TestTabs::No); >- checkRelativeURL("//A|", "file:///C:/a/b", {"file", "", "", "", 0, "/A:", "", "", "file:///A:"}, TestTabs::No); >- >- // The checking of slashes in SpecialAuthoritySlashes needed to get this to pass contradicts what is in the spec, >- // but it is included in the web platform tests. >- checkRelativeURL("http:\\\\host\\foo", "about:blank", {"http", "", "", "host", 0, "/foo", "", "", "http://host/foo"}); >-} >- >-// These are differences between the new URLParser and the old URL::parse which make URLParser more standards compliant. >-TEST_F(URLParserTest, ParserDifferences) >-{ >- checkURLDifferences("http://127.0.1", >- {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}, >- {"http", "", "", "127.0.1", 0, "/", "", "", "http://127.0.1/"}); >- checkURLDifferences("http://011.11.0X11.0x011", >- {"http", "", "", "9.11.17.17", 0, "/", "", "", "http://9.11.17.17/"}, >- {"http", "", "", "011.11.0x11.0x011", 0, "/", "", "", "http://011.11.0x11.0x011/"}); >- checkURLDifferences("http://[1234:0078:90AB:CdEf:0123:0007:89AB:0000]", >- {"http", "", "", "[1234:78:90ab:cdef:123:7:89ab:0]", 0, "/", "", "", "http://[1234:78:90ab:cdef:123:7:89ab:0]/"}, >- {"http", "", "", "[1234:0078:90ab:cdef:0123:0007:89ab:0000]", 0, "/", "", "", "http://[1234:0078:90ab:cdef:0123:0007:89ab:0000]/"}); >- checkURLDifferences("http://[0:f:0:0:f:f:0:0]", >- {"http", "", "", "[0:f::f:f:0:0]", 0, "/", "", "", "http://[0:f::f:f:0:0]/"}, >- {"http", "", "", "[0:f:0:0:f:f:0:0]", 0, "/", "", "", "http://[0:f:0:0:f:f:0:0]/"}); >- checkURLDifferences("http://[0:f:0:0:f:0:0:0]", >- {"http", "", "", "[0:f:0:0:f::]", 0, "/", "", "", "http://[0:f:0:0:f::]/"}, >- {"http", "", "", "[0:f:0:0:f:0:0:0]", 0, "/", "", "", "http://[0:f:0:0:f:0:0:0]/"}); >- checkURLDifferences("http://[0:0:f:0:0:f:0:0]", >- {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"}, >- {"http", "", "", "[0:0:f:0:0:f:0:0]", 0, "/", "", "", "http://[0:0:f:0:0:f:0:0]/"}); >- checkURLDifferences("http://[a:0:0:0:b:c::d]", >- {"http", "", "", "[a::b:c:0:d]", 0, "/", "", "", "http://[a::b:c:0:d]/"}, >- {"http", "", "", "[a:0:0:0:b:c::d]", 0, "/", "", "", "http://[a:0:0:0:b:c::d]/"}); >- checkURLDifferences("http://[::7f00:0001]/", >- {"http", "", "", "[::7f00:1]", 0, "/", "", "", "http://[::7f00:1]/"}, >- {"http", "", "", "[::7f00:0001]", 0, "/", "", "", "http://[::7f00:0001]/"}); >- checkURLDifferences("http://[::7f00:00]/", >- {"http", "", "", "[::7f00:0]", 0, "/", "", "", "http://[::7f00:0]/"}, >- {"http", "", "", "[::7f00:00]", 0, "/", "", "", "http://[::7f00:00]/"}); >- checkURLDifferences("http://[::0:7f00:0001]/", >- {"http", "", "", "[::7f00:1]", 0, "/", "", "", "http://[::7f00:1]/"}, >- {"http", "", "", "[::0:7f00:0001]", 0, "/", "", "", "http://[::0:7f00:0001]/"}); >- checkURLDifferences("http://127.00.0.1/", >- {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}, >- {"http", "", "", "127.00.0.1", 0, "/", "", "", "http://127.00.0.1/"}); >- checkURLDifferences("http://127.0.0.01/", >- {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}, >- {"http", "", "", "127.0.0.01", 0, "/", "", "", "http://127.0.0.01/"}); >- checkURLDifferences("http://example.com/path1/.%2e", >- {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}, >- {"http", "", "", "example.com", 0, "/path1/.%2e", "", "", "http://example.com/path1/.%2e"}); >- checkURLDifferences("http://example.com/path1/.%2E", >- {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}, >- {"http", "", "", "example.com", 0, "/path1/.%2E", "", "", "http://example.com/path1/.%2E"}); >- checkURLDifferences("http://example.com/path1/.%2E/", >- {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}, >- {"http", "", "", "example.com", 0, "/path1/.%2E/", "", "", "http://example.com/path1/.%2E/"}); >- checkURLDifferences("http://example.com/path1/%2e.", >- {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}, >- {"http", "", "", "example.com", 0, "/path1/%2e.", "", "", "http://example.com/path1/%2e."}); >- checkURLDifferences("http://example.com/path1/%2E%2e", >- {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}, >- {"http", "", "", "example.com", 0, "/path1/%2E%2e", "", "", "http://example.com/path1/%2E%2e"}); >- checkURLDifferences("http://example.com/path1/%2e", >- {"http", "", "", "example.com", 0, "/path1/", "", "", "http://example.com/path1/"}, >- {"http", "", "", "example.com", 0, "/path1/%2e", "", "", "http://example.com/path1/%2e"}); >- checkURLDifferences("http://example.com/path1/%2E", >- {"http", "", "", "example.com", 0, "/path1/", "", "", "http://example.com/path1/"}, >- {"http", "", "", "example.com", 0, "/path1/%2E", "", "", "http://example.com/path1/%2E"}); >- checkURLDifferences("http://example.com/path1/%2E/", >- {"http", "", "", "example.com", 0, "/path1/", "", "", "http://example.com/path1/"}, >- {"http", "", "", "example.com", 0, "/path1/%2E/", "", "", "http://example.com/path1/%2E/"}); >- checkURLDifferences("http://example.com/path1/path2/%2e?query", >- {"http", "", "", "example.com", 0, "/path1/path2/", "query", "", "http://example.com/path1/path2/?query"}, >- {"http", "", "", "example.com", 0, "/path1/path2/%2e", "query", "", "http://example.com/path1/path2/%2e?query"}); >- checkURLDifferences("http://example.com/path1/path2/%2e%2e?query", >- {"http", "", "", "example.com", 0, "/path1/", "query", "", "http://example.com/path1/?query"}, >- {"http", "", "", "example.com", 0, "/path1/path2/%2e%2e", "query", "", "http://example.com/path1/path2/%2e%2e?query"}); >- checkURLDifferences("http://example.com/path1/path2/%2e#fragment", >- {"http", "", "", "example.com", 0, "/path1/path2/", "", "fragment", "http://example.com/path1/path2/#fragment"}, >- {"http", "", "", "example.com", 0, "/path1/path2/%2e", "", "fragment", "http://example.com/path1/path2/%2e#fragment"}); >- checkURLDifferences("http://example.com/path1/path2/%2e%2e#fragment", >- {"http", "", "", "example.com", 0, "/path1/", "", "fragment", "http://example.com/path1/#fragment"}, >- {"http", "", "", "example.com", 0, "/path1/path2/%2e%2e", "", "fragment", "http://example.com/path1/path2/%2e%2e#fragment"}); >- checkURL("http://example.com/path1/path2/A%2e%2e#fragment", {"http", "", "", "example.com", 0, "/path1/path2/A%2e%2e", "", "fragment", "http://example.com/path1/path2/A%2e%2e#fragment"}); >- checkURLDifferences("file://[0:a:0:0:b:c:0:0]/path", >- {"file", "", "", "[0:a::b:c:0:0]", 0, "/path", "", "", "file://[0:a::b:c:0:0]/path"}, >- {"file", "", "", "[0:a:0:0:b:c:0:0]", 0, "/path", "", "", "file://[0:a:0:0:b:c:0:0]/path"}); >- checkURLDifferences("http://", >- {"", "", "", "", 0, "", "", "", "http://"}, >- {"http", "", "", "", 0, "/", "", "", "http:/"}); >- checkRelativeURLDifferences("//", "https://www.webkit.org/path", >- {"", "", "", "", 0, "", "", "", "//"}, >- {"https", "", "", "", 0, "/", "", "", "https:/"}); >- checkURLDifferences("http://127.0.0.1:65536/path", >- {"", "", "", "", 0, "", "", "", "http://127.0.0.1:65536/path"}, >- {"http", "", "", "127.0.0.1", 0, "/path", "", "", "http://127.0.0.1:65536/path"}); >- checkURLDifferences("http://host:65536", >- {"", "", "", "", 0, "", "", "", "http://host:65536"}, >- {"http", "", "", "host", 0, "/", "", "", "http://host:65536/"}); >- checkURLDifferences("http://127.0.0.1:65536", >- {"", "", "", "", 0, "", "", "", "http://127.0.0.1:65536"}, >- {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1:65536/"}); >- checkURLDifferences("http://[0:f::f:f:0:0]:65536", >- {"", "", "", "", 0, "", "", "", "http://[0:f::f:f:0:0]:65536"}, >- {"http", "", "", "[0:f::f:f:0:0]", 0, "/", "", "", "http://[0:f::f:f:0:0]:65536/"}); >- checkRelativeURLDifferences(":foo.com\\", "notspecial://example.org/foo/bar", >- {"notspecial", "", "", "example.org", 0, "/foo/:foo.com\\", "", "", "notspecial://example.org/foo/:foo.com\\"}, >- {"notspecial", "", "", "example.org", 0, "/foo/:foo.com/", "", "", "notspecial://example.org/foo/:foo.com/"}); >- checkURL("sc://pa", {"sc", "", "", "pa", 0, "", "", "", "sc://pa"}); >- checkRelativeURLDifferences("notspecial:\\\\foo.com\\", "http://example.org/foo/bar", >- {"notspecial", "", "", "", 0, "\\\\foo.com\\", "", "", "notspecial:\\\\foo.com\\"}, >- {"notspecial", "", "", "foo.com", 0, "/", "", "", "notspecial://foo.com/"}); >- checkRelativeURLDifferences("notspecial:\\\\foo.com/", "http://example.org/foo/bar", >- {"notspecial", "", "", "", 0, "\\\\foo.com/", "", "", "notspecial:\\\\foo.com/"}, >- {"notspecial", "", "", "foo.com", 0, "/", "", "", "notspecial://foo.com/"}); >- checkRelativeURLDifferences("notspecial:\\\\foo.com", "http://example.org/foo/bar", >- {"notspecial", "", "", "", 0, "\\\\foo.com", "", "", "notspecial:\\\\foo.com"}, >- {"notspecial", "", "", "foo.com", 0, "", "", "", "notspecial://foo.com"}); >- checkURLDifferences("file://notuser:notpassword@test", >- {"", "", "", "", 0, "", "", "", "file://notuser:notpassword@test"}, >- {"file", "notuser", "notpassword", "test", 0, "/", "", "", "file://notuser:notpassword@test/"}); >- checkURLDifferences("file://notuser:notpassword@test/", >- {"", "", "", "", 0, "", "", "", "file://notuser:notpassword@test/"}, >- {"file", "notuser", "notpassword", "test", 0, "/", "", "", "file://notuser:notpassword@test/"}); >- checkRelativeURLDifferences("http:/", "about:blank", >- {"", "", "", "", 0, "", "", "", "http:/"}, >- {"http", "", "", "", 0, "/", "", "", "http:/"}); >- checkRelativeURLDifferences("http:", "about:blank", >- {"http", "", "", "", 0, "", "", "", "http:"}, >- {"http", "", "", "", 0, "/", "", "", "http:/"}); >- checkRelativeURLDifferences("http:/", "http://host", >- {"", "", "", "", 0, "", "", "", "http:/"}, >- {"http", "", "", "", 0, "/", "", "", "http:/"}); >- checkURLDifferences("http:/", >- {"", "", "", "", 0, "", "", "", "http:/"}, >- {"http", "", "", "", 0, "/", "", "", "http:/"}); >- checkURLDifferences("http:", >- {"http", "", "", "", 0, "", "", "", "http:"}, >- {"http", "", "", "", 0, "/", "", "", "http:/"}); >- checkRelativeURLDifferences("http:/example.com/", "http://example.org/foo/bar", >- {"http", "", "", "example.org", 0, "/example.com/", "", "", "http://example.org/example.com/"}, >- {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >- >- // This behavior matches Chrome and Firefox, but not WebKit using URL::parse. >- // The behavior of URL::parse is clearly wrong because reparsing file://path would make path the host. >- // The spec is unclear. >- checkURLDifferences("file:path", >- {"file", "", "", "", 0, "/path", "", "", "file:///path"}, >- {"file", "", "", "", 0, "path", "", "", "file://path"}); >- checkURLDifferences("file:pAtH", >- {"file", "", "", "", 0, "/pAtH", "", "", "file:///pAtH"}, >- {"file", "", "", "", 0, "pAtH", "", "", "file://pAtH"}); >- checkURLDifferences("file:pAtH/", >- {"file", "", "", "", 0, "/pAtH/", "", "", "file:///pAtH/"}, >- {"file", "", "", "", 0, "pAtH/", "", "", "file://pAtH/"}); >- checkURLDifferences("http://example.com%A0", >- {"", "", "", "", 0, "", "", "", "http://example.com%A0"}, >- {"http", "", "", "example.com%a0", 0, "/", "", "", "http://example.com%a0/"}); >- checkURLDifferences("http://%E2%98%83", >- {"http", "", "", "xn--n3h", 0, "/", "", "", "http://xn--n3h/"}, >- {"http", "", "", "%e2%98%83", 0, "/", "", "", "http://%e2%98%83/"}); >- checkURLDifferences("http://host%73", >- {"http", "", "", "hosts", 0, "/", "", "", "http://hosts/"}, >- {"http", "", "", "host%73", 0, "/", "", "", "http://host%73/"}); >- checkURLDifferences("http://host%53", >- {"http", "", "", "hosts", 0, "/", "", "", "http://hosts/"}, >- {"http", "", "", "host%53", 0, "/", "", "", "http://host%53/"}); >- checkURLDifferences("http://%", >- {"", "", "", "", 0, "", "", "", "http://%"}, >- {"http", "", "", "%", 0, "/", "", "", "http://%/"}); >- checkURLDifferences("http://%7", >- {"", "", "", "", 0, "", "", "", "http://%7"}, >- {"http", "", "", "%7", 0, "/", "", "", "http://%7/"}); >- checkURLDifferences("http://%7s", >- {"", "", "", "", 0, "", "", "", "http://%7s"}, >- {"http", "", "", "%7s", 0, "/", "", "", "http://%7s/"}); >- checkURLDifferences("http://%73", >- {"http", "", "", "s", 0, "/", "", "", "http://s/"}, >- {"http", "", "", "%73", 0, "/", "", "", "http://%73/"}); >- checkURLDifferences("http://abcdefg%", >- {"", "", "", "", 0, "", "", "", "http://abcdefg%"}, >- {"http", "", "", "abcdefg%", 0, "/", "", "", "http://abcdefg%/"}); >- checkURLDifferences("http://abcd%7Xefg", >- {"", "", "", "", 0, "", "", "", "http://abcd%7Xefg"}, >- {"http", "", "", "abcd%7xefg", 0, "/", "", "", "http://abcd%7xefg/"}); >- >- >- // URLParser matches Chrome and the spec, but not URL::parse or Firefox. >- checkURLDifferences(utf16String(u"http://ï¼ï¼¸ï½ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼"), >- {"http", "", "", "192.168.0.1", 0, "/", "", "", "http://192.168.0.1/"}, >- {"http", "", "", "0xc0.0250.01", 0, "/", "", "", "http://0xc0.0250.01/"}); >- >- checkURL("http://host/path%2e.%2E", {"http", "", "", "host", 0, "/path%2e.%2E", "", "", "http://host/path%2e.%2E"}); >- >- checkRelativeURLDifferences(utf16String(u"http://foo:ð©@example.com/bar"), "http://other.com/", >- {"http", "foo", utf16String(u"ð©"), "example.com", 0, "/bar", "", "", "http://foo:%F0%9F%92%A9@example.com/bar"}, >- {"", "", "", "", 0, "", "", "", utf16String(u"http://foo:ð©@example.com/bar")}, testTabsValueForSurrogatePairs); >- checkRelativeURLDifferences("http://&a:foo(b]c@d:2/", "http://example.org/foo/bar", >- {"http", "&a", "foo(b]c", "d", 2, "/", "", "", "http://&a:foo(b%5Dc@d:2/"}, >- {"", "", "", "", 0, "", "", "", "http://&a:foo(b]c@d:2/"}); >- checkRelativeURLDifferences("http://`{}:`{}@h/`{}?`{}", "http://doesnotmatter/", >- {"http", "`{}", "`{}", "h", 0, "/%60%7B%7D", "`{}", "", "http://%60%7B%7D:%60%7B%7D@h/%60%7B%7D?`{}"}, >- {"", "", "", "", 0, "", "", "", "http://`{}:`{}@h/`{}?`{}"}); >- checkURLDifferences("http://[0:f::f::f]", >- {"", "", "", "", 0, "" , "", "", "http://[0:f::f::f]"}, >- {"http", "", "", "[0:f::f::f]", 0, "/" , "", "", "http://[0:f::f::f]/"}); >- checkURLDifferences("http://123", >- {"http", "", "", "0.0.0.123", 0, "/", "", "", "http://0.0.0.123/"}, >- {"http", "", "", "123", 0, "/", "", "", "http://123/"}); >- checkURLDifferences("http://123.234/", >- {"http", "", "", "123.0.0.234", 0, "/", "", "", "http://123.0.0.234/"}, >- {"http", "", "", "123.234", 0, "/", "", "", "http://123.234/"}); >- checkURLDifferences("http://123.234.012", >- {"http", "", "", "123.234.0.10", 0, "/", "", "", "http://123.234.0.10/"}, >- {"http", "", "", "123.234.012", 0, "/", "", "", "http://123.234.012/"}); >- checkURLDifferences("http://123.234.12", >- {"http", "", "", "123.234.0.12", 0, "/", "", "", "http://123.234.0.12/"}, >- {"http", "", "", "123.234.12", 0, "/", "", "", "http://123.234.12/"}); >- checkRelativeURLDifferences("file:c:\\foo\\bar.html", "file:///tmp/mock/path", >- {"file", "", "", "", 0, "/c:/foo/bar.html", "", "", "file:///c:/foo/bar.html"}, >- {"file", "", "", "", 0, "/tmp/mock/c:/foo/bar.html", "", "", "file:///tmp/mock/c:/foo/bar.html"}); >- checkRelativeURLDifferences(" File:c|////foo\\bar.html", "file:///tmp/mock/path", >- {"file", "", "", "", 0, "/c:////foo/bar.html", "", "", "file:///c:////foo/bar.html"}, >- {"file", "", "", "", 0, "/tmp/mock/c|////foo/bar.html", "", "", "file:///tmp/mock/c|////foo/bar.html"}); >- checkRelativeURLDifferences(" Fil\t\n\te\n\t\n:\t\n\tc\t\n\t|\n\t\n/\t\n\t/\n\t\n//foo\\bar.html", "file:///tmp/mock/path", >- {"file", "", "", "", 0, "/c:////foo/bar.html", "", "", "file:///c:////foo/bar.html"}, >- {"file", "", "", "", 0, "/tmp/mock/c|////foo/bar.html", "", "", "file:///tmp/mock/c|////foo/bar.html"}); >- checkRelativeURLDifferences("C|/foo/bar", "file:///tmp/mock/path", >- {"file", "", "", "", 0, "/C:/foo/bar", "", "", "file:///C:/foo/bar"}, >- {"file", "", "", "", 0, "/tmp/mock/C|/foo/bar", "", "", "file:///tmp/mock/C|/foo/bar"}); >- checkRelativeURLDifferences("/C|/foo/bar", "file:///tmp/mock/path", >- {"file", "", "", "", 0, "/C:/foo/bar", "", "", "file:///C:/foo/bar"}, >- {"file", "", "", "", 0, "/C|/foo/bar", "", "", "file:///C|/foo/bar"}); >- checkRelativeURLDifferences("https://@test@test@example:800/", "http://doesnotmatter/", >- {"https", "@test@test", "", "example", 800, "/", "", "", "https://%40test%40test@example:800/"}, >- {"", "", "", "", 0, "", "", "", "https://@test@test@example:800/"}); >- checkRelativeURLDifferences("https://@test@test@example:800/path@end", "http://doesnotmatter/", >- {"https", "@test@test", "", "example", 800, "/path@end", "", "", "https://%40test%40test@example:800/path@end"}, >- {"", "", "", "", 0, "", "", "", "https://@test@test@example:800/path@end"}); >- checkURLDifferences("notspecial://@test@test@example:800/path@end", >- {"notspecial", "@test@test", "", "example", 800, "/path@end", "", "", "notspecial://%40test%40test@example:800/path@end"}, >- {"", "", "", "", 0, "", "", "", "notspecial://@test@test@example:800/path@end"}); >- checkURLDifferences("notspecial://@test@test@example:800\\path@end", >- {"notspecial", "@test@test@example", "800\\path", "end", 0, "", "", "", "notspecial://%40test%40test%40example:800%5Cpath@end"}, >- {"", "", "", "", 0, "", "", "", "notspecial://@test@test@example:800\\path@end"}); >- checkURLDifferences("http://%48OsT", >- {"http", "", "", "host", 0, "/", "", "", "http://host/"}, >- {"http", "", "", "%48ost", 0, "/", "", "", "http://%48ost/"}); >- checkURLDifferences("http://h%4FsT", >- {"http", "", "", "host", 0, "/", "", "", "http://host/"}, >- {"http", "", "", "h%4fst", 0, "/", "", "", "http://h%4fst/"}); >- checkURLDifferences("http://h%4fsT", >- {"http", "", "", "host", 0, "/", "", "", "http://host/"}, >- {"http", "", "", "h%4fst", 0, "/", "", "", "http://h%4fst/"}); >- checkURLDifferences("http://h%6fsT", >- {"http", "", "", "host", 0, "/", "", "", "http://host/"}, >- {"http", "", "", "h%6fst", 0, "/", "", "", "http://h%6fst/"}); >- checkURLDifferences("http://host/`", >- {"http", "", "", "host", 0, "/%60", "", "", "http://host/%60"}, >- {"http", "", "", "host", 0, "/`", "", "", "http://host/`"}); >- checkURLDifferences("http://://", >- {"", "", "", "", 0, "", "", "", "http://://"}, >- {"http", "", "", "", 0, "//", "", "", "http://://"}); >- checkURLDifferences("http://:123?", >- {"", "", "", "", 0, "", "", "", "http://:123?"}, >- {"http", "", "", "", 123, "/", "", "", "http://:123/?"}); >- checkURLDifferences("http:/:", >- {"", "", "", "", 0, "", "", "", "http:/:"}, >- {"http", "", "", "", 0, "/", "", "", "http://:/"}); >- checkURLDifferences("asdf://:", >- {"", "", "", "", 0, "", "", "", "asdf://:"}, >- {"asdf", "", "", "", 0, "", "", "", "asdf://:"}); >- checkURLDifferences("http://:", >- {"", "", "", "", 0, "", "", "", "http://:"}, >- {"http", "", "", "", 0, "/", "", "", "http://:/"}); >- checkURLDifferences("http:##foo", >- {"", "", "", "", 0, "", "", "", "http:##foo"}, >- {"http", "", "", "", 0, "/", "", "#foo", "http:/##foo"}); >- checkURLDifferences("http:??bar", >- {"", "", "", "", 0, "", "", "", "http:??bar"}, >- {"http", "", "", "", 0, "/", "?bar", "", "http:/??bar"}); >- checkURL("asdf:##foo", {"asdf", "", "", "", 0, "", "", "#foo", "asdf:##foo"}); >- checkURL("asdf:??bar", {"asdf", "", "", "", 0, "", "?bar", "", "asdf:??bar"}); >- checkRelativeURLDifferences("//C|/foo/bar", "file:///tmp/mock/path", >- {"file", "", "", "", 0, "/C:/foo/bar", "", "", "file:///C:/foo/bar"}, >- {"", "", "", "", 0, "", "", "", "//C|/foo/bar"}); >- checkRelativeURLDifferences("//C:/foo/bar", "file:///tmp/mock/path", >- {"file", "", "", "", 0, "/C:/foo/bar", "", "", "file:///C:/foo/bar"}, >- {"file", "", "", "c", 0, "/foo/bar", "", "", "file://c/foo/bar"}); >- checkRelativeURLDifferences("//C|?foo/bar", "file:///tmp/mock/path", >- {"file", "", "", "", 0, "/C:/", "foo/bar", "", "file:///C:/?foo/bar"}, >- {"", "", "", "", 0, "", "", "", "//C|?foo/bar"}); >- checkRelativeURLDifferences("//C|#foo/bar", "file:///tmp/mock/path", >- {"file", "", "", "", 0, "/C:/", "", "foo/bar", "file:///C:/#foo/bar"}, >- {"", "", "", "", 0, "", "", "", "//C|#foo/bar"}); >- checkURLDifferences("http://0xFFFFFfFF/", >- {"http", "", "", "255.255.255.255", 0, "/", "", "", "http://255.255.255.255/"}, >- {"http", "", "", "0xffffffff", 0, "/", "", "", "http://0xffffffff/"}); >- checkURLDifferences("http://0000000000000000037777777777/", >- {"http", "", "", "255.255.255.255", 0, "/", "", "", "http://255.255.255.255/"}, >- {"http", "", "", "0000000000000000037777777777", 0, "/", "", "", "http://0000000000000000037777777777/"}); >- checkURLDifferences("http://4294967295/", >- {"http", "", "", "255.255.255.255", 0, "/", "", "", "http://255.255.255.255/"}, >- {"http", "", "", "4294967295", 0, "/", "", "", "http://4294967295/"}); >- checkURLDifferences("http://256/", >- {"http", "", "", "0.0.1.0", 0, "/", "", "", "http://0.0.1.0/"}, >- {"http", "", "", "256", 0, "/", "", "", "http://256/"}); >- checkURLDifferences("http://256./", >- {"http", "", "", "0.0.1.0", 0, "/", "", "", "http://0.0.1.0/"}, >- {"http", "", "", "256.", 0, "/", "", "", "http://256./"}); >- checkURLDifferences("http://123.256/", >- {"http", "", "", "123.0.1.0", 0, "/", "", "", "http://123.0.1.0/"}, >- {"http", "", "", "123.256", 0, "/", "", "", "http://123.256/"}); >- checkURLDifferences("http://127.%.0.1/", >- {"", "", "", "", 0, "", "", "", "http://127.%.0.1/"}, >- {"http", "", "", "127.%.0.1", 0, "/", "", "", "http://127.%.0.1/"}); >- checkURLDifferences("http://[1:2:3:4:5:6:7:8:]/", >- {"", "", "", "", 0, "", "", "", "http://[1:2:3:4:5:6:7:8:]/"}, >- {"http", "", "", "[1:2:3:4:5:6:7:8:]", 0, "/", "", "", "http://[1:2:3:4:5:6:7:8:]/"}); >- checkURLDifferences("http://[:2:3:4:5:6:7:8:]/", >- {"", "", "", "", 0, "", "", "", "http://[:2:3:4:5:6:7:8:]/"}, >- {"http", "", "", "[:2:3:4:5:6:7:8:]", 0, "/", "", "", "http://[:2:3:4:5:6:7:8:]/"}); >- checkURLDifferences("http://[1:2:3:4:5:6:7::]/", >- {"http", "", "", "[1:2:3:4:5:6:7:0]", 0, "/", "", "", "http://[1:2:3:4:5:6:7:0]/"}, >- {"http", "", "", "[1:2:3:4:5:6:7::]", 0, "/", "", "", "http://[1:2:3:4:5:6:7::]/"}); >- checkURLDifferences("http://[1:2:3:4:5:6:7:::]/", >- {"", "", "", "", 0, "", "", "", "http://[1:2:3:4:5:6:7:::]/"}, >- {"http", "", "", "[1:2:3:4:5:6:7:::]", 0, "/", "", "", "http://[1:2:3:4:5:6:7:::]/"}); >- checkURLDifferences("http://127.0.0.1~/", >- {"http", "", "", "127.0.0.1~", 0, "/", "", "", "http://127.0.0.1~/"}, >- {"", "", "", "", 0, "", "", "", "http://127.0.0.1~/"}); >- checkURLDifferences("http://127.0.1~/", >- {"http", "", "", "127.0.1~", 0, "/", "", "", "http://127.0.1~/"}, >- {"", "", "", "", 0, "", "", "", "http://127.0.1~/"}); >- checkURLDifferences("http://127.0.1./", >- {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}, >- {"http", "", "", "127.0.1.", 0, "/", "", "", "http://127.0.1./"}); >- checkURLDifferences("http://127.0.1.~/", >- {"http", "", "", "127.0.1.~", 0, "/", "", "", "http://127.0.1.~/"}, >- {"", "", "", "", 0, "", "", "", "http://127.0.1.~/"}); >- checkURLDifferences("http://127.0.1.~", >- {"http", "", "", "127.0.1.~", 0, "/", "", "", "http://127.0.1.~/"}, >- {"", "", "", "", 0, "", "", "", "http://127.0.1.~"}); >- checkRelativeURLDifferences("http://f:000/c", "http://example.org/foo/bar", >- {"http", "", "", "f", 0, "/c", "", "", "http://f:0/c"}, >- {"http", "", "", "f", 0, "/c", "", "", "http://f:000/c"}); >- checkRelativeURLDifferences("http://f:010/c", "http://example.org/foo/bar", >- {"http", "", "", "f", 10, "/c", "", "", "http://f:10/c"}, >- {"http", "", "", "f", 10, "/c", "", "", "http://f:010/c"}); >- checkURL("notspecial://HoSt", {"notspecial", "", "", "HoSt", 0, "", "", "", "notspecial://HoSt"}); >- checkURL("notspecial://H%6FSt", {"notspecial", "", "", "H%6FSt", 0, "", "", "", "notspecial://H%6FSt"}); >- checkURL("notspecial://H%4fSt", {"notspecial", "", "", "H%4fSt", 0, "", "", "", "notspecial://H%4fSt"}); >- checkURLDifferences(utf16String(u"notspecial://HðÃt"), >- {"notspecial", "", "", "H%F0%9F%98%8D%C3%9Ft", 0, "", "", "", "notspecial://H%F0%9F%98%8D%C3%9Ft"}, >- {"notspecial", "", "", "xn--hsst-qc83c", 0, "", "", "", "notspecial://xn--hsst-qc83c"}, testTabsValueForSurrogatePairs); >- checkURLDifferences("http://[ffff:aaaa:cccc:eeee:bbbb:dddd:255.255.255.255]/", >- {"http", "", "", "[ffff:aaaa:cccc:eeee:bbbb:dddd:ffff:ffff]", 0, "/", "", "", "http://[ffff:aaaa:cccc:eeee:bbbb:dddd:ffff:ffff]/"}, >- {"http", "", "", "[ffff:aaaa:cccc:eeee:bbbb:dddd:255.255.255.255]", 0, "/", "", "", "http://[ffff:aaaa:cccc:eeee:bbbb:dddd:255.255.255.255]/"}, TestTabs::No); >- checkURLDifferences("http://[::123.234.12.210]/", >- {"http", "", "", "[::7bea:cd2]", 0, "/", "", "", "http://[::7bea:cd2]/"}, >- {"http", "", "", "[::123.234.12.210]", 0, "/", "", "", "http://[::123.234.12.210]/"}); >- checkURLDifferences("http://[::a:255.255.255.255]/", >- {"http", "", "", "[::a:ffff:ffff]", 0, "/", "", "", "http://[::a:ffff:ffff]/"}, >- {"http", "", "", "[::a:255.255.255.255]", 0, "/", "", "", "http://[::a:255.255.255.255]/"}); >- checkURLDifferences("http://[::0.00.255.255]/", >- {"", "", "", "", 0, "", "", "", "http://[::0.00.255.255]/"}, >- {"http", "", "", "[::0.00.255.255]", 0, "/", "", "", "http://[::0.00.255.255]/"}); >- checkURLDifferences("http://[::0.0.255.255]/", >- {"http", "", "", "[::ffff]", 0, "/", "", "", "http://[::ffff]/"}, >- {"http", "", "", "[::0.0.255.255]", 0, "/", "", "", "http://[::0.0.255.255]/"}); >- checkURLDifferences("http://[::0:1.0.255.255]/", >- {"http", "", "", "[::100:ffff]", 0, "/", "", "", "http://[::100:ffff]/"}, >- {"http", "", "", "[::0:1.0.255.255]", 0, "/", "", "", "http://[::0:1.0.255.255]/"}); >- checkURLDifferences("http://[::A:1.0.255.255]/", >- {"http", "", "", "[::a:100:ffff]", 0, "/", "", "", "http://[::a:100:ffff]/"}, >- {"http", "", "", "[::a:1.0.255.255]", 0, "/", "", "", "http://[::a:1.0.255.255]/"}); >- checkURLDifferences("http://[:127.0.0.1]", >- {"", "", "", "", 0, "", "", "", "http://[:127.0.0.1]"}, >- {"http", "", "", "[:127.0.0.1]", 0, "/", "", "", "http://[:127.0.0.1]/"}); >- checkURLDifferences("http://[127.0.0.1]", >- {"", "", "", "", 0, "", "", "", "http://[127.0.0.1]"}, >- {"http", "", "", "[127.0.0.1]", 0, "/", "", "", "http://[127.0.0.1]/"}); >- checkURLDifferences("http://[a:b:c:d:e:f:127.0.0.1]", >- {"http", "", "", "[a:b:c:d:e:f:7f00:1]", 0, "/", "", "", "http://[a:b:c:d:e:f:7f00:1]/"}, >- {"http", "", "", "[a:b:c:d:e:f:127.0.0.1]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0.0.1]/"}); >- checkURLDifferences("http://[a:b:c:d:e:f:127.0.0.101]", >- {"http", "", "", "[a:b:c:d:e:f:7f00:65]", 0, "/", "", "", "http://[a:b:c:d:e:f:7f00:65]/"}, >- {"http", "", "", "[a:b:c:d:e:f:127.0.0.101]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0.0.101]/"}); >- checkURLDifferences("http://[::a:b:c:d:e:f:127.0.0.1]", >- {"", "", "", "", 0, "", "", "", "http://[::a:b:c:d:e:f:127.0.0.1]"}, >- {"http", "", "", "[::a:b:c:d:e:f:127.0.0.1]", 0, "/", "", "", "http://[::a:b:c:d:e:f:127.0.0.1]/"}); >- checkURLDifferences("http://[a:b::c:d:e:f:127.0.0.1]", >- {"", "", "", "", 0, "", "", "", "http://[a:b::c:d:e:f:127.0.0.1]"}, >- {"http", "", "", "[a:b::c:d:e:f:127.0.0.1]", 0, "/", "", "", "http://[a:b::c:d:e:f:127.0.0.1]/"}); >- checkURLDifferences("http://[a:b:c:d:e:127.0.0.1]", >- {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:127.0.0.1]"}, >- {"http", "", "", "[a:b:c:d:e:127.0.0.1]", 0, "/", "", "", "http://[a:b:c:d:e:127.0.0.1]/"}); >- checkURLDifferences("http://[a:b:c:d:e:f:127.0.0.0.1]", >- {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f:127.0.0.0.1]"}, >- {"http", "", "", "[a:b:c:d:e:f:127.0.0.0.1]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0.0.0.1]/"}); >- checkURLDifferences("http://[a:b:c:d:e:f:127.0.1]", >- {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f:127.0.1]"}, >- {"http", "", "", "[a:b:c:d:e:f:127.0.1]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0.1]/"}); >- checkURLDifferences("http://[a:b:c:d:e:f:127.0.0.011]", // Chrome treats this as octal, Firefox and the spec fail >- {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f:127.0.0.011]"}, >- {"http", "", "", "[a:b:c:d:e:f:127.0.0.011]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0.0.011]/"}); >- checkURLDifferences("http://[a:b:c:d:e:f:127.0.00.1]", >- {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f:127.0.00.1]"}, >- {"http", "", "", "[a:b:c:d:e:f:127.0.00.1]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0.00.1]/"}); >- checkURLDifferences("http://[a:b:c:d:e:f:127.0.0.1.]", >- {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f:127.0.0.1.]"}, >- {"http", "", "", "[a:b:c:d:e:f:127.0.0.1.]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0.0.1.]/"}); >- checkURLDifferences("http://[a:b:c:d:e:f:127.0..0.1]", >- {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f:127.0..0.1]"}, >- {"http", "", "", "[a:b:c:d:e:f:127.0..0.1]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0..0.1]/"}); >- checkURLDifferences("http://[a:b:c:d:e:f::127.0.0.1]", >- {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f::127.0.0.1]"}, >- {"http", "", "", "[a:b:c:d:e:f::127.0.0.1]", 0, "/", "", "", "http://[a:b:c:d:e:f::127.0.0.1]/"}); >- checkURLDifferences("http://[a:b:c:d:e::127.0.0.1]", >- {"http", "", "", "[a:b:c:d:e:0:7f00:1]", 0, "/", "", "", "http://[a:b:c:d:e:0:7f00:1]/"}, >- {"http", "", "", "[a:b:c:d:e::127.0.0.1]", 0, "/", "", "", "http://[a:b:c:d:e::127.0.0.1]/"}); >- checkURLDifferences("http://[a:b:c:d::e:127.0.0.1]", >- {"http", "", "", "[a:b:c:d:0:e:7f00:1]", 0, "/", "", "", "http://[a:b:c:d:0:e:7f00:1]/"}, >- {"http", "", "", "[a:b:c:d::e:127.0.0.1]", 0, "/", "", "", "http://[a:b:c:d::e:127.0.0.1]/"}); >- checkURLDifferences("http://[a:b:c:d:e:f::127.0.0.]", >- {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f::127.0.0.]"}, >- {"http", "", "", "[a:b:c:d:e:f::127.0.0.]", 0, "/", "", "", "http://[a:b:c:d:e:f::127.0.0.]/"}); >- checkURLDifferences("http://[a:b:c:d:e:f::127.0.0.256]", >- {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f::127.0.0.256]"}, >- {"http", "", "", "[a:b:c:d:e:f::127.0.0.256]", 0, "/", "", "", "http://[a:b:c:d:e:f::127.0.0.256]/"}); >- checkURLDifferences("http://123456", {"http", "", "", "0.1.226.64", 0, "/", "", "", "http://0.1.226.64/"}, {"http", "", "", "123456", 0, "/", "", "", "http://123456/"}); >- checkURL("asdf://123456", {"asdf", "", "", "123456", 0, "", "", "", "asdf://123456"}); >- checkURLDifferences("http://[0:0:0:0:a:b:c:d]", >- {"http", "", "", "[::a:b:c:d]", 0, "/", "", "", "http://[::a:b:c:d]/"}, >- {"http", "", "", "[0:0:0:0:a:b:c:d]", 0, "/", "", "", "http://[0:0:0:0:a:b:c:d]/"}); >- checkURLDifferences("asdf://[0:0:0:0:a:b:c:d]", >- {"asdf", "", "", "[::a:b:c:d]", 0, "", "", "", "asdf://[::a:b:c:d]"}, >- {"asdf", "", "", "[0:0:0:0:a:b:c:d]", 0, "", "", "", "asdf://[0:0:0:0:a:b:c:d]"}, TestTabs::No); >- shouldFail("a://%:a"); >- checkURL("a://%:/", {"a", "", "", "%", 0, "/", "", "", "a://%/"}); >- checkURL("a://%:", {"a", "", "", "%", 0, "", "", "", "a://%"}); >- checkURL("a://%:1/", {"a", "", "", "%", 1, "/", "", "", "a://%:1/"}); >- checkURLDifferences("http://%:", >- {"", "", "", "", 0, "", "", "", "http://%:"}, >- {"http", "", "", "%", 0, "/", "", "", "http://%/"}); >- checkURL("a://123456", {"a", "", "", "123456", 0, "", "", "", "a://123456"}); >- checkURL("a://123456:7", {"a", "", "", "123456", 7, "", "", "", "a://123456:7"}); >- checkURL("a://123456:7/", {"a", "", "", "123456", 7, "/", "", "", "a://123456:7/"}); >- checkURL("a://A", {"a", "", "", "A", 0, "", "", "", "a://A"}); >- checkURL("a://A:2", {"a", "", "", "A", 2, "", "", "", "a://A:2"}); >- checkURL("a://A:2/", {"a", "", "", "A", 2, "/", "", "", "a://A:2/"}); >- checkURLDifferences(u8"asd://Ã", >- {"asd", "", "", "%C3%83%C2%9F", 0, "", "", "", "asd://%C3%83%C2%9F"}, >- {"", "", "", "", 0, "", "", "", "about:blank"}, TestTabs::No); >- checkURLDifferences(u8"asd://Ã:4", >- {"asd", "", "", "%C3%83%C2%9F", 4, "", "", "", "asd://%C3%83%C2%9F:4"}, >- {"", "", "", "", 0, "", "", "", "about:blank"}, TestTabs::No); >- checkURLDifferences(u8"asd://Ã:4/", >- {"asd", "", "", "%C3%83%C2%9F", 4, "/", "", "", "asd://%C3%83%C2%9F:4/"}, >- {"", "", "", "", 0, "", "", "", "about:blank"}, TestTabs::No); >- checkURLDifferences("a://[A::b]:4", >- {"a", "", "", "[a::b]", 4, "", "", "", "a://[a::b]:4"}, >- {"a", "", "", "[A::b]", 4, "", "", "", "a://[A::b]:4"}); >- shouldFail("http://[~]"); >- shouldFail("a://[~]"); >- checkRelativeURLDifferences("a://b", "//[aBc]", >- {"a", "", "", "b", 0, "", "", "", "a://b"}, >- {"", "", "", "", 0, "", "", "", "a://b"}); >- checkURL(utf16String(u"http://öbb.at"), {"http", "", "", "xn--bb-eka.at", 0, "/", "", "", "http://xn--bb-eka.at/"}); >- checkURL(utf16String(u"http://ÃBB.at"), {"http", "", "", "xn--bb-eka.at", 0, "/", "", "", "http://xn--bb-eka.at/"}); >- checkURL(utf16String(u"http://â.com"), {"http", "", "", "xn--19g.com", 0, "/", "", "", "http://xn--19g.com/"}); >- checkURLDifferences(utf16String(u"http://faÃ.de"), >- {"http", "", "", "xn--fa-hia.de", 0, "/", "", "", "http://xn--fa-hia.de/"}, >- {"http", "", "", "fass.de", 0, "/", "", "", "http://fass.de/"}); >- checkURL(utf16String(u"http://ÔÓлп.com"), {"http", "", "", "xn--k1ai47bhi.com", 0, "/", "", "", "http://xn--k1ai47bhi.com/"}); >- checkURLDifferences(utf16String(u"http://Ⱥbby.com"), >- {"http", "", "", "xn--bby-iy0b.com", 0, "/", "", "", "http://xn--bby-iy0b.com/"}, >- {"http", "", "", "xn--bby-spb.com", 0, "/", "", "", "http://xn--bby-spb.com/"}); >- checkURLDifferences(utf16String(u"http://\u2132"), >- {"", "", "", "", 0, "", "", "", utf16String(u"http://â²")}, >- {"http", "", "", "xn--f3g", 0, "/", "", "", "http://xn--f3g/"}); >- checkURLDifferences(utf16String(u"http://\u05D9\u05B4\u05D5\u05D0\u05B8/"), >- {"http", "", "", "xn--cdbi5etas", 0, "/", "", "", "http://xn--cdbi5etas/"}, >- {"", "", "", "", 0, "", "", "", "about:blank"}, TestTabs::No); >- checkURLDifferences(utf16String(u"http://bidirectional\u0786\u07AE\u0782\u07B0\u0795\u07A9\u0793\u07A6\u0783\u07AA/"), >- {"", "", "", "", 0, "", "", "", utf16String(u"http://bidirectionalÞÞ®ÞÞ°ÞÞ©ÞÞ¦ÞÞª/")}, >- {"", "", "", "", 0, "", "", "", "about:blank"}, TestTabs::No); >- checkURLDifferences(utf16String(u"http://contextj\u200D"), >- {"", "", "", "", 0, "", "", "", utf16String(u"http://contextj\u200D")}, >- {"http", "", "", "contextj", 0, "/", "", "", "http://contextj/"}); >- checkURL(utf16String(u"http://contexto\u30FB"), {"http", "", "", "xn--contexto-wg5g", 0, "/", "", "", "http://xn--contexto-wg5g/"}); >- checkURLDifferences(utf16String(u"http://\u321D\u321E/"), >- {"http", "", "", "xn--()()-bs0sc174agx4b", 0, "/", "", "", "http://xn--()()-bs0sc174agx4b/"}, >- {"http", "", "", "xn--5mkc", 0, "/", "", "", "http://xn--5mkc/"}); >-} >- >-TEST_F(URLParserTest, DefaultPort) >-{ >- checkURL("FtP://host:21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}); >- checkURL("ftp://host:21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}); >- checkURL("f\ttp://host:21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}); >- checkURL("f\ttp://host\t:21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}); >- checkURL("f\ttp://host:\t21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}); >- checkURL("f\ttp://host:2\t1/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}); >- checkURL("f\ttp://host:21\t/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}); >- checkURL("ftp://host\t:21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}); >- checkURL("ftp://host:\t21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}); >- checkURL("ftp://host:2\t1/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}); >- checkURL("ftp://host:21\t/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}); >- checkURL("ftp://host:22/", {"ftp", "", "", "host", 22, "/", "", "", "ftp://host:22/"}); >- checkURLDifferences("ftp://host:21", >- {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"}, >- {"ftp", "", "", "host", 0, "", "", "", "ftp://host"}); >- checkURLDifferences("ftp://host:22", >- {"ftp", "", "", "host", 22, "/", "", "", "ftp://host:22/"}, >- {"ftp", "", "", "host", 22, "", "", "", "ftp://host:22"}); >- >- checkURL("gOpHeR://host:70/", {"gopher", "", "", "host", 0, "/", "", "", "gopher://host/"}); >- checkURL("gopher://host:70/", {"gopher", "", "", "host", 0, "/", "", "", "gopher://host/"}); >- checkURL("gopher://host:71/", {"gopher", "", "", "host", 71, "/", "", "", "gopher://host:71/"}); >- // Spec, Chrome, Firefox, and URLParser have "/", URL::parse does not. >- // Spec, Chrome, URLParser, URL::parse recognize gopher default port, Firefox does not. >- checkURLDifferences("gopher://host:70", >- {"gopher", "", "", "host", 0, "/", "", "", "gopher://host/"}, >- {"gopher", "", "", "host", 0, "", "", "", "gopher://host"}); >- checkURLDifferences("gopher://host:71", >- {"gopher", "", "", "host", 71, "/", "", "", "gopher://host:71/"}, >- {"gopher", "", "", "host", 71, "", "", "", "gopher://host:71"}); >- >- checkURL("hTtP://host:80", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >- checkURL("http://host:80", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >- checkURL("http://host:80/", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); >- checkURL("http://host:81", {"http", "", "", "host", 81, "/", "", "", "http://host:81/"}); >- checkURL("http://host:81/", {"http", "", "", "host", 81, "/", "", "", "http://host:81/"}); >- >- checkURL("hTtPs://host:443", {"https", "", "", "host", 0, "/", "", "", "https://host/"}); >- checkURL("https://host:443", {"https", "", "", "host", 0, "/", "", "", "https://host/"}); >- checkURL("https://host:443/", {"https", "", "", "host", 0, "/", "", "", "https://host/"}); >- checkURL("https://host:444", {"https", "", "", "host", 444, "/", "", "", "https://host:444/"}); >- checkURL("https://host:444/", {"https", "", "", "host", 444, "/", "", "", "https://host:444/"}); >- >- checkURL("wS://host:80/", {"ws", "", "", "host", 0, "/", "", "", "ws://host/"}); >- checkURL("ws://host:80/", {"ws", "", "", "host", 0, "/", "", "", "ws://host/"}); >- checkURL("ws://host:81/", {"ws", "", "", "host", 81, "/", "", "", "ws://host:81/"}); >- // URLParser matches Chrome and Firefox, but not URL::parse >- checkURLDifferences("ws://host:80", >- {"ws", "", "", "host", 0, "/", "", "", "ws://host/"}, >- {"ws", "", "", "host", 0, "", "", "", "ws://host"}); >- checkURLDifferences("ws://host:81", >- {"ws", "", "", "host", 81, "/", "", "", "ws://host:81/"}, >- {"ws", "", "", "host", 81, "", "", "", "ws://host:81"}); >- >- checkURL("WsS://host:443/", {"wss", "", "", "host", 0, "/", "", "", "wss://host/"}); >- checkURL("wss://host:443/", {"wss", "", "", "host", 0, "/", "", "", "wss://host/"}); >- checkURL("wss://host:444/", {"wss", "", "", "host", 444, "/", "", "", "wss://host:444/"}); >- // URLParser matches Chrome and Firefox, but not URL::parse >- checkURLDifferences("wss://host:443", >- {"wss", "", "", "host", 0, "/", "", "", "wss://host/"}, >- {"wss", "", "", "host", 0, "", "", "", "wss://host"}); >- checkURLDifferences("wss://host:444", >- {"wss", "", "", "host", 444, "/", "", "", "wss://host:444/"}, >- {"wss", "", "", "host", 444, "", "", "", "wss://host:444"}); >- >- checkURL("fTpS://host:990/", {"ftps", "", "", "host", 990, "/", "", "", "ftps://host:990/"}); >- checkURL("ftps://host:990/", {"ftps", "", "", "host", 990, "/", "", "", "ftps://host:990/"}); >- checkURL("ftps://host:991/", {"ftps", "", "", "host", 991, "/", "", "", "ftps://host:991/"}); >- checkURL("ftps://host:990", {"ftps", "", "", "host", 990, "", "", "", "ftps://host:990"}); >- checkURL("ftps://host:991", {"ftps", "", "", "host", 991, "", "", "", "ftps://host:991"}); >- >- checkURL("uNkNoWn://host:80/", {"unknown", "", "", "host", 80, "/", "", "", "unknown://host:80/"}); >- checkURL("unknown://host:80/", {"unknown", "", "", "host", 80, "/", "", "", "unknown://host:80/"}); >- checkURL("unknown://host:81/", {"unknown", "", "", "host", 81, "/", "", "", "unknown://host:81/"}); >- checkURL("unknown://host:80", {"unknown", "", "", "host", 80, "", "", "", "unknown://host:80"}); >- checkURL("unknown://host:81", {"unknown", "", "", "host", 81, "", "", "", "unknown://host:81"}); >- >- checkURL("file://host:0", {"file", "", "", "host", 0, "/", "", "", "file://host:0/"}); >- checkURL("file://host:80", {"file", "", "", "host", 80, "/", "", "", "file://host:80/"}); >- checkURL("file://host:80/path", {"file", "", "", "host", 80, "/path", "", "", "file://host:80/path"}); >- checkURLDifferences("file://:80/path", >- {"", "", "", "", 0, "", "", "", "file://:80/path"}, >- {"file", "", "", "", 80, "/path", "", "", "file://:80/path"}); >- checkURLDifferences("file://:0/path", >- {"", "", "", "", 0, "", "", "", "file://:0/path"}, >- {"file", "", "", "", 0, "/path", "", "", "file://:0/path"}); >- >- checkURL("http://example.com:0000000000000077", {"http", "", "", "example.com", 77, "/", "", "", "http://example.com:77/"}); >- checkURL("http://example.com:0000000000000080", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"}); >-} >- >-TEST_F(URLParserTest, ParserFailures) >-{ >- shouldFail(" "); >- shouldFail(" \a "); >- shouldFail(""); >- shouldFail(String()); >- shouldFail("", "about:blank"); >- shouldFail(String(), "about:blank"); >- shouldFail("http://127.0.0.1:abc"); >- shouldFail("http://host:abc"); >- shouldFail("http://:abc"); >- shouldFail("http://a:@", "about:blank"); >- shouldFail("http://:b@", "about:blank"); >- shouldFail("http://:@", "about:blank"); >- shouldFail("http://a:@"); >- shouldFail("http://:b@"); >- shouldFail("http://@"); >- shouldFail("http://[0:f::f:f:0:0]:abc"); >- shouldFail("../i", "sc:sd"); >- shouldFail("../i", "sc:sd/sd"); >- shouldFail("/i", "sc:sd"); >- shouldFail("/i", "sc:sd/sd"); >- shouldFail("?i", "sc:sd"); >- shouldFail("?i", "sc:sd/sd"); >- shouldFail("http://example example.com", "http://other.com/"); >- shouldFail("http://[www.example.com]/", "about:blank"); >- shouldFail("http://192.168.0.1 hello", "http://other.com/"); >- shouldFail("http://[example.com]", "http://other.com/"); >- shouldFail("i", "sc:sd"); >- shouldFail("i", "sc:sd/sd"); >- shouldFail("i"); >- shouldFail("asdf"); >- shouldFail("~"); >- shouldFail("%"); >- shouldFail("//%"); >- shouldFail("~", "about:blank"); >- shouldFail("~~~"); >- shouldFail("://:0/"); >- shouldFail("://:0/", ""); >- shouldFail("://:0/", "about:blank"); >- shouldFail("about~"); >- shouldFail("//C:asdf/foo/bar", "file:///tmp/mock/path"); >- shouldFail("http://[1234::ab#]"); >- shouldFail("http://[1234::ab/]"); >- shouldFail("http://[1234::ab?]"); >- shouldFail("http://[1234::ab@]"); >- shouldFail("http://[1234::ab~]"); >- shouldFail("http://[2001::1"); >- shouldFail("http://4:b\xE1"); >- shouldFail("http://[1:2:3:4:5:6:7:8~]/"); >- shouldFail("http://[a:b:c:d:e:f:g:127.0.0.1]"); >- shouldFail("http://[a:b:c:d:e:f:g:h:127.0.0.1]"); >- shouldFail("http://[a:b:c:d:e:f:127.0.0.0x11]"); // Chrome treats this as hex, Firefox and the spec fail >- shouldFail("http://[a:b:c:d:e:f:127.0.-0.1]"); >- shouldFail("asdf://space In\aHost"); >- shouldFail("asdf://[0:0:0:0:a:b:c:d"); >-} >- >-// These are in the spec but not in the web platform tests. >-TEST_F(URLParserTest, AdditionalTests) >-{ >- checkURL("about:\a\aabc", {"about", "", "", "", 0, "%07%07abc", "", "", "about:%07%07abc"}); >- checkURL("notspecial:\t\t\n\t", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"}); >- checkURL("notspecial\t\t\n\t:\t\t\n\t/\t\t\n\t/\t\t\n\thost", {"notspecial", "", "", "host", 0, "", "", "", "notspecial://host"}); >- checkRelativeURL("http:", "http://example.org/foo/bar?query#fragment", {"http", "", "", "example.org", 0, "/foo/bar", "query", "", "http://example.org/foo/bar?query"}); >- checkRelativeURLDifferences("ws:", "http://example.org/foo/bar", >- {"ws", "", "", "", 0, "", "", "", "ws:"}, >- {"ws", "", "", "", 0, "s:", "", "", "ws:s:"}); >- checkRelativeURL("notspecial:", "http://example.org/foo/bar", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"}); >- >- const wchar_t surrogateBegin = 0xD800; >- const wchar_t validSurrogateEnd = 0xDD55; >- const wchar_t invalidSurrogateEnd = 'A'; >- const wchar_t replacementCharacter = 0xFFFD; >- checkURL(utf16String<12>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', surrogateBegin, validSurrogateEnd, '\0'}), >- {"http", "", "", "w", 0, "/%F0%90%85%95", "", "", "http://w/%F0%90%85%95"}, testTabsValueForSurrogatePairs); >- shouldFail(utf16String<10>({'h', 't', 't', 'p', ':', '/', surrogateBegin, invalidSurrogateEnd, '/', '\0'})); >- shouldFail(utf16String<9>({'h', 't', 't', 'p', ':', '/', replacementCharacter, '/', '\0'})); >- >- // URLParser matches Chrome and Firefox but not URL::parse. >- checkURLDifferences(utf16String<12>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', surrogateBegin, invalidSurrogateEnd}), >- {"http", "", "", "w", 0, "/%EF%BF%BDA", "", "", "http://w/%EF%BF%BDA"}, >- {"http", "", "", "w", 0, "/%ED%A0%80A", "", "", "http://w/%ED%A0%80A"}); >- checkURLDifferences(utf16String<13>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', '?', surrogateBegin, invalidSurrogateEnd, '\0'}), >- {"http", "", "", "w", 0, "/", "%EF%BF%BDA", "", "http://w/?%EF%BF%BDA"}, >- {"http", "", "", "w", 0, "/", "%ED%A0%80A", "", "http://w/?%ED%A0%80A"}); >- checkURLDifferences(utf16String<11>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', surrogateBegin, '\0'}), >- {"http", "", "", "w", 0, "/%EF%BF%BD", "", "", "http://w/%EF%BF%BD"}, >- {"http", "", "", "w", 0, "/%ED%A0%80", "", "", "http://w/%ED%A0%80"}); >- checkURLDifferences(utf16String<12>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', '?', surrogateBegin, '\0'}), >- {"http", "", "", "w", 0, "/", "%EF%BF%BD", "", "http://w/?%EF%BF%BD"}, >- {"http", "", "", "w", 0, "/", "%ED%A0%80", "", "http://w/?%ED%A0%80"}); >- checkURLDifferences(utf16String<13>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', '?', surrogateBegin, ' ', '\0'}), >- {"http", "", "", "w", 0, "/", "%EF%BF%BD", "", "http://w/?%EF%BF%BD"}, >- {"http", "", "", "w", 0, "/", "%ED%A0%80", "", "http://w/?%ED%A0%80"}); >- >- // 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 >diff --git a/Tools/TestWebKitAPI/Tests/WebCore/URLParserTextEncoding.cpp b/Tools/TestWebKitAPI/Tests/WebCore/URLParserTextEncoding.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..23e6b8553f3ce065a8a4976b1307e2a46c9ca287 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebCore/URLParserTextEncoding.cpp >@@ -0,0 +1,202 @@ >+/* >+ * 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 ExpectedParts& parts, TestTabs testTabs = TestTabs::Yes) >+{ >+ auto url = URL(URL(), urlString); >+ >+ 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())); >+ >+ EXPECT_TRUE(WTF::URLParser::internalValuesConsistent(url)); >+ >+ if (testTabs == TestTabs::No) >+ return; >+ >+ for (size_t i = 0; i < urlString.length(); ++i) { >+ String urlStringWithTab = insertTabAtLocation(urlString, i); >+ checkURL(urlStringWithTab, >+ parts.isInvalid() ? invalidParts(urlStringWithTab) : parts, >+ 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 >diff --git a/Tools/TestWebKitAPI/Tests/WebCore/cocoa/URLExtras.mm b/Tools/TestWebKitAPI/Tests/WebCore/cocoa/URLExtras.mm >deleted file mode 100644 >index b640b10bff2f019b727243a7c600851adafd75e0..0000000000000000000000000000000000000000 >--- a/Tools/TestWebKitAPI/Tests/WebCore/cocoa/URLExtras.mm >+++ /dev/null >@@ -1,207 +0,0 @@ >-/* >- * Copyright (C) 2014 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. >- */ >- >-#import "config.h" >- >-#import <wtf/Vector.h> >-#import <wtf/cocoa/NSURLExtras.h> >-#import <wtf/text/WTFString.h> >- >-namespace TestWebKitAPI { >- >-static NSData *literalAsData(const char* literal) >-{ >- return [NSData dataWithBytes:literal length:strlen(literal)]; >-} >- >-static const char* dataAsString(NSData *data) >-{ >- static char buffer[1000]; >- if ([data length] > sizeof(buffer) - 1) >- return "ERROR"; >- if (memchr([data bytes], 0, [data length])) >- return "ERROR"; >- memcpy(buffer, [data bytes], [data length]); >- buffer[[data length]] = '\0'; >- return buffer; >-} >- >-static const char* originalDataAsString(NSURL *URL) >-{ >- return dataAsString(WTF::originalURLData(URL)); >-} >- >-static const char* userVisibleString(NSURL *URL) >-{ >- return [WTF::userVisibleString(URL) UTF8String]; >-} >- >-static NSURL *literalURL(const char* literal) >-{ >- return WTF::URLWithData(literalAsData(literal), nil); >-} >- >-TEST(WebCore, URLExtras) >-{ >- EXPECT_STREQ("http://site.com", originalDataAsString(literalURL("http://site.com"))); >- EXPECT_STREQ("http://%77ebsite.com", originalDataAsString(literalURL("http://%77ebsite.com"))); >- >- EXPECT_STREQ("http://site.com", userVisibleString(literalURL("http://site.com"))); >- EXPECT_STREQ("http://%77ebsite.com", userVisibleString(literalURL("http://%77ebsite.com"))); >-} >- >-TEST(WebCore, URLExtras_Spoof) >-{ >- Vector<String> punycodedSpoofHosts = { >- "xn--cfa45g", // U+0131, U+0307 >- "xn--tma03b", // U+0237, U+0307 >- "xn--tma03bxga", // U+0237, U+034F, U+034F, U+0307 >- "xn--tma03bl01e", // U+0237, U+200B, U+0307 >- "xn--a-egb", // a, U+034F >- "xn--a-qgn", // a, U+200B >- "xn--a-mgn", // a, U+2009 >- "xn--u7f", // U+1D04 >- "xn--57f", // U+1D0F >- "xn--i38a", // U+A731 >- "xn--j8f", // U+1D1C >- "xn--n8f", // U+1D20 >- "xn--o8f", // U+1D21 >- "xn--p8f", // U+1D22 >- "xn--0na", // U+0261 >- "xn--cn-ded", // U+054D >- "xn--ews-nfe.org", // U+054D >- "xn--yotube-qkh", // U+0578 >- "xn--cla-7fe.edu", // U+0578 >- "xn--rsa94l", // U+05D5 U+0307 >- "xn--hdb9c", // U+05D5 U+05B9 >- "xn--idb7c", // U+05D5 U+05BA >- "xn--pdb3b", // U+05D5 U+05C1 >- "xn--qdb1b", // U+05D5 U+05C2 >- "xn--sdb7a", // U+05D5 U+05C4 >- "xn--2-zic", // U+0032 U+05E1 >- }; >- for (const String& host : punycodedSpoofHosts) { >- auto url = makeString("http://", host, "/").utf8(); >- EXPECT_STREQ(url.data(), userVisibleString(literalURL(url.data()))); >- } >-} >- >-TEST(WebCore, 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"))); >- EXPECT_STREQ("https://\u0573\u0574\u0578.\u0570\u0561\u0575", userVisibleString(literalURL("https://\u0573\u0574\u0578.\u0570\u0561\u0575"))); >- EXPECT_STREQ("https://\u0573-1-\u0574\u0578.\u0570\u0561\u0575", userVisibleString(literalURL("https://\u0573-1-\u0574\u0578.\u0570\u0561\u0575"))); >- EXPECT_STREQ("https://2\u0573_\u0574\u0578.\u0570\u0561\u0575", userVisibleString(literalURL("https://2\u0573_\u0574\u0578.\u0570\u0561\u0575"))); >- EXPECT_STREQ("https://\u0573_\u0574\u05783.\u0570\u0561\u0575", userVisibleString(literalURL("https://\u0573_\u0574\u05783.\u0570\u0561\u0575"))); >- EXPECT_STREQ("https://got\u0551\u0535\u0543.com", userVisibleString(literalURL("https://got\u0551\u0535\u0543.com"))); >- EXPECT_STREQ("https://\u0551\u0535\u0543fans.net", userVisibleString(literalURL("https://\u0551\u0535\u0543fans.net"))); >- EXPECT_STREQ("https://\u0551\u0535or\u0575\u0543.biz", userVisibleString(literalURL("https://\u0551\u0535or\u0575\u0543.biz"))); >- EXPECT_STREQ("https://\u0551\u0535and!$^&*()-~+={}or<>,.?\u0575\u0543.biz", userVisibleString(literalURL("https://\u0551\u0535and!$^&*()-~+={}or<>,.?\u0575\u0543.biz"))); >-} >- >-TEST(WebCore, 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. >- >- // Code path similar to the one used when typing in a URL. >- EXPECT_STREQ("http://site.xn--comothersite-kjb.org", originalDataAsString(WTF::URLWithUserTypedString(@"http://site.com\xC3\xB7othersite.org", nil))); >- EXPECT_STREQ("http://site.com\xC3\xB7othersite.org", userVisibleString(WTF::URLWithUserTypedString(@"http://site.com\xC3\xB7othersite.org", nil))); >- >- // Code paths similar to the ones used for URLs found in webpages or HTTP responses. >- EXPECT_STREQ("http://site.com\xC3\xB7othersite.org", originalDataAsString(literalURL("http://site.com\xC3\xB7othersite.org"))); >- EXPECT_STREQ("http://site.com\xC3\xB7othersite.org", userVisibleString(literalURL("http://site.com\xC3\xB7othersite.org"))); >- EXPECT_STREQ("http://site.com%C3%B7othersite.org", originalDataAsString(literalURL("http://site.com%C3%B7othersite.org"))); >- EXPECT_STREQ("http://site.com\xC3\xB7othersite.org", userVisibleString(literalURL("http://site.com%C3%B7othersite.org"))); >- >- // Separate functions that deal with just a host name on its own. >- EXPECT_STREQ("site.xn--comothersite-kjb.org", [WTF::encodeHostName(@"site.com\xC3\xB7othersite.org") UTF8String]); >- EXPECT_STREQ("site.com\xC3\xB7othersite.org", [WTF::decodeHostName(@"site.com\xC3\xB7othersite.org") UTF8String]); >-} >- >-TEST(WTF, URLExtras_Solidus) >-{ >- // Selected full width solidus, which looks like the solidus, which is the character that indicates the end of the host name. >- >- // Code path similar to the one used when typing in a URL. >- EXPECT_STREQ("http://site.com/othersite.org", originalDataAsString(WTF::URLWithUserTypedString(@"http://site.com\xEF\xBC\x8Fothersite.org", nil))); >- EXPECT_STREQ("http://site.com/othersite.org", userVisibleString(WTF::URLWithUserTypedString(@"http://site.com\xEF\xBC\x8Fothersite.org", nil))); >- >- // Code paths similar to the ones used for URLs found in webpages or HTTP responses. >- EXPECT_STREQ("http://site.com\xEF\xBC\x8Fothersite.org", originalDataAsString(literalURL("http://site.com\xEF\xBC\x8Fothersite.org"))); >- EXPECT_STREQ("http://site.com%EF%BC%8Fothersite.org", userVisibleString(literalURL("http://site.com\xEF\xBC\x8Fothersite.org"))); >- EXPECT_STREQ("http://site.com%EF%BC%8Fothersite.org", originalDataAsString(literalURL("http://site.com%EF%BC%8Fothersite.org"))); >- EXPECT_STREQ("http://site.com%EF%BC%8Fothersite.org", userVisibleString(literalURL("http://site.com%EF%BC%8Fothersite.org"))); >- >- // Separate functions that deal with just a host name on its own. >- EXPECT_STREQ("site.com/othersite.org", [WTF::encodeHostName(@"site.com\xEF\xBC\x8Fothersite.org") UTF8String]); >- EXPECT_STREQ("site.com/othersite.org", [WTF::decodeHostName(@"site.com\xEF\xBC\x8Fothersite.org") UTF8String]); >-} >- >-TEST(WebCore, URLExtras_Space) >-{ >- // Selected ideographic space, which looks like the ASCII space, which is not allowed unescaped. >- >- // Code path similar to the one used when typing in a URL. >- EXPECT_STREQ("http://site.com%20othersite.org", originalDataAsString(WTF::URLWithUserTypedString(@"http://site.com\xE3\x80\x80othersite.org", nil))); >- EXPECT_STREQ("http://site.com%20othersite.org", userVisibleString(WTF::URLWithUserTypedString(@"http://site.com\xE3\x80\x80othersite.org", nil))); >- >- // Code paths similar to the ones used for URLs found in webpages or HTTP responses. >- EXPECT_STREQ("http://site.com\xE3\x80\x80othersite.org", originalDataAsString(literalURL("http://site.com\xE3\x80\x80othersite.org"))); >- EXPECT_STREQ("http://site.com%E3%80%80othersite.org", userVisibleString(literalURL("http://site.com\xE3\x80\x80othersite.org"))); >- EXPECT_STREQ("http://site.com%E3%80%80othersite.org", originalDataAsString(literalURL("http://site.com%E3%80%80othersite.org"))); >- EXPECT_STREQ("http://site.com%E3%80%80othersite.org", userVisibleString(literalURL("http://site.com%E3%80%80othersite.org"))); >- >- // Separate functions that deal with just a host name on its own. >- EXPECT_STREQ("site.com othersite.org", [WTF::encodeHostName(@"site.com\xE3\x80\x80othersite.org") UTF8String]); >- EXPECT_STREQ("site.com\xE3\x80\x80othersite.org", [WTF::decodeHostName(@"site.com\xE3\x80\x80othersite.org") UTF8String]); >-} >- >-TEST(WebCore, URLExtras_File) >-{ >- EXPECT_STREQ("file:///%E2%98%83", [[WTF::URLWithUserTypedString(@"file:///â", nil) absoluteString] UTF8String]); >-} >- >-TEST(WebCore, URLExtras_ParsingError) >-{ >- // Expect IDN failure. >- NSURL *url = WTF::URLWithUserTypedString(@"http://.com", nil); >- EXPECT_TRUE(url == nil); >- >- NSString *encodedHostName = WTF::encodeHostName(@"http://.com"); >- EXPECT_TRUE(encodedHostName == nil); >-} >- >-TEST(WebCore, URLExtras_Nil) >-{ >- NSURL *url1 = WTF::URLWithUserTypedString(nil, nil); >- EXPECT_TRUE(url1 == nil); >- >- NSURL *url2 = WTF::URLWithUserTypedStringDeprecated(nil, nil); >- EXPECT_TRUE(url2 == nil); >-} >- >-} // namespace TestWebKitAPI >-
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 192275
:
356293
|
356296