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

Unified Diff: components/url_formatter/url_formatter_unittest.cc

Issue 2963883002: Omnibox UI Experiments: Refactor HTTPS trimming into UrlFormatter. (Closed)
Patch Set: fix Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/url_formatter/url_formatter.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/url_formatter/url_formatter_unittest.cc
diff --git a/components/url_formatter/url_formatter_unittest.cc b/components/url_formatter/url_formatter_unittest.cc
index fc8011853aa6e1cee444d8e2003b0473430ab4c1..3ba5e361b4fef70c25f413819466d67e2f48365b 100644
--- a/components/url_formatter/url_formatter_unittest.cc
+++ b/components/url_formatter/url_formatter_unittest.cc
@@ -825,12 +825,15 @@ TEST(UrlFormatterTest, FormatUrl) {
// Disabled: the resultant URL becomes "...user%253A:%2540passwd...".
// -------- omit http: --------
- {"omit http with user name", "http://user@example.com/foo",
- kFormatUrlOmitAll, net::UnescapeRule::NORMAL, L"example.com/foo", 0},
-
{"omit http", "http://www.google.com/", kFormatUrlOmitHTTP,
net::UnescapeRule::NORMAL, L"www.google.com/", 0},
+ {"omit http on bare scheme", "http://", kFormatUrlOmitAll,
+ net::UnescapeRule::NORMAL, L"", 0},
+
+ {"omit http with user name", "http://user@example.com/foo",
+ kFormatUrlOmitAll, net::UnescapeRule::NORMAL, L"example.com/foo", 0},
+
{"omit http with https", "https://www.google.com/", kFormatUrlOmitHTTP,
net::UnescapeRule::NORMAL, L"https://www.google.com/", 8},
@@ -913,6 +916,24 @@ TEST(UrlFormatterTest, FormatUrl) {
"http://google.com////???####",
kFormatUrlOmitAll | kFormatUrlExperimentalElideAfterHost,
net::UnescapeRule::NORMAL, L"google.com/\x2026\x0000", 0},
+
+ // -------- omit https --------
+ {"omit https", "https://www.google.com/", kFormatUrlExperimentalOmitHTTPS,
+ net::UnescapeRule::NORMAL, L"www.google.com/", 0},
+ {"omit https but do not omit http", "http://www.google.com/",
+ kFormatUrlExperimentalOmitHTTPS, net::UnescapeRule::NORMAL,
+ L"http://www.google.com/", 7},
+ {"omit https, username, and password",
+ "https://user:password@example.com/foo",
+ kFormatUrlOmitAll | kFormatUrlExperimentalOmitHTTPS,
+ net::UnescapeRule::NORMAL, L"example.com/foo", 0},
+ {"omit https, but preserve user name and password",
+ "https://user:password@example.com/foo", kFormatUrlExperimentalOmitHTTPS,
+ net::UnescapeRule::NORMAL, L"user:password@example.com/foo", 14},
+ {"omit https should not affect hosts starting with ftp.",
+ "https://ftp.google.com/",
+ kFormatUrlOmitHTTP | kFormatUrlExperimentalOmitHTTPS,
+ net::UnescapeRule::NORMAL, L"https://ftp.google.com/", 8},
};
for (size_t i = 0; i < arraysize(tests); ++i) {
@@ -1277,6 +1298,21 @@ TEST(UrlFormatterTest, FormatUrlWithOffsets) {
CheckAdjustedOffsets("http://foo.com//??###",
kFormatUrlOmitAll | kFormatUrlExperimentalElideAfterHost,
net::UnescapeRule::NORMAL, elide_after_host_offsets);
+
+ const size_t omit_https_offsets[] = {
+ 0, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, 0, 1, 2, 3,
+ 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14};
+ CheckAdjustedOffsets("https://www.google.com/",
+ kFormatUrlExperimentalOmitHTTPS,
+ net::UnescapeRule::NORMAL, omit_https_offsets);
+
+ const size_t omit_https_with_auth_offsets[] = {
+ 0, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, 0,
+ kNpos, kNpos, kNpos, 0, 1, 2, 3, 4, 5,
+ 6, 7, 8, 9, 10, 11, 12, 13, 14};
+ CheckAdjustedOffsets("https://u:p@www.google.com/",
+ kFormatUrlOmitAll | kFormatUrlExperimentalOmitHTTPS,
+ net::UnescapeRule::NORMAL, omit_https_with_auth_offsets);
}
} // namespace
« no previous file with comments | « components/url_formatter/url_formatter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698