| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/url_formatter/url_formatter.h" | 5 #include "components/url_formatter/url_formatter.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 kFormatUrlOmitAll | kFormatUrlExperimentalElideAfterHost, | 906 kFormatUrlOmitAll | kFormatUrlExperimentalElideAfterHost, |
| 907 net::UnescapeRule::NORMAL, L"google.com/\x2026\x0000", 0}, | 907 net::UnescapeRule::NORMAL, L"google.com/\x2026\x0000", 0}, |
| 908 {"elide after host with path, query and ref", | 908 {"elide after host with path, query and ref", |
| 909 "http://google.com/foo?a=b#c", | 909 "http://google.com/foo?a=b#c", |
| 910 kFormatUrlOmitAll | kFormatUrlExperimentalElideAfterHost, | 910 kFormatUrlOmitAll | kFormatUrlExperimentalElideAfterHost, |
| 911 net::UnescapeRule::NORMAL, L"google.com/\x2026\x0000", 0}, | 911 net::UnescapeRule::NORMAL, L"google.com/\x2026\x0000", 0}, |
| 912 {"elide after host with repeated delimiters (sanity check)", | 912 {"elide after host with repeated delimiters (sanity check)", |
| 913 "http://google.com////???####", | 913 "http://google.com////???####", |
| 914 kFormatUrlOmitAll | kFormatUrlExperimentalElideAfterHost, | 914 kFormatUrlOmitAll | kFormatUrlExperimentalElideAfterHost, |
| 915 net::UnescapeRule::NORMAL, L"google.com/\x2026\x0000", 0}, | 915 net::UnescapeRule::NORMAL, L"google.com/\x2026\x0000", 0}, |
| 916 |
| 917 // -------- omit https -------- |
| 918 {"omit https", "https://www.google.com/", kFormatUrlExperimentalOmitHTTPS, |
| 919 net::UnescapeRule::NORMAL, L"www.google.com/", 0}, |
| 920 {"omit https but do not omit http", "http://www.google.com/", |
| 921 kFormatUrlExperimentalOmitHTTPS, net::UnescapeRule::NORMAL, |
| 922 L"http://www.google.com/", 7}, |
| 923 {"omit https, username, and password", |
| 924 "https://user:password@example.com/foo", |
| 925 kFormatUrlOmitAll | kFormatUrlExperimentalOmitHTTPS, |
| 926 net::UnescapeRule::NORMAL, L"example.com/foo", 0}, |
| 927 {"omit https, but preserve user name and password", |
| 928 "https://user:password@example.com/foo", kFormatUrlExperimentalOmitHTTPS, |
| 929 net::UnescapeRule::NORMAL, L"user:password@example.com/foo", 14}, |
| 930 {"omit https should not affect hosts starting with ftp.", |
| 931 "https://ftp.google.com/", |
| 932 kFormatUrlOmitHTTP | kFormatUrlExperimentalOmitHTTPS, |
| 933 net::UnescapeRule::NORMAL, L"https://ftp.google.com/", 8}, |
| 916 }; | 934 }; |
| 917 | 935 |
| 918 for (size_t i = 0; i < arraysize(tests); ++i) { | 936 for (size_t i = 0; i < arraysize(tests); ++i) { |
| 919 size_t prefix_len; | 937 size_t prefix_len; |
| 920 base::string16 formatted = FormatUrl( | 938 base::string16 formatted = FormatUrl( |
| 921 GURL(tests[i].input), tests[i].format_types, tests[i].escape_rules, | 939 GURL(tests[i].input), tests[i].format_types, tests[i].escape_rules, |
| 922 nullptr, &prefix_len, nullptr); | 940 nullptr, &prefix_len, nullptr); |
| 923 EXPECT_EQ(WideToUTF16(tests[i].output), formatted) << tests[i].description; | 941 EXPECT_EQ(WideToUTF16(tests[i].output), formatted) << tests[i].description; |
| 924 EXPECT_EQ(tests[i].prefix_len, prefix_len) << tests[i].description; | 942 EXPECT_EQ(tests[i].prefix_len, prefix_len) << tests[i].description; |
| 925 } | 943 } |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 net::UnescapeRule::NORMAL, elide_after_host_offsets); | 1288 net::UnescapeRule::NORMAL, elide_after_host_offsets); |
| 1271 CheckAdjustedOffsets("http://foo.com/abc#def", | 1289 CheckAdjustedOffsets("http://foo.com/abc#def", |
| 1272 kFormatUrlOmitAll | kFormatUrlExperimentalElideAfterHost, | 1290 kFormatUrlOmitAll | kFormatUrlExperimentalElideAfterHost, |
| 1273 net::UnescapeRule::NORMAL, elide_after_host_offsets); | 1291 net::UnescapeRule::NORMAL, elide_after_host_offsets); |
| 1274 CheckAdjustedOffsets("http://foo.com/a?a=b#f", | 1292 CheckAdjustedOffsets("http://foo.com/a?a=b#f", |
| 1275 kFormatUrlOmitAll | kFormatUrlExperimentalElideAfterHost, | 1293 kFormatUrlOmitAll | kFormatUrlExperimentalElideAfterHost, |
| 1276 net::UnescapeRule::NORMAL, elide_after_host_offsets); | 1294 net::UnescapeRule::NORMAL, elide_after_host_offsets); |
| 1277 CheckAdjustedOffsets("http://foo.com//??###", | 1295 CheckAdjustedOffsets("http://foo.com//??###", |
| 1278 kFormatUrlOmitAll | kFormatUrlExperimentalElideAfterHost, | 1296 kFormatUrlOmitAll | kFormatUrlExperimentalElideAfterHost, |
| 1279 net::UnescapeRule::NORMAL, elide_after_host_offsets); | 1297 net::UnescapeRule::NORMAL, elide_after_host_offsets); |
| 1298 |
| 1299 const size_t omit_https_offsets[] = { |
| 1300 0, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, 0, 1, 2, 3, |
| 1301 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}; |
| 1302 CheckAdjustedOffsets("https://www.google.com/", |
| 1303 kFormatUrlExperimentalOmitHTTPS, |
| 1304 net::UnescapeRule::NORMAL, omit_https_offsets); |
| 1305 |
| 1306 const size_t omit_https_with_auth_offsets[] = { |
| 1307 0, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, 0, |
| 1308 kNpos, kNpos, kNpos, 0, 1, 2, 3, 4, 5, |
| 1309 6, 7, 8, 9, 10, 11, 12, 13, 14}; |
| 1310 CheckAdjustedOffsets("https://u:p@www.google.com/", |
| 1311 kFormatUrlOmitAll | kFormatUrlExperimentalOmitHTTPS, |
| 1312 net::UnescapeRule::NORMAL, omit_https_with_auth_offsets); |
| 1280 } | 1313 } |
| 1281 | 1314 |
| 1282 } // namespace | 1315 } // namespace |
| 1283 | 1316 |
| 1284 } // namespace url_formatter | 1317 } // namespace url_formatter |
| OLD | NEW |