diff options
author | apavlov@chromium.org <apavlov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-03 13:51:58 +0000 |
---|---|---|
committer | apavlov@chromium.org <apavlov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-03 13:51:58 +0000 |
commit | f1f8639f531a3a919a13d8f8aa8008e8b88e3b1f (patch) | |
tree | 74fb091262f2850a55aa99bbedcdaa163f0c09d1 /chrome/common/content_settings_pattern_unittest.cc | |
parent | bd070e2f0795ef0661be6be7585a62c81fbf7459 (diff) | |
download | chromium_src-f1f8639f531a3a919a13d8f8aa8008e8b88e3b1f.zip chromium_src-f1f8639f531a3a919a13d8f8aa8008e8b88e3b1f.tar.gz chromium_src-f1f8639f531a3a919a13d8f8aa8008e8b88e3b1f.tar.bz2 |
Reapply 130248 - Add full support for filesystem URLs. Trying to get the build into the right state.
TBR=pfeldman
Review URL: https://chromiumcodereview.appspot.com/9956101
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130363 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/content_settings_pattern_unittest.cc')
-rw-r--r-- | chrome/common/content_settings_pattern_unittest.cc | 61 |
1 files changed, 59 insertions, 2 deletions
diff --git a/chrome/common/content_settings_pattern_unittest.cc b/chrome/common/content_settings_pattern_unittest.cc index f0eeca5..bd79338 100644 --- a/chrome/common/content_settings_pattern_unittest.cc +++ b/chrome/common/content_settings_pattern_unittest.cc @@ -73,6 +73,7 @@ TEST(ContentSettingsPatternTest, FromURL) { pattern = ContentSettingsPattern::FromURL(GURL("https://www.google.com:443")); EXPECT_TRUE(pattern.Matches(GURL("https://www.google.com"))); + EXPECT_TRUE(pattern.Matches(GURL("https://foo.www.google.com"))); EXPECT_TRUE(pattern.Matches(GURL("https://www.google.com:443"))); EXPECT_FALSE(pattern.Matches(GURL("https://www.google.com:444"))); EXPECT_FALSE(pattern.Matches(GURL("http://www.google.com:443"))); @@ -89,6 +90,49 @@ TEST(ContentSettingsPatternTest, FromURL) { EXPECT_EQ("file:///foo/bar.html", pattern.ToString()); } +TEST(ContentSettingsPatternTest, FilesystemUrls) { + ContentSettingsPattern pattern = + ContentSettingsPattern::FromURL(GURL("http://www.google.com")); + EXPECT_TRUE(pattern.Matches( + GURL("filesystem:http://www.google.com/temporary/"))); + EXPECT_TRUE(pattern.Matches( + GURL("filesystem:http://foo.www.google.com/temporary/"))); + EXPECT_TRUE(pattern.Matches( + GURL("filesystem:http://www.google.com:80/temporary/"))); + EXPECT_TRUE(pattern.Matches( + GURL("filesystem:http://www.google.com:81/temporary/"))); + + pattern = ContentSettingsPattern::FromURL(GURL("https://www.google.com")); + EXPECT_TRUE(pattern.Matches( + GURL("filesystem:https://www.google.com/temporary/"))); + EXPECT_TRUE(pattern.Matches( + GURL("filesystem:https://www.google.com:443/temporary/"))); + EXPECT_TRUE(pattern.Matches( + GURL("filesystem:https://foo.www.google.com/temporary/"))); + EXPECT_FALSE(pattern.Matches( + GURL("filesystem:https://www.google.com:81/temporary/"))); + + // A pattern from a filesystem URLs is equivalent to a pattern from the inner + // URL of the filesystem URL. + ContentSettingsPattern pattern2 = ContentSettingsPattern::FromURL( + GURL("filesystem:https://www.google.com/temporary/")); + EXPECT_EQ(ContentSettingsPattern::IDENTITY, pattern.Compare(pattern2)); + + EXPECT_STREQ("https://[*.]www.google.com:443", pattern2.ToString().c_str()); + + pattern = + ContentSettingsPattern::FromURL( + GURL("filesystem:file:///temporary/foo/bar")); + EXPECT_TRUE(pattern.Matches(GURL("filesystem:file:///temporary/"))); + EXPECT_TRUE(pattern.Matches(GURL("filesystem:file:///temporary/test.txt"))); + EXPECT_TRUE(pattern.Matches(GURL("file:///temporary"))); + EXPECT_FALSE(pattern.Matches(GURL("file://foo/bar"))); + pattern2 = + ContentSettingsPattern::FromURL( + GURL("filesystem:file:///persistent/foo2/bar2")); + EXPECT_EQ(ContentSettingsPattern::IDENTITY, pattern.Compare(pattern2)); +} + TEST(ContentSettingsPatternTest, FromURLNoWildcard) { // If no port is specifed GURLs always use the default port for the schemes // HTTP and HTTPS. Hence a GURL always carries a port specification either @@ -114,8 +158,21 @@ TEST(ContentSettingsPatternTest, FromURLNoWildcard) { EXPECT_TRUE(pattern.Matches(GURL("https://www.example.com"))); EXPECT_FALSE(pattern.Matches(GURL("http://foo.www.example.com"))); - pattern = ContentSettingsPattern::FromURLNoWildcard( - GURL("https://www.example.com")); + // Pattern for filesystem URLs + pattern = + ContentSettingsPattern::FromURLNoWildcard( + GURL("filesystem:http://www.google.com/temporary/")); + EXPECT_TRUE(pattern.IsValid()); + EXPECT_TRUE(pattern.Matches(GURL("http://www.google.com"))); + EXPECT_FALSE(pattern.Matches(GURL("http://foo.www.google.com"))); + EXPECT_TRUE(pattern.Matches( + GURL("filesystem:http://www.google.com/persistent/"))); + EXPECT_FALSE(pattern.Matches( + GURL("filesystem:https://www.google.com/persistent/"))); + EXPECT_FALSE(pattern.Matches( + GURL("filesystem:https://www.google.com:81/temporary/"))); + EXPECT_FALSE(pattern.Matches( + GURL("filesystem:https://foo.www.google.com/temporary/"))); } TEST(ContentSettingsPatternTest, Wildcard) { |