[email protected] | 51bcc5d | 2013-04-24 01:41:37 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
[email protected] | 07abf6ab | 2013-04-10 21:41:04 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 4 | |
viettrungluu | 4b691586 | 2014-10-16 03:42:49 | [diff] [blame] | 5 | #include "base/macros.h" |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 6 | #include "testing/gtest/include/gtest/gtest.h" |
[email protected] | 318076b | 2013-04-18 21:19:45 | [diff] [blame] | 7 | #include "url/gurl.h" |
| 8 | #include "url/url_canon.h" |
| 9 | #include "url/url_test_utils.h" |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 10 | |
[email protected] | 0318f92 | 2014-04-22 00:09:23 | [diff] [blame] | 11 | namespace url { |
| 12 | |
| 13 | using test_utils::WStringToUTF16; |
| 14 | using test_utils::ConvertUTF8ToUTF16; |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 15 | |
| 16 | namespace { |
| 17 | |
| 18 | template<typename CHAR> |
[email protected] | 0318f92 | 2014-04-22 00:09:23 | [diff] [blame] | 19 | void SetupReplacement( |
| 20 | void (Replacements<CHAR>::*func)(const CHAR*, const Component&), |
| 21 | Replacements<CHAR>* replacements, |
| 22 | const CHAR* str) { |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 23 | if (str) { |
[email protected] | 0318f92 | 2014-04-22 00:09:23 | [diff] [blame] | 24 | Component comp; |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 25 | if (str[0]) |
| 26 | comp.len = static_cast<int>(strlen(str)); |
| 27 | (replacements->*func)(str, comp); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | // Returns the canonicalized string for the given URL string for the |
| 32 | // GURLTest.Types test. |
| 33 | std::string TypesTestCase(const char* src) { |
| 34 | GURL gurl(src); |
| 35 | return gurl.possibly_invalid_spec(); |
| 36 | } |
| 37 | |
| 38 | } // namespace |
| 39 | |
[email protected] | 47e365de | 2014-05-02 00:02:25 | [diff] [blame] | 40 | // Different types of URLs should be handled differently, and handed off to |
| 41 | // different canonicalizers. |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 42 | TEST(GURLTest, Types) { |
| 43 | // URLs with unknown schemes should be treated as path URLs, even when they |
| 44 | // have things like "://". |
| 45 | EXPECT_EQ("something:///HOSTNAME.com/", |
| 46 | TypesTestCase("something:///HOSTNAME.com/")); |
| 47 | |
| 48 | // In the reverse, known schemes should always trigger standard URL handling. |
| 49 | EXPECT_EQ("http://hostname.com/", TypesTestCase("http:HOSTNAME.com")); |
| 50 | EXPECT_EQ("http://hostname.com/", TypesTestCase("http:/HOSTNAME.com")); |
| 51 | EXPECT_EQ("http://hostname.com/", TypesTestCase("http://HOSTNAME.com")); |
| 52 | EXPECT_EQ("http://hostname.com/", TypesTestCase("http:///HOSTNAME.com")); |
| 53 | |
| 54 | #ifdef WIN32 |
| 55 | // URLs that look like absolute Windows drive specs. |
| 56 | EXPECT_EQ("file:///C:/foo.txt", TypesTestCase("c:\\foo.txt")); |
| 57 | EXPECT_EQ("file:///Z:/foo.txt", TypesTestCase("Z|foo.txt")); |
| 58 | EXPECT_EQ("file://server/foo.txt", TypesTestCase("\\\\server\\foo.txt")); |
| 59 | EXPECT_EQ("file://server/foo.txt", TypesTestCase("//server/foo.txt")); |
| 60 | #endif |
| 61 | } |
| 62 | |
| 63 | // Test the basic creation and querying of components in a GURL. We assume |
| 64 | // the parser is already tested and works, so we are mostly interested if the |
| 65 | // object does the right thing with the results. |
| 66 | TEST(GURLTest, Components) { |
| 67 | GURL url(WStringToUTF16(L"http://user:[email protected]:99/foo;bar?q=a#ref")); |
| 68 | EXPECT_TRUE(url.is_valid()); |
| 69 | EXPECT_TRUE(url.SchemeIs("http")); |
| 70 | EXPECT_FALSE(url.SchemeIsFile()); |
| 71 | |
| 72 | // This is the narrow version of the URL, which should match the wide input. |
| 73 | EXPECT_EQ("http://user:[email protected]:99/foo;bar?q=a#ref", url.spec()); |
| 74 | |
| 75 | EXPECT_EQ("http", url.scheme()); |
| 76 | EXPECT_EQ("user", url.username()); |
| 77 | EXPECT_EQ("pass", url.password()); |
| 78 | EXPECT_EQ("google.com", url.host()); |
| 79 | EXPECT_EQ("99", url.port()); |
| 80 | EXPECT_EQ(99, url.IntPort()); |
| 81 | EXPECT_EQ("/foo;bar", url.path()); |
| 82 | EXPECT_EQ("q=a", url.query()); |
| 83 | EXPECT_EQ("ref", url.ref()); |
[email protected] | e9185c8 | 2014-04-18 10:06:50 | [diff] [blame] | 84 | |
| 85 | // Test parsing userinfo with special characters. |
| 86 | GURL url_special_pass("http://user:%40!$&'()*+,;=:@google.com:12345"); |
| 87 | EXPECT_TRUE(url_special_pass.is_valid()); |
| 88 | // GURL canonicalizes some delimiters. |
| 89 | EXPECT_EQ("%40!$&%27()*+,%3B%3D%3A", url_special_pass.password()); |
| 90 | EXPECT_EQ("google.com", url_special_pass.host()); |
| 91 | EXPECT_EQ("12345", url_special_pass.port()); |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | TEST(GURLTest, Empty) { |
| 95 | GURL url; |
| 96 | EXPECT_FALSE(url.is_valid()); |
| 97 | EXPECT_EQ("", url.spec()); |
| 98 | |
| 99 | EXPECT_EQ("", url.scheme()); |
| 100 | EXPECT_EQ("", url.username()); |
| 101 | EXPECT_EQ("", url.password()); |
| 102 | EXPECT_EQ("", url.host()); |
| 103 | EXPECT_EQ("", url.port()); |
[email protected] | 0318f92 | 2014-04-22 00:09:23 | [diff] [blame] | 104 | EXPECT_EQ(PORT_UNSPECIFIED, url.IntPort()); |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 105 | EXPECT_EQ("", url.path()); |
| 106 | EXPECT_EQ("", url.query()); |
| 107 | EXPECT_EQ("", url.ref()); |
| 108 | } |
| 109 | |
| 110 | TEST(GURLTest, Copy) { |
| 111 | GURL url(WStringToUTF16(L"http://user:[email protected]:99/foo;bar?q=a#ref")); |
| 112 | |
| 113 | GURL url2(url); |
| 114 | EXPECT_TRUE(url2.is_valid()); |
| 115 | |
| 116 | EXPECT_EQ("http://user:[email protected]:99/foo;bar?q=a#ref", url2.spec()); |
| 117 | EXPECT_EQ("http", url2.scheme()); |
| 118 | EXPECT_EQ("user", url2.username()); |
| 119 | EXPECT_EQ("pass", url2.password()); |
| 120 | EXPECT_EQ("google.com", url2.host()); |
| 121 | EXPECT_EQ("99", url2.port()); |
| 122 | EXPECT_EQ(99, url2.IntPort()); |
| 123 | EXPECT_EQ("/foo;bar", url2.path()); |
| 124 | EXPECT_EQ("q=a", url2.query()); |
| 125 | EXPECT_EQ("ref", url2.ref()); |
| 126 | |
| 127 | // Copying of invalid URL should be invalid |
| 128 | GURL invalid; |
| 129 | GURL invalid2(invalid); |
| 130 | EXPECT_FALSE(invalid2.is_valid()); |
| 131 | EXPECT_EQ("", invalid2.spec()); |
| 132 | EXPECT_EQ("", invalid2.scheme()); |
| 133 | EXPECT_EQ("", invalid2.username()); |
| 134 | EXPECT_EQ("", invalid2.password()); |
| 135 | EXPECT_EQ("", invalid2.host()); |
| 136 | EXPECT_EQ("", invalid2.port()); |
[email protected] | 0318f92 | 2014-04-22 00:09:23 | [diff] [blame] | 137 | EXPECT_EQ(PORT_UNSPECIFIED, invalid2.IntPort()); |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 138 | EXPECT_EQ("", invalid2.path()); |
| 139 | EXPECT_EQ("", invalid2.query()); |
| 140 | EXPECT_EQ("", invalid2.ref()); |
| 141 | } |
| 142 | |
[email protected] | 8093a31b | 2013-10-24 21:56:33 | [diff] [blame] | 143 | TEST(GURLTest, Assign) { |
| 144 | GURL url(WStringToUTF16(L"http://user:[email protected]:99/foo;bar?q=a#ref")); |
| 145 | |
| 146 | GURL url2; |
| 147 | url2 = url; |
| 148 | EXPECT_TRUE(url2.is_valid()); |
| 149 | |
| 150 | EXPECT_EQ("http://user:[email protected]:99/foo;bar?q=a#ref", url2.spec()); |
| 151 | EXPECT_EQ("http", url2.scheme()); |
| 152 | EXPECT_EQ("user", url2.username()); |
| 153 | EXPECT_EQ("pass", url2.password()); |
| 154 | EXPECT_EQ("google.com", url2.host()); |
| 155 | EXPECT_EQ("99", url2.port()); |
| 156 | EXPECT_EQ(99, url2.IntPort()); |
| 157 | EXPECT_EQ("/foo;bar", url2.path()); |
| 158 | EXPECT_EQ("q=a", url2.query()); |
| 159 | EXPECT_EQ("ref", url2.ref()); |
| 160 | |
| 161 | // Assignment of invalid URL should be invalid |
| 162 | GURL invalid; |
| 163 | GURL invalid2; |
| 164 | invalid2 = invalid; |
| 165 | EXPECT_FALSE(invalid2.is_valid()); |
| 166 | EXPECT_EQ("", invalid2.spec()); |
| 167 | EXPECT_EQ("", invalid2.scheme()); |
| 168 | EXPECT_EQ("", invalid2.username()); |
| 169 | EXPECT_EQ("", invalid2.password()); |
| 170 | EXPECT_EQ("", invalid2.host()); |
| 171 | EXPECT_EQ("", invalid2.port()); |
[email protected] | 0318f92 | 2014-04-22 00:09:23 | [diff] [blame] | 172 | EXPECT_EQ(PORT_UNSPECIFIED, invalid2.IntPort()); |
[email protected] | 8093a31b | 2013-10-24 21:56:33 | [diff] [blame] | 173 | EXPECT_EQ("", invalid2.path()); |
| 174 | EXPECT_EQ("", invalid2.query()); |
| 175 | EXPECT_EQ("", invalid2.ref()); |
| 176 | } |
| 177 | |
| 178 | // This is a regression test for http://crbug.com/309975 . |
| 179 | TEST(GURLTest, SelfAssign) { |
| 180 | GURL a("filesystem:http://example.com/temporary/"); |
| 181 | // This should not crash. |
| 182 | a = a; |
| 183 | } |
| 184 | |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 185 | TEST(GURLTest, CopyFileSystem) { |
| 186 | GURL url(WStringToUTF16(L"filesystem:https://user:[email protected]:99/t/foo;bar?q=a#ref")); |
| 187 | |
| 188 | GURL url2(url); |
| 189 | EXPECT_TRUE(url2.is_valid()); |
| 190 | |
| 191 | EXPECT_EQ("filesystem:https://user:[email protected]:99/t/foo;bar?q=a#ref", url2.spec()); |
| 192 | EXPECT_EQ("filesystem", url2.scheme()); |
| 193 | EXPECT_EQ("", url2.username()); |
| 194 | EXPECT_EQ("", url2.password()); |
| 195 | EXPECT_EQ("", url2.host()); |
| 196 | EXPECT_EQ("", url2.port()); |
[email protected] | 0318f92 | 2014-04-22 00:09:23 | [diff] [blame] | 197 | EXPECT_EQ(PORT_UNSPECIFIED, url2.IntPort()); |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 198 | EXPECT_EQ("/foo;bar", url2.path()); |
| 199 | EXPECT_EQ("q=a", url2.query()); |
| 200 | EXPECT_EQ("ref", url2.ref()); |
| 201 | |
| 202 | const GURL* inner = url2.inner_url(); |
| 203 | ASSERT_TRUE(inner); |
| 204 | EXPECT_EQ("https", inner->scheme()); |
| 205 | EXPECT_EQ("user", inner->username()); |
| 206 | EXPECT_EQ("pass", inner->password()); |
| 207 | EXPECT_EQ("google.com", inner->host()); |
| 208 | EXPECT_EQ("99", inner->port()); |
| 209 | EXPECT_EQ(99, inner->IntPort()); |
| 210 | EXPECT_EQ("/t", inner->path()); |
| 211 | EXPECT_EQ("", inner->query()); |
| 212 | EXPECT_EQ("", inner->ref()); |
| 213 | } |
| 214 | |
[email protected] | e9185c8 | 2014-04-18 10:06:50 | [diff] [blame] | 215 | TEST(GURLTest, IsValid) { |
| 216 | const char* valid_cases[] = { |
| 217 | "http://google.com", |
| 218 | "unknown://google.com", |
| 219 | "http://user:[email protected]", |
| 220 | "http://google.com:12345", |
| 221 | "http://google.com/path", |
| 222 | "http://google.com//path", |
| 223 | "http://google.com?k=v#fragment", |
| 224 | "http://user:[email protected]:12345/path?k=v#fragment", |
| 225 | "http:/path", |
| 226 | "http:path", |
| 227 | "://google.com", |
| 228 | }; |
viettrungluu | 4b691586 | 2014-10-16 03:42:49 | [diff] [blame] | 229 | for (size_t i = 0; i < arraysize(valid_cases); i++) { |
[email protected] | e9185c8 | 2014-04-18 10:06:50 | [diff] [blame] | 230 | EXPECT_TRUE(GURL(valid_cases[i]).is_valid()) |
| 231 | << "Case: " << valid_cases[i]; |
| 232 | } |
| 233 | |
| 234 | const char* invalid_cases[] = { |
| 235 | "http://?k=v", |
| 236 | "http:://google.com", |
| 237 | "http//google.com", |
| 238 | "http://google.com:12three45", |
| 239 | "path", |
| 240 | }; |
viettrungluu | 4b691586 | 2014-10-16 03:42:49 | [diff] [blame] | 241 | for (size_t i = 0; i < arraysize(invalid_cases); i++) { |
[email protected] | e9185c8 | 2014-04-18 10:06:50 | [diff] [blame] | 242 | EXPECT_FALSE(GURL(invalid_cases[i]).is_valid()) |
| 243 | << "Case: " << invalid_cases[i]; |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | TEST(GURLTest, ExtraSlashesBeforeAuthority) { |
| 248 | // According to RFC3986, the hier-part for URI with an authority must use only |
| 249 | // two slashes, GURL intentionally just ignores slashes more than 2 and parses |
| 250 | // the following part as an authority. |
| 251 | GURL url("http:///host"); |
| 252 | EXPECT_EQ("host", url.host()); |
| 253 | EXPECT_EQ("/", url.path()); |
| 254 | } |
| 255 | |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 256 | // Given an invalid URL, we should still get most of the components. |
[email protected] | e9185c8 | 2014-04-18 10:06:50 | [diff] [blame] | 257 | TEST(GURLTest, ComponentGettersWorkEvenForInvalidURL) { |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 258 | GURL url("http:google.com:foo"); |
| 259 | EXPECT_FALSE(url.is_valid()); |
| 260 | EXPECT_EQ("http://google.com:foo/", url.possibly_invalid_spec()); |
| 261 | |
| 262 | EXPECT_EQ("http", url.scheme()); |
| 263 | EXPECT_EQ("", url.username()); |
| 264 | EXPECT_EQ("", url.password()); |
| 265 | EXPECT_EQ("google.com", url.host()); |
| 266 | EXPECT_EQ("foo", url.port()); |
[email protected] | 0318f92 | 2014-04-22 00:09:23 | [diff] [blame] | 267 | EXPECT_EQ(PORT_INVALID, url.IntPort()); |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 268 | EXPECT_EQ("/", url.path()); |
| 269 | EXPECT_EQ("", url.query()); |
| 270 | EXPECT_EQ("", url.ref()); |
| 271 | } |
| 272 | |
| 273 | TEST(GURLTest, Resolve) { |
| 274 | // The tricky cases for relative URL resolving are tested in the |
| 275 | // canonicalizer unit test. Here, we just test that the GURL integration |
| 276 | // works properly. |
| 277 | struct ResolveCase { |
| 278 | const char* base; |
| 279 | const char* relative; |
| 280 | bool expected_valid; |
| 281 | const char* expected; |
| 282 | } resolve_cases[] = { |
| 283 | {"http://www.google.com/", "foo.html", true, "http://www.google.com/foo.html"}, |
| 284 | {"http://www.google.com/", "http://images.google.com/foo.html", true, "http://images.google.com/foo.html"}, |
| 285 | {"http://www.google.com/blah/bloo?c#d", "../../../hello/./world.html?a#b", true, "http://www.google.com/hello/world.html?a#b"}, |
| 286 | {"http://www.google.com/foo#bar", "#com", true, "http://www.google.com/foo#com"}, |
| 287 | {"http://www.google.com/", "Https:images.google.com", true, "https://images.google.com/"}, |
| 288 | // A non-standard base can be replaced with a standard absolute URL. |
| 289 | {"data:blahblah", "http://google.com/", true, "http://google.com/"}, |
| 290 | {"data:blahblah", "http:google.com", true, "http://google.com/"}, |
| 291 | // Filesystem URLs have different paths to test. |
| 292 | {"filesystem:http://www.google.com/type/", "foo.html", true, "filesystem:http://www.google.com/type/foo.html"}, |
| 293 | {"filesystem:http://www.google.com/type/", "../foo.html", true, "filesystem:http://www.google.com/type/foo.html"}, |
| 294 | }; |
| 295 | |
viettrungluu | 4b691586 | 2014-10-16 03:42:49 | [diff] [blame] | 296 | for (size_t i = 0; i < arraysize(resolve_cases); i++) { |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 297 | // 8-bit code path. |
| 298 | GURL input(resolve_cases[i].base); |
| 299 | GURL output = input.Resolve(resolve_cases[i].relative); |
| 300 | EXPECT_EQ(resolve_cases[i].expected_valid, output.is_valid()) << i; |
| 301 | EXPECT_EQ(resolve_cases[i].expected, output.spec()) << i; |
| 302 | EXPECT_EQ(output.SchemeIsFileSystem(), output.inner_url() != NULL); |
| 303 | |
| 304 | // Wide code path. |
| 305 | GURL inputw(ConvertUTF8ToUTF16(resolve_cases[i].base)); |
| 306 | GURL outputw = |
| 307 | input.Resolve(ConvertUTF8ToUTF16(resolve_cases[i].relative)); |
| 308 | EXPECT_EQ(resolve_cases[i].expected_valid, outputw.is_valid()) << i; |
| 309 | EXPECT_EQ(resolve_cases[i].expected, outputw.spec()) << i; |
| 310 | EXPECT_EQ(outputw.SchemeIsFileSystem(), outputw.inner_url() != NULL); |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | TEST(GURLTest, GetOrigin) { |
| 315 | struct TestCase { |
| 316 | const char* input; |
| 317 | const char* expected; |
| 318 | } cases[] = { |
| 319 | {"http://www.google.com", "http://www.google.com/"}, |
| 320 | {"javascript:window.alert(\"hello,world\");", ""}, |
| 321 | {"http://user:[email protected]:21/blah#baz", "http://www.google.com:21/"}, |
| 322 | {"http://[email protected]", "http://www.google.com/"}, |
| 323 | {"http://:[email protected]", "http://www.google.com/"}, |
| 324 | {"http://:@www.google.com", "http://www.google.com/"}, |
| 325 | {"filesystem:http://www.google.com/temp/foo?q#b", "http://www.google.com/"}, |
| 326 | {"filesystem:http://user:[email protected]:21/blah#baz", "http://google.com:21/"}, |
| 327 | }; |
viettrungluu | 4b691586 | 2014-10-16 03:42:49 | [diff] [blame] | 328 | for (size_t i = 0; i < arraysize(cases); i++) { |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 329 | GURL url(cases[i].input); |
| 330 | GURL origin = url.GetOrigin(); |
| 331 | EXPECT_EQ(cases[i].expected, origin.spec()); |
| 332 | } |
| 333 | } |
| 334 | |
[email protected] | 6b775ee | 2014-03-20 20:27:25 | [diff] [blame] | 335 | TEST(GURLTest, GetAsReferrer) { |
| 336 | struct TestCase { |
| 337 | const char* input; |
| 338 | const char* expected; |
| 339 | } cases[] = { |
| 340 | {"http://www.google.com", "http://www.google.com/"}, |
| 341 | {"http://user:[email protected]:21/blah#baz", "http://www.google.com:21/blah"}, |
| 342 | {"http://[email protected]", "http://www.google.com/"}, |
| 343 | {"http://:[email protected]", "http://www.google.com/"}, |
| 344 | {"http://:@www.google.com", "http://www.google.com/"}, |
| 345 | {"http://www.google.com/temp/foo?q#b", "http://www.google.com/temp/foo?q"}, |
jochen | 4245039 | 2014-11-24 19:47:22 | [diff] [blame^] | 346 | {"not a url", ""}, |
| 347 | {"unknown-scheme://foo.html", ""}, |
| 348 | {"file:///tmp/test.html", ""}, |
| 349 | {"https://www.google.com", "https://www.google.com/"}, |
[email protected] | 6b775ee | 2014-03-20 20:27:25 | [diff] [blame] | 350 | }; |
viettrungluu | 4b691586 | 2014-10-16 03:42:49 | [diff] [blame] | 351 | for (size_t i = 0; i < arraysize(cases); i++) { |
[email protected] | 6b775ee | 2014-03-20 20:27:25 | [diff] [blame] | 352 | GURL url(cases[i].input); |
| 353 | GURL origin = url.GetAsReferrer(); |
| 354 | EXPECT_EQ(cases[i].expected, origin.spec()); |
| 355 | } |
| 356 | } |
| 357 | |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 358 | TEST(GURLTest, GetWithEmptyPath) { |
| 359 | struct TestCase { |
| 360 | const char* input; |
| 361 | const char* expected; |
| 362 | } cases[] = { |
| 363 | {"http://www.google.com", "http://www.google.com/"}, |
| 364 | {"javascript:window.alert(\"hello, world\");", ""}, |
| 365 | {"http://www.google.com/foo/bar.html?baz=22", "http://www.google.com/"}, |
| 366 | {"filesystem:http://www.google.com/temporary/bar.html?baz=22", "filesystem:http://www.google.com/temporary/"}, |
| 367 | {"filesystem:file:///temporary/bar.html?baz=22", "filesystem:file:///temporary/"}, |
| 368 | }; |
| 369 | |
viettrungluu | 4b691586 | 2014-10-16 03:42:49 | [diff] [blame] | 370 | for (size_t i = 0; i < arraysize(cases); i++) { |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 371 | GURL url(cases[i].input); |
| 372 | GURL empty_path = url.GetWithEmptyPath(); |
| 373 | EXPECT_EQ(cases[i].expected, empty_path.spec()); |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | TEST(GURLTest, Replacements) { |
| 378 | // The url canonicalizer replacement test will handle most of these case. |
| 379 | // The most important thing to do here is to check that the proper |
| 380 | // canonicalizer gets called based on the scheme of the input. |
| 381 | struct ReplaceCase { |
| 382 | const char* base; |
| 383 | const char* scheme; |
| 384 | const char* username; |
| 385 | const char* password; |
| 386 | const char* host; |
| 387 | const char* port; |
| 388 | const char* path; |
| 389 | const char* query; |
| 390 | const char* ref; |
| 391 | const char* expected; |
| 392 | } replace_cases[] = { |
| 393 | {"http://www.google.com/foo/bar.html?foo#bar", NULL, NULL, NULL, NULL, NULL, "/", "", "", "http://www.google.com/"}, |
| 394 | {"http://www.google.com/foo/bar.html?foo#bar", "javascript", "", "", "", "", "window.open('foo');", "", "", "javascript:window.open('foo');"}, |
| 395 | {"file:///C:/foo/bar.txt", "http", NULL, NULL, "www.google.com", "99", "/foo","search", "ref", "http://www.google.com:99/foo?search#ref"}, |
| 396 | #ifdef WIN32 |
| 397 | {"http://www.google.com/foo/bar.html?foo#bar", "file", "", "", "", "", "c:\\", "", "", "file:///C:/"}, |
| 398 | #endif |
| 399 | {"filesystem:http://www.google.com/foo/bar.html?foo#bar", NULL, NULL, NULL, NULL, NULL, "/", "", "", "filesystem:http://www.google.com/foo/"}, |
| 400 | }; |
| 401 | |
viettrungluu | 4b691586 | 2014-10-16 03:42:49 | [diff] [blame] | 402 | for (size_t i = 0; i < arraysize(replace_cases); i++) { |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 403 | const ReplaceCase& cur = replace_cases[i]; |
| 404 | GURL url(cur.base); |
| 405 | GURL::Replacements repl; |
| 406 | SetupReplacement(&GURL::Replacements::SetScheme, &repl, cur.scheme); |
| 407 | SetupReplacement(&GURL::Replacements::SetUsername, &repl, cur.username); |
| 408 | SetupReplacement(&GURL::Replacements::SetPassword, &repl, cur.password); |
| 409 | SetupReplacement(&GURL::Replacements::SetHost, &repl, cur.host); |
| 410 | SetupReplacement(&GURL::Replacements::SetPort, &repl, cur.port); |
| 411 | SetupReplacement(&GURL::Replacements::SetPath, &repl, cur.path); |
| 412 | SetupReplacement(&GURL::Replacements::SetQuery, &repl, cur.query); |
| 413 | SetupReplacement(&GURL::Replacements::SetRef, &repl, cur.ref); |
| 414 | GURL output = url.ReplaceComponents(repl); |
| 415 | |
| 416 | EXPECT_EQ(replace_cases[i].expected, output.spec()); |
| 417 | EXPECT_EQ(output.SchemeIsFileSystem(), output.inner_url() != NULL); |
| 418 | } |
| 419 | } |
| 420 | |
[email protected] | 369e84f7 | 2013-11-23 01:53:52 | [diff] [blame] | 421 | TEST(GURLTest, ClearFragmentOnDataUrl) { |
| 422 | // http://crbug.com/291747 - a data URL may legitimately have trailing |
| 423 | // whitespace in the spec after the ref is cleared. Test this does not trigger |
[email protected] | 0318f92 | 2014-04-22 00:09:23 | [diff] [blame] | 424 | // the Parsed importing validation DCHECK in GURL. |
[email protected] | 369e84f7 | 2013-11-23 01:53:52 | [diff] [blame] | 425 | GURL url(" data: one ? two # three "); |
| 426 | |
| 427 | // By default the trailing whitespace will have been stripped. |
| 428 | EXPECT_EQ("data: one ? two # three", url.spec()); |
| 429 | GURL::Replacements repl; |
| 430 | repl.ClearRef(); |
| 431 | GURL url_no_ref = url.ReplaceComponents(repl); |
| 432 | |
| 433 | EXPECT_EQ("data: one ? two ", url_no_ref.spec()); |
| 434 | |
| 435 | // Importing a parsed url via this constructor overload will retain trailing |
| 436 | // whitespace. |
| 437 | GURL import_url(url_no_ref.spec(), |
| 438 | url_no_ref.parsed_for_possibly_invalid_spec(), |
| 439 | url_no_ref.is_valid()); |
| 440 | EXPECT_EQ(url_no_ref, import_url); |
| 441 | EXPECT_EQ(import_url.query(), " two "); |
| 442 | } |
| 443 | |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 444 | TEST(GURLTest, PathForRequest) { |
| 445 | struct TestCase { |
| 446 | const char* input; |
| 447 | const char* expected; |
| 448 | const char* inner_expected; |
| 449 | } cases[] = { |
| 450 | {"http://www.google.com", "/", NULL}, |
| 451 | {"http://www.google.com/", "/", NULL}, |
| 452 | {"http://www.google.com/foo/bar.html?baz=22", "/foo/bar.html?baz=22", NULL}, |
| 453 | {"http://www.google.com/foo/bar.html#ref", "/foo/bar.html", NULL}, |
| 454 | {"http://www.google.com/foo/bar.html?query#ref", "/foo/bar.html?query", NULL}, |
| 455 | {"filesystem:http://www.google.com/temporary/foo/bar.html?query#ref", "/foo/bar.html?query", "/temporary"}, |
| 456 | {"filesystem:http://www.google.com/temporary/foo/bar.html?query", "/foo/bar.html?query", "/temporary"}, |
| 457 | }; |
| 458 | |
viettrungluu | 4b691586 | 2014-10-16 03:42:49 | [diff] [blame] | 459 | for (size_t i = 0; i < arraysize(cases); i++) { |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 460 | GURL url(cases[i].input); |
| 461 | std::string path_request = url.PathForRequest(); |
| 462 | EXPECT_EQ(cases[i].expected, path_request); |
| 463 | EXPECT_EQ(cases[i].inner_expected == NULL, url.inner_url() == NULL); |
| 464 | if (url.inner_url() && cases[i].inner_expected) |
| 465 | EXPECT_EQ(cases[i].inner_expected, url.inner_url()->PathForRequest()); |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | TEST(GURLTest, EffectiveIntPort) { |
| 470 | struct PortTest { |
| 471 | const char* spec; |
| 472 | int expected_int_port; |
| 473 | } port_tests[] = { |
| 474 | // http |
| 475 | {"http://www.google.com/", 80}, |
| 476 | {"http://www.google.com:80/", 80}, |
| 477 | {"http://www.google.com:443/", 443}, |
| 478 | |
| 479 | // https |
| 480 | {"https://www.google.com/", 443}, |
| 481 | {"https://www.google.com:443/", 443}, |
| 482 | {"https://www.google.com:80/", 80}, |
| 483 | |
| 484 | // ftp |
| 485 | {"ftp://www.google.com/", 21}, |
| 486 | {"ftp://www.google.com:21/", 21}, |
| 487 | {"ftp://www.google.com:80/", 80}, |
| 488 | |
| 489 | // gopher |
| 490 | {"gopher://www.google.com/", 70}, |
| 491 | {"gopher://www.google.com:70/", 70}, |
| 492 | {"gopher://www.google.com:80/", 80}, |
| 493 | |
| 494 | // file - no port |
[email protected] | 0318f92 | 2014-04-22 00:09:23 | [diff] [blame] | 495 | {"file://www.google.com/", PORT_UNSPECIFIED}, |
| 496 | {"file://www.google.com:443/", PORT_UNSPECIFIED}, |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 497 | |
| 498 | // data - no port |
[email protected] | 0318f92 | 2014-04-22 00:09:23 | [diff] [blame] | 499 | {"data:www.google.com:90", PORT_UNSPECIFIED}, |
| 500 | {"data:www.google.com", PORT_UNSPECIFIED}, |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 501 | |
| 502 | // filesystem - no port |
[email protected] | 0318f92 | 2014-04-22 00:09:23 | [diff] [blame] | 503 | {"filesystem:http://www.google.com:90/t/foo", PORT_UNSPECIFIED}, |
| 504 | {"filesystem:file:///t/foo", PORT_UNSPECIFIED}, |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 505 | }; |
| 506 | |
viettrungluu | 4b691586 | 2014-10-16 03:42:49 | [diff] [blame] | 507 | for (size_t i = 0; i < arraysize(port_tests); i++) { |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 508 | GURL url(port_tests[i].spec); |
| 509 | EXPECT_EQ(port_tests[i].expected_int_port, url.EffectiveIntPort()); |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | TEST(GURLTest, IPAddress) { |
| 514 | struct IPTest { |
| 515 | const char* spec; |
| 516 | bool expected_ip; |
| 517 | } ip_tests[] = { |
| 518 | {"http://www.google.com/", false}, |
| 519 | {"http://192.168.9.1/", true}, |
| 520 | {"http://192.168.9.1.2/", false}, |
| 521 | {"http://192.168.m.1/", false}, |
| 522 | {"http://2001:db8::1/", false}, |
| 523 | {"http://[2001:db8::1]/", true}, |
| 524 | {"", false}, |
| 525 | {"some random input!", false}, |
| 526 | }; |
| 527 | |
viettrungluu | 4b691586 | 2014-10-16 03:42:49 | [diff] [blame] | 528 | for (size_t i = 0; i < arraysize(ip_tests); i++) { |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 529 | GURL url(ip_tests[i].spec); |
| 530 | EXPECT_EQ(ip_tests[i].expected_ip, url.HostIsIPAddress()); |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | TEST(GURLTest, HostNoBrackets) { |
| 535 | struct TestCase { |
| 536 | const char* input; |
| 537 | const char* expected_host; |
| 538 | const char* expected_plainhost; |
| 539 | } cases[] = { |
| 540 | {"http://www.google.com", "www.google.com", "www.google.com"}, |
| 541 | {"http://[2001:db8::1]/", "[2001:db8::1]", "2001:db8::1"}, |
| 542 | {"http://[::]/", "[::]", "::"}, |
| 543 | |
| 544 | // Don't require a valid URL, but don't crash either. |
| 545 | {"http://[]/", "[]", ""}, |
| 546 | {"http://[x]/", "[x]", "x"}, |
| 547 | {"http://[x/", "[x", "[x"}, |
| 548 | {"http://x]/", "x]", "x]"}, |
| 549 | {"http://[/", "[", "["}, |
| 550 | {"http://]/", "]", "]"}, |
| 551 | {"", "", ""}, |
| 552 | }; |
viettrungluu | 4b691586 | 2014-10-16 03:42:49 | [diff] [blame] | 553 | for (size_t i = 0; i < arraysize(cases); i++) { |
[email protected] | e7bba5f8 | 2013-04-10 20:10:52 | [diff] [blame] | 554 | GURL url(cases[i].input); |
| 555 | EXPECT_EQ(cases[i].expected_host, url.host()); |
| 556 | EXPECT_EQ(cases[i].expected_plainhost, url.HostNoBrackets()); |
| 557 | } |
| 558 | } |
| 559 | |
| 560 | TEST(GURLTest, DomainIs) { |
| 561 | const char google_domain[] = "google.com"; |
| 562 | |
| 563 | GURL url_1("http://www.google.com:99/foo"); |
| 564 | EXPECT_TRUE(url_1.DomainIs(google_domain)); |
| 565 | |
| 566 | GURL url_2("http://google.com:99/foo"); |
| 567 | EXPECT_TRUE(url_2.DomainIs(google_domain)); |
| 568 | |
| 569 | GURL url_3("http://google.com./foo"); |
| 570 | EXPECT_TRUE(url_3.DomainIs(google_domain)); |
| 571 | |
| 572 | GURL url_4("http://google.com/foo"); |
| 573 | EXPECT_FALSE(url_4.DomainIs("google.com.")); |
| 574 | |
| 575 | GURL url_5("http://google.com./foo"); |
| 576 | EXPECT_TRUE(url_5.DomainIs("google.com.")); |
| 577 | |
| 578 | GURL url_6("http://www.google.com./foo"); |
| 579 | EXPECT_TRUE(url_6.DomainIs(".com.")); |
| 580 | |
| 581 | GURL url_7("http://www.balabala.com/foo"); |
| 582 | EXPECT_FALSE(url_7.DomainIs(google_domain)); |
| 583 | |
| 584 | GURL url_8("http://www.google.com.cn/foo"); |
| 585 | EXPECT_FALSE(url_8.DomainIs(google_domain)); |
| 586 | |
| 587 | GURL url_9("http://www.iamnotgoogle.com/foo"); |
| 588 | EXPECT_FALSE(url_9.DomainIs(google_domain)); |
| 589 | |
| 590 | GURL url_10("http://www.iamnotgoogle.com../foo"); |
| 591 | EXPECT_FALSE(url_10.DomainIs(".com")); |
| 592 | |
| 593 | GURL url_11("filesystem:http://www.google.com:99/foo/"); |
| 594 | EXPECT_TRUE(url_11.DomainIs(google_domain)); |
| 595 | |
| 596 | GURL url_12("filesystem:http://www.iamnotgoogle.com/foo/"); |
| 597 | EXPECT_FALSE(url_12.DomainIs(google_domain)); |
| 598 | } |
| 599 | |
| 600 | // Newlines should be stripped from inputs. |
| 601 | TEST(GURLTest, Newlines) { |
| 602 | // Constructor. |
| 603 | GURL url_1(" \t ht\ntp://\twww.goo\rgle.com/as\ndf \n "); |
| 604 | EXPECT_EQ("http://www.google.com/asdf", url_1.spec()); |
| 605 | |
| 606 | // Relative path resolver. |
| 607 | GURL url_2 = url_1.Resolve(" \n /fo\to\r "); |
| 608 | EXPECT_EQ("http://www.google.com/foo", url_2.spec()); |
| 609 | |
| 610 | // Note that newlines are NOT stripped from ReplaceComponents. |
| 611 | } |
| 612 | |
| 613 | TEST(GURLTest, IsStandard) { |
| 614 | GURL a("http:foo/bar"); |
| 615 | EXPECT_TRUE(a.IsStandard()); |
| 616 | |
| 617 | GURL b("foo:bar/baz"); |
| 618 | EXPECT_FALSE(b.IsStandard()); |
| 619 | |
| 620 | GURL c("foo://bar/baz"); |
| 621 | EXPECT_FALSE(c.IsStandard()); |
| 622 | } |
[email protected] | 9690b99 | 2013-11-22 07:40:46 | [diff] [blame] | 623 | |
| 624 | TEST(GURLTest, SchemeIsHTTPOrHTTPS) { |
| 625 | EXPECT_TRUE(GURL("http://bar/").SchemeIsHTTPOrHTTPS()); |
| 626 | EXPECT_TRUE(GURL("HTTPS://BAR").SchemeIsHTTPOrHTTPS()); |
| 627 | EXPECT_FALSE(GURL("ftp://bar/").SchemeIsHTTPOrHTTPS()); |
| 628 | } |
| 629 | |
| 630 | TEST(GURLTest, SchemeIsWSOrWSS) { |
| 631 | EXPECT_TRUE(GURL("WS://BAR/").SchemeIsWSOrWSS()); |
| 632 | EXPECT_TRUE(GURL("wss://bar/").SchemeIsWSOrWSS()); |
| 633 | EXPECT_FALSE(GURL("http://bar/").SchemeIsWSOrWSS()); |
| 634 | } |
[email protected] | 0318f92 | 2014-04-22 00:09:23 | [diff] [blame] | 635 | |
amogh.bihani | ee85a11 | 2014-09-01 06:06:51 | [diff] [blame] | 636 | TEST(GURLTest, SchemeIsBlob) { |
| 637 | EXPECT_TRUE(GURL("BLOB://BAR/").SchemeIsBlob()); |
| 638 | EXPECT_TRUE(GURL("blob://bar/").SchemeIsBlob()); |
| 639 | EXPECT_FALSE(GURL("http://bar/").SchemeIsBlob()); |
| 640 | } |
| 641 | |
[email protected] | 0318f92 | 2014-04-22 00:09:23 | [diff] [blame] | 642 | } // namespace url |