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

Side by Side Diff: url/url_util_unittest.cc

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « url/url_canon_relative.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/macros.h" 5 #include "base/macros.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "url/url_canon.h" 7 #include "url/url_canon.h"
8 #include "url/url_canon_stdstring.h" 8 #include "url/url_canon_stdstring.h"
9 #include "url/url_parse.h" 9 #include "url/url_parse.h"
10 #include "url/url_test_utils.h" 10 #include "url/url_test_utils.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 // missing a path component (the '/' at the end). 266 // missing a path component (the '/' at the end).
267 {"scheme://Authority", "path", false, ""}, 267 {"scheme://Authority", "path", false, ""},
268 // Test resolving a fragment (only) against any kind of base-URL. 268 // Test resolving a fragment (only) against any kind of base-URL.
269 {"about:blank", "#id42", true, "about:blank#id42" }, 269 {"about:blank", "#id42", true, "about:blank#id42" },
270 {"about:blank", " #id42", true, "about:blank#id42" }, 270 {"about:blank", " #id42", true, "about:blank#id42" },
271 {"about:blank#oldfrag", "#newfrag", true, "about:blank#newfrag" }, 271 {"about:blank#oldfrag", "#newfrag", true, "about:blank#newfrag" },
272 // A surprising side effect of allowing fragments to resolve against 272 // A surprising side effect of allowing fragments to resolve against
273 // any URL scheme is we might break javascript: URLs by doing so... 273 // any URL scheme is we might break javascript: URLs by doing so...
274 {"javascript:alert('foo#bar')", "#badfrag", true, 274 {"javascript:alert('foo#bar')", "#badfrag", true,
275 "javascript:alert('foo#badfrag" }, 275 "javascript:alert('foo#badfrag" },
276 // In this case, the backslashes will not be canonicalized because it's a
277 // non-standard URL, but they will be treated as a path separators,
278 // giving the base URL here a path of "\".
279 //
280 // The result here is somewhat arbitrary. One could argue it should be
281 // either "aaa://a\" or "aaa://a/" since the path is being replaced with
282 // the "current directory". But in the context of resolving on data URLs,
283 // adding the requested dot doesn't seem wrong either.
284 {"aaa://a\\", "aaa:.", true, "aaa://a\\." }
276 }; 285 };
277 286
278 for (size_t i = 0; i < arraysize(resolve_non_standard_cases); i++) { 287 for (size_t i = 0; i < arraysize(resolve_non_standard_cases); i++) {
279 const ResolveRelativeCase& test_data = resolve_non_standard_cases[i]; 288 const ResolveRelativeCase& test_data = resolve_non_standard_cases[i];
280 Parsed base_parsed; 289 Parsed base_parsed;
281 ParsePathURL(test_data.base, strlen(test_data.base), false, &base_parsed); 290 ParsePathURL(test_data.base, strlen(test_data.base), false, &base_parsed);
282 291
283 std::string resolved; 292 std::string resolved;
284 StdStringCanonOutput output(&resolved); 293 StdStringCanonOutput output(&resolved);
285 Parsed resolved_parsed; 294 Parsed resolved_parsed;
(...skipping 24 matching lines...) Expand all
310 319
311 bool valid = ResolveRelative(base, strlen(base), 320 bool valid = ResolveRelative(base, strlen(base),
312 base_parsed, rel, 321 base_parsed, rel,
313 strlen(rel), NULL, &output, 322 strlen(rel), NULL, &output,
314 &resolved_parsed); 323 &resolved_parsed);
315 EXPECT_TRUE(valid); 324 EXPECT_TRUE(valid);
316 EXPECT_FALSE(resolved_parsed.ref.is_valid()); 325 EXPECT_FALSE(resolved_parsed.ref.is_valid());
317 } 326 }
318 327
319 } // namespace url 328 } // namespace url
OLDNEW
« no previous file with comments | « url/url_canon_relative.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698