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

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

Issue 2643613002: Reduce the perf overhead of our dangling markup experiments. (Closed)
Patch Set: unittest Created 3 years, 11 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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 295
296 // Encoding should not NFC-normalize the string. 296 // Encoding should not NFC-normalize the string.
297 // Contain a combining character ('e' + COMBINING OGONEK). 297 // Contain a combining character ('e' + COMBINING OGONEK).
298 String combining(String::fromUTF8("\x65\xCC\xA8")); 298 String combining(String::fromUTF8("\x65\xCC\xA8"));
299 EXPECT_EQ(encodeWithURLEscapeSequences(combining), "e%CC%A8"); 299 EXPECT_EQ(encodeWithURLEscapeSequences(combining), "e%CC%A8");
300 // Contain a precomposed character corresponding to |combining|. 300 // Contain a precomposed character corresponding to |combining|.
301 String precomposed(String::fromUTF8("\xC4\x99")); 301 String precomposed(String::fromUTF8("\xC4\x99"));
302 EXPECT_EQ(encodeWithURLEscapeSequences(precomposed), "%C4%99"); 302 EXPECT_EQ(encodeWithURLEscapeSequences(precomposed), "%C4%99");
303 } 303 }
304 304
305 TEST(KURLTest, RemoveWhitespace) {
306 struct {
307 const char* input;
308 const char* expected;
309 } cases[] = {
310 {"ht\ntps://example.com/yay?boo#foo", "https://example.com/yay?boo#foo"},
311 {"ht\ttps://example.com/yay?boo#foo", "https://example.com/yay?boo#foo"},
312 {"ht\rtps://example.com/yay?boo#foo", "https://example.com/yay?boo#foo"},
313 {"https://exa\nmple.com/yay?boo#foo", "https://example.com/yay?boo#foo"},
314 {"https://exa\tmple.com/yay?boo#foo", "https://example.com/yay?boo#foo"},
315 {"https://exa\rmple.com/yay?boo#foo", "https://example.com/yay?boo#foo"},
316 {"https://example.com/y\nay?boo#foo", "https://example.com/yay?boo#foo"},
317 {"https://example.com/y\tay?boo#foo", "https://example.com/yay?boo#foo"},
318 {"https://example.com/y\ray?boo#foo", "https://example.com/yay?boo#foo"},
319 {"https://example.com/yay?b\noo#foo", "https://example.com/yay?boo#foo"},
320 {"https://example.com/yay?b\too#foo", "https://example.com/yay?boo#foo"},
321 {"https://example.com/yay?b\roo#foo", "https://example.com/yay?boo#foo"},
322 {"https://example.com/yay?boo#f\noo", "https://example.com/yay?boo#foo"},
323 {"https://example.com/yay?boo#f\too", "https://example.com/yay?boo#foo"},
324 {"https://example.com/yay?boo#f\roo", "https://example.com/yay?boo#foo"},
325 };
326
327 for (const auto& test : cases) {
328 const KURL input(ParsedURLString, test.input);
329 const KURL expected(ParsedURLString, test.expected);
330 EXPECT_EQ(input, expected);
331 EXPECT_TRUE(input.whitespaceRemoved());
332 EXPECT_FALSE(expected.whitespaceRemoved());
333 }
334 }
335
305 TEST(KURLTest, ResolveEmpty) { 336 TEST(KURLTest, ResolveEmpty) {
306 KURL emptyBase; 337 KURL emptyBase;
307 338
308 // WebKit likes to be able to resolve absolute input agains empty base URLs, 339 // WebKit likes to be able to resolve absolute input agains empty base URLs,
309 // which would normally be invalid since the base URL is invalid. 340 // which would normally be invalid since the base URL is invalid.
310 const char abs[] = "http://www.google.com/"; 341 const char abs[] = "http://www.google.com/";
311 KURL resolveAbs(emptyBase, abs); 342 KURL resolveAbs(emptyBase, abs);
312 EXPECT_TRUE(resolveAbs.isValid()); 343 EXPECT_TRUE(resolveAbs.isValid());
313 EXPECT_STREQ(abs, resolveAbs.getString().utf8().data()); 344 EXPECT_STREQ(abs, resolveAbs.getString().utf8().data());
314 345
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 }; 755 };
725 756
726 for (size_t i = 0; i < WTF_ARRAY_LENGTH(referrerCases); i++) { 757 for (size_t i = 0; i < WTF_ARRAY_LENGTH(referrerCases); i++) {
727 KURL kurl(ParsedURLString, referrerCases[i].input); 758 KURL kurl(ParsedURLString, referrerCases[i].input);
728 String referrer = kurl.strippedForUseAsReferrer(); 759 String referrer = kurl.strippedForUseAsReferrer();
729 EXPECT_STREQ(referrerCases[i].output, referrer.utf8().data()); 760 EXPECT_STREQ(referrerCases[i].output, referrer.utf8().data());
730 } 761 }
731 } 762 }
732 763
733 } // namespace blink 764 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/weborigin/KURL.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698