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

Unified Diff: extensions/common/url_pattern_unittest.cc

Issue 2455373002: Add implicit trailing dot domain matching support to URLPattern. (Closed)
Patch Set: Add a comment with additional links to an external spec, cleanup test. Created 4 years, 1 month 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 | « extensions/common/url_pattern.cc ('k') | extensions/common/user_script_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/url_pattern_unittest.cc
diff --git a/extensions/common/url_pattern_unittest.cc b/extensions/common/url_pattern_unittest.cc
index 87ce1a1d7780bd21d4a0ca17744579e2f60849a8..860d487e3ab946c86116c6b53513d83c5abf51c4 100644
--- a/extensions/common/url_pattern_unittest.cc
+++ b/extensions/common/url_pattern_unittest.cc
@@ -849,4 +849,33 @@ TEST(ExtensionURLPatternTest, MatchesSingleOrigin) {
.MatchesSingleOrigin());
}
+TEST(ExtensionURLPatternTest, TrailingDotDomain) {
+ const GURL normal_domain("http://example.com/");
+ const GURL trailing_dot_domain("http://example.com./");
+
+ // Both patterns should match trailing dot and non trailing dot domains. More
+ // information about this not obvious behaviour can be found in [1].
+ //
+ // RFC 1738 [2] specifies clearly that the <host> part of a URL is supposed to
+ // contain a fully qualified domain name:
+ //
+ // 3.1. Common Internet Scheme Syntax
+ // //<user>:<password>@<host>:<port>/<url-path>
+ //
+ // host
+ // The fully qualified domain name of a network host
+ //
+ // [1] http://www.dns-sd.org./TrailingDotsInDomainNames.html
+ // [2] http://www.ietf.org/rfc/rfc1738.txt
+
+ const URLPattern pattern(URLPattern::SCHEME_HTTP, "*://example.com/*");
+ EXPECT_TRUE(pattern.MatchesURL(normal_domain));
+ EXPECT_TRUE(pattern.MatchesURL(trailing_dot_domain));
+
+ const URLPattern trailing_pattern(URLPattern::SCHEME_HTTP,
+ "*://example.com./*");
+ EXPECT_TRUE(trailing_pattern.MatchesURL(normal_domain));
+ EXPECT_TRUE(trailing_pattern.MatchesURL(trailing_dot_domain));
+}
+
} // namespace
« no previous file with comments | « extensions/common/url_pattern.cc ('k') | extensions/common/user_script_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698