2 * Copyright (C) 2016 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
27 #include "WTFStringUtilities.h"
28 #include <WebCore/URLParser.h>
29 #include <wtf/MainThread.h>
30 #include <wtf/text/StringBuilder.h>
32 using namespace WebCore;
34 namespace TestWebKitAPI {
36 class URLParserTest : public testing::Test {
39 WTF::initializeMainThread();
43 struct ExpectedParts {
54 bool isInvalid() const
56 return protocol.isEmpty()
63 && fragment.isEmpty();
67 static bool eq(const String& s1, const String& s2)
69 EXPECT_STREQ(s1.utf8().data(), s2.utf8().data());
70 return s1.utf8() == s2.utf8();
73 static String insertTabAtLocation(const String& string, size_t location)
75 ASSERT(location <= string.length());
76 return makeString(string.substring(0, location), "\t", string.substring(location));
79 static ExpectedParts invalidParts(const String& urlStringWithTab)
81 return {"", "", "", "", 0, "" , "", "", urlStringWithTab};
84 enum class TestTabs { No, Yes };
86 // Inserting tabs between surrogate pairs changes the encoded value instead of being skipped by the URLParser.
87 const TestTabs testTabsValueForSurrogatePairs = TestTabs::No;
89 static void checkURL(const String& urlString, const ExpectedParts& parts, TestTabs testTabs = TestTabs::Yes)
91 auto url = URL(URL(), urlString);
93 EXPECT_TRUE(eq(parts.protocol, url.protocol().toString()));
94 EXPECT_TRUE(eq(parts.user, url.user()));
95 EXPECT_TRUE(eq(parts.password, url.pass()));
96 EXPECT_TRUE(eq(parts.host, url.host()));
97 EXPECT_EQ(parts.port, url.port().value_or(0));
98 EXPECT_TRUE(eq(parts.path, url.path()));
99 EXPECT_TRUE(eq(parts.query, url.query()));
100 EXPECT_TRUE(eq(parts.fragment, url.fragmentIdentifier()));
101 EXPECT_TRUE(eq(parts.string, url.string()));
103 EXPECT_TRUE(URLParser::internalValuesConsistent(url));
105 if (testTabs == TestTabs::No)
108 for (size_t i = 0; i < urlString.length(); ++i) {
109 String urlStringWithTab = insertTabAtLocation(urlString, i);
110 checkURL(urlStringWithTab,
111 parts.isInvalid() ? invalidParts(urlStringWithTab) : parts,
116 static void checkRelativeURL(const String& urlString, const String& baseURLString, const ExpectedParts& parts, TestTabs testTabs = TestTabs::Yes)
118 auto url = URL(URL(URL(), baseURLString), urlString);
120 EXPECT_TRUE(eq(parts.protocol, url.protocol().toString()));
121 EXPECT_TRUE(eq(parts.user, url.user()));
122 EXPECT_TRUE(eq(parts.password, url.pass()));
123 EXPECT_TRUE(eq(parts.host, url.host()));
124 EXPECT_EQ(parts.port, url.port().value_or(0));
125 EXPECT_TRUE(eq(parts.path, url.path()));
126 EXPECT_TRUE(eq(parts.query, url.query()));
127 EXPECT_TRUE(eq(parts.fragment, url.fragmentIdentifier()));
128 EXPECT_TRUE(eq(parts.string, url.string()));
130 EXPECT_TRUE(URLParser::internalValuesConsistent(url));
132 if (testTabs == TestTabs::No)
135 for (size_t i = 0; i < urlString.length(); ++i) {
136 String urlStringWithTab = insertTabAtLocation(urlString, i);
137 checkRelativeURL(urlStringWithTab,
139 parts.isInvalid() ? invalidParts(urlStringWithTab) : parts,
144 static void checkURLDifferences(const String& urlString, const ExpectedParts& partsNew, const ExpectedParts& partsOld, TestTabs testTabs = TestTabs::Yes)
146 UNUSED_PARAM(partsOld); // FIXME: Remove all the old expected parts.
147 auto url = URL(URL(), urlString);
149 EXPECT_TRUE(eq(partsNew.protocol, url.protocol().toString()));
150 EXPECT_TRUE(eq(partsNew.user, url.user()));
151 EXPECT_TRUE(eq(partsNew.password, url.pass()));
152 EXPECT_TRUE(eq(partsNew.host, url.host()));
153 EXPECT_EQ(partsNew.port, url.port().value_or(0));
154 EXPECT_TRUE(eq(partsNew.path, url.path()));
155 EXPECT_TRUE(eq(partsNew.query, url.query()));
156 EXPECT_TRUE(eq(partsNew.fragment, url.fragmentIdentifier()));
157 EXPECT_TRUE(eq(partsNew.string, url.string()));
159 EXPECT_TRUE(URLParser::internalValuesConsistent(url));
161 if (testTabs == TestTabs::No)
164 for (size_t i = 0; i < urlString.length(); ++i) {
165 String urlStringWithTab = insertTabAtLocation(urlString, i);
166 checkURLDifferences(urlStringWithTab,
167 partsNew.isInvalid() ? invalidParts(urlStringWithTab) : partsNew,
168 partsOld.isInvalid() ? invalidParts(urlStringWithTab) : partsOld,
173 static void checkRelativeURLDifferences(const String& urlString, const String& baseURLString, const ExpectedParts& partsNew, const ExpectedParts& partsOld, TestTabs testTabs = TestTabs::Yes)
175 UNUSED_PARAM(partsOld); // FIXME: Remove all the old expected parts.
176 auto url = URL(URL(URL(), baseURLString), urlString);
178 EXPECT_TRUE(eq(partsNew.protocol, url.protocol().toString()));
179 EXPECT_TRUE(eq(partsNew.user, url.user()));
180 EXPECT_TRUE(eq(partsNew.password, url.pass()));
181 EXPECT_TRUE(eq(partsNew.host, url.host()));
182 EXPECT_EQ(partsNew.port, url.port().value_or(0));
183 EXPECT_TRUE(eq(partsNew.path, url.path()));
184 EXPECT_TRUE(eq(partsNew.query, url.query()));
185 EXPECT_TRUE(eq(partsNew.fragment, url.fragmentIdentifier()));
186 EXPECT_TRUE(eq(partsNew.string, url.string()));
188 EXPECT_TRUE(URLParser::internalValuesConsistent(url));
190 if (testTabs == TestTabs::No)
193 for (size_t i = 0; i < urlString.length(); ++i) {
194 String urlStringWithTab = insertTabAtLocation(urlString, i);
195 checkRelativeURLDifferences(urlStringWithTab, baseURLString,
196 partsNew.isInvalid() ? invalidParts(urlStringWithTab) : partsNew,
197 partsOld.isInvalid() ? invalidParts(urlStringWithTab) : partsOld,
202 static void shouldFail(const String& urlString)
204 checkURL(urlString, {"", "", "", "", 0, "", "", "", urlString});
207 static void shouldFail(const String& urlString, const String& baseString)
209 checkRelativeURL(urlString, baseString, {"", "", "", "", 0, "", "", "", urlString});
212 static void checkURL(const String& urlString, const TextEncoding& encoding, const ExpectedParts& parts, TestTabs testTabs = TestTabs::Yes)
214 URLParser parser(urlString, { }, encoding);
215 auto url = parser.result();
216 EXPECT_TRUE(eq(parts.protocol, url.protocol().toString()));
217 EXPECT_TRUE(eq(parts.user, url.user()));
218 EXPECT_TRUE(eq(parts.password, url.pass()));
219 EXPECT_TRUE(eq(parts.host, url.host()));
220 EXPECT_EQ(parts.port, url.port().value_or(0));
221 EXPECT_TRUE(eq(parts.path, url.path()));
222 EXPECT_TRUE(eq(parts.query, url.query()));
223 EXPECT_TRUE(eq(parts.fragment, url.fragmentIdentifier()));
224 EXPECT_TRUE(eq(parts.string, url.string()));
226 if (testTabs == TestTabs::No)
229 for (size_t i = 0; i < urlString.length(); ++i) {
230 String urlStringWithTab = insertTabAtLocation(urlString, i);
231 checkURL(urlStringWithTab, encoding,
232 parts.isInvalid() ? invalidParts(urlStringWithTab) : parts,
237 static void checkURL(const String& urlString, const String& baseURLString, const TextEncoding& encoding, const ExpectedParts& parts, TestTabs testTabs = TestTabs::Yes)
239 URLParser baseParser(baseURLString, { }, encoding);
240 URLParser parser(urlString, baseParser.result(), encoding);
241 auto url = parser.result();
242 EXPECT_TRUE(eq(parts.protocol, url.protocol().toString()));
243 EXPECT_TRUE(eq(parts.user, url.user()));
244 EXPECT_TRUE(eq(parts.password, url.pass()));
245 EXPECT_TRUE(eq(parts.host, url.host()));
246 EXPECT_EQ(parts.port, url.port().value_or(0));
247 EXPECT_TRUE(eq(parts.path, url.path()));
248 EXPECT_TRUE(eq(parts.query, url.query()));
249 EXPECT_TRUE(eq(parts.fragment, url.fragmentIdentifier()));
250 EXPECT_TRUE(eq(parts.string, url.string()));
252 if (testTabs == TestTabs::No)
255 for (size_t i = 0; i < urlString.length(); ++i) {
256 String urlStringWithTab = insertTabAtLocation(urlString, i);
257 checkURL(urlStringWithTab, baseURLString, encoding,
258 parts.isInvalid() ? invalidParts(urlStringWithTab) : parts,
263 TEST_F(URLParserTest, Basic)
265 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"});
266 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"});
267 checkURL("http://user:pass@webkit.org:123/path", {"http", "user", "pass", "webkit.org", 123, "/path", "", "", "http://user:pass@webkit.org:123/path"});
268 checkURL("http://user:pass@webkit.org:123/", {"http", "user", "pass", "webkit.org", 123, "/", "", "", "http://user:pass@webkit.org:123/"});
269 checkURL("http://user:pass@webkit.org:123", {"http", "user", "pass", "webkit.org", 123, "/", "", "", "http://user:pass@webkit.org:123/"});
270 checkURL("http://user:pass@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"});
271 checkURL("http://user:\t\t\tpass@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"});
272 checkURL("http://us\ter:pass@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"});
273 checkURL("http://user:pa\tss@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"});
274 checkURL("http://user:pass\t@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"});
275 checkURL("http://\tuser:pass@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"});
276 checkURL("http://user\t:pass@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"});
277 checkURL("http://webkit.org", {"http", "", "", "webkit.org", 0, "/", "", "", "http://webkit.org/"});
278 checkURL("http://127.0.0.1", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"});
279 checkURL("http://webkit.org/", {"http", "", "", "webkit.org", 0, "/", "", "", "http://webkit.org/"});
280 checkURL("http://webkit.org/path1/path2/index.html", {"http", "", "", "webkit.org", 0, "/path1/path2/index.html", "", "", "http://webkit.org/path1/path2/index.html"});
281 checkURL("about:blank", {"about", "", "", "", 0, "blank", "", "", "about:blank"});
282 checkURL("about:blank?query", {"about", "", "", "", 0, "blank", "query", "", "about:blank?query"});
283 checkURL("about:blank#fragment", {"about", "", "", "", 0, "blank", "", "fragment", "about:blank#fragment"});
284 checkURL("http://[0:f::f:f:0:0]", {"http", "", "", "[0:f::f:f:0:0]", 0, "/", "", "", "http://[0:f::f:f:0:0]/"});
285 checkURL("http://[0:f:0:0:f::]", {"http", "", "", "[0:f:0:0:f::]", 0, "/", "", "", "http://[0:f:0:0:f::]/"});
286 checkURL("http://[::f:0:0:f:0:0]", {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"});
287 checkURL("http://[0:f:0:0:f::]:", {"http", "", "", "[0:f:0:0:f::]", 0, "/", "", "", "http://[0:f:0:0:f::]/"});
288 checkURL("http://[0:f:0:0:f::]:\t", {"http", "", "", "[0:f:0:0:f::]", 0, "/", "", "", "http://[0:f:0:0:f::]/"});
289 checkURL("http://[0:f:0:0:f::]\t:", {"http", "", "", "[0:f:0:0:f::]", 0, "/", "", "", "http://[0:f:0:0:f::]/"});
290 checkURL("http://\t[::f:0:0:f:0:0]", {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"});
291 checkURL("http://[\t::f:0:0:f:0:0]", {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"});
292 checkURL("http://[:\t:f:0:0:f:0:0]", {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"});
293 checkURL("http://[::\tf:0:0:f:0:0]", {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"});
294 checkURL("http://[::f\t:0:0:f:0:0]", {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"});
295 checkURL("http://[::f:\t0:0:f:0:0]", {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"});
296 checkURL("http://example.com/path1/path2/.", {"http", "", "", "example.com", 0, "/path1/path2/", "", "", "http://example.com/path1/path2/"});
297 checkURL("http://example.com/path1/path2/..", {"http", "", "", "example.com", 0, "/path1/", "", "", "http://example.com/path1/"});
298 checkURL("http://example.com/path1/path2/./path3", {"http", "", "", "example.com", 0, "/path1/path2/path3", "", "", "http://example.com/path1/path2/path3"});
299 checkURL("http://example.com/path1/path2/.\\path3", {"http", "", "", "example.com", 0, "/path1/path2/path3", "", "", "http://example.com/path1/path2/path3"});
300 checkURL("http://example.com/path1/path2/../path3", {"http", "", "", "example.com", 0, "/path1/path3", "", "", "http://example.com/path1/path3"});
301 checkURL("http://example.com/path1/path2/..\\path3", {"http", "", "", "example.com", 0, "/path1/path3", "", "", "http://example.com/path1/path3"});
302 checkURL("http://example.com/.", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"});
303 checkURL("http://example.com/..", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"});
304 checkURL("http://example.com/./path1", {"http", "", "", "example.com", 0, "/path1", "", "", "http://example.com/path1"});
305 checkURL("http://example.com/../path1", {"http", "", "", "example.com", 0, "/path1", "", "", "http://example.com/path1"});
306 checkURL("http://example.com/../path1/../../path2/path3/../path4", {"http", "", "", "example.com", 0, "/path2/path4", "", "", "http://example.com/path2/path4"});
307 checkURL("http://example.com/path1/.%2", {"http", "", "", "example.com", 0, "/path1/.%2", "", "", "http://example.com/path1/.%2"});
308 checkURL("http://example.com/path1/%2", {"http", "", "", "example.com", 0, "/path1/%2", "", "", "http://example.com/path1/%2"});
309 checkURL("http://example.com/path1/%", {"http", "", "", "example.com", 0, "/path1/%", "", "", "http://example.com/path1/%"});
310 checkURL("http://example.com/path1/.%", {"http", "", "", "example.com", 0, "/path1/.%", "", "", "http://example.com/path1/.%"});
311 checkURL("http://example.com//.", {"http", "", "", "example.com", 0, "//", "", "", "http://example.com//"});
312 checkURL("http://example.com//./", {"http", "", "", "example.com", 0, "//", "", "", "http://example.com//"});
313 checkURL("http://example.com//.//", {"http", "", "", "example.com", 0, "///", "", "", "http://example.com///"});
314 checkURL("http://example.com//..", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"});
315 checkURL("http://example.com//../", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"});
316 checkURL("http://example.com//..//", {"http", "", "", "example.com", 0, "//", "", "", "http://example.com//"});
317 checkURL("http://example.com//..", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"});
318 checkURL("http://example.com/.//", {"http", "", "", "example.com", 0, "//", "", "", "http://example.com//"});
319 checkURL("http://example.com/..//", {"http", "", "", "example.com", 0, "//", "", "", "http://example.com//"});
320 checkURL("http://example.com/./", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"});
321 checkURL("http://example.com/../", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"});
322 checkURL("http://example.com/path1/.../path3", {"http", "", "", "example.com", 0, "/path1/.../path3", "", "", "http://example.com/path1/.../path3"});
323 checkURL("http://example.com/path1/...", {"http", "", "", "example.com", 0, "/path1/...", "", "", "http://example.com/path1/..."});
324 checkURL("http://example.com/path1/.../", {"http", "", "", "example.com", 0, "/path1/.../", "", "", "http://example.com/path1/.../"});
325 checkURL("http://example.com/.path1/", {"http", "", "", "example.com", 0, "/.path1/", "", "", "http://example.com/.path1/"});
326 checkURL("http://example.com/..path1/", {"http", "", "", "example.com", 0, "/..path1/", "", "", "http://example.com/..path1/"});
327 checkURL("http://example.com/path1/.path2", {"http", "", "", "example.com", 0, "/path1/.path2", "", "", "http://example.com/path1/.path2"});
328 checkURL("http://example.com/path1/..path2", {"http", "", "", "example.com", 0, "/path1/..path2", "", "", "http://example.com/path1/..path2"});
329 checkURL("http://example.com/path1/path2/.?query", {"http", "", "", "example.com", 0, "/path1/path2/", "query", "", "http://example.com/path1/path2/?query"});
330 checkURL("http://example.com/path1/path2/..?query", {"http", "", "", "example.com", 0, "/path1/", "query", "", "http://example.com/path1/?query"});
331 checkURL("http://example.com/path1/path2/.#fragment", {"http", "", "", "example.com", 0, "/path1/path2/", "", "fragment", "http://example.com/path1/path2/#fragment"});
332 checkURL("http://example.com/path1/path2/..#fragment", {"http", "", "", "example.com", 0, "/path1/", "", "fragment", "http://example.com/path1/#fragment"});
334 checkURL("file:", {"file", "", "", "", 0, "/", "", "", "file:///"});
335 checkURL("file:/", {"file", "", "", "", 0, "/", "", "", "file:///"});
336 checkURL("file://", {"file", "", "", "", 0, "/", "", "", "file:///"});
337 checkURL("file:///", {"file", "", "", "", 0, "/", "", "", "file:///"});
338 checkURL("file:////", {"file", "", "", "", 0, "//", "", "", "file:////"}); // This matches Firefox and URL::parse which I believe are correct, but not Chrome.
339 checkURL("file:/path", {"file", "", "", "", 0, "/path", "", "", "file:///path"});
340 checkURL("file://host/path", {"file", "", "", "host", 0, "/path", "", "", "file://host/path"});
341 checkURL("file://host", {"file", "", "", "host", 0, "/", "", "", "file://host/"});
342 checkURL("file://host/", {"file", "", "", "host", 0, "/", "", "", "file://host/"});
343 checkURL("file:///path", {"file", "", "", "", 0, "/path", "", "", "file:///path"});
344 checkURL("file:////path", {"file", "", "", "", 0, "//path", "", "", "file:////path"});
345 checkURL("file://localhost/path", {"file", "", "", "", 0, "/path", "", "", "file:///path"});
346 checkURL("file://localhost/", {"file", "", "", "", 0, "/", "", "", "file:///"});
347 checkURL("file://localhost", {"file", "", "", "", 0, "/", "", "", "file:///"});
348 checkURL("file://lOcAlHoSt", {"file", "", "", "", 0, "/", "", "", "file:///"});
349 checkURL("file://lOcAlHoSt/", {"file", "", "", "", 0, "/", "", "", "file:///"});
350 checkURL("file:/pAtH/", {"file", "", "", "", 0, "/pAtH/", "", "", "file:///pAtH/"});
351 checkURL("file:/pAtH", {"file", "", "", "", 0, "/pAtH", "", "", "file:///pAtH"});
352 checkURL("file:?query", {"file", "", "", "", 0, "/", "query", "", "file:///?query"});
353 checkURL("file:#fragment", {"file", "", "", "", 0, "/", "", "fragment", "file:///#fragment"});
354 checkURL("file:?query#fragment", {"file", "", "", "", 0, "/", "query", "fragment", "file:///?query#fragment"});
355 checkURL("file:#fragment?notquery", {"file", "", "", "", 0, "/", "", "fragment?notquery", "file:///#fragment?notquery"});
356 checkURL("file:/?query", {"file", "", "", "", 0, "/", "query", "", "file:///?query"});
357 checkURL("file:/#fragment", {"file", "", "", "", 0, "/", "", "fragment", "file:///#fragment"});
358 checkURL("file://?query", {"file", "", "", "", 0, "/", "query", "", "file:///?query"});
359 checkURL("file://#fragment", {"file", "", "", "", 0, "/", "", "fragment", "file:///#fragment"});
360 checkURL("file:///?query", {"file", "", "", "", 0, "/", "query", "", "file:///?query"});
361 checkURL("file:///#fragment", {"file", "", "", "", 0, "/", "", "fragment", "file:///#fragment"});
362 checkURL("file:////?query", {"file", "", "", "", 0, "//", "query", "", "file:////?query"});
363 checkURL("file:////#fragment", {"file", "", "", "", 0, "//", "", "fragment", "file:////#fragment"});
364 checkURL("http://host/A b", {"http", "", "", "host", 0, "/A%20b", "", "", "http://host/A%20b"});
365 checkURL("http://host/a%20B", {"http", "", "", "host", 0, "/a%20B", "", "", "http://host/a%20B"});
366 checkURL("http://host?q=@ <>!#fragment", {"http", "", "", "host", 0, "/", "q=@%20%3C%3E!", "fragment", "http://host/?q=@%20%3C%3E!#fragment"});
367 checkURL("http://user:@host", {"http", "user", "", "host", 0, "/", "", "", "http://user@host/"});
368 checkURL("http://user:@\thost", {"http", "user", "", "host", 0, "/", "", "", "http://user@host/"});
369 checkURL("http://user:\t@host", {"http", "user", "", "host", 0, "/", "", "", "http://user@host/"});
370 checkURL("http://user\t:@host", {"http", "user", "", "host", 0, "/", "", "", "http://user@host/"});
371 checkURL("http://use\tr:@host", {"http", "user", "", "host", 0, "/", "", "", "http://user@host/"});
372 checkURL("http://127.0.0.1:10100/path", {"http", "", "", "127.0.0.1", 10100, "/path", "", "", "http://127.0.0.1:10100/path"});
373 checkURL("http://127.0.0.1:/path", {"http", "", "", "127.0.0.1", 0, "/path", "", "", "http://127.0.0.1/path"});
374 checkURL("http://127.0.0.1\t:/path", {"http", "", "", "127.0.0.1", 0, "/path", "", "", "http://127.0.0.1/path"});
375 checkURL("http://127.0.0.1:\t/path", {"http", "", "", "127.0.0.1", 0, "/path", "", "", "http://127.0.0.1/path"});
376 checkURL("http://127.0.0.1:/\tpath", {"http", "", "", "127.0.0.1", 0, "/path", "", "", "http://127.0.0.1/path"});
377 checkURL("http://127.0.0.1:123", {"http", "", "", "127.0.0.1", 123, "/", "", "", "http://127.0.0.1:123/"});
378 checkURL("http://127.0.0.1:", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"});
379 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"});
380 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/"});
381 checkURL("http://[0:f:0:0:f:\t:]:123", {"http", "", "", "[0:f:0:0:f::]", 123, "/", "", "", "http://[0:f:0:0:f::]:123/"});
382 checkURL("http://[0:f:0:0:f::\t]:123", {"http", "", "", "[0:f:0:0:f::]", 123, "/", "", "", "http://[0:f:0:0:f::]:123/"});
383 checkURL("http://[0:f:0:0:f::]\t:123", {"http", "", "", "[0:f:0:0:f::]", 123, "/", "", "", "http://[0:f:0:0:f::]:123/"});
384 checkURL("http://[0:f:0:0:f::]:\t123", {"http", "", "", "[0:f:0:0:f::]", 123, "/", "", "", "http://[0:f:0:0:f::]:123/"});
385 checkURL("http://[0:f:0:0:f::]:1\t23", {"http", "", "", "[0:f:0:0:f::]", 123, "/", "", "", "http://[0:f:0:0:f::]:123/"});
386 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"});
387 checkURL("http://[0:f::f:f:0:0]:", {"http", "", "", "[0:f::f:f:0:0]", 0, "/", "", "", "http://[0:f::f:f:0:0]/"});
388 checkURL("http://host:10100/path", {"http", "", "", "host", 10100, "/path", "", "", "http://host:10100/path"});
389 checkURL("http://host:/path", {"http", "", "", "host", 0, "/path", "", "", "http://host/path"});
390 checkURL("http://host:123", {"http", "", "", "host", 123, "/", "", "", "http://host:123/"});
391 checkURL("http://host:", {"http", "", "", "host", 0, "/", "", "", "http://host/"});
392 checkURL("http://hos\tt\n:\t1\n2\t3\t/\npath", {"http", "", "", "host", 123, "/path", "", "", "http://host:123/path"});
393 checkURL("http://user@example.org/path3", {"http", "user", "", "example.org", 0, "/path3", "", "", "http://user@example.org/path3"});
394 checkURL("sc:/pa/pa", {"sc", "", "", "", 0, "/pa/pa", "", "", "sc:/pa/pa"});
395 checkURL("sc:/pa", {"sc", "", "", "", 0, "/pa", "", "", "sc:/pa"});
396 checkURL("sc:/pa/", {"sc", "", "", "", 0, "/pa/", "", "", "sc:/pa/"});
397 checkURL("notspecial:/notuser:notpassword@nothost", {"notspecial", "", "", "", 0, "/notuser:notpassword@nothost", "", "", "notspecial:/notuser:notpassword@nothost"});
398 checkURL("sc://pa/", {"sc", "", "", "pa", 0, "/", "", "", "sc://pa/"});
399 checkURL("sc://\tpa/", {"sc", "", "", "pa", 0, "/", "", "", "sc://pa/"});
400 checkURL("sc:/\t/pa/", {"sc", "", "", "pa", 0, "/", "", "", "sc://pa/"});
401 checkURL("sc:\t//pa/", {"sc", "", "", "pa", 0, "/", "", "", "sc://pa/"});
402 checkURL("http://host \a ", {"http", "", "", "host", 0, "/", "", "", "http://host/"});
403 checkURL("notspecial:/a", {"notspecial", "", "", "", 0, "/a", "", "", "notspecial:/a"});
404 checkURL("notspecial:", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"});
405 checkURL("http:/a", {"http", "", "", "a", 0, "/", "", "", "http://a/"});
406 checkURL("http://256../", {"http", "", "", "256..", 0, "/", "", "", "http://256../"});
407 checkURL("http://256..", {"http", "", "", "256..", 0, "/", "", "", "http://256../"});
408 checkURL("http://127..1/", {"http", "", "", "127..1", 0, "/", "", "", "http://127..1/"});
409 checkURL("http://127.a.0.1/", {"http", "", "", "127.a.0.1", 0, "/", "", "", "http://127.a.0.1/"});
410 checkURL("http://127.0.0.1/", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"});
411 checkURL("http://12\t7.0.0.1/", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"});
412 checkURL("http://127.\t0.0.1/", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"});
413 checkURL("http://./", {"http", "", "", ".", 0, "/", "", "", "http://./"});
414 checkURL("http://.", {"http", "", "", ".", 0, "/", "", "", "http://./"});
415 checkURL("notspecial:/a", {"notspecial", "", "", "", 0, "/a", "", "", "notspecial:/a"});
416 checkURL("notspecial:", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"});
417 checkURL("notspecial:/", {"notspecial", "", "", "", 0, "/", "", "", "notspecial:/"});
418 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"});
419 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"});
420 checkURL("about:~", {"about", "", "", "", 0, "~", "", "", "about:~"});
421 checkURL("https://@test@test@example:800\\path@end", {"", "", "", "", 0, "", "", "", "https://@test@test@example:800\\path@end"});
422 checkURL("http://www.example.com/#a\nb\rc\td", {"http", "", "", "www.example.com", 0, "/", "", "abcd", "http://www.example.com/#abcd"});
423 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]/"});
424 checkURL("http:////////user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://user@webkit.org:99/?foo"});
425 checkURL("http:////////user:@webkit.org:99#foo", {"http", "user", "", "webkit.org", 99, "/", "", "foo", "http://user@webkit.org:99/#foo"});
426 checkURL("http:////\t////user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://user@webkit.org:99/?foo"});
427 checkURL("http://\t//\\///user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://user@webkit.org:99/?foo"});
428 checkURL("http:/\\user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://user@webkit.org:99/?foo"});
429 checkURL("http://127.0.0.1", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"});
430 checkURLDifferences("http://127.0.0.1.",
431 {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"},
432 {"http", "", "", "127.0.0.1.", 0, "/", "", "", "http://127.0.0.1./"});
433 checkURLDifferences("http://127.0.0.1./",
434 {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"},
435 {"http", "", "", "127.0.0.1.", 0, "/", "", "", "http://127.0.0.1./"});
436 checkURL("http://127.0.0.1../", {"http", "", "", "127.0.0.1..", 0, "/", "", "", "http://127.0.0.1../"});
437 checkURLDifferences("http://0x100.0/",
438 {"", "", "", "", 0, "", "", "", "http://0x100.0/"},
439 {"http", "", "", "0x100.0", 0, "/", "", "", "http://0x100.0/"});
440 checkURLDifferences("http://0.0.0x100.0/",
441 {"", "", "", "", 0, "", "", "", "http://0.0.0x100.0/"},
442 {"http", "", "", "0.0.0x100.0", 0, "/", "", "", "http://0.0.0x100.0/"});
443 checkURLDifferences("http://0.0.0.0x100/",
444 {"", "", "", "", 0, "", "", "", "http://0.0.0.0x100/"},
445 {"http", "", "", "0.0.0.0x100", 0, "/", "", "", "http://0.0.0.0x100/"});
446 checkURL("http://host:123?", {"http", "", "", "host", 123, "/", "", "", "http://host:123/?"});
447 checkURL("http://host:123?query", {"http", "", "", "host", 123, "/", "query", "", "http://host:123/?query"});
448 checkURL("http://host:123#", {"http", "", "", "host", 123, "/", "", "", "http://host:123/#"});
449 checkURL("http://host:123#fragment", {"http", "", "", "host", 123, "/", "", "fragment", "http://host:123/#fragment"});
450 checkURLDifferences("foo:////",
451 {"foo", "", "", "", 0, "//", "", "", "foo:////"},
452 {"foo", "", "", "", 0, "////", "", "", "foo:////"});
453 checkURLDifferences("foo:///?",
454 {"foo", "", "", "", 0, "/", "", "", "foo:///?"},
455 {"foo", "", "", "", 0, "///", "", "", "foo:///?"});
456 checkURLDifferences("foo:///#",
457 {"foo", "", "", "", 0, "/", "", "", "foo:///#"},
458 {"foo", "", "", "", 0, "///", "", "", "foo:///#"});
459 checkURLDifferences("foo:///",
460 {"foo", "", "", "", 0, "/", "", "", "foo:///"},
461 {"foo", "", "", "", 0, "///", "", "", "foo:///"});
462 checkURLDifferences("foo://?",
463 {"foo", "", "", "", 0, "", "", "", "foo://?"},
464 {"foo", "", "", "", 0, "//", "", "", "foo://?"});
465 checkURLDifferences("foo://#",
466 {"foo", "", "", "", 0, "", "", "", "foo://#"},
467 {"foo", "", "", "", 0, "//", "", "", "foo://#"});
468 checkURLDifferences("foo://",
469 {"foo", "", "", "", 0, "", "", "", "foo://"},
470 {"foo", "", "", "", 0, "//", "", "", "foo://"});
471 checkURL("foo:/?", {"foo", "", "", "", 0, "/", "", "", "foo:/?"});
472 checkURL("foo:/#", {"foo", "", "", "", 0, "/", "", "", "foo:/#"});
473 checkURL("foo:/", {"foo", "", "", "", 0, "/", "", "", "foo:/"});
474 checkURL("foo:?", {"foo", "", "", "", 0, "", "", "", "foo:?"});
475 checkURL("foo:#", {"foo", "", "", "", 0, "", "", "", "foo:#"});
476 checkURLDifferences("A://",
477 {"a", "", "", "", 0, "", "", "", "a://"},
478 {"a", "", "", "", 0, "//", "", "", "a://"});
479 checkURLDifferences("aA://",
480 {"aa", "", "", "", 0, "", "", "", "aa://"},
481 {"aa", "", "", "", 0, "//", "", "", "aa://"});
482 checkURL(utf16String(u"foo://host/#ПП\u0007 a</"), {"foo", "", "", "host", 0, "/", "", "%D0%9F%D0%9F%07 a</", "foo://host/#%D0%9F%D0%9F%07 a</"});
483 checkURL(utf16String(u"foo://host/#\u0007 a</"), {"foo", "", "", "host", 0, "/", "", "%07 a</", "foo://host/#%07 a</"});
484 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);
485 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);
486 checkURL(utf16String(u"http://host/#ПП\u0007 a</"), {"http", "", "", "host", 0, "/", "", "%D0%9F%D0%9F%07 a</", "http://host/#%D0%9F%D0%9F%07 a</"});
487 checkURL(utf16String(u"http://host/#\u0007 a</"), {"http", "", "", "host", 0, "/", "", "%07 a</", "http://host/#%07 a</"});
489 // This disagrees with the web platform test for http://:@www.example.com but agrees with Chrome and URL::parse,
490 // and Firefox fails the web platform test differently. Maybe the web platform test ought to be changed.
491 checkURL("http://:@host", {"http", "", "", "host", 0, "/", "", "", "http://host/"});
494 TEST_F(URLParserTest, ParseRelative)
496 checkRelativeURL("/index.html", "http://webkit.org/path1/path2/", {"http", "", "", "webkit.org", 0, "/index.html", "", "", "http://webkit.org/index.html"});
497 checkRelativeURL("http://whatwg.org/index.html", "http://webkit.org/path1/path2/", {"http", "", "", "whatwg.org", 0, "/index.html", "", "", "http://whatwg.org/index.html"});
498 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"});
499 checkRelativeURL("//whatwg.org/index.html", "https://www.webkit.org/path", {"https", "", "", "whatwg.org", 0, "/index.html", "", "", "https://whatwg.org/index.html"});
500 checkRelativeURL("http://example\t.\norg", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/", "", "", "http://example.org/"});
501 checkRelativeURL("test", "file:///path1/path2", {"file", "", "", "", 0, "/path1/test", "", "", "file:///path1/test"});
502 checkRelativeURL(utf16String(u"http://www.foo。bar.com"), "http://other.com/", {"http", "", "", "www.foo.bar.com", 0, "/", "", "", "http://www.foo.bar.com/"});
503 checkRelativeURLDifferences(utf16String(u"sc://ñ.test/"), "about:blank",
504 {"sc", "", "", "%C3%B1.test", 0, "/", "", "", "sc://%C3%B1.test/"},
505 {"sc", "", "", "xn--ida.test", 0, "/", "", "", "sc://xn--ida.test/"});
506 checkRelativeURL("#fragment", "http://host/path", {"http", "", "", "host", 0, "/path", "", "fragment", "http://host/path#fragment"});
507 checkRelativeURL("#fragment", "file:///path", {"file", "", "", "", 0, "/path", "", "fragment", "file:///path#fragment"});
508 checkRelativeURL("#fragment", "file:///path#old", {"file", "", "", "", 0, "/path", "", "fragment", "file:///path#fragment"});
509 checkRelativeURL("#", "file:///path#old", {"file", "", "", "", 0, "/path", "", "", "file:///path#"});
510 checkRelativeURL(" ", "file:///path#old", {"file", "", "", "", 0, "/path", "", "", "file:///path"});
511 checkRelativeURL("#", "file:///path", {"file", "", "", "", 0, "/path", "", "", "file:///path#"});
512 checkRelativeURL("#", "file:///path?query", {"file", "", "", "", 0, "/path", "query", "", "file:///path?query#"});
513 checkRelativeURL("#", "file:///path?query#old", {"file", "", "", "", 0, "/path", "query", "", "file:///path?query#"});
514 checkRelativeURL("?query", "http://host/path", {"http", "", "", "host", 0, "/path", "query", "", "http://host/path?query"});
515 checkRelativeURL("?query#fragment", "http://host/path", {"http", "", "", "host", 0, "/path", "query", "fragment", "http://host/path?query#fragment"});
516 checkRelativeURL("?new", "file:///path?old#fragment", {"file", "", "", "", 0, "/path", "new", "", "file:///path?new"});
517 checkRelativeURL("?", "file:///path?old#fragment", {"file", "", "", "", 0, "/path", "", "", "file:///path?"});
518 checkRelativeURL("?", "file:///path", {"file", "", "", "", 0, "/path", "", "", "file:///path?"});
519 checkRelativeURL("?query", "file:///path", {"file", "", "", "", 0, "/path", "query", "", "file:///path?query"});
520 checkRelativeURL(utf16String(u"?β"), "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "%CE%B2", "", "http://example.org/foo/bar?%CE%B2"});
521 checkRelativeURL("?", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar?"});
522 checkRelativeURL("#", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar#"});
523 checkRelativeURL("?#", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar?#"});
524 checkRelativeURL("#?", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "?", "http://example.org/foo/bar#?"});
525 checkRelativeURL("/", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/", "", "", "http://example.org/"});
526 checkRelativeURL("http://@host", "about:blank", {"http", "", "", "host", 0, "/", "", "", "http://host/"});
527 checkRelativeURL("http://:@host", "about:blank", {"http", "", "", "host", 0, "/", "", "", "http://host/"});
528 checkRelativeURL("http://foo.com/\\@", "http://example.org/foo/bar", {"http", "", "", "foo.com", 0, "//@", "", "", "http://foo.com//@"});
529 checkRelativeURL("\\@", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/@", "", "", "http://example.org/@"});
530 checkRelativeURL("/path3", "http://user@example.org/path1/path2", {"http", "user", "", "example.org", 0, "/path3", "", "", "http://user@example.org/path3"});
531 checkRelativeURL("", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar"});
532 checkRelativeURL("\t", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar"});
533 checkRelativeURL(" ", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar"});
534 checkRelativeURL(" \a \t\n", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar"});
535 checkRelativeURL(":foo.com\\", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/:foo.com/", "", "", "http://example.org/foo/:foo.com/"});
536 checkRelativeURL("http:/example.com/", "about:blank", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"});
537 checkRelativeURL("http:example.com/", "about:blank", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"});
538 checkRelativeURL("http:\\\\foo.com\\", "http://example.org/foo/bar", {"http", "", "", "foo.com", 0, "/", "", "", "http://foo.com/"});
539 checkRelativeURL("http:\\\\foo.com/", "http://example.org/foo/bar", {"http", "", "", "foo.com", 0, "/", "", "", "http://foo.com/"});
540 checkRelativeURL("http:\\\\foo.com", "http://example.org/foo/bar", {"http", "", "", "foo.com", 0, "/", "", "", "http://foo.com/"});
541 checkRelativeURL("http://ExAmPlE.CoM", "http://other.com", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"});
542 checkRelativeURL("http:", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar"});
543 checkRelativeURL("#x", "data:,", {"data", "", "", "", 0, ",", "", "x", "data:,#x"});
544 checkRelativeURL("#x", "about:blank", {"about", "", "", "", 0, "blank", "", "x", "about:blank#x"});
545 checkRelativeURL(" foo.com ", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/foo.com", "", "", "http://example.org/foo/foo.com"});
546 checkRelativeURL(" \a baz", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/baz", "", "", "http://example.org/foo/baz"});
547 checkRelativeURL("~", "http://example.org", {"http", "", "", "example.org", 0, "/~", "", "", "http://example.org/~"});
548 checkRelativeURL("notspecial:", "about:blank", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"});
549 checkRelativeURL("notspecial:", "http://host", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"});
550 checkRelativeURL("http:", "http://host", {"http", "", "", "host", 0, "/", "", "", "http://host/"});
551 checkRelativeURL("i", "sc:/pa/po", {"sc", "", "", "", 0, "/pa/i", "", "", "sc:/pa/i"});
552 checkRelativeURL("i ", "sc:/pa/po", {"sc", "", "", "", 0, "/pa/i", "", "", "sc:/pa/i"});
553 checkRelativeURL("i\t\n ", "sc:/pa/po", {"sc", "", "", "", 0, "/pa/i", "", "", "sc:/pa/i"});
554 checkRelativeURL("i", "sc://ho/pa", {"sc", "", "", "ho", 0, "/i", "", "", "sc://ho/i"});
555 checkRelativeURL("!", "sc://ho/pa", {"sc", "", "", "ho", 0, "/!", "", "", "sc://ho/!"});
556 checkRelativeURL("!", "sc:/ho/pa", {"sc", "", "", "", 0, "/ho/!", "", "", "sc:/ho/!"});
557 checkRelativeURL("notspecial:/", "about:blank", {"notspecial", "", "", "", 0, "/", "", "", "notspecial:/"});
558 checkRelativeURL("notspecial:/", "http://host", {"notspecial", "", "", "", 0, "/", "", "", "notspecial:/"});
559 checkRelativeURL("foo:/", "http://example.org/foo/bar", {"foo", "", "", "", 0, "/", "", "", "foo:/"});
560 checkRelativeURL("://:0/", "http://webkit.org/", {"http", "", "", "webkit.org", 0, "/://:0/", "", "", "http://webkit.org/://:0/"});
561 checkRelativeURL(String(), "http://webkit.org/", {"http", "", "", "webkit.org", 0, "/", "", "", "http://webkit.org/"});
562 checkRelativeURL("https://@test@test@example:800\\path@end", "http://doesnotmatter/", {"", "", "", "", 0, "", "", "", "https://@test@test@example:800\\path@end"});
563 checkRelativeURL("http://f:0/c", "http://example.org/foo/bar", {"http", "", "", "f", 0, "/c", "", "", "http://f:0/c"});
564 checkRelativeURL(String(), "http://host/#fragment", {"http", "", "", "host", 0, "/", "", "", "http://host/"});
565 checkRelativeURL("", "http://host/#fragment", {"http", "", "", "host", 0, "/", "", "", "http://host/"});
566 checkRelativeURL(" ", "http://host/#fragment", {"http", "", "", "host", 0, "/", "", "", "http://host/"});
567 checkRelativeURL(" ", "http://host/path?query#fra#gment", {"http", "", "", "host", 0, "/path", "query", "", "http://host/path?query"});
568 checkRelativeURL(" \a ", "http://host/#fragment", {"http", "", "", "host", 0, "/", "", "", "http://host/"});
569 checkRelativeURLDifferences("foo://", "http://example.org/foo/bar",
570 {"foo", "", "", "", 0, "", "", "", "foo://"},
571 {"foo", "", "", "", 0, "//", "", "", "foo://"});
572 checkRelativeURL(utf16String(u"#β"), "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "%CE%B2", "http://example.org/foo/bar#%CE%B2"});
573 checkRelativeURL("index.html", "applewebdata://Host/", {"applewebdata", "", "", "Host", 0, "/index.html", "", "", "applewebdata://Host/index.html"});
574 checkRelativeURL("index.html", "applewebdata://Host", {"applewebdata", "", "", "Host", 0, "/index.html", "", "", "applewebdata://Host/index.html"});
575 checkRelativeURL("", "applewebdata://Host", {"applewebdata", "", "", "Host", 0, "", "", "", "applewebdata://Host"});
576 checkRelativeURL("?query", "applewebdata://Host", {"applewebdata", "", "", "Host", 0, "", "query", "", "applewebdata://Host?query"});
577 checkRelativeURL("#fragment", "applewebdata://Host", {"applewebdata", "", "", "Host", 0, "", "", "fragment", "applewebdata://Host#fragment"});
578 checkRelativeURL("notspecial://something?", "file:////var//containers//stuff/", {"notspecial", "", "", "something", 0, "", "", "", "notspecial://something?"}, TestTabs::No);
579 checkRelativeURL("notspecial://something#", "file:////var//containers//stuff/", {"notspecial", "", "", "something", 0, "", "", "", "notspecial://something#"}, TestTabs::No);
580 checkRelativeURL("http://something?", "file:////var//containers//stuff/", {"http", "", "", "something", 0, "/", "", "", "http://something/?"}, TestTabs::No);
581 checkRelativeURL("http://something#", "file:////var//containers//stuff/", {"http", "", "", "something", 0, "/", "", "", "http://something/#"}, TestTabs::No);
582 checkRelativeURL("file:", "file:///path?query#fragment", {"file", "", "", "", 0, "/path", "query", "", "file:///path?query"});
583 checkRelativeURL("/", "file:///C:/a/b", {"file", "", "", "", 0, "/C:/", "", "", "file:///C:/"});
584 checkRelativeURL("/abc", "file:///C:/a/b", {"file", "", "", "", 0, "/C:/abc", "", "", "file:///C:/abc"});
585 checkRelativeURL("/abc", "file:///C:", {"file", "", "", "", 0, "/C:/abc", "", "", "file:///C:/abc"});
586 checkRelativeURL("/abc", "file:///", {"file", "", "", "", 0, "/abc", "", "", "file:///abc"});
587 checkRelativeURL("//d:", "file:///C:/a/b", {"file", "", "", "", 0, "/d:", "", "", "file:///d:"}, TestTabs::No);
588 checkRelativeURL("//d|", "file:///C:/a/b", {"file", "", "", "", 0, "/d:", "", "", "file:///d:"}, TestTabs::No);
589 checkRelativeURL("//A|", "file:///C:/a/b", {"file", "", "", "", 0, "/A:", "", "", "file:///A:"}, TestTabs::No);
591 // The checking of slashes in SpecialAuthoritySlashes needed to get this to pass contradicts what is in the spec,
592 // but it is included in the web platform tests.
593 checkRelativeURL("http:\\\\host\\foo", "about:blank", {"http", "", "", "host", 0, "/foo", "", "", "http://host/foo"});
596 // These are differences between the new URLParser and the old URL::parse which make URLParser more standards compliant.
597 TEST_F(URLParserTest, ParserDifferences)
599 checkURLDifferences("http://127.0.1",
600 {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"},
601 {"http", "", "", "127.0.1", 0, "/", "", "", "http://127.0.1/"});
602 checkURLDifferences("http://011.11.0X11.0x011",
603 {"http", "", "", "9.11.17.17", 0, "/", "", "", "http://9.11.17.17/"},
604 {"http", "", "", "011.11.0x11.0x011", 0, "/", "", "", "http://011.11.0x11.0x011/"});
605 checkURLDifferences("http://[1234:0078:90AB:CdEf:0123:0007:89AB:0000]",
606 {"http", "", "", "[1234:78:90ab:cdef:123:7:89ab:0]", 0, "/", "", "", "http://[1234:78:90ab:cdef:123:7:89ab:0]/"},
607 {"http", "", "", "[1234:0078:90ab:cdef:0123:0007:89ab:0000]", 0, "/", "", "", "http://[1234:0078:90ab:cdef:0123:0007:89ab:0000]/"});
608 checkURLDifferences("http://[0:f:0:0:f:f:0:0]",
609 {"http", "", "", "[0:f::f:f:0:0]", 0, "/", "", "", "http://[0:f::f:f:0:0]/"},
610 {"http", "", "", "[0:f:0:0:f:f:0:0]", 0, "/", "", "", "http://[0:f:0:0:f:f:0:0]/"});
611 checkURLDifferences("http://[0:f:0:0:f:0:0:0]",
612 {"http", "", "", "[0:f:0:0:f::]", 0, "/", "", "", "http://[0:f:0:0:f::]/"},
613 {"http", "", "", "[0:f:0:0:f:0:0:0]", 0, "/", "", "", "http://[0:f:0:0:f:0:0:0]/"});
614 checkURLDifferences("http://[0:0:f:0:0:f:0:0]",
615 {"http", "", "", "[::f:0:0:f:0:0]", 0, "/", "", "", "http://[::f:0:0:f:0:0]/"},
616 {"http", "", "", "[0:0:f:0:0:f:0:0]", 0, "/", "", "", "http://[0:0:f:0:0:f:0:0]/"});
617 checkURLDifferences("http://[a:0:0:0:b:c::d]",
618 {"http", "", "", "[a::b:c:0:d]", 0, "/", "", "", "http://[a::b:c:0:d]/"},
619 {"http", "", "", "[a:0:0:0:b:c::d]", 0, "/", "", "", "http://[a:0:0:0:b:c::d]/"});
620 checkURLDifferences("http://[::7f00:0001]/",
621 {"http", "", "", "[::7f00:1]", 0, "/", "", "", "http://[::7f00:1]/"},
622 {"http", "", "", "[::7f00:0001]", 0, "/", "", "", "http://[::7f00:0001]/"});
623 checkURLDifferences("http://[::7f00:00]/",
624 {"http", "", "", "[::7f00:0]", 0, "/", "", "", "http://[::7f00:0]/"},
625 {"http", "", "", "[::7f00:00]", 0, "/", "", "", "http://[::7f00:00]/"});
626 checkURLDifferences("http://[::0:7f00:0001]/",
627 {"http", "", "", "[::7f00:1]", 0, "/", "", "", "http://[::7f00:1]/"},
628 {"http", "", "", "[::0:7f00:0001]", 0, "/", "", "", "http://[::0:7f00:0001]/"});
629 checkURLDifferences("http://127.00.0.1/",
630 {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"},
631 {"http", "", "", "127.00.0.1", 0, "/", "", "", "http://127.00.0.1/"});
632 checkURLDifferences("http://127.0.0.01/",
633 {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"},
634 {"http", "", "", "127.0.0.01", 0, "/", "", "", "http://127.0.0.01/"});
635 checkURLDifferences("http://example.com/path1/.%2e",
636 {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"},
637 {"http", "", "", "example.com", 0, "/path1/.%2e", "", "", "http://example.com/path1/.%2e"});
638 checkURLDifferences("http://example.com/path1/.%2E",
639 {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"},
640 {"http", "", "", "example.com", 0, "/path1/.%2E", "", "", "http://example.com/path1/.%2E"});
641 checkURLDifferences("http://example.com/path1/.%2E/",
642 {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"},
643 {"http", "", "", "example.com", 0, "/path1/.%2E/", "", "", "http://example.com/path1/.%2E/"});
644 checkURLDifferences("http://example.com/path1/%2e.",
645 {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"},
646 {"http", "", "", "example.com", 0, "/path1/%2e.", "", "", "http://example.com/path1/%2e."});
647 checkURLDifferences("http://example.com/path1/%2E%2e",
648 {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"},
649 {"http", "", "", "example.com", 0, "/path1/%2E%2e", "", "", "http://example.com/path1/%2E%2e"});
650 checkURLDifferences("http://example.com/path1/%2e",
651 {"http", "", "", "example.com", 0, "/path1/", "", "", "http://example.com/path1/"},
652 {"http", "", "", "example.com", 0, "/path1/%2e", "", "", "http://example.com/path1/%2e"});
653 checkURLDifferences("http://example.com/path1/%2E",
654 {"http", "", "", "example.com", 0, "/path1/", "", "", "http://example.com/path1/"},
655 {"http", "", "", "example.com", 0, "/path1/%2E", "", "", "http://example.com/path1/%2E"});
656 checkURLDifferences("http://example.com/path1/%2E/",
657 {"http", "", "", "example.com", 0, "/path1/", "", "", "http://example.com/path1/"},
658 {"http", "", "", "example.com", 0, "/path1/%2E/", "", "", "http://example.com/path1/%2E/"});
659 checkURLDifferences("http://example.com/path1/path2/%2e?query",
660 {"http", "", "", "example.com", 0, "/path1/path2/", "query", "", "http://example.com/path1/path2/?query"},
661 {"http", "", "", "example.com", 0, "/path1/path2/%2e", "query", "", "http://example.com/path1/path2/%2e?query"});
662 checkURLDifferences("http://example.com/path1/path2/%2e%2e?query",
663 {"http", "", "", "example.com", 0, "/path1/", "query", "", "http://example.com/path1/?query"},
664 {"http", "", "", "example.com", 0, "/path1/path2/%2e%2e", "query", "", "http://example.com/path1/path2/%2e%2e?query"});
665 checkURLDifferences("http://example.com/path1/path2/%2e#fragment",
666 {"http", "", "", "example.com", 0, "/path1/path2/", "", "fragment", "http://example.com/path1/path2/#fragment"},
667 {"http", "", "", "example.com", 0, "/path1/path2/%2e", "", "fragment", "http://example.com/path1/path2/%2e#fragment"});
668 checkURLDifferences("http://example.com/path1/path2/%2e%2e#fragment",
669 {"http", "", "", "example.com", 0, "/path1/", "", "fragment", "http://example.com/path1/#fragment"},
670 {"http", "", "", "example.com", 0, "/path1/path2/%2e%2e", "", "fragment", "http://example.com/path1/path2/%2e%2e#fragment"});
671 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"});
672 checkURLDifferences("file://[0:a:0:0:b:c:0:0]/path",
673 {"file", "", "", "[0:a::b:c:0:0]", 0, "/path", "", "", "file://[0:a::b:c:0:0]/path"},
674 {"file", "", "", "[0:a:0:0:b:c:0:0]", 0, "/path", "", "", "file://[0:a:0:0:b:c:0:0]/path"});
675 checkURLDifferences("http://",
676 {"", "", "", "", 0, "", "", "", "http://"},
677 {"http", "", "", "", 0, "/", "", "", "http:/"});
678 checkRelativeURLDifferences("//", "https://www.webkit.org/path",
679 {"", "", "", "", 0, "", "", "", "//"},
680 {"https", "", "", "", 0, "/", "", "", "https:/"});
681 checkURLDifferences("http://127.0.0.1:65536/path",
682 {"", "", "", "", 0, "", "", "", "http://127.0.0.1:65536/path"},
683 {"http", "", "", "127.0.0.1", 0, "/path", "", "", "http://127.0.0.1:65536/path"});
684 checkURLDifferences("http://host:65536",
685 {"", "", "", "", 0, "", "", "", "http://host:65536"},
686 {"http", "", "", "host", 0, "/", "", "", "http://host:65536/"});
687 checkURLDifferences("http://127.0.0.1:65536",
688 {"", "", "", "", 0, "", "", "", "http://127.0.0.1:65536"},
689 {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1:65536/"});
690 checkURLDifferences("http://[0:f::f:f:0:0]:65536",
691 {"", "", "", "", 0, "", "", "", "http://[0:f::f:f:0:0]:65536"},
692 {"http", "", "", "[0:f::f:f:0:0]", 0, "/", "", "", "http://[0:f::f:f:0:0]:65536/"});
693 checkRelativeURLDifferences(":foo.com\\", "notspecial://example.org/foo/bar",
694 {"notspecial", "", "", "example.org", 0, "/foo/:foo.com\\", "", "", "notspecial://example.org/foo/:foo.com\\"},
695 {"notspecial", "", "", "example.org", 0, "/foo/:foo.com/", "", "", "notspecial://example.org/foo/:foo.com/"});
696 checkURL("sc://pa", {"sc", "", "", "pa", 0, "", "", "", "sc://pa"});
697 checkRelativeURLDifferences("notspecial:\\\\foo.com\\", "http://example.org/foo/bar",
698 {"notspecial", "", "", "", 0, "\\\\foo.com\\", "", "", "notspecial:\\\\foo.com\\"},
699 {"notspecial", "", "", "foo.com", 0, "/", "", "", "notspecial://foo.com/"});
700 checkRelativeURLDifferences("notspecial:\\\\foo.com/", "http://example.org/foo/bar",
701 {"notspecial", "", "", "", 0, "\\\\foo.com/", "", "", "notspecial:\\\\foo.com/"},
702 {"notspecial", "", "", "foo.com", 0, "/", "", "", "notspecial://foo.com/"});
703 checkRelativeURLDifferences("notspecial:\\\\foo.com", "http://example.org/foo/bar",
704 {"notspecial", "", "", "", 0, "\\\\foo.com", "", "", "notspecial:\\\\foo.com"},
705 {"notspecial", "", "", "foo.com", 0, "", "", "", "notspecial://foo.com"});
706 checkURLDifferences("file://notuser:notpassword@test",
707 {"", "", "", "", 0, "", "", "", "file://notuser:notpassword@test"},
708 {"file", "notuser", "notpassword", "test", 0, "/", "", "", "file://notuser:notpassword@test/"});
709 checkURLDifferences("file://notuser:notpassword@test/",
710 {"", "", "", "", 0, "", "", "", "file://notuser:notpassword@test/"},
711 {"file", "notuser", "notpassword", "test", 0, "/", "", "", "file://notuser:notpassword@test/"});
712 checkRelativeURLDifferences("http:/", "about:blank",
713 {"", "", "", "", 0, "", "", "", "http:/"},
714 {"http", "", "", "", 0, "/", "", "", "http:/"});
715 checkRelativeURLDifferences("http:", "about:blank",
716 {"http", "", "", "", 0, "", "", "", "http:"},
717 {"http", "", "", "", 0, "/", "", "", "http:/"});
718 checkRelativeURLDifferences("http:/", "http://host",
719 {"", "", "", "", 0, "", "", "", "http:/"},
720 {"http", "", "", "", 0, "/", "", "", "http:/"});
721 checkURLDifferences("http:/",
722 {"", "", "", "", 0, "", "", "", "http:/"},
723 {"http", "", "", "", 0, "/", "", "", "http:/"});
724 checkURLDifferences("http:",
725 {"http", "", "", "", 0, "", "", "", "http:"},
726 {"http", "", "", "", 0, "/", "", "", "http:/"});
727 checkRelativeURLDifferences("http:/example.com/", "http://example.org/foo/bar",
728 {"http", "", "", "example.org", 0, "/example.com/", "", "", "http://example.org/example.com/"},
729 {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"});
731 // This behavior matches Chrome and Firefox, but not WebKit using URL::parse.
732 // The behavior of URL::parse is clearly wrong because reparsing file://path would make path the host.
733 // The spec is unclear.
734 checkURLDifferences("file:path",
735 {"file", "", "", "", 0, "/path", "", "", "file:///path"},
736 {"file", "", "", "", 0, "path", "", "", "file://path"});
737 checkURLDifferences("file:pAtH",
738 {"file", "", "", "", 0, "/pAtH", "", "", "file:///pAtH"},
739 {"file", "", "", "", 0, "pAtH", "", "", "file://pAtH"});
740 checkURLDifferences("file:pAtH/",
741 {"file", "", "", "", 0, "/pAtH/", "", "", "file:///pAtH/"},
742 {"file", "", "", "", 0, "pAtH/", "", "", "file://pAtH/"});
743 checkURLDifferences("http://example.com%A0",
744 {"", "", "", "", 0, "", "", "", "http://example.com%A0"},
745 {"http", "", "", "example.com%a0", 0, "/", "", "", "http://example.com%a0/"});
746 checkURLDifferences("http://%E2%98%83",
747 {"http", "", "", "xn--n3h", 0, "/", "", "", "http://xn--n3h/"},
748 {"http", "", "", "%e2%98%83", 0, "/", "", "", "http://%e2%98%83/"});
749 checkURLDifferences("http://host%73",
750 {"http", "", "", "hosts", 0, "/", "", "", "http://hosts/"},
751 {"http", "", "", "host%73", 0, "/", "", "", "http://host%73/"});
752 checkURLDifferences("http://host%53",
753 {"http", "", "", "hosts", 0, "/", "", "", "http://hosts/"},
754 {"http", "", "", "host%53", 0, "/", "", "", "http://host%53/"});
755 checkURLDifferences("http://%",
756 {"", "", "", "", 0, "", "", "", "http://%"},
757 {"http", "", "", "%", 0, "/", "", "", "http://%/"});
758 checkURLDifferences("http://%7",
759 {"", "", "", "", 0, "", "", "", "http://%7"},
760 {"http", "", "", "%7", 0, "/", "", "", "http://%7/"});
761 checkURLDifferences("http://%7s",
762 {"", "", "", "", 0, "", "", "", "http://%7s"},
763 {"http", "", "", "%7s", 0, "/", "", "", "http://%7s/"});
764 checkURLDifferences("http://%73",
765 {"http", "", "", "s", 0, "/", "", "", "http://s/"},
766 {"http", "", "", "%73", 0, "/", "", "", "http://%73/"});
767 checkURLDifferences("http://abcdefg%",
768 {"", "", "", "", 0, "", "", "", "http://abcdefg%"},
769 {"http", "", "", "abcdefg%", 0, "/", "", "", "http://abcdefg%/"});
770 checkURLDifferences("http://abcd%7Xefg",
771 {"", "", "", "", 0, "", "", "", "http://abcd%7Xefg"},
772 {"http", "", "", "abcd%7xefg", 0, "/", "", "", "http://abcd%7xefg/"});
775 // URLParser matches Chrome and the spec, but not URL::parse or Firefox.
776 checkURLDifferences(utf16String(u"http://0Xc0.0250.01"),
777 {"http", "", "", "192.168.0.1", 0, "/", "", "", "http://192.168.0.1/"},
778 {"http", "", "", "0xc0.0250.01", 0, "/", "", "", "http://0xc0.0250.01/"});
780 checkURL("http://host/path%2e.%2E", {"http", "", "", "host", 0, "/path%2e.%2E", "", "", "http://host/path%2e.%2E"});
782 checkRelativeURLDifferences(utf16String(u"http://foo:💩@example.com/bar"), "http://other.com/",
783 {"http", "foo", utf16String(u"💩"), "example.com", 0, "/bar", "", "", "http://foo:%F0%9F%92%A9@example.com/bar"},
784 {"", "", "", "", 0, "", "", "", utf16String(u"http://foo:💩@example.com/bar")}, testTabsValueForSurrogatePairs);
785 checkRelativeURLDifferences("http://&a:foo(b]c@d:2/", "http://example.org/foo/bar",
786 {"http", "&a", "foo(b]c", "d", 2, "/", "", "", "http://&a:foo(b%5Dc@d:2/"},
787 {"", "", "", "", 0, "", "", "", "http://&a:foo(b]c@d:2/"});
788 checkRelativeURLDifferences("http://`{}:`{}@h/`{}?`{}", "http://doesnotmatter/",
789 {"http", "`{}", "`{}", "h", 0, "/%60%7B%7D", "`{}", "", "http://%60%7B%7D:%60%7B%7D@h/%60%7B%7D?`{}"},
790 {"", "", "", "", 0, "", "", "", "http://`{}:`{}@h/`{}?`{}"});
791 checkURLDifferences("http://[0:f::f::f]",
792 {"", "", "", "", 0, "" , "", "", "http://[0:f::f::f]"},
793 {"http", "", "", "[0:f::f::f]", 0, "/" , "", "", "http://[0:f::f::f]/"});
794 checkURLDifferences("http://123",
795 {"http", "", "", "0.0.0.123", 0, "/", "", "", "http://0.0.0.123/"},
796 {"http", "", "", "123", 0, "/", "", "", "http://123/"});
797 checkURLDifferences("http://123.234/",
798 {"http", "", "", "123.0.0.234", 0, "/", "", "", "http://123.0.0.234/"},
799 {"http", "", "", "123.234", 0, "/", "", "", "http://123.234/"});
800 checkURLDifferences("http://123.234.012",
801 {"http", "", "", "123.234.0.10", 0, "/", "", "", "http://123.234.0.10/"},
802 {"http", "", "", "123.234.012", 0, "/", "", "", "http://123.234.012/"});
803 checkURLDifferences("http://123.234.12",
804 {"http", "", "", "123.234.0.12", 0, "/", "", "", "http://123.234.0.12/"},
805 {"http", "", "", "123.234.12", 0, "/", "", "", "http://123.234.12/"});
806 checkRelativeURLDifferences("file:c:\\foo\\bar.html", "file:///tmp/mock/path",
807 {"file", "", "", "", 0, "/c:/foo/bar.html", "", "", "file:///c:/foo/bar.html"},
808 {"file", "", "", "", 0, "/tmp/mock/c:/foo/bar.html", "", "", "file:///tmp/mock/c:/foo/bar.html"});
809 checkRelativeURLDifferences(" File:c|////foo\\bar.html", "file:///tmp/mock/path",
810 {"file", "", "", "", 0, "/c:////foo/bar.html", "", "", "file:///c:////foo/bar.html"},
811 {"file", "", "", "", 0, "/tmp/mock/c|////foo/bar.html", "", "", "file:///tmp/mock/c|////foo/bar.html"});
812 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",
813 {"file", "", "", "", 0, "/c:////foo/bar.html", "", "", "file:///c:////foo/bar.html"},
814 {"file", "", "", "", 0, "/tmp/mock/c|////foo/bar.html", "", "", "file:///tmp/mock/c|////foo/bar.html"});
815 checkRelativeURLDifferences("C|/foo/bar", "file:///tmp/mock/path",
816 {"file", "", "", "", 0, "/C:/foo/bar", "", "", "file:///C:/foo/bar"},
817 {"file", "", "", "", 0, "/tmp/mock/C|/foo/bar", "", "", "file:///tmp/mock/C|/foo/bar"});
818 checkRelativeURLDifferences("/C|/foo/bar", "file:///tmp/mock/path",
819 {"file", "", "", "", 0, "/C:/foo/bar", "", "", "file:///C:/foo/bar"},
820 {"file", "", "", "", 0, "/C|/foo/bar", "", "", "file:///C|/foo/bar"});
821 checkRelativeURLDifferences("https://@test@test@example:800/", "http://doesnotmatter/",
822 {"https", "@test@test", "", "example", 800, "/", "", "", "https://%40test%40test@example:800/"},
823 {"", "", "", "", 0, "", "", "", "https://@test@test@example:800/"});
824 checkRelativeURLDifferences("https://@test@test@example:800/path@end", "http://doesnotmatter/",
825 {"https", "@test@test", "", "example", 800, "/path@end", "", "", "https://%40test%40test@example:800/path@end"},
826 {"", "", "", "", 0, "", "", "", "https://@test@test@example:800/path@end"});
827 checkURLDifferences("notspecial://@test@test@example:800/path@end",
828 {"notspecial", "@test@test", "", "example", 800, "/path@end", "", "", "notspecial://%40test%40test@example:800/path@end"},
829 {"", "", "", "", 0, "", "", "", "notspecial://@test@test@example:800/path@end"});
830 checkURLDifferences("notspecial://@test@test@example:800\\path@end",
831 {"notspecial", "@test@test@example", "800\\path", "end", 0, "", "", "", "notspecial://%40test%40test%40example:800%5Cpath@end"},
832 {"", "", "", "", 0, "", "", "", "notspecial://@test@test@example:800\\path@end"});
833 checkURLDifferences("http://%48OsT",
834 {"http", "", "", "host", 0, "/", "", "", "http://host/"},
835 {"http", "", "", "%48ost", 0, "/", "", "", "http://%48ost/"});
836 checkURLDifferences("http://h%4FsT",
837 {"http", "", "", "host", 0, "/", "", "", "http://host/"},
838 {"http", "", "", "h%4fst", 0, "/", "", "", "http://h%4fst/"});
839 checkURLDifferences("http://h%4fsT",
840 {"http", "", "", "host", 0, "/", "", "", "http://host/"},
841 {"http", "", "", "h%4fst", 0, "/", "", "", "http://h%4fst/"});
842 checkURLDifferences("http://h%6fsT",
843 {"http", "", "", "host", 0, "/", "", "", "http://host/"},
844 {"http", "", "", "h%6fst", 0, "/", "", "", "http://h%6fst/"});
845 checkURLDifferences("http://host/`",
846 {"http", "", "", "host", 0, "/%60", "", "", "http://host/%60"},
847 {"http", "", "", "host", 0, "/`", "", "", "http://host/`"});
848 checkURLDifferences("http://://",
849 {"", "", "", "", 0, "", "", "", "http://://"},
850 {"http", "", "", "", 0, "//", "", "", "http://://"});
851 checkURLDifferences("http://:123?",
852 {"", "", "", "", 0, "", "", "", "http://:123?"},
853 {"http", "", "", "", 123, "/", "", "", "http://:123/?"});
854 checkURLDifferences("http:/:",
855 {"", "", "", "", 0, "", "", "", "http:/:"},
856 {"http", "", "", "", 0, "/", "", "", "http://:/"});
857 checkURLDifferences("asdf://:",
858 {"", "", "", "", 0, "", "", "", "asdf://:"},
859 {"asdf", "", "", "", 0, "", "", "", "asdf://:"});
860 checkURLDifferences("http://:",
861 {"", "", "", "", 0, "", "", "", "http://:"},
862 {"http", "", "", "", 0, "/", "", "", "http://:/"});
863 checkURLDifferences("http:##foo",
864 {"", "", "", "", 0, "", "", "", "http:##foo"},
865 {"http", "", "", "", 0, "/", "", "#foo", "http:/##foo"});
866 checkURLDifferences("http:??bar",
867 {"", "", "", "", 0, "", "", "", "http:??bar"},
868 {"http", "", "", "", 0, "/", "?bar", "", "http:/??bar"});
869 checkURL("asdf:##foo", {"asdf", "", "", "", 0, "", "", "#foo", "asdf:##foo"});
870 checkURL("asdf:??bar", {"asdf", "", "", "", 0, "", "?bar", "", "asdf:??bar"});
871 checkRelativeURLDifferences("//C|/foo/bar", "file:///tmp/mock/path",
872 {"file", "", "", "", 0, "/C:/foo/bar", "", "", "file:///C:/foo/bar"},
873 {"", "", "", "", 0, "", "", "", "//C|/foo/bar"});
874 checkRelativeURLDifferences("//C:/foo/bar", "file:///tmp/mock/path",
875 {"file", "", "", "", 0, "/C:/foo/bar", "", "", "file:///C:/foo/bar"},
876 {"file", "", "", "c", 0, "/foo/bar", "", "", "file://c/foo/bar"});
877 checkRelativeURLDifferences("//C|?foo/bar", "file:///tmp/mock/path",
878 {"file", "", "", "", 0, "/C:/", "foo/bar", "", "file:///C:/?foo/bar"},
879 {"", "", "", "", 0, "", "", "", "//C|?foo/bar"});
880 checkRelativeURLDifferences("//C|#foo/bar", "file:///tmp/mock/path",
881 {"file", "", "", "", 0, "/C:/", "", "foo/bar", "file:///C:/#foo/bar"},
882 {"", "", "", "", 0, "", "", "", "//C|#foo/bar"});
883 checkURLDifferences("http://0xFFFFFfFF/",
884 {"http", "", "", "255.255.255.255", 0, "/", "", "", "http://255.255.255.255/"},
885 {"http", "", "", "0xffffffff", 0, "/", "", "", "http://0xffffffff/"});
886 checkURLDifferences("http://0000000000000000037777777777/",
887 {"http", "", "", "255.255.255.255", 0, "/", "", "", "http://255.255.255.255/"},
888 {"http", "", "", "0000000000000000037777777777", 0, "/", "", "", "http://0000000000000000037777777777/"});
889 checkURLDifferences("http://4294967295/",
890 {"http", "", "", "255.255.255.255", 0, "/", "", "", "http://255.255.255.255/"},
891 {"http", "", "", "4294967295", 0, "/", "", "", "http://4294967295/"});
892 checkURLDifferences("http://256/",
893 {"http", "", "", "0.0.1.0", 0, "/", "", "", "http://0.0.1.0/"},
894 {"http", "", "", "256", 0, "/", "", "", "http://256/"});
895 checkURLDifferences("http://256./",
896 {"http", "", "", "0.0.1.0", 0, "/", "", "", "http://0.0.1.0/"},
897 {"http", "", "", "256.", 0, "/", "", "", "http://256./"});
898 checkURLDifferences("http://123.256/",
899 {"http", "", "", "123.0.1.0", 0, "/", "", "", "http://123.0.1.0/"},
900 {"http", "", "", "123.256", 0, "/", "", "", "http://123.256/"});
901 checkURLDifferences("http://127.%.0.1/",
902 {"", "", "", "", 0, "", "", "", "http://127.%.0.1/"},
903 {"http", "", "", "127.%.0.1", 0, "/", "", "", "http://127.%.0.1/"});
904 checkURLDifferences("http://[1:2:3:4:5:6:7:8:]/",
905 {"", "", "", "", 0, "", "", "", "http://[1:2:3:4:5:6:7:8:]/"},
906 {"http", "", "", "[1:2:3:4:5:6:7:8:]", 0, "/", "", "", "http://[1:2:3:4:5:6:7:8:]/"});
907 checkURLDifferences("http://[:2:3:4:5:6:7:8:]/",
908 {"", "", "", "", 0, "", "", "", "http://[:2:3:4:5:6:7:8:]/"},
909 {"http", "", "", "[:2:3:4:5:6:7:8:]", 0, "/", "", "", "http://[:2:3:4:5:6:7:8:]/"});
910 checkURLDifferences("http://[1:2:3:4:5:6:7::]/",
911 {"http", "", "", "[1:2:3:4:5:6:7:0]", 0, "/", "", "", "http://[1:2:3:4:5:6:7:0]/"},
912 {"http", "", "", "[1:2:3:4:5:6:7::]", 0, "/", "", "", "http://[1:2:3:4:5:6:7::]/"});
913 checkURLDifferences("http://[1:2:3:4:5:6:7:::]/",
914 {"", "", "", "", 0, "", "", "", "http://[1:2:3:4:5:6:7:::]/"},
915 {"http", "", "", "[1:2:3:4:5:6:7:::]", 0, "/", "", "", "http://[1:2:3:4:5:6:7:::]/"});
916 checkURLDifferences("http://127.0.0.1~/",
917 {"http", "", "", "127.0.0.1~", 0, "/", "", "", "http://127.0.0.1~/"},
918 {"", "", "", "", 0, "", "", "", "http://127.0.0.1~/"});
919 checkURLDifferences("http://127.0.1~/",
920 {"http", "", "", "127.0.1~", 0, "/", "", "", "http://127.0.1~/"},
921 {"", "", "", "", 0, "", "", "", "http://127.0.1~/"});
922 checkURLDifferences("http://127.0.1./",
923 {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"},
924 {"http", "", "", "127.0.1.", 0, "/", "", "", "http://127.0.1./"});
925 checkURLDifferences("http://127.0.1.~/",
926 {"http", "", "", "127.0.1.~", 0, "/", "", "", "http://127.0.1.~/"},
927 {"", "", "", "", 0, "", "", "", "http://127.0.1.~/"});
928 checkURLDifferences("http://127.0.1.~",
929 {"http", "", "", "127.0.1.~", 0, "/", "", "", "http://127.0.1.~/"},
930 {"", "", "", "", 0, "", "", "", "http://127.0.1.~"});
931 checkRelativeURLDifferences("http://f:000/c", "http://example.org/foo/bar",
932 {"http", "", "", "f", 0, "/c", "", "", "http://f:0/c"},
933 {"http", "", "", "f", 0, "/c", "", "", "http://f:000/c"});
934 checkRelativeURLDifferences("http://f:010/c", "http://example.org/foo/bar",
935 {"http", "", "", "f", 10, "/c", "", "", "http://f:10/c"},
936 {"http", "", "", "f", 10, "/c", "", "", "http://f:010/c"});
937 checkURL("notspecial://HoSt", {"notspecial", "", "", "HoSt", 0, "", "", "", "notspecial://HoSt"});
938 checkURL("notspecial://H%6FSt", {"notspecial", "", "", "H%6FSt", 0, "", "", "", "notspecial://H%6FSt"});
939 checkURL("notspecial://H%4fSt", {"notspecial", "", "", "H%4fSt", 0, "", "", "", "notspecial://H%4fSt"});
940 checkURLDifferences(utf16String(u"notspecial://H😍ßt"),
941 {"notspecial", "", "", "H%F0%9F%98%8D%C3%9Ft", 0, "", "", "", "notspecial://H%F0%9F%98%8D%C3%9Ft"},
942 {"notspecial", "", "", "xn--hsst-qc83c", 0, "", "", "", "notspecial://xn--hsst-qc83c"}, testTabsValueForSurrogatePairs);
943 checkURLDifferences("http://[ffff:aaaa:cccc:eeee:bbbb:dddd:255.255.255.255]/",
944 {"http", "", "", "[ffff:aaaa:cccc:eeee:bbbb:dddd:ffff:ffff]", 0, "/", "", "", "http://[ffff:aaaa:cccc:eeee:bbbb:dddd:ffff:ffff]/"},
945 {"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);
946 checkURLDifferences("http://[::123.234.12.210]/",
947 {"http", "", "", "[::7bea:cd2]", 0, "/", "", "", "http://[::7bea:cd2]/"},
948 {"http", "", "", "[::123.234.12.210]", 0, "/", "", "", "http://[::123.234.12.210]/"});
949 checkURLDifferences("http://[::a:255.255.255.255]/",
950 {"http", "", "", "[::a:ffff:ffff]", 0, "/", "", "", "http://[::a:ffff:ffff]/"},
951 {"http", "", "", "[::a:255.255.255.255]", 0, "/", "", "", "http://[::a:255.255.255.255]/"});
952 checkURLDifferences("http://[::0.00.255.255]/",
953 {"", "", "", "", 0, "", "", "", "http://[::0.00.255.255]/"},
954 {"http", "", "", "[::0.00.255.255]", 0, "/", "", "", "http://[::0.00.255.255]/"});
955 checkURLDifferences("http://[::0.0.255.255]/",
956 {"http", "", "", "[::ffff]", 0, "/", "", "", "http://[::ffff]/"},
957 {"http", "", "", "[::0.0.255.255]", 0, "/", "", "", "http://[::0.0.255.255]/"});
958 checkURLDifferences("http://[::0:1.0.255.255]/",
959 {"http", "", "", "[::100:ffff]", 0, "/", "", "", "http://[::100:ffff]/"},
960 {"http", "", "", "[::0:1.0.255.255]", 0, "/", "", "", "http://[::0:1.0.255.255]/"});
961 checkURLDifferences("http://[::A:1.0.255.255]/",
962 {"http", "", "", "[::a:100:ffff]", 0, "/", "", "", "http://[::a:100:ffff]/"},
963 {"http", "", "", "[::a:1.0.255.255]", 0, "/", "", "", "http://[::a:1.0.255.255]/"});
964 checkURLDifferences("http://[:127.0.0.1]",
965 {"", "", "", "", 0, "", "", "", "http://[:127.0.0.1]"},
966 {"http", "", "", "[:127.0.0.1]", 0, "/", "", "", "http://[:127.0.0.1]/"});
967 checkURLDifferences("http://[127.0.0.1]",
968 {"", "", "", "", 0, "", "", "", "http://[127.0.0.1]"},
969 {"http", "", "", "[127.0.0.1]", 0, "/", "", "", "http://[127.0.0.1]/"});
970 checkURLDifferences("http://[a:b:c:d:e:f:127.0.0.1]",
971 {"http", "", "", "[a:b:c:d:e:f:7f00:1]", 0, "/", "", "", "http://[a:b:c:d:e:f:7f00:1]/"},
972 {"http", "", "", "[a:b:c:d:e:f:127.0.0.1]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0.0.1]/"});
973 checkURLDifferences("http://[a:b:c:d:e:f:127.0.0.101]",
974 {"http", "", "", "[a:b:c:d:e:f:7f00:65]", 0, "/", "", "", "http://[a:b:c:d:e:f:7f00:65]/"},
975 {"http", "", "", "[a:b:c:d:e:f:127.0.0.101]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0.0.101]/"});
976 checkURLDifferences("http://[::a:b:c:d:e:f:127.0.0.1]",
977 {"", "", "", "", 0, "", "", "", "http://[::a:b:c:d:e:f:127.0.0.1]"},
978 {"http", "", "", "[::a:b:c:d:e:f:127.0.0.1]", 0, "/", "", "", "http://[::a:b:c:d:e:f:127.0.0.1]/"});
979 checkURLDifferences("http://[a:b::c:d:e:f:127.0.0.1]",
980 {"", "", "", "", 0, "", "", "", "http://[a:b::c:d:e:f:127.0.0.1]"},
981 {"http", "", "", "[a:b::c:d:e:f:127.0.0.1]", 0, "/", "", "", "http://[a:b::c:d:e:f:127.0.0.1]/"});
982 checkURLDifferences("http://[a:b:c:d:e:127.0.0.1]",
983 {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:127.0.0.1]"},
984 {"http", "", "", "[a:b:c:d:e:127.0.0.1]", 0, "/", "", "", "http://[a:b:c:d:e:127.0.0.1]/"});
985 checkURLDifferences("http://[a:b:c:d:e:f:127.0.0.0.1]",
986 {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f:127.0.0.0.1]"},
987 {"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]/"});
988 checkURLDifferences("http://[a:b:c:d:e:f:127.0.1]",
989 {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f:127.0.1]"},
990 {"http", "", "", "[a:b:c:d:e:f:127.0.1]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0.1]/"});
991 checkURLDifferences("http://[a:b:c:d:e:f:127.0.0.011]", // Chrome treats this as octal, Firefox and the spec fail
992 {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f:127.0.0.011]"},
993 {"http", "", "", "[a:b:c:d:e:f:127.0.0.011]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0.0.011]/"});
994 checkURLDifferences("http://[a:b:c:d:e:f:127.0.00.1]",
995 {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f:127.0.00.1]"},
996 {"http", "", "", "[a:b:c:d:e:f:127.0.00.1]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0.00.1]/"});
997 checkURLDifferences("http://[a:b:c:d:e:f:127.0.0.1.]",
998 {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f:127.0.0.1.]"},
999 {"http", "", "", "[a:b:c:d:e:f:127.0.0.1.]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0.0.1.]/"});
1000 checkURLDifferences("http://[a:b:c:d:e:f:127.0..0.1]",
1001 {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f:127.0..0.1]"},
1002 {"http", "", "", "[a:b:c:d:e:f:127.0..0.1]", 0, "/", "", "", "http://[a:b:c:d:e:f:127.0..0.1]/"});
1003 checkURLDifferences("http://[a:b:c:d:e:f::127.0.0.1]",
1004 {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f::127.0.0.1]"},
1005 {"http", "", "", "[a:b:c:d:e:f::127.0.0.1]", 0, "/", "", "", "http://[a:b:c:d:e:f::127.0.0.1]/"});
1006 checkURLDifferences("http://[a:b:c:d:e::127.0.0.1]",
1007 {"http", "", "", "[a:b:c:d:e:0:7f00:1]", 0, "/", "", "", "http://[a:b:c:d:e:0:7f00:1]/"},
1008 {"http", "", "", "[a:b:c:d:e::127.0.0.1]", 0, "/", "", "", "http://[a:b:c:d:e::127.0.0.1]/"});
1009 checkURLDifferences("http://[a:b:c:d::e:127.0.0.1]",
1010 {"http", "", "", "[a:b:c:d:0:e:7f00:1]", 0, "/", "", "", "http://[a:b:c:d:0:e:7f00:1]/"},
1011 {"http", "", "", "[a:b:c:d::e:127.0.0.1]", 0, "/", "", "", "http://[a:b:c:d::e:127.0.0.1]/"});
1012 checkURLDifferences("http://[a:b:c:d:e:f::127.0.0.]",
1013 {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f::127.0.0.]"},
1014 {"http", "", "", "[a:b:c:d:e:f::127.0.0.]", 0, "/", "", "", "http://[a:b:c:d:e:f::127.0.0.]/"});
1015 checkURLDifferences("http://[a:b:c:d:e:f::127.0.0.256]",
1016 {"", "", "", "", 0, "", "", "", "http://[a:b:c:d:e:f::127.0.0.256]"},
1017 {"http", "", "", "[a:b:c:d:e:f::127.0.0.256]", 0, "/", "", "", "http://[a:b:c:d:e:f::127.0.0.256]/"});
1018 checkURLDifferences("http://123456", {"http", "", "", "0.1.226.64", 0, "/", "", "", "http://0.1.226.64/"}, {"http", "", "", "123456", 0, "/", "", "", "http://123456/"});
1019 checkURL("asdf://123456", {"asdf", "", "", "123456", 0, "", "", "", "asdf://123456"});
1020 checkURLDifferences("http://[0:0:0:0:a:b:c:d]",
1021 {"http", "", "", "[::a:b:c:d]", 0, "/", "", "", "http://[::a:b:c:d]/"},
1022 {"http", "", "", "[0:0:0:0:a:b:c:d]", 0, "/", "", "", "http://[0:0:0:0:a:b:c:d]/"});
1023 checkURLDifferences("asdf://[0:0:0:0:a:b:c:d]",
1024 {"asdf", "", "", "[::a:b:c:d]", 0, "", "", "", "asdf://[::a:b:c:d]"},
1025 {"asdf", "", "", "[0:0:0:0:a:b:c:d]", 0, "", "", "", "asdf://[0:0:0:0:a:b:c:d]"}, TestTabs::No);
1026 shouldFail("a://%:a");
1027 checkURL("a://%:/", {"a", "", "", "%", 0, "/", "", "", "a://%/"});
1028 checkURL("a://%:", {"a", "", "", "%", 0, "", "", "", "a://%"});
1029 checkURL("a://%:1/", {"a", "", "", "%", 1, "/", "", "", "a://%:1/"});
1030 checkURLDifferences("http://%:",
1031 {"", "", "", "", 0, "", "", "", "http://%:"},
1032 {"http", "", "", "%", 0, "/", "", "", "http://%/"});
1033 checkURL("a://123456", {"a", "", "", "123456", 0, "", "", "", "a://123456"});
1034 checkURL("a://123456:7", {"a", "", "", "123456", 7, "", "", "", "a://123456:7"});
1035 checkURL("a://123456:7/", {"a", "", "", "123456", 7, "/", "", "", "a://123456:7/"});
1036 checkURL("a://A", {"a", "", "", "A", 0, "", "", "", "a://A"});
1037 checkURL("a://A:2", {"a", "", "", "A", 2, "", "", "", "a://A:2"});
1038 checkURL("a://A:2/", {"a", "", "", "A", 2, "/", "", "", "a://A:2/"});
1039 checkURLDifferences(u8"asd://ß",
1040 {"asd", "", "", "%C3%83%C2%9F", 0, "", "", "", "asd://%C3%83%C2%9F"},
1041 {"", "", "", "", 0, "", "", "", "about:blank"}, TestTabs::No);
1042 checkURLDifferences(u8"asd://ß:4",
1043 {"asd", "", "", "%C3%83%C2%9F", 4, "", "", "", "asd://%C3%83%C2%9F:4"},
1044 {"", "", "", "", 0, "", "", "", "about:blank"}, TestTabs::No);
1045 checkURLDifferences(u8"asd://ß:4/",
1046 {"asd", "", "", "%C3%83%C2%9F", 4, "/", "", "", "asd://%C3%83%C2%9F:4/"},
1047 {"", "", "", "", 0, "", "", "", "about:blank"}, TestTabs::No);
1048 checkURLDifferences("a://[A::b]:4",
1049 {"a", "", "", "[a::b]", 4, "", "", "", "a://[a::b]:4"},
1050 {"a", "", "", "[A::b]", 4, "", "", "", "a://[A::b]:4"});
1051 shouldFail("http://[~]");
1052 shouldFail("a://[~]");
1053 checkRelativeURLDifferences("a://b", "//[aBc]",
1054 {"a", "", "", "b", 0, "", "", "", "a://b"},
1055 {"", "", "", "", 0, "", "", "", "a://b"});
1056 checkURL(utf16String(u"http://öbb.at"), {"http", "", "", "xn--bb-eka.at", 0, "/", "", "", "http://xn--bb-eka.at/"});
1057 checkURL(utf16String(u"http://ÖBB.at"), {"http", "", "", "xn--bb-eka.at", 0, "/", "", "", "http://xn--bb-eka.at/"});
1058 checkURL(utf16String(u"http://√.com"), {"http", "", "", "xn--19g.com", 0, "/", "", "", "http://xn--19g.com/"});
1059 checkURLDifferences(utf16String(u"http://faß.de"),
1060 {"http", "", "", "xn--fa-hia.de", 0, "/", "", "", "http://xn--fa-hia.de/"},
1061 {"http", "", "", "fass.de", 0, "/", "", "", "http://fass.de/"});
1062 checkURL(utf16String(u"http://ԛәлп.com"), {"http", "", "", "xn--k1ai47bhi.com", 0, "/", "", "", "http://xn--k1ai47bhi.com/"});
1063 checkURLDifferences(utf16String(u"http://Ⱥbby.com"),
1064 {"http", "", "", "xn--bby-iy0b.com", 0, "/", "", "", "http://xn--bby-iy0b.com/"},
1065 {"http", "", "", "xn--bby-spb.com", 0, "/", "", "", "http://xn--bby-spb.com/"});
1066 checkURLDifferences(utf16String(u"http://\u2132"),
1067 {"", "", "", "", 0, "", "", "", utf16String(u"http://Ⅎ")},
1068 {"http", "", "", "xn--f3g", 0, "/", "", "", "http://xn--f3g/"});
1069 checkURLDifferences(utf16String(u"http://\u05D9\u05B4\u05D5\u05D0\u05B8/"),
1070 {"http", "", "", "xn--cdbi5etas", 0, "/", "", "", "http://xn--cdbi5etas/"},
1071 {"", "", "", "", 0, "", "", "", "about:blank"}, TestTabs::No);
1072 checkURLDifferences(utf16String(u"http://bidirectional\u0786\u07AE\u0782\u07B0\u0795\u07A9\u0793\u07A6\u0783\u07AA/"),
1073 {"", "", "", "", 0, "", "", "", utf16String(u"http://bidirectionalކޮންޕީޓަރު/")},
1074 {"", "", "", "", 0, "", "", "", "about:blank"}, TestTabs::No);
1075 checkURLDifferences(utf16String(u"http://contextj\u200D"),
1076 {"", "", "", "", 0, "", "", "", utf16String(u"http://contextj\u200D")},
1077 {"http", "", "", "contextj", 0, "/", "", "", "http://contextj/"});
1078 checkURL(utf16String(u"http://contexto\u30FB"), {"http", "", "", "xn--contexto-wg5g", 0, "/", "", "", "http://xn--contexto-wg5g/"});
1079 checkURLDifferences(utf16String(u"http://\u321D\u321E/"),
1080 {"http", "", "", "xn--()()-bs0sc174agx4b", 0, "/", "", "", "http://xn--()()-bs0sc174agx4b/"},
1081 {"http", "", "", "xn--5mkc", 0, "/", "", "", "http://xn--5mkc/"});
1084 TEST_F(URLParserTest, DefaultPort)
1086 checkURL("FtP://host:21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"});
1087 checkURL("ftp://host:21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"});
1088 checkURL("f\ttp://host:21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"});
1089 checkURL("f\ttp://host\t:21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"});
1090 checkURL("f\ttp://host:\t21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"});
1091 checkURL("f\ttp://host:2\t1/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"});
1092 checkURL("f\ttp://host:21\t/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"});
1093 checkURL("ftp://host\t:21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"});
1094 checkURL("ftp://host:\t21/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"});
1095 checkURL("ftp://host:2\t1/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"});
1096 checkURL("ftp://host:21\t/", {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"});
1097 checkURL("ftp://host:22/", {"ftp", "", "", "host", 22, "/", "", "", "ftp://host:22/"});
1098 checkURLDifferences("ftp://host:21",
1099 {"ftp", "", "", "host", 0, "/", "", "", "ftp://host/"},
1100 {"ftp", "", "", "host", 0, "", "", "", "ftp://host"});
1101 checkURLDifferences("ftp://host:22",
1102 {"ftp", "", "", "host", 22, "/", "", "", "ftp://host:22/"},
1103 {"ftp", "", "", "host", 22, "", "", "", "ftp://host:22"});
1105 checkURL("gOpHeR://host:70/", {"gopher", "", "", "host", 0, "/", "", "", "gopher://host/"});
1106 checkURL("gopher://host:70/", {"gopher", "", "", "host", 0, "/", "", "", "gopher://host/"});
1107 checkURL("gopher://host:71/", {"gopher", "", "", "host", 71, "/", "", "", "gopher://host:71/"});
1108 // Spec, Chrome, Firefox, and URLParser have "/", URL::parse does not.
1109 // Spec, Chrome, URLParser, URL::parse recognize gopher default port, Firefox does not.
1110 checkURLDifferences("gopher://host:70",
1111 {"gopher", "", "", "host", 0, "/", "", "", "gopher://host/"},
1112 {"gopher", "", "", "host", 0, "", "", "", "gopher://host"});
1113 checkURLDifferences("gopher://host:71",
1114 {"gopher", "", "", "host", 71, "/", "", "", "gopher://host:71/"},
1115 {"gopher", "", "", "host", 71, "", "", "", "gopher://host:71"});
1117 checkURL("hTtP://host:80", {"http", "", "", "host", 0, "/", "", "", "http://host/"});
1118 checkURL("http://host:80", {"http", "", "", "host", 0, "/", "", "", "http://host/"});
1119 checkURL("http://host:80/", {"http", "", "", "host", 0, "/", "", "", "http://host/"});
1120 checkURL("http://host:81", {"http", "", "", "host", 81, "/", "", "", "http://host:81/"});
1121 checkURL("http://host:81/", {"http", "", "", "host", 81, "/", "", "", "http://host:81/"});
1123 checkURL("hTtPs://host:443", {"https", "", "", "host", 0, "/", "", "", "https://host/"});
1124 checkURL("https://host:443", {"https", "", "", "host", 0, "/", "", "", "https://host/"});
1125 checkURL("https://host:443/", {"https", "", "", "host", 0, "/", "", "", "https://host/"});
1126 checkURL("https://host:444", {"https", "", "", "host", 444, "/", "", "", "https://host:444/"});
1127 checkURL("https://host:444/", {"https", "", "", "host", 444, "/", "", "", "https://host:444/"});
1129 checkURL("wS://host:80/", {"ws", "", "", "host", 0, "/", "", "", "ws://host/"});
1130 checkURL("ws://host:80/", {"ws", "", "", "host", 0, "/", "", "", "ws://host/"});
1131 checkURL("ws://host:81/", {"ws", "", "", "host", 81, "/", "", "", "ws://host:81/"});
1132 // URLParser matches Chrome and Firefox, but not URL::parse
1133 checkURLDifferences("ws://host:80",
1134 {"ws", "", "", "host", 0, "/", "", "", "ws://host/"},
1135 {"ws", "", "", "host", 0, "", "", "", "ws://host"});
1136 checkURLDifferences("ws://host:81",
1137 {"ws", "", "", "host", 81, "/", "", "", "ws://host:81/"},
1138 {"ws", "", "", "host", 81, "", "", "", "ws://host:81"});
1140 checkURL("WsS://host:443/", {"wss", "", "", "host", 0, "/", "", "", "wss://host/"});
1141 checkURL("wss://host:443/", {"wss", "", "", "host", 0, "/", "", "", "wss://host/"});
1142 checkURL("wss://host:444/", {"wss", "", "", "host", 444, "/", "", "", "wss://host:444/"});
1143 // URLParser matches Chrome and Firefox, but not URL::parse
1144 checkURLDifferences("wss://host:443",
1145 {"wss", "", "", "host", 0, "/", "", "", "wss://host/"},
1146 {"wss", "", "", "host", 0, "", "", "", "wss://host"});
1147 checkURLDifferences("wss://host:444",
1148 {"wss", "", "", "host", 444, "/", "", "", "wss://host:444/"},
1149 {"wss", "", "", "host", 444, "", "", "", "wss://host:444"});
1151 checkURL("fTpS://host:990/", {"ftps", "", "", "host", 990, "/", "", "", "ftps://host:990/"});
1152 checkURL("ftps://host:990/", {"ftps", "", "", "host", 990, "/", "", "", "ftps://host:990/"});
1153 checkURL("ftps://host:991/", {"ftps", "", "", "host", 991, "/", "", "", "ftps://host:991/"});
1154 checkURL("ftps://host:990", {"ftps", "", "", "host", 990, "", "", "", "ftps://host:990"});
1155 checkURL("ftps://host:991", {"ftps", "", "", "host", 991, "", "", "", "ftps://host:991"});
1157 checkURL("uNkNoWn://host:80/", {"unknown", "", "", "host", 80, "/", "", "", "unknown://host:80/"});
1158 checkURL("unknown://host:80/", {"unknown", "", "", "host", 80, "/", "", "", "unknown://host:80/"});
1159 checkURL("unknown://host:81/", {"unknown", "", "", "host", 81, "/", "", "", "unknown://host:81/"});
1160 checkURL("unknown://host:80", {"unknown", "", "", "host", 80, "", "", "", "unknown://host:80"});
1161 checkURL("unknown://host:81", {"unknown", "", "", "host", 81, "", "", "", "unknown://host:81"});
1163 checkURL("file://host:0", {"file", "", "", "host", 0, "/", "", "", "file://host:0/"});
1164 checkURL("file://host:80", {"file", "", "", "host", 80, "/", "", "", "file://host:80/"});
1165 checkURL("file://host:80/path", {"file", "", "", "host", 80, "/path", "", "", "file://host:80/path"});
1166 checkURLDifferences("file://:80/path",
1167 {"", "", "", "", 0, "", "", "", "file://:80/path"},
1168 {"file", "", "", "", 80, "/path", "", "", "file://:80/path"});
1169 checkURLDifferences("file://:0/path",
1170 {"", "", "", "", 0, "", "", "", "file://:0/path"},
1171 {"file", "", "", "", 0, "/path", "", "", "file://:0/path"});
1174 TEST_F(URLParserTest, ParserFailures)
1179 shouldFail(String());
1180 shouldFail("", "about:blank");
1181 shouldFail(String(), "about:blank");
1182 shouldFail("http://127.0.0.1:abc");
1183 shouldFail("http://host:abc");
1184 shouldFail("http://:abc");
1185 shouldFail("http://a:@", "about:blank");
1186 shouldFail("http://:b@", "about:blank");
1187 shouldFail("http://:@", "about:blank");
1188 shouldFail("http://a:@");
1189 shouldFail("http://:b@");
1190 shouldFail("http://@");
1191 shouldFail("http://[0:f::f:f:0:0]:abc");
1192 shouldFail("../i", "sc:sd");
1193 shouldFail("../i", "sc:sd/sd");
1194 shouldFail("/i", "sc:sd");
1195 shouldFail("/i", "sc:sd/sd");
1196 shouldFail("?i", "sc:sd");
1197 shouldFail("?i", "sc:sd/sd");
1198 shouldFail("http://example example.com", "http://other.com/");
1199 shouldFail("http://[www.example.com]/", "about:blank");
1200 shouldFail("http://192.168.0.1 hello", "http://other.com/");
1201 shouldFail("http://[example.com]", "http://other.com/");
1202 shouldFail("i", "sc:sd");
1203 shouldFail("i", "sc:sd/sd");
1209 shouldFail("~", "about:blank");
1211 shouldFail("://:0/");
1212 shouldFail("://:0/", "");
1213 shouldFail("://:0/", "about:blank");
1214 shouldFail("about~");
1215 shouldFail("//C:asdf/foo/bar", "file:///tmp/mock/path");
1216 shouldFail("http://[1234::ab#]");
1217 shouldFail("http://[1234::ab/]");
1218 shouldFail("http://[1234::ab?]");
1219 shouldFail("http://[1234::ab@]");
1220 shouldFail("http://[1234::ab~]");
1221 shouldFail("http://[2001::1");
1222 shouldFail("http://4:b\xE1");
1223 shouldFail("http://[1:2:3:4:5:6:7:8~]/");
1224 shouldFail("http://[a:b:c:d:e:f:g:127.0.0.1]");
1225 shouldFail("http://[a:b:c:d:e:f:g:h:127.0.0.1]");
1226 shouldFail("http://[a:b:c:d:e:f:127.0.0.0x11]"); // Chrome treats this as hex, Firefox and the spec fail
1227 shouldFail("http://[a:b:c:d:e:f:127.0.-0.1]");
1228 shouldFail("asdf://space In\aHost");
1229 shouldFail("asdf://[0:0:0:0:a:b:c:d");
1232 // These are in the spec but not in the web platform tests.
1233 TEST_F(URLParserTest, AdditionalTests)
1235 checkURL("about:\a\aabc", {"about", "", "", "", 0, "%07%07abc", "", "", "about:%07%07abc"});
1236 checkURL("notspecial:\t\t\n\t", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"});
1237 checkURL("notspecial\t\t\n\t:\t\t\n\t/\t\t\n\t/\t\t\n\thost", {"notspecial", "", "", "host", 0, "", "", "", "notspecial://host"});
1238 checkRelativeURL("http:", "http://example.org/foo/bar?query#fragment", {"http", "", "", "example.org", 0, "/foo/bar", "query", "", "http://example.org/foo/bar?query"});
1239 checkRelativeURLDifferences("ws:", "http://example.org/foo/bar",
1240 {"ws", "", "", "", 0, "", "", "", "ws:"},
1241 {"ws", "", "", "", 0, "s:", "", "", "ws:s:"});
1242 checkRelativeURL("notspecial:", "http://example.org/foo/bar", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"});
1244 const wchar_t surrogateBegin = 0xD800;
1245 const wchar_t validSurrogateEnd = 0xDD55;
1246 const wchar_t invalidSurrogateEnd = 'A';
1247 checkURL(utf16String<12>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', surrogateBegin, validSurrogateEnd, '\0'}),
1248 {"http", "", "", "w", 0, "/%F0%90%85%95", "", "", "http://w/%F0%90%85%95"}, testTabsValueForSurrogatePairs);
1250 // URLParser matches Chrome and Firefox but not URL::parse.
1251 checkURLDifferences(utf16String<12>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', surrogateBegin, invalidSurrogateEnd}),
1252 {"http", "", "", "w", 0, "/%EF%BF%BDA", "", "", "http://w/%EF%BF%BDA"},
1253 {"http", "", "", "w", 0, "/%ED%A0%80A", "", "", "http://w/%ED%A0%80A"});
1254 checkURLDifferences(utf16String<13>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', '?', surrogateBegin, invalidSurrogateEnd, '\0'}),
1255 {"http", "", "", "w", 0, "/", "%EF%BF%BDA", "", "http://w/?%EF%BF%BDA"},
1256 {"http", "", "", "w", 0, "/", "%ED%A0%80A", "", "http://w/?%ED%A0%80A"});
1257 checkURLDifferences(utf16String<11>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', surrogateBegin, '\0'}),
1258 {"http", "", "", "w", 0, "/%EF%BF%BD", "", "", "http://w/%EF%BF%BD"},
1259 {"http", "", "", "w", 0, "/%ED%A0%80", "", "", "http://w/%ED%A0%80"});
1260 checkURLDifferences(utf16String<12>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', '?', surrogateBegin, '\0'}),
1261 {"http", "", "", "w", 0, "/", "%EF%BF%BD", "", "http://w/?%EF%BF%BD"},
1262 {"http", "", "", "w", 0, "/", "%ED%A0%80", "", "http://w/?%ED%A0%80"});
1263 checkURLDifferences(utf16String<13>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', '?', surrogateBegin, ' ', '\0'}),
1264 {"http", "", "", "w", 0, "/", "%EF%BF%BD", "", "http://w/?%EF%BF%BD"},
1265 {"http", "", "", "w", 0, "/", "%ED%A0%80", "", "http://w/?%ED%A0%80"});
1267 // FIXME: Write more invalid surrogate pair tests based on feedback from https://bugs.webkit.org/show_bug.cgi?id=162105
1270 TEST_F(URLParserTest, QueryEncoding)
1272 checkURL(utf16String(u"http://host?ß😍#ß😍"), UTF8Encoding(), {"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);
1274 TextEncoding latin1(String("latin1"));
1275 checkURL("http://host/?query with%20spaces", latin1, {"http", "", "", "host", 0, "/", "query%20with%20spaces", "", "http://host/?query%20with%20spaces"});
1276 checkURL("http://host/?query", latin1, {"http", "", "", "host", 0, "/", "query", "", "http://host/?query"});
1277 checkURL("http://host/?\tquery", latin1, {"http", "", "", "host", 0, "/", "query", "", "http://host/?query"});
1278 checkURL("http://host/?q\tuery", latin1, {"http", "", "", "host", 0, "/", "query", "", "http://host/?query"});
1279 checkURL("http://host/?query with SpAcEs#fragment", latin1, {"http", "", "", "host", 0, "/", "query%20with%20SpAcEs", "fragment", "http://host/?query%20with%20SpAcEs#fragment"});
1280 checkURL("http://host/?que\rry\t\r\n#fragment", latin1, {"http", "", "", "host", 0, "/", "query", "fragment", "http://host/?query#fragment"});
1282 TextEncoding unrecognized(String("unrecognized invalid encoding name"));
1283 checkURL("http://host/?query", unrecognized, {"http", "", "", "host", 0, "/", "", "", "http://host/?"});
1284 checkURL("http://host/?", unrecognized, {"http", "", "", "host", 0, "/", "", "", "http://host/?"});
1286 TextEncoding iso88591(String("ISO-8859-1"));
1287 String withUmlauts = utf16String<4>({0xDC, 0x430, 0x451, '\0'});
1288 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"});
1289 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"});
1290 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"});
1291 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"});
1292 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"});
1293 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"});
1294 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"});
1295 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"});
1296 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"});
1297 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"});
1298 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"});
1299 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"});
1301 checkURL("http://host/pa'th?qu'ery#fr'agment", UTF8Encoding(), {"http", "", "", "host", 0, "/pa'th", "qu%27ery", "fr'agment", "http://host/pa'th?qu%27ery#fr'agment"});
1302 checkURL("asdf://host/pa'th?qu'ery#fr'agment", UTF8Encoding(), {"asdf", "", "", "host", 0, "/pa'th", "qu'ery", "fr'agment", "asdf://host/pa'th?qu'ery#fr'agment"});
1303 checkURL("http://host/?query=foo'bar", UTF8Encoding(), {"http", "", "", "host", 0, "/", "query=foo%27bar", "", "http://host/?query=foo%27bar"});
1304 // FIXME: Add more tests with other encodings and things like non-ascii characters, emoji and unmatched surrogate pairs.
1307 } // namespace TestWebKitAPI