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

Unified Diff: url/url_util_unittest.cc

Issue 2890143002: Set 'whitespace_removed' correctly when resolving relative URLs. (Closed)
Patch Set: Test. Created 3 years, 7 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 | « url/url_canon_relative.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: url/url_util_unittest.cc
diff --git a/url/url_util_unittest.cc b/url/url_util_unittest.cc
index a706f5a08a04bbfeca8a9cf936ad4bee664a079f..9c3606cd0e6412b49d39529593b910781ce7b300 100644
--- a/url/url_util_unittest.cc
+++ b/url/url_util_unittest.cc
@@ -374,6 +374,44 @@ TEST(URLUtilTest, TestNoRefComponent) {
EXPECT_FALSE(resolved_parsed.ref.is_valid());
}
+TEST(URLUtilTest, RelativeWhitespaceRemoved) {
+ struct ResolveRelativeCase {
+ const char* base;
+ const char* rel;
+ bool whitespace_removed;
+ const char* out;
+ } cases[] = {
+ {"https://example.com/", "/path", false, "https://example.com/path"},
+ {"https://example.com/", "\n/path", true, "https://example.com/path"},
+ {"https://example.com/", "\r/path", true, "https://example.com/path"},
+ {"https://example.com/", "\t/path", true, "https://example.com/path"},
+ {"https://example.com/", "/pa\nth", true, "https://example.com/path"},
+ {"https://example.com/", "/pa\rth", true, "https://example.com/path"},
+ {"https://example.com/", "/pa\tth", true, "https://example.com/path"},
+ {"https://example.com/", "/path\n", true, "https://example.com/path"},
+ {"https://example.com/", "/path\r", true, "https://example.com/path"},
+ {"https://example.com/", "/path\r", true, "https://example.com/path"},
+ };
+
+ for (const auto& test : cases) {
+ SCOPED_TRACE(::testing::Message() << test.base << ", " << test.rel);
+ Parsed base_parsed;
+ ParseStandardURL(test.base, strlen(test.base), &base_parsed);
+
+ std::string resolved;
+ StdStringCanonOutput output(&resolved);
+ Parsed resolved_parsed;
+ bool valid =
+ ResolveRelative(test.base, strlen(test.base), base_parsed, test.rel,
+ strlen(test.rel), NULL, &output, &resolved_parsed);
+ ASSERT_TRUE(valid);
+ output.Complete();
+
+ EXPECT_EQ(test.whitespace_removed, resolved_parsed.whitespace_removed);
+ EXPECT_EQ(test.out, resolved);
+ }
+}
+
TEST(URLUtilTest, TestDomainIs) {
const struct {
const char* canonicalized_host;
« 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