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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "chrome/common/extensions/url_pattern.h" | 6 #include "chrome/common/extensions/url_pattern.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
9 | 9 |
10 // See url_pattern.h for examples of valid and invalid patterns. | 10 // See url_pattern.h for examples of valid and invalid patterns. |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 | 659 |
660 EXPECT_FALSE(pattern2.MatchesURL(GURL("http://bb.com/path"))); | 660 EXPECT_FALSE(pattern2.MatchesURL(GURL("http://bb.com/path"))); |
661 EXPECT_TRUE(pattern2.MatchesURL(GURL("http://aa.com/path"))); | 661 EXPECT_TRUE(pattern2.MatchesURL(GURL("http://aa.com/path"))); |
662 EXPECT_FALSE(pattern2.MatchesURL(GURL("http://sub.aa.com/path"))); | 662 EXPECT_FALSE(pattern2.MatchesURL(GURL("http://sub.aa.com/path"))); |
663 | 663 |
664 URLPattern pattern3(URLPattern::SCHEME_ALL, "http://aa.com/*"); | 664 URLPattern pattern3(URLPattern::SCHEME_ALL, "http://aa.com/*"); |
665 EXPECT_EQ(URLPattern::PARSE_SUCCESS, pattern3.Parse("http://aa.com:88/*")); | 665 EXPECT_EQ(URLPattern::PARSE_SUCCESS, pattern3.Parse("http://aa.com:88/*")); |
666 EXPECT_FALSE(pattern3.MatchesURL(GURL("http://aa.com/path"))); | 666 EXPECT_FALSE(pattern3.MatchesURL(GURL("http://aa.com/path"))); |
667 EXPECT_TRUE(pattern3.MatchesURL(GURL("http://aa.com:88/path"))); | 667 EXPECT_TRUE(pattern3.MatchesURL(GURL("http://aa.com:88/path"))); |
668 } | 668 } |
| 669 |
| 670 TEST(ExtensionURLPatternTest, IgnoresTrailingSlash) { |
| 671 URLPattern pattern1(URLPattern::SCHEME_ALL); |
| 672 EXPECT_EQ(URLPattern::PARSE_SUCCESS, pattern1.Parse("http://a.com/b/")); |
| 673 EXPECT_TRUE(pattern1.MatchesURL(GURL("http://a.com/b"))); |
| 674 |
| 675 URLPattern pattern2(URLPattern::SCHEME_ALL); |
| 676 EXPECT_EQ(URLPattern::PARSE_SUCCESS, pattern2.Parse("http://a.com/")); |
| 677 EXPECT_TRUE(pattern2.MatchesURL(GURL("http://a.com"))); |
| 678 |
| 679 URLPattern pattern3(URLPattern::SCHEME_ALL); |
| 680 EXPECT_EQ(URLPattern::PARSE_SUCCESS, pattern3.Parse("http://a.com/b")); |
| 681 EXPECT_TRUE(pattern3.MatchesURL(GURL("http://a.com/b/"))); |
| 682 } |
OLD | NEW |