Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(517)

Side by Side Diff: third_party/WebKit/Source/platform/weborigin/KURLTest.cpp

Issue 1548993002: Switch to standard integer types in base/strings/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 const char* ref; 66 const char* ref;
67 bool hasRef; 67 bool hasRef;
68 } cases[] = { 68 } cases[] = {
69 {"http://www.google.com/foo/blah?bar=baz#ref", "http", "www.google.com", 0, "", 0, "blah", "bar=baz", "ref", true}, 69 {"http://www.google.com/foo/blah?bar=baz#ref", "http", "www.google.com", 0, "", 0, "blah", "bar=baz", "ref", true},
70 {"http://foo.com:1234/foo/bar/", "http", "foo.com", 1234, "", 0, "bar", 0, 0, false}, 70 {"http://foo.com:1234/foo/bar/", "http", "foo.com", 1234, "", 0, "bar", 0, 0, false},
71 {"http://www.google.com?#", "http", "www.google.com", 0, "", 0, 0, "", " ", true}, 71 {"http://www.google.com?#", "http", "www.google.com", 0, "", 0, 0, "", " ", true},
72 {"https://me:pass@google.com:23#foo", "https", "google.com", 23, "me", " pass", 0, 0, "foo", true}, 72 {"https://me:pass@google.com:23#foo", "https", "google.com", 23, "me", " pass", 0, 0, "foo", true},
73 {"javascript:hello!//world", "javascript", "", 0, "", 0, "world", 0, 0, false}, 73 {"javascript:hello!//world", "javascript", "", 0, "", 0, "world", 0, 0, false},
74 }; 74 };
75 75
76 for (size_t i = 0; i < arraysize(cases); i++) { 76 for (size_t i = 0; i < WTF_ARRAY_LENGTH(cases); i++) {
77 // UTF-8 77 // UTF-8
78 KURL kurl(ParsedURLString, cases[i].url); 78 KURL kurl(ParsedURLString, cases[i].url);
79 79
80 EXPECT_EQ(cases[i].protocol, kurl.protocol()); 80 EXPECT_EQ(cases[i].protocol, kurl.protocol());
81 EXPECT_EQ(cases[i].host, kurl.host()); 81 EXPECT_EQ(cases[i].host, kurl.host());
82 EXPECT_EQ(cases[i].port, kurl.port()); 82 EXPECT_EQ(cases[i].port, kurl.port());
83 EXPECT_EQ(cases[i].user, kurl.user()); 83 EXPECT_EQ(cases[i].user, kurl.user());
84 EXPECT_EQ(cases[i].pass, kurl.pass()); 84 EXPECT_EQ(cases[i].pass, kurl.pass());
85 EXPECT_EQ(cases[i].lastPathComponent, kurl.lastPathComponent()); 85 EXPECT_EQ(cases[i].lastPathComponent, kurl.lastPathComponent());
86 EXPECT_EQ(cases[i].query, kurl.query()); 86 EXPECT_EQ(cases[i].query, kurl.query());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // disagree with us about where the path is for this URL. 118 // disagree with us about where the path is for this URL.
119 {"http://a.com/hello;world", "http", "a.com", 0, "", 0, "hello", 0, 0}, 119 {"http://a.com/hello;world", "http", "a.com", 0, "", 0, "hello", 0, 0},
120 120
121 // WebKit doesn't like UTF-8 or UTF-16 input. 121 // WebKit doesn't like UTF-8 or UTF-16 input.
122 {"http://\xe4\xbd\xa0\xe5\xa5\xbd\xe4\xbd\xa0\xe5\xa5\xbd/", "http", "xn --6qqa088eba", 0, "", 0, 0, 0, 0}, 122 {"http://\xe4\xbd\xa0\xe5\xa5\xbd\xe4\xbd\xa0\xe5\xa5\xbd/", "http", "xn --6qqa088eba", 0, "", 0, 0, 0, 0},
123 123
124 // WebKit %-escapes non-ASCII characters in reference, but we don't. 124 // WebKit %-escapes non-ASCII characters in reference, but we don't.
125 {"http://www.google.com/foo/blah?bar=baz#\xce\xb1\xce\xb2", "http", "www .google.com", 0, "", 0, "blah", "bar=baz", "\xce\xb1\xce\xb2"}, 125 {"http://www.google.com/foo/blah?bar=baz#\xce\xb1\xce\xb2", "http", "www .google.com", 0, "", 0, "blah", "bar=baz", "\xce\xb1\xce\xb2"},
126 }; 126 };
127 127
128 for (size_t i = 0; i < arraysize(cases); i++) { 128 for (size_t i = 0; i < WTF_ARRAY_LENGTH(cases); i++) {
129 KURL kurl(ParsedURLString, cases[i].url); 129 KURL kurl(ParsedURLString, cases[i].url);
130 130
131 EXPECT_EQ(cases[i].protocol, kurl.protocol()); 131 EXPECT_EQ(cases[i].protocol, kurl.protocol());
132 EXPECT_EQ(cases[i].host, kurl.host()); 132 EXPECT_EQ(cases[i].host, kurl.host());
133 EXPECT_EQ(cases[i].port, kurl.port()); 133 EXPECT_EQ(cases[i].port, kurl.port());
134 EXPECT_EQ(cases[i].user, kurl.user()); 134 EXPECT_EQ(cases[i].user, kurl.user());
135 EXPECT_EQ(cases[i].pass, kurl.pass()); 135 EXPECT_EQ(cases[i].pass, kurl.pass());
136 EXPECT_EQ(cases[i].lastPath, kurl.lastPathComponent()); 136 EXPECT_EQ(cases[i].lastPath, kurl.lastPathComponent());
137 EXPECT_EQ(cases[i].query, kurl.query()); 137 EXPECT_EQ(cases[i].query, kurl.query());
138 // Want to compare UCS-16 refs (or to null). 138 // Want to compare UCS-16 refs (or to null).
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 "", "http://:pass@goo.com:92/a?f#b", 229 "", "http://:pass@goo.com:92/a?f#b",
230 // pass 230 // pass
231 "", "http://goo.com:92/a?f#b", 231 "", "http://goo.com:92/a?f#b",
232 // path 232 // path
233 "/", "http://goo.com:92/?f#b", 233 "/", "http://goo.com:92/?f#b",
234 // query 234 // query
235 0, "http://goo.com:92/#b" 235 0, "http://goo.com:92/#b"
236 }, 236 },
237 }; 237 };
238 238
239 for (size_t i = 0; i < arraysize(cases); i++) { 239 for (size_t i = 0; i < WTF_ARRAY_LENGTH(cases); i++) {
240 KURL kurl(ParsedURLString, cases[i].url); 240 KURL kurl(ParsedURLString, cases[i].url);
241 241
242 kurl.setProtocol(cases[i].protocol); 242 kurl.setProtocol(cases[i].protocol);
243 EXPECT_STREQ(cases[i].expectedProtocol, kurl.string().utf8().data()); 243 EXPECT_STREQ(cases[i].expectedProtocol, kurl.string().utf8().data());
244 244
245 kurl.setHost(cases[i].host); 245 kurl.setHost(cases[i].host);
246 EXPECT_STREQ(cases[i].expectedHost, kurl.string().utf8().data()); 246 EXPECT_STREQ(cases[i].expectedHost, kurl.string().utf8().data());
247 247
248 kurl.setPort(cases[i].port); 248 kurl.setPort(cases[i].port);
249 EXPECT_STREQ(cases[i].expectedPort, kurl.string().utf8().data()); 249 EXPECT_STREQ(cases[i].expectedPort, kurl.string().utf8().data());
(...skipping 28 matching lines...) Expand all
278 {"%20%21%22%23%24%25%26%27%28%29%2a%2B%2C%2D%2e%2f/", " !\"#$%&'()*+,-./ /"}, 278 {"%20%21%22%23%24%25%26%27%28%29%2a%2B%2C%2D%2e%2f/", " !\"#$%&'()*+,-./ /"},
279 {"%30%31%32%33%34%35%36%37%38%39%3a%3B%3C%3D%3e%3f/", "0123456789:;<=>?/ "}, 279 {"%30%31%32%33%34%35%36%37%38%39%3a%3B%3C%3D%3e%3f/", "0123456789:;<=>?/ "},
280 {"%40%41%42%43%44%45%46%47%48%49%4a%4B%4C%4D%4e%4f/", "@ABCDEFGHIJKLMNO/ "}, 280 {"%40%41%42%43%44%45%46%47%48%49%4a%4B%4C%4D%4e%4f/", "@ABCDEFGHIJKLMNO/ "},
281 {"%50%51%52%53%54%55%56%57%58%59%5a%5B%5C%5D%5e%5f/", "PQRSTUVWXYZ[\\]^_ /"}, 281 {"%50%51%52%53%54%55%56%57%58%59%5a%5B%5C%5D%5e%5f/", "PQRSTUVWXYZ[\\]^_ /"},
282 {"%60%61%62%63%64%65%66%67%68%69%6a%6B%6C%6D%6e%6f/", "`abcdefghijklmno/ "}, 282 {"%60%61%62%63%64%65%66%67%68%69%6a%6B%6C%6D%6e%6f/", "`abcdefghijklmno/ "},
283 {"%70%71%72%73%74%75%76%77%78%79%7a%7B%7C%7D%7e%7f/", "pqrstuvwxyz{|}~\x 7f/"}, 283 {"%70%71%72%73%74%75%76%77%78%79%7a%7B%7C%7D%7e%7f/", "pqrstuvwxyz{|}~\x 7f/"},
284 // Test un-UTF-8-ization. 284 // Test un-UTF-8-ization.
285 {"%e4%bd%a0%e5%a5%bd", "\xe4\xbd\xa0\xe5\xa5\xbd"}, 285 {"%e4%bd%a0%e5%a5%bd", "\xe4\xbd\xa0\xe5\xa5\xbd"},
286 }; 286 };
287 287
288 for (size_t i = 0; i < arraysize(decodeCases); i++) { 288 for (size_t i = 0; i < WTF_ARRAY_LENGTH(decodeCases); i++) {
289 String input(decodeCases[i].input); 289 String input(decodeCases[i].input);
290 String str = decodeURLEscapeSequences(input); 290 String str = decodeURLEscapeSequences(input);
291 EXPECT_STREQ(decodeCases[i].output, str.utf8().data()); 291 EXPECT_STREQ(decodeCases[i].output, str.utf8().data());
292 } 292 }
293 293
294 // Our decode should decode %00 294 // Our decode should decode %00
295 String zero = decodeURLEscapeSequences("%00"); 295 String zero = decodeURLEscapeSequences("%00");
296 EXPECT_STRNE("%00", zero.utf8().data()); 296 EXPECT_STRNE("%00", zero.utf8().data());
297 297
298 // Test the error behavior for invalid UTF-8 (we differ from WebKit here). 298 // Test the error behavior for invalid UTF-8 (we differ from WebKit here).
(...skipping 22 matching lines...) Expand all
321 {"@ABCDEFGHIJKLMNO", 321 {"@ABCDEFGHIJKLMNO",
322 "%40ABCDEFGHIJKLMNO"}, 322 "%40ABCDEFGHIJKLMNO"},
323 {"PQRSTUVWXYZ[\\]^_", 323 {"PQRSTUVWXYZ[\\]^_",
324 "PQRSTUVWXYZ%5B%5C%5D%5E_"}, 324 "PQRSTUVWXYZ%5B%5C%5D%5E_"},
325 {"`abcdefghijklmno", 325 {"`abcdefghijklmno",
326 "%60abcdefghijklmno"}, 326 "%60abcdefghijklmno"},
327 {"pqrstuvwxyz{|}~\x7f", 327 {"pqrstuvwxyz{|}~\x7f",
328 "pqrstuvwxyz%7B%7C%7D~%7F"}, 328 "pqrstuvwxyz%7B%7C%7D~%7F"},
329 }; 329 };
330 330
331 for (size_t i = 0; i < arraysize(encode_cases); i++) { 331 for (size_t i = 0; i < WTF_ARRAY_LENGTH(encode_cases); i++) {
332 String input(encode_cases[i].input); 332 String input(encode_cases[i].input);
333 String expectedOutput(encode_cases[i].output); 333 String expectedOutput(encode_cases[i].output);
334 String output = encodeWithURLEscapeSequences(input); 334 String output = encodeWithURLEscapeSequences(input);
335 EXPECT_EQ(expectedOutput, output); 335 EXPECT_EQ(expectedOutput, output);
336 } 336 }
337 337
338 // Our encode escapes NULLs for safety, so we need to check that too. 338 // Our encode escapes NULLs for safety, so we need to check that too.
339 String input("\x00\x01", 2); 339 String input("\x00\x01", 2);
340 String reference("%00%01"); 340 String reference("%00%01");
341 341
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 {"about:config", ""}, 748 {"about:config", ""},
749 {"https://www.google.com/", "https://www.google.com/"}, 749 {"https://www.google.com/", "https://www.google.com/"},
750 {"http://me@news.google.com:8888/", "http://news.google.com:8888/"}, 750 {"http://me@news.google.com:8888/", "http://news.google.com:8888/"},
751 {"http://:pass@news.google.com:8888/foo", "http://news.google.com:8888/f oo"}, 751 {"http://:pass@news.google.com:8888/foo", "http://news.google.com:8888/f oo"},
752 {"http://me:pass@news.google.com:8888/", "http://news.google.com:8888/"} , 752 {"http://me:pass@news.google.com:8888/", "http://news.google.com:8888/"} ,
753 {"https://www.google.com/a?f#b", "https://www.google.com/a?f"}, 753 {"https://www.google.com/a?f#b", "https://www.google.com/a?f"},
754 {"file:///tmp/test.html", ""}, 754 {"file:///tmp/test.html", ""},
755 {"https://www.google.com/#", "https://www.google.com/"}, 755 {"https://www.google.com/#", "https://www.google.com/"},
756 }; 756 };
757 757
758 for (size_t i = 0; i < arraysize(referrerCases); i++) { 758 for (size_t i = 0; i < WTF_ARRAY_LENGTH(referrerCases); i++) {
759 KURL kurl(ParsedURLString, referrerCases[i].input); 759 KURL kurl(ParsedURLString, referrerCases[i].input);
760 String referrer = kurl.strippedForUseAsReferrer(); 760 String referrer = kurl.strippedForUseAsReferrer();
761 EXPECT_STREQ(referrerCases[i].output, referrer.utf8().data()); 761 EXPECT_STREQ(referrerCases[i].output, referrer.utf8().data());
762 } 762 }
763 } 763 }
764 764
765 } // namespace blink 765 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698