Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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. | |
|
Devlin
2016/10/31 16:13:17
For those interested in the future, can we add a l
Devlin
2016/11/01 14:52:14
Looks like you missed this one.
| |
| 857 const URLPattern pattern(URLPattern::SCHEME_HTTP, "*://example.com/*"); | |
| 858 EXPECT_TRUE(pattern.MatchesURL(GURL(normal_domain))); | |
|
Devlin
2016/10/31 16:13:17
No need for the GURL() ctor here - we can just pas
Devlin
2016/11/01 14:52:14
And this one.
| |
| 859 EXPECT_TRUE(pattern.MatchesURL(GURL(trailing_dot_domain))); | |
| 860 | |
| 861 const URLPattern trailing_pattern(URLPattern::SCHEME_HTTP, | |
| 862 "*://example.com./*"); | |
| 863 EXPECT_TRUE(trailing_pattern.MatchesURL(GURL(normal_domain))); | |
| 864 EXPECT_TRUE(trailing_pattern.MatchesURL(GURL(trailing_dot_domain))); | |
| 865 } | |
| 866 | |
| 852 } // namespace | 867 } // namespace |
| OLD | NEW |