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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "extensions/common/url_pattern.h" 5 #include "extensions/common/url_pattern.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 .MatchesSingleOrigin()); 842 .MatchesSingleOrigin());
843 EXPECT_TRUE(URLPattern(URLPattern::SCHEME_HTTPS, "https://www.google.com/") 843 EXPECT_TRUE(URLPattern(URLPattern::SCHEME_HTTPS, "https://www.google.com/")
844 .MatchesSingleOrigin()); 844 .MatchesSingleOrigin());
845 EXPECT_FALSE(URLPattern(URLPattern::SCHEME_HTTP, 845 EXPECT_FALSE(URLPattern(URLPattern::SCHEME_HTTP,
846 "http://*.google.com/foo/bar").MatchesSingleOrigin()); 846 "http://*.google.com/foo/bar").MatchesSingleOrigin());
847 EXPECT_TRUE( 847 EXPECT_TRUE(
848 URLPattern(URLPattern::SCHEME_HTTP, "http://www.google.com/foo/bar") 848 URLPattern(URLPattern::SCHEME_HTTP, "http://www.google.com/foo/bar")
849 .MatchesSingleOrigin()); 849 .MatchesSingleOrigin());
850 } 850 }
851 851
852 TEST(ExtensionURLPatternTest, TrailingDotDomain) {
853 const GURL normal_domain("http://example.com/");
854 const GURL trailing_dot_domain("http://example.com./");
855
856 // Both patterns should match trailing dot and non trailing dot domains. More
857 // information about this not obvious behaviour can be found in [1].
858 //
859 // RFC 1738 [2] specifies clearly that the <host> part of a URL is supposed to
860 // contain a fully qualified domain name:
861 //
862 // 3.1. Common Internet Scheme Syntax
863 // //<user>:<password>@<host>:<port>/<url-path>
864 //
865 // host
866 // The fully qualified domain name of a network host
867 //
868 // [1] http://www.dns-sd.org./TrailingDotsInDomainNames.html
869 // [2] http://www.ietf.org/rfc/rfc1738.txt
870
871 const URLPattern pattern(URLPattern::SCHEME_HTTP, "*://example.com/*");
872 EXPECT_TRUE(pattern.MatchesURL(normal_domain));
873 EXPECT_TRUE(pattern.MatchesURL(trailing_dot_domain));
874
875 const URLPattern trailing_pattern(URLPattern::SCHEME_HTTP,
876 "*://example.com./*");
877 EXPECT_TRUE(trailing_pattern.MatchesURL(normal_domain));
878 EXPECT_TRUE(trailing_pattern.MatchesURL(trailing_dot_domain));
879 }
880
852 } // namespace 881 } // namespace
OLDNEW
« 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