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

Unified Diff: url/url_util_unittest.cc

Issue 2584513003: PlzNavigate: identify same-page browser-initiated navigation. (Closed)
Patch Set: Rebase. Created 3 years, 11 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
« url/gurl.h ('K') | « url/gurl.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 a3b61fff8a6ae17b31f2bfa81e74ef504920bc6d..7c3aaa4540d012dfd2a994bc85148632594ac71a 100644
--- a/url/url_util_unittest.cc
+++ b/url/url_util_unittest.cc
@@ -433,4 +433,58 @@ TEST(URLUtilTest, IsAboutBlank) {
EXPECT_FALSE(IsAboutBlank(GURL(url)));
}
+TEST(URLUtilTest, EqualsIgnoringRef) {
+ const struct {
+ const char* url_a;
+ const char* url_b;
+ bool are_equals;
+ } kTestCases[] = {
+ // No ref.
+ {"http://a.com", "http://a.com", true},
+ {"http://a.com", "http://b.com", false},
+
+ // Same Ref.
+ {"http://a.com#foo", "http://a.com#foo", true},
+ {"http://a.com#foo", "http://b.com#foo", false},
+
+ // Different Refs.
+ {"http://a.com#foo", "http://a.com#bar", true},
+ {"http://a.com#foo", "http://b.com#bar", false},
brettw 2017/02/07 06:37:48 Can you add a case below this of one with URL with
arthursonzogni 2017/02/07 12:04:50 What do you mean by "text"? I will do as if you sa
+
+ // Empty refs.
+ {"http://a.com#", "http://a.com#", true},
+ {"http://a.com#", "http://a.com", true},
+ {"http://a.com", "http://a.com#", true},
+
+ // URLs that differ only by their last character.
+ {"http://aaa", "http://aab", false},
+ {"http://aaa#foo", "http://aab#foo", false},
+
+ // Different size of the part before the ref.
+ {"http://123#a", "http://123456#a", false},
+ {"http://123456#a", "http://123#a", false},
+
+ // Blob urls
+ {"blob:http://a.com#foo", "blob:http://a.com#foo", true},
+ {"blob:http://a.com#foo", "blob:http://a.com#bar", true},
+ {"blob:http://a.com#foo", "blob:http://b.com#bar", false},
+
+ // Filesystem url
+ {"filesystem:http://a.com#foo", "filesystem:http://a.com#foo", true},
+ {"filesystem:http://a.com#foo", "filesystem:http://a.com#bar", true},
+ {"filesystem:http://a.com#foo", "filesystem:http://b.com#bar", false},
+ };
+
+ for (const auto& test_case : kTestCases) {
+ SCOPED_TRACE(testing::Message()
+ << std::endl
+ << "url_a = " << test_case.url_a << std::endl
+ << "url_b = " << test_case.url_b << std::endl);
+
+ EXPECT_EQ(
+ test_case.are_equals,
+ GURL::EqualsIgnoringRef(GURL(test_case.url_a), GURL(test_case.url_b)));
+ }
+}
+
} // namespace url
« url/gurl.h ('K') | « url/gurl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698