blob: e2fc4410b3d42874da57537d87174381a4219c7c [file] [log] [blame]
miguelgdbcfb122015-07-23 10:45:111// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
rsleevi24f64dc22015-08-07 21:39:215#include "components/url_formatter/elide_url.h"
miguelgdbcfb122015-07-23 10:45:116
avi5dd91f82015-12-25 22:30:467#include <stddef.h>
8
avi5dd91f82015-12-25 22:30:469#include "base/macros.h"
gabf64a25e2017-05-12 19:42:5610#include "base/message_loop/message_loop.h"
kulshince612eb2016-06-29 18:46:5111#include "base/run_loop.h"
miguelgdbcfb122015-07-23 10:45:1112#include "base/strings/utf_string_conversions.h"
avi5dd91f82015-12-25 22:30:4613#include "build/build_config.h"
Christopher Grant6871e1212017-10-09 15:47:5014#include "components/url_formatter/url_formatter.h"
15#include "net/base/escape.h"
miguelgdbcfb122015-07-23 10:45:1116#include "testing/gtest/include/gtest/gtest.h"
Christopher Grant6871e1212017-10-09 15:47:5017#include "ui/gfx/font_list.h"
18#include "ui/gfx/text_elider.h"
19#include "ui/gfx/text_utils.h"
miguelgdbcfb122015-07-23 10:45:1120#include "url/gurl.h"
juncaicb63cac2016-05-13 00:41:5921#include "url/origin.h"
miguelgdbcfb122015-07-23 10:45:1122
miguelgdbcfb122015-07-23 10:45:1123namespace {
24
25struct Testcase {
26 const std::string input;
27 const std::string output;
28};
29
Christopher Grant5ed8d112017-09-12 20:00:0630struct ProgressiveTestcase {
31 const std::string input;
32 const std::vector<std::string> output;
33};
34
Christopher Grant6871e1212017-10-09 15:47:5035struct UrlComponent {
36 url::Parsed::ComponentType type;
37 int begin;
38 int len;
39};
40
41struct ParsingTestcase {
42 const std::string input;
43 const std::string output;
44 const std::vector<UrlComponent> components;
45};
46
Christopher Grantd477bee2018-01-24 17:08:4147#if !defined(OS_ANDROID)
48
Trent Apted3bef7a32018-01-23 05:39:0749// Returns the width of a utf8 or utf16 string using the BROWSER typesetter and
50// default UI font, or the provided |font_list|.
51float GetWidth(const std::string& utf8,
52 const gfx::FontList& font_list = gfx::FontList()) {
53 return gfx::GetStringWidthF(base::UTF8ToUTF16(utf8), font_list,
54 gfx::Typesetter::BROWSER);
55}
56float GetWidth(const base::string16& utf16,
57 const gfx::FontList& font_list = gfx::FontList()) {
58 return gfx::GetStringWidthF(utf16, font_list, gfx::Typesetter::BROWSER);
59}
60
Christopher Grant5ed8d112017-09-12 20:00:0661// Verify that one or more URLs passes through an explicit sequence of elided
62// strings as available space progressively decreases. This helps ensure that
63// transitional corner cases are handled properly. To be tolerant of
64// character-width variation across platforms, the test allows a limited number
65// of expected strings to be skipped mid-run. The first and last expected
66// strings must be matched. If the algorithm produces a string that isn't in the
67// expected string list, the test fill fail. Example test expectations:
68//
69// google.com/intl/en/.../ads/ <-- Must match.
70// google.com/intl/.../ads/
71// google.com/.../ads/
72// google.com/intl... <- Elider can skip this, in case the 'l' does not fit.
73// google.com/int...
74// google.com/in... <- Must match.
75//
76void RunProgressiveElisionTest(
Christopher Grantd477bee2018-01-24 17:08:4177 const std::vector<ProgressiveTestcase>& testcases) {
Christopher Grant5ed8d112017-09-12 20:00:0678 const gfx::FontList font_list;
79 for (const auto& testcase : testcases) {
80 SCOPED_TRACE("Eliding " + testcase.input);
81 const GURL url(testcase.input);
82
83 // Occasionally, a parsed URL can grow in length before elision, such as
84 // when parsing a Windows file path with missing slashes.
85 ASSERT_FALSE(testcase.output.empty());
Trent Apted3bef7a32018-01-23 05:39:0786 float width = std::max(GetWidth(testcase.input, font_list),
87 GetWidth(testcase.output.front(), font_list));
Christopher Grant5ed8d112017-09-12 20:00:0688
89 // Ideally, this test would iterate through all available field widths on a
90 // per-pixel basis, but this is slow. Instead, compute the next input field
91 // width as slightly less than the previous elided string. This approach
92 // misses coverage in cases where a smaller available width generates a
93 // longer string than some other larger available width, but the tradeoff
94 // feels acceptable.
95 int mismatches = 0;
96 const int kMaxConsecutiveMismatches = 3;
97 for (size_t i = 0; i < testcase.output.size(); i++) {
98 const auto& expected = testcase.output[i];
99 base::string16 expected_utf16 = base::UTF8ToUTF16(expected);
Christopher Grantd477bee2018-01-24 17:08:41100 base::string16 elided = url_formatter::ElideUrl(url, font_list, width,
101 gfx::Typesetter::BROWSER);
Christopher Grant5ed8d112017-09-12 20:00:06102 if (expected_utf16 != elided) {
103 if (i > 0 && i < testcase.output.size() - 1 &&
104 mismatches < kMaxConsecutiveMismatches) {
105 mismatches++;
106 continue;
107 }
108 EXPECT_EQ(expected_utf16, elided);
109 break;
110 }
111 mismatches = 0;
Trent Apted3bef7a32018-01-23 05:39:07112 float new_width = GetWidth(elided, font_list);
Christopher Grant5ed8d112017-09-12 20:00:06113 // Elision rounds fractional available widths up.
114 EXPECT_LE(new_width, std::ceil(width)) << " at " << elided;
115 width = new_width - 1.0f;
116 }
117 }
118}
119
Christopher Grant6871e1212017-10-09 15:47:50120void RunElisionTest(const std::vector<Testcase>& testcases) {
121 const gfx::FontList font_list;
122 for (const auto& testcase : testcases) {
123 SCOPED_TRACE("Eliding " + testcase.input);
124 const GURL url(testcase.input);
Trent Apted3bef7a32018-01-23 05:39:07125 const float available_width = GetWidth(testcase.output, font_list);
Christopher Grant6871e1212017-10-09 15:47:50126 EXPECT_EQ(base::UTF8ToUTF16(testcase.output),
Trent Apted3bef7a32018-01-23 05:39:07127 url_formatter::ElideUrl(url, font_list, available_width,
128 gfx::Typesetter::BROWSER));
Christopher Grant6871e1212017-10-09 15:47:50129 }
130}
131
miguelgdbcfb122015-07-23 10:45:11132// Test eliding of commonplace URLs.
Trent Apted3bef7a32018-01-23 05:39:07133TEST(TextEliderTest, TestGeneralEliding) {
rsleevi24f64dc22015-08-07 21:39:21134 const std::string kEllipsisStr(gfx::kEllipsis);
Christopher Grant5ed8d112017-09-12 20:00:06135 const std::vector<ProgressiveTestcase> progressive_testcases = {
136 // Elide a non-www URL (www URLs are handled differently). In this first
137 // case, elide down to nothing to test the terminal cases.
138 {"http://xyz.google.com/foo?bar",
139 {
140 /* clang-format off */
141 "xyz.google.com/foo?bar",
142 "xyz.google.com/foo?b" + kEllipsisStr,
143 "xyz.google.com/foo?" + kEllipsisStr,
144 "xyz.google.com/foo" + kEllipsisStr,
145 "xyz.google.com/fo" + kEllipsisStr,
146 "xyz.google.com/f" + kEllipsisStr,
147 kEllipsisStr + "google.com/foo" + kEllipsisStr,
148 kEllipsisStr + "google.com/fo" + kEllipsisStr,
149 kEllipsisStr + "google.com/f" + kEllipsisStr,
150 kEllipsisStr + "google.com/" + kEllipsisStr,
151 kEllipsisStr + "google.com" + kEllipsisStr,
152 kEllipsisStr + "google.co" + kEllipsisStr,
153 kEllipsisStr + "google.c" + kEllipsisStr,
154 kEllipsisStr + "google." + kEllipsisStr,
155 kEllipsisStr + "google" + kEllipsisStr,
156 kEllipsisStr + "googl" + kEllipsisStr,
157 kEllipsisStr + "goog" + kEllipsisStr,
158 kEllipsisStr + "goo" + kEllipsisStr,
159 kEllipsisStr + "go" + kEllipsisStr,
160 kEllipsisStr + "g" + kEllipsisStr,
161 kEllipsisStr + kEllipsisStr,
162 kEllipsisStr,
163 ""
164 /* clang-format on */
165 }},
166 // The trailing directory name is preserved
miguelgdbcfb122015-07-23 10:45:11167 {"http://www.google.com/intl/en/ads/",
Christopher Grant5ed8d112017-09-12 20:00:06168 {
169 /* clang-format off */
170 "www.google.com/intl/en/ads/",
171 "google.com/intl/en/ads/",
172 "google.com/intl/" + kEllipsisStr + "/ads/",
173 "google.com/" + kEllipsisStr + "/ads/",
174 "google.com/" + kEllipsisStr + "/ad" + kEllipsisStr,
175 "google.com/" + kEllipsisStr + "/a" + kEllipsisStr,
176 "google.com/intl/e" + kEllipsisStr,
177 "google.com/intl/" + kEllipsisStr,
178 "google.com/intl" + kEllipsisStr,
179 "google.com/int" + kEllipsisStr,
180 "google.com/in" + kEllipsisStr,
181 "google.com/i" + kEllipsisStr,
182 "google.com/" + kEllipsisStr,
183 "google.com" + kEllipsisStr,
184 "google.co" + kEllipsisStr,
185 "google.c" + kEllipsisStr,
186 "google." + kEllipsisStr,
187 "google" + kEllipsisStr,
188 "googl" + kEllipsisStr,
189 /* clang-format on */
190 }},
191 // Subdomain is completely elided if the last path element doesn't fit.
miguelgdbcfb122015-07-23 10:45:11192 {"https://subdomain.foo.com/bar/filename.html",
Christopher Grant5ed8d112017-09-12 20:00:06193 {
194 /* clang-format off */
195 "https://subdomain.foo.com/bar/filename.html",
196 "subdomain.foo.com/bar/filename.html",
197 "subdomain.foo.com/" + kEllipsisStr + "/filename.html",
198 kEllipsisStr + "foo.com/bar/filename.html",
199 kEllipsisStr + "foo.com/" + kEllipsisStr + "/filename.html",
200 /* clang-format on */
201 }},
202 // Path eliding works when a query is present.
203 {"http://www.g.com/subdir/ads/?query",
204 {
205 /* clang-format off */
206 "www.g.com/subdir/ads/?query",
207 "www.g.com/subdir/ads/?que" + kEllipsisStr,
208 "www.g.com/subdir/ads/?qu" + kEllipsisStr,
209 "www.g.com/subdir/ads/?q" + kEllipsisStr,
210 "www.g.com/subdir/ads/?" + kEllipsisStr,
211 "www.g.com/subdir/ads/" + kEllipsisStr,
212 "www.g.com/subdir/ads" + kEllipsisStr,
213 "www.g.com/subdir/ad" + kEllipsisStr,
214 /* clang-format on */
215 }},
miguelgdbcfb122015-07-23 10:45:11216 };
Christopher Grantd477bee2018-01-24 17:08:41217 RunProgressiveElisionTest(progressive_testcases);
miguelgdbcfb122015-07-23 10:45:11218}
219
220// When there is very little space available, the elision code will shorten
221// both path AND file name to an ellipsis - ".../...". To avoid this result,
222// there is a hack in place that simply treats them as one string in this
223// case.
224TEST(TextEliderTest, TestTrailingEllipsisSlashEllipsisHack) {
rsleevi24f64dc22015-08-07 21:39:21225 const std::string kEllipsisStr(gfx::kEllipsis);
miguelgdbcfb122015-07-23 10:45:11226
227 // Very little space, would cause double ellipsis.
228 gfx::FontList font_list;
229 GURL url("http://battersbox.com/directory/foo/peter_paul_and_mary.html");
Trent Apted3bef7a32018-01-23 05:39:07230 float available_width = GetWidth(
231 "battersbox.com/" + kEllipsisStr + "/" + kEllipsisStr, font_list);
miguelgdbcfb122015-07-23 10:45:11232
233 // Create the expected string, after elision. Depending on font size, the
234 // directory might become /dir... or /di... or/d... - it never should be
235 // shorter than that. (If it is, the font considers d... to be longer
236 // than .../... - that should never happen).
Trent Apted3bef7a32018-01-23 05:39:07237 ASSERT_GT(GetWidth(kEllipsisStr + "/" + kEllipsisStr, font_list),
238 GetWidth("d" + kEllipsisStr, font_list));
miguelgdbcfb122015-07-23 10:45:11239 GURL long_url("http://battersbox.com/directorynameisreallylongtoforcetrunc");
rsleevi24f64dc22015-08-07 21:39:21240 base::string16 expected = url_formatter::ElideUrl(
Trent Apted3bef7a32018-01-23 05:39:07241 long_url, font_list, available_width, gfx::Typesetter::BROWSER);
miguelgdbcfb122015-07-23 10:45:11242 // Ensure that the expected result still contains part of the directory name.
243 ASSERT_GT(expected.length(), std::string("battersbox.com/d").length());
Trent Apted3bef7a32018-01-23 05:39:07244 EXPECT_EQ(expected, url_formatter::ElideUrl(url, font_list, available_width,
245 gfx::Typesetter::BROWSER));
miguelgdbcfb122015-07-23 10:45:11246
Matt Giuca49fcda172017-08-29 07:16:12247 // Regression test for https://crbug.com/756717. An empty path, eliding to a
248 // width in between the full domain ("www.angelfire.lycos.com") and a bit
249 // longer than the ETLD+1 ("…lycos.com…/…UV"). This previously crashed due to
250 // the path being empty.
251 url = GURL("http://www.angelfire.lycos.com/");
Trent Apted3bef7a32018-01-23 05:39:07252 available_width = GetWidth(kEllipsisStr + "angelfire.lycos.com", font_list);
Matt Giuca49fcda172017-08-29 07:16:12253 EXPECT_EQ(base::UTF8ToUTF16(kEllipsisStr + "lycos.com"),
Trent Apted3bef7a32018-01-23 05:39:07254 url_formatter::ElideUrl(url, font_list, available_width,
255 gfx::Typesetter::BROWSER));
Matt Giuca49fcda172017-08-29 07:16:12256
miguelgdbcfb122015-07-23 10:45:11257 // More space available - elide directories, partially elide filename.
Christopher Grant5ed8d112017-09-12 20:00:06258 const std::vector<Testcase> testcases = {
miguelgdbcfb122015-07-23 10:45:11259 {"http://battersbox.com/directory/foo/peter_paul_and_mary.html",
260 "battersbox.com/" + kEllipsisStr + "/peter" + kEllipsisStr},
261 };
Christopher Grant5ed8d112017-09-12 20:00:06262 RunElisionTest(testcases);
miguelgdbcfb122015-07-23 10:45:11263}
264
265// Test eliding of empty strings, URLs with ports, passwords, queries, etc.
Christopher Grant5ed8d112017-09-12 20:00:06266TEST(TextEliderTest, TestElisionSpecialCases) {
kulshince612eb2016-06-29 18:46:51267#if defined(OS_WIN)
268 // Needed to bypass DCHECK in GetFallbackFont.
269 base::MessageLoopForUI message_loop;
270#endif
rsleevi24f64dc22015-08-07 21:39:21271 const std::string kEllipsisStr(gfx::kEllipsis);
Christopher Grant5ed8d112017-09-12 20:00:06272 const std::vector<Testcase> testcases = {
Matt Giuca49fcda172017-08-29 07:16:12273 // URL with "www" subdomain (gets removed specially).
274 {"http://www.google.com/foo?bar", "www.google.com/foo?bar"},
275 {"http://www.google.com/foo?bar", "google.com/foo?bar"},
276
Matt Giuca51f68cc2017-07-07 01:34:57277 // URL with no path.
Matt Giuca49fcda172017-08-29 07:16:12278 {"http://xyz.google.com", kEllipsisStr + "google.com"},
279 {"https://xyz.google.com", kEllipsisStr + "google.com"},
Matt Giuca51f68cc2017-07-07 01:34:57280
miguelgdbcfb122015-07-23 10:45:11281 {"http://a.b.com/pathname/c?d", "a.b.com/" + kEllipsisStr + "/c?d"},
282 {"", ""},
283 {"http://foo.bar..example.com...hello/test/filename.html",
284 "foo.bar..example.com...hello/" + kEllipsisStr + "/filename.html"},
285 {"http://foo.bar../", "foo.bar.."},
286 {"http://xn--1lq90i.cn/foo", "\xe5\x8c\x97\xe4\xba\xac.cn/foo"},
287 {"http://me:[email protected]:99/foo?bar#baz",
288 "secrethost.com:99/foo?bar#baz"},
289 {"http://me:mypass@ss%xxfdsf.com/foo", "ss%25xxfdsf.com/foo"},
290 {"mailto:[email protected]", "mailto:[email protected]"},
291 {"javascript:click(0)", "javascript:click(0)"},
292 {"https://chess.eecs.berkeley.edu:4430/login/arbitfilename",
293 "chess.eecs.berkeley.edu:4430/login/arbitfilename"},
294 {"https://chess.eecs.berkeley.edu:4430/login/arbitfilename",
295 kEllipsisStr + "berkeley.edu:4430/" + kEllipsisStr + "/arbitfilename"},
296
297 // Unescaping.
Eric Lawrence03f9a902017-12-16 04:48:11298 {"http://www/%E4%BD%A0%E5%A5%BD?"
299 "q=%E4%BD%A0%E5%A5%BD#\xe4\xbd\xa0\xe4\xbd\xa0\xe4\xbd\xa0",
300 "www/\xe4\xbd\xa0\xe5\xa5\xbd?q=\xe4\xbd\xa0\xe5\xa5\xbd#\xe4\xbd\xa0" +
Mike Westf8f6ed52017-10-09 20:58:50301 kEllipsisStr},
miguelgdbcfb122015-07-23 10:45:11302
303 // Invalid unescaping for path. The ref will always be valid UTF-8. We
Christopher Grant5ed8d112017-09-12 20:00:06304 // don't bother to do too many edge cases, since these are handled by the
305 // escaper unittest.
miguelgdbcfb122015-07-23 10:45:11306 {"http://www/%E4%A0%E5%A5%BD?q=%E4%BD%A0%E5%A5%BD#\xe4\xbd\xa0",
Eric Lawrence03f9a902017-12-16 04:48:11307 "www/%E4%A0%E5%A5%BD?q=\xe4\xbd\xa0\xe5\xa5\xbd#\xe4\xbd\xa0"},
miguelgdbcfb122015-07-23 10:45:11308 };
309
Christopher Grant5ed8d112017-09-12 20:00:06310 RunElisionTest(testcases);
miguelgdbcfb122015-07-23 10:45:11311}
312
313// Test eliding of file: URLs.
Trent Apted3bef7a32018-01-23 05:39:07314TEST(TextEliderTest, TestFileURLEliding) {
rsleevi24f64dc22015-08-07 21:39:21315 const std::string kEllipsisStr(gfx::kEllipsis);
Christopher Grant5ed8d112017-09-12 20:00:06316 const std::vector<ProgressiveTestcase> progressive_testcases = {
miguelgdbcfb122015-07-23 10:45:11317 {"file:///C:/path1/path2/path3/filename",
Christopher Grant5ed8d112017-09-12 20:00:06318 {
319 /* clang-format off */
320 "file:///C:/path1/path2/path3/filename",
321 "C:/path1/path2/path3/filename",
322 "C:/path1/path2/" + kEllipsisStr + "/filename",
323 /* clang-format on */
324 }},
miguelgdbcfb122015-07-23 10:45:11325// GURL parses "file:///C:path" differently on windows than it does on posix.
326#if defined(OS_WIN)
327 {"file:///C:path1/path2/path3/filename",
Christopher Grant5ed8d112017-09-12 20:00:06328 {
329 /* clang-format off */
330 "file:///C:/path1/path2/path3/filename",
331 "C:/path1/path2/path3/filename",
332 "C:/path1/path2/" + kEllipsisStr + "/filename",
333 "C:/path1/" + kEllipsisStr + "/filename",
334 "C:/" + kEllipsisStr + "/filename",
335 /* clang-format on */
336 }},
miguelgdbcfb122015-07-23 10:45:11337#endif // defined(OS_WIN)
Christopher Grant5ed8d112017-09-12 20:00:06338 {"file://filer/foo/bar/file",
339 {
340 /* clang-format off */
341 "file://filer/foo/bar/file",
342 "filer/foo/bar/file",
343 "filer/foo/" + kEllipsisStr + "/file",
344 "filer/" + kEllipsisStr + "/file",
345 "filer/foo" + kEllipsisStr,
346 "filer/fo" + kEllipsisStr,
347 "filer/f" + kEllipsisStr,
348 "filer/" + kEllipsisStr,
349 "filer" + kEllipsisStr,
350 "file" + kEllipsisStr,
351 /* clang-format on */
352 }},
miguelgdbcfb122015-07-23 10:45:11353 };
354
Christopher Grantd477bee2018-01-24 17:08:41355 RunProgressiveElisionTest(progressive_testcases);
Christopher Grant5ed8d112017-09-12 20:00:06356
357 const std::vector<Testcase> testcases = {
358 // Eliding file URLs with nothing after the ':' shouldn't crash.
359 {"file:///aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:", "aaa" + kEllipsisStr},
360 {"file:///aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:/", "aaa" + kEllipsisStr},
361 };
362 RunElisionTest(testcases);
miguelgdbcfb122015-07-23 10:45:11363}
364
365TEST(TextEliderTest, TestHostEliding) {
rsleevi24f64dc22015-08-07 21:39:21366 const std::string kEllipsisStr(gfx::kEllipsis);
miguelgdbcfb122015-07-23 10:45:11367 Testcase testcases[] = {
pkl2affa912017-02-22 15:23:20368 {"http://google.com", "google.com"},
369 {"http://reallyreallyreallylongdomainname.com",
370 "reallyreallyreallylongdomainname.com"},
371 {"http://foo", "foo"},
372 {"http://foo.bar", "foo.bar"},
pkl2affa912017-02-22 15:23:20373 {"http://subdomain.google.com", kEllipsisStr + ".google.com"},
374 {"http://a.b.c.d.e.f.com", kEllipsisStr + "f.com"},
375 {"http://subdomain.foo.bar", kEllipsisStr + "in.foo.bar"},
376 {"http://subdomain.reallylongdomainname.com",
377 kEllipsisStr + "ain.reallylongdomainname.com"},
378 {"http://a.b.c.d.e.f.com", kEllipsisStr + ".e.f.com"},
379 // IDN - Greek alpha.beta.gamma.delta.epsilon.zeta.com
380 {"http://xn--mxa.xn--nxa.xn--oxa.xn--pxa.xn--qxa.xn--rxa.com",
381 kEllipsisStr + ".\xCE\xB5.\xCE\xB6.com"},
miguelgdbcfb122015-07-23 10:45:11382 };
383
384 for (size_t i = 0; i < arraysize(testcases); ++i) {
Trent Apted3bef7a32018-01-23 05:39:07385 // Note this does not use GetWidth(), so typesetting will be done with
386 // gfx::Typesetter::DEFAULT. ElideHost() supports either typesetter on Mac.
rsleevi24f64dc22015-08-07 21:39:21387 const float available_width = gfx::GetStringWidthF(
388 base::UTF8ToUTF16(testcases[i].output), gfx::FontList());
389 EXPECT_EQ(base::UTF8ToUTF16(testcases[i].output),
390 url_formatter::ElideHost(GURL(testcases[i].input),
391 gfx::FontList(), available_width));
miguelgdbcfb122015-07-23 10:45:11392 }
393
394 // Trying to elide to a really short length will still keep the full TLD+1
395 EXPECT_EQ(
396 base::ASCIIToUTF16("google.com"),
rsleevi24f64dc22015-08-07 21:39:21397 url_formatter::ElideHost(GURL("http://google.com"), gfx::FontList(), 2));
miguelgdbcfb122015-07-23 10:45:11398 EXPECT_EQ(base::UTF8ToUTF16(kEllipsisStr + ".google.com"),
rsleevi24f64dc22015-08-07 21:39:21399 url_formatter::ElideHost(GURL("http://subdomain.google.com"),
400 gfx::FontList(), 2));
miguelgdbcfb122015-07-23 10:45:11401 EXPECT_EQ(
402 base::ASCIIToUTF16("foo.bar"),
rsleevi24f64dc22015-08-07 21:39:21403 url_formatter::ElideHost(GURL("http://foo.bar"), gfx::FontList(), 2));
miguelgdbcfb122015-07-23 10:45:11404}
405
406#endif // !defined(OS_ANDROID)
407
juncaicb63cac2016-05-13 00:41:59408struct OriginTestData {
409 const char* const description;
410 const char* const input;
411 const wchar_t* const output;
412 const wchar_t* const output_omit_web_scheme;
413 const wchar_t* const output_omit_cryptographic_scheme;
414};
415
416// Common test data for both FormatUrlForSecurityDisplay() and
417// FormatOriginForSecurityDisplay()
418const OriginTestData common_tests[] = {
419 {"Empty URL", "", L"", L"", L""},
420 {"HTTP URL", "http://www.google.com/", L"http://www.google.com",
421 L"www.google.com", L"http://www.google.com"},
422 {"HTTPS URL", "https://www.google.com/", L"https://www.google.com",
423 L"www.google.com", L"www.google.com"},
424 {"Standard HTTP port", "http://www.google.com:80/",
425 L"http://www.google.com", L"www.google.com", L"http://www.google.com"},
426 {"Standard HTTPS port", "https://www.google.com:443/",
427 L"https://www.google.com", L"www.google.com", L"www.google.com"},
428 {"Standard HTTP port, IDN Chinese",
429 "http://\xe4\xb8\xad\xe5\x9b\xbd.icom.museum:80",
jshin78809c4d82016-10-06 20:15:45430 L"http://\x4e2d\x56fd.icom.museum", L"\x4e2d\x56fd.icom.museum",
431 L"http://\x4e2d\x56fd.icom.museum"},
juncaicb63cac2016-05-13 00:41:59432 {"HTTP URL, IDN Hebrew (RTL)",
433 "http://"
434 "\xd7\x90\xd7\x99\xd7\xa7\xd7\x95\xd7\xb4\xd7\x9d."
435 "\xd7\x99\xd7\xa9\xd7\xa8\xd7\x90\xd7\x9c.museum/",
436 L"http://xn--4dbklr2c8d.xn--4dbrk0ce.museum",
437 L"xn--4dbklr2c8d.xn--4dbrk0ce.museum",
438 L"http://xn--4dbklr2c8d.xn--4dbrk0ce.museum"},
439 {"HTTP URL with query string, IDN Arabic (RTL)",
440 "http://\xd9\x85\xd8\xb5\xd8\xb1.icom.museum/foo.html?yes=no",
441 L"http://xn--wgbh1c.icom.museum", L"xn--wgbh1c.icom.museum",
442 L"http://xn--wgbh1c.icom.museum"},
443 {"Non-standard HTTP port", "http://www.google.com:9000/",
444 L"http://www.google.com:9000", L"www.google.com:9000",
445 L"http://www.google.com:9000"},
446 {"Non-standard HTTPS port", "https://www.google.com:9000/",
447 L"https://www.google.com:9000", L"www.google.com:9000",
448 L"www.google.com:9000"},
449 {"HTTP URL with path", "http://www.google.com/test.html",
450 L"http://www.google.com", L"www.google.com", L"http://www.google.com"},
451 {"HTTPS URL with path", "https://www.google.com/test.html",
452 L"https://www.google.com", L"www.google.com", L"www.google.com"},
453 {"Unusual secure scheme (wss)", "wss://www.google.com/",
454 L"wss://www.google.com", L"wss://www.google.com", L"www.google.com"},
455 {"Unusual non-secure scheme (gopher)", "gopher://www.google.com/",
456 L"gopher://www.google.com", L"gopher://www.google.com",
457 L"gopher://www.google.com"},
458 {"Unlisted scheme (chrome)", "chrome://version", L"chrome://version",
459 L"chrome://version", L"chrome://version"},
460 {"HTTP IP address", "http://173.194.65.103", L"http://173.194.65.103",
461 L"173.194.65.103", L"http://173.194.65.103"},
462 {"HTTPS IP address", "https://173.194.65.103", L"https://173.194.65.103",
463 L"173.194.65.103", L"173.194.65.103"},
464 {"HTTP IPv6 address", "http://[FE80:0000:0000:0000:0202:B3FF:FE1E:8329]/",
465 L"http://[fe80::202:b3ff:fe1e:8329]", L"[fe80::202:b3ff:fe1e:8329]",
466 L"http://[fe80::202:b3ff:fe1e:8329]"},
467 {"HTTPs IPv6 address", "https://[FE80:0000:0000:0000:0202:B3FF:FE1E:8329]/",
468 L"https://[fe80::202:b3ff:fe1e:8329]", L"[fe80::202:b3ff:fe1e:8329]",
469 L"[fe80::202:b3ff:fe1e:8329]"},
470 {"HTTP IPv6 address with port",
471 "http://[FE80:0000:0000:0000:0202:B3FF:FE1E:8329]:80/",
472 L"http://[fe80::202:b3ff:fe1e:8329]", L"[fe80::202:b3ff:fe1e:8329]",
473 L"http://[fe80::202:b3ff:fe1e:8329]"},
474 {"HTTPs IPv6 address with port",
475 "https://[FE80:0000:0000:0000:0202:B3FF:FE1E:8329]:443/",
476 L"https://[fe80::202:b3ff:fe1e:8329]", L"[fe80::202:b3ff:fe1e:8329]",
477 L"[fe80::202:b3ff:fe1e:8329]"},
478 {"HTTPS IP address, non-default port", "https://173.194.65.103:8443",
479 L"https://173.194.65.103:8443", L"173.194.65.103:8443",
480 L"173.194.65.103:8443"},
481 {"Invalid host 1", "https://www.cyber../wow.php", L"https://www.cyber..",
482 L"www.cyber..", L"www.cyber.."},
483 {"Invalid host 2", "https://www...cyber/wow.php", L"https://www...cyber",
484 L"www...cyber", L"www...cyber"},
485 {"Invalid port 3", "https://173.194.65.103:/hello.aspx",
486 L"https://173.194.65.103", L"173.194.65.103", L"173.194.65.103"},
487 {"Trailing dot in DNS name", "https://www.example.com./get/goat",
488 L"https://www.example.com.", L"www.example.com.", L"www.example.com."}};
489
miguelgdbcfb122015-07-23 10:45:11490TEST(TextEliderTest, FormatUrlForSecurityDisplay) {
juncaicb63cac2016-05-13 00:41:59491 for (size_t i = 0; i < arraysize(common_tests); ++i) {
492 base::string16 formatted =
493 url_formatter::FormatUrlForSecurityDisplay(GURL(common_tests[i].input));
494 EXPECT_EQ(base::WideToUTF16(common_tests[i].output), formatted)
495 << common_tests[i].description;
496
497 base::string16 formatted_omit_web_scheme =
498 url_formatter::FormatUrlForSecurityDisplay(
499 GURL(common_tests[i].input),
500 url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
501 EXPECT_EQ(base::WideToUTF16(common_tests[i].output_omit_web_scheme),
502 formatted_omit_web_scheme)
503 << common_tests[i].description;
504
505 base::string16 formatted_omit_cryptographic_scheme =
506 url_formatter::FormatUrlForSecurityDisplay(
507 GURL(common_tests[i].input),
508 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC);
509 EXPECT_EQ(
510 base::WideToUTF16(common_tests[i].output_omit_cryptographic_scheme),
511 formatted_omit_cryptographic_scheme)
512 << common_tests[i].description;
513 }
miguelgdbcfb122015-07-23 10:45:11514
515 const OriginTestData tests[] = {
miguelgdbcfb122015-07-23 10:45:11516 {"File URI", "file:///usr/example/file.html",
benwells2337b8102016-04-20 01:53:53517 L"file:///usr/example/file.html", L"file:///usr/example/file.html",
518 L"file:///usr/example/file.html"},
miguelgdbcfb122015-07-23 10:45:11519 {"File URI with hostname", "file://localhost/usr/example/file.html",
benwells2337b8102016-04-20 01:53:53520 L"file:///usr/example/file.html", L"file:///usr/example/file.html",
521 L"file:///usr/example/file.html"},
miguelgdbcfb122015-07-23 10:45:11522 {"UNC File URI 1", "file:///CONTOSO/accounting/money.xls",
palmer153af982015-09-15 02:04:19523 L"file:///CONTOSO/accounting/money.xls",
benwells2337b8102016-04-20 01:53:53524 L"file:///CONTOSO/accounting/money.xls",
miguelgdbcfb122015-07-23 10:45:11525 L"file:///CONTOSO/accounting/money.xls"},
526 {"UNC File URI 2",
527 "file:///C:/Program%20Files/Music/Web%20Sys/main.html?REQUEST=RADIO",
palmer153af982015-09-15 02:04:19528 L"file:///C:/Program%20Files/Music/Web%20Sys/main.html",
benwells2337b8102016-04-20 01:53:53529 L"file:///C:/Program%20Files/Music/Web%20Sys/main.html",
miguelgdbcfb122015-07-23 10:45:11530 L"file:///C:/Program%20Files/Music/Web%20Sys/main.html"},
benwells2337b8102016-04-20 01:53:53531 {"Invalid IPv6 address", "https://[2001:db8:0:1]/",
532 L"https://[2001:db8:0:1]", L"https://[2001:db8:0:1]",
533 L"https://[2001:db8:0:1]"},
miguelgdbcfb122015-07-23 10:45:11534 {"HTTP filesystem: URL with path",
535 "filesystem:http://www.google.com/temporary/test.html",
benwells2337b8102016-04-20 01:53:53536 L"filesystem:http://www.google.com", L"filesystem:http://www.google.com",
miguelgdbcfb122015-07-23 10:45:11537 L"filesystem:http://www.google.com"},
538 {"File filesystem: URL with path",
juncaicb63cac2016-05-13 00:41:59539 "filesystem:file://localhost/temporary/stuff/"
540 "test.html?z=fun&goat=billy",
palmer153af982015-09-15 02:04:19541 L"filesystem:file:///temporary/stuff/test.html",
benwells2337b8102016-04-20 01:53:53542 L"filesystem:file:///temporary/stuff/test.html",
miguelgdbcfb122015-07-23 10:45:11543 L"filesystem:file:///temporary/stuff/test.html"},
544 {"Invalid scheme 1", "twelve://www.cyber.org/wow.php",
benwells2337b8102016-04-20 01:53:53545 L"twelve://www.cyber.org/wow.php", L"twelve://www.cyber.org/wow.php",
546 L"twelve://www.cyber.org/wow.php"},
miguelgdbcfb122015-07-23 10:45:11547 {"Invalid scheme 2", "://www.cyber.org/wow.php",
benwells2337b8102016-04-20 01:53:53548 L"://www.cyber.org/wow.php", L"://www.cyber.org/wow.php",
549 L"://www.cyber.org/wow.php"},
miguelgdbcfb122015-07-23 10:45:11550 {"Invalid port 1", "https://173.194.65.103:000",
benwells2337b8102016-04-20 01:53:53551 L"https://173.194.65.103:0", L"173.194.65.103:0", L"173.194.65.103:0"},
miguelgdbcfb122015-07-23 10:45:11552 {"Invalid port 2", "https://173.194.65.103:gruffle",
benwells2337b8102016-04-20 01:53:53553 L"https://173.194.65.103:gruffle", L"https://173.194.65.103:gruffle",
554 L"https://173.194.65.103:gruffle"},
miguelgdbcfb122015-07-23 10:45:11555 {"Blob URL",
nick1b17dc32016-04-15 21:34:04556 "blob:http://www.html5rocks.com/4d4ff040-6d61-4446-86d3-13ca07ec9ab9",
557 L"blob:http://www.html5rocks.com/"
palmer153af982015-09-15 02:04:19558 L"4d4ff040-6d61-4446-86d3-13ca07ec9ab9",
nick1b17dc32016-04-15 21:34:04559 L"blob:http://www.html5rocks.com/"
benwells2337b8102016-04-20 01:53:53560 L"4d4ff040-6d61-4446-86d3-13ca07ec9ab9",
561 L"blob:http://www.html5rocks.com/"
palmer153af982015-09-15 02:04:19562 L"4d4ff040-6d61-4446-86d3-13ca07ec9ab9"}};
miguelgdbcfb122015-07-23 10:45:11563
miguelgdbcfb122015-07-23 10:45:11564 for (size_t i = 0; i < arraysize(tests); ++i) {
jshin1fb76462016-04-05 22:13:03565 base::string16 formatted =
566 url_formatter::FormatUrlForSecurityDisplay(GURL(tests[i].input));
miguelgdbcfb122015-07-23 10:45:11567 EXPECT_EQ(base::WideToUTF16(tests[i].output), formatted)
568 << tests[i].description;
palmer153af982015-09-15 02:04:19569
benwells2337b8102016-04-20 01:53:53570 base::string16 formatted_omit_web_scheme =
571 url_formatter::FormatUrlForSecurityDisplay(
572 GURL(tests[i].input),
573 url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
574 EXPECT_EQ(base::WideToUTF16(tests[i].output_omit_web_scheme),
575 formatted_omit_web_scheme)
576 << tests[i].description;
577
578 base::string16 formatted_omit_cryptographic_scheme =
579 url_formatter::FormatUrlForSecurityDisplay(
580 GURL(tests[i].input),
581 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC);
582 EXPECT_EQ(base::WideToUTF16(tests[i].output_omit_cryptographic_scheme),
583 formatted_omit_cryptographic_scheme)
palmer153af982015-09-15 02:04:19584 << tests[i].description;
miguelgdbcfb122015-07-23 10:45:11585 }
586
juncaicb63cac2016-05-13 00:41:59587 base::string16 formatted = url_formatter::FormatUrlForSecurityDisplay(GURL());
miguelgdbcfb122015-07-23 10:45:11588 EXPECT_EQ(base::string16(), formatted)
589 << "Explicitly test the 0-argument GURL constructor";
palmer153af982015-09-15 02:04:19590
591 base::string16 formatted_omit_scheme =
benwells2337b8102016-04-20 01:53:53592 url_formatter::FormatUrlForSecurityDisplay(
593 GURL(), url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
594 EXPECT_EQ(base::string16(), formatted_omit_scheme)
595 << "Explicitly test the 0-argument GURL constructor";
596
597 formatted_omit_scheme = url_formatter::FormatUrlForSecurityDisplay(
598 GURL(), url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC);
palmer153af982015-09-15 02:04:19599 EXPECT_EQ(base::string16(), formatted_omit_scheme)
600 << "Explicitly test the 0-argument GURL constructor";
miguelgdbcfb122015-07-23 10:45:11601}
602
juncaicb63cac2016-05-13 00:41:59603TEST(TextEliderTest, FormatOriginForSecurityDisplay) {
604 for (size_t i = 0; i < arraysize(common_tests); ++i) {
605 base::string16 formatted = url_formatter::FormatOriginForSecurityDisplay(
Daniel Cheng88186bd52017-10-20 08:14:46606 url::Origin::Create(GURL(common_tests[i].input)));
juncaicb63cac2016-05-13 00:41:59607 EXPECT_EQ(base::WideToUTF16(common_tests[i].output), formatted)
608 << common_tests[i].description;
609
610 base::string16 formatted_omit_web_scheme =
611 url_formatter::FormatOriginForSecurityDisplay(
Daniel Cheng88186bd52017-10-20 08:14:46612 url::Origin::Create(GURL(common_tests[i].input)),
juncaicb63cac2016-05-13 00:41:59613 url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
614 EXPECT_EQ(base::WideToUTF16(common_tests[i].output_omit_web_scheme),
615 formatted_omit_web_scheme)
616 << common_tests[i].description;
617
618 base::string16 formatted_omit_cryptographic_scheme =
619 url_formatter::FormatOriginForSecurityDisplay(
Daniel Cheng88186bd52017-10-20 08:14:46620 url::Origin::Create(GURL(common_tests[i].input)),
juncaicb63cac2016-05-13 00:41:59621 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC);
622 EXPECT_EQ(
623 base::WideToUTF16(common_tests[i].output_omit_cryptographic_scheme),
624 formatted_omit_cryptographic_scheme)
625 << common_tests[i].description;
626 }
627
628 const OriginTestData tests[] = {
629 {"File URI", "file:///usr/example/file.html", L"file://", L"file://",
630 L"file://"},
631 {"File URI with hostname", "file://localhost/usr/example/file.html",
632 L"file://localhost", L"file://localhost", L"file://localhost"},
633 {"UNC File URI 1", "file:///CONTOSO/accounting/money.xls", L"file://",
634 L"file://", L"file://"},
635 {"UNC File URI 2",
636 "file:///C:/Program%20Files/Music/Web%20Sys/main.html?REQUEST=RADIO",
637 L"file://", L"file://", L"file://"},
638 {"Invalid IPv6 address", "https://[2001:db8:0:1]/", L"", L"", L""},
639 {"HTTP filesystem: URL with path",
640 "filesystem:http://www.google.com/temporary/test.html",
641 L"http://www.google.com", L"www.google.com", L"http://www.google.com"},
642 {"File filesystem: URL with path",
643 "filesystem:file://localhost/temporary/stuff/test.html?z=fun&goat=billy",
644 L"file://", L"file://", L"file://"},
645 {"Invalid scheme 1", "twelve://www.cyber.org/wow.php", L"", L"", L""},
646 {"Invalid scheme 2", "://www.cyber.org/wow.php", L"", L"", L""},
647 {"Invalid port 1", "https://173.194.65.103:000", L"", L"", L""},
648 {"Invalid port 2", "https://173.194.65.103:gruffle", L"", L"", L""},
649 {"Blob URL",
650 "blob:http://www.html5rocks.com/4d4ff040-6d61-4446-86d3-13ca07ec9ab9",
651 L"http://www.html5rocks.com", L"www.html5rocks.com",
652 L"http://www.html5rocks.com"}};
653
654 for (size_t i = 0; i < arraysize(tests); ++i) {
655 base::string16 formatted = url_formatter::FormatOriginForSecurityDisplay(
Daniel Cheng88186bd52017-10-20 08:14:46656 url::Origin::Create(GURL(tests[i].input)));
juncaicb63cac2016-05-13 00:41:59657 EXPECT_EQ(base::WideToUTF16(tests[i].output), formatted)
658 << tests[i].description;
659
660 base::string16 formatted_omit_web_scheme =
661 url_formatter::FormatOriginForSecurityDisplay(
Daniel Cheng88186bd52017-10-20 08:14:46662 url::Origin::Create(GURL(tests[i].input)),
juncaicb63cac2016-05-13 00:41:59663 url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
664 EXPECT_EQ(base::WideToUTF16(tests[i].output_omit_web_scheme),
665 formatted_omit_web_scheme)
666 << tests[i].description;
667
668 base::string16 formatted_omit_cryptographic_scheme =
669 url_formatter::FormatOriginForSecurityDisplay(
Daniel Cheng88186bd52017-10-20 08:14:46670 url::Origin::Create(GURL(tests[i].input)),
juncaicb63cac2016-05-13 00:41:59671 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC);
672 EXPECT_EQ(base::WideToUTF16(tests[i].output_omit_cryptographic_scheme),
673 formatted_omit_cryptographic_scheme)
674 << tests[i].description;
675 }
676
Daniel Cheng88186bd52017-10-20 08:14:46677 base::string16 formatted = url_formatter::FormatOriginForSecurityDisplay(
678 url::Origin::Create(GURL()));
juncaicb63cac2016-05-13 00:41:59679 EXPECT_EQ(base::string16(), formatted)
680 << "Explicitly test the url::Origin which takes an empty, invalid URL";
681
682 base::string16 formatted_omit_scheme =
683 url_formatter::FormatOriginForSecurityDisplay(
Daniel Cheng88186bd52017-10-20 08:14:46684 url::Origin::Create(GURL()),
juncaicb63cac2016-05-13 00:41:59685 url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
686 EXPECT_EQ(base::string16(), formatted_omit_scheme)
687 << "Explicitly test the url::Origin which takes an empty, invalid URL";
688
689 formatted_omit_scheme = url_formatter::FormatOriginForSecurityDisplay(
Daniel Cheng88186bd52017-10-20 08:14:46690 url::Origin::Create(GURL()),
691 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC);
juncaicb63cac2016-05-13 00:41:59692 EXPECT_EQ(base::string16(), formatted_omit_scheme)
693 << "Explicitly test the url::Origin which takes an empty, invalid URL";
694}
695
miguelgdbcfb122015-07-23 10:45:11696} // namespace