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

Unified Diff: chrome/common/content_settings_pattern_unittest.cc

Issue 9133002: Added support for file URI path wildcards in content settings (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 8 years, 11 months 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
Index: chrome/common/content_settings_pattern_unittest.cc
===================================================================
--- chrome/common/content_settings_pattern_unittest.cc (revision 116863)
+++ chrome/common/content_settings_pattern_unittest.cc (working copy)
@@ -172,37 +172,52 @@
}
TEST(ContentSettingsPatternTest, FromString_FilePatterns) {
+ // "/" is an invalid file path.
EXPECT_FALSE(Pattern("file:///").IsValid());
Francois 2012/01/18 15:34:45 Please note that my new CL (Patch Set 4) removes t
Francois 2012/01/19 08:43:07 Added back in Patch Set 5.
// Non-empty domains aren't allowed in file patterns.
EXPECT_FALSE(Pattern("file://foo/").IsValid());
-
- // Domain wildcards aren't allowed in file patterns.
+ EXPECT_FALSE(Pattern("file://localhost/foo/bar/test.html").IsValid());
+ EXPECT_FALSE(Pattern("file://*").IsValid());
EXPECT_FALSE(Pattern("file://*/").IsValid());
+ EXPECT_FALSE(Pattern("file://*/*").IsValid());
+ EXPECT_FALSE(Pattern("file://*/foo/bar/test.html").IsValid());
EXPECT_FALSE(Pattern("file://[*.]/").IsValid());
- // These specify a path that contains '*', which isn't allowed to avoid
- // user confusion.
- EXPECT_FALSE(Pattern("file:///*").IsValid());
+ // This is the only valid file path wildcard format.
+ EXPECT_TRUE(Pattern("file:///*").IsValid());
+ EXPECT_EQ("file:///*", Pattern("file:///*").ToString());
+
+ // Wildcards are not allowed anywhere in the file path.
+ EXPECT_FALSE(Pattern("file:///f*o/bar/file.html").IsValid());
+ EXPECT_FALSE(Pattern("file:///*/bar/file.html").IsValid());
+ EXPECT_FALSE(Pattern("file:///foo/*").IsValid());
EXPECT_FALSE(Pattern("file:///foo/bar/*").IsValid());
+ EXPECT_FALSE(Pattern("file:///foo/*/file.html").IsValid());
+ EXPECT_FALSE(Pattern("file:///foo/bar/*.html").IsValid());
+ EXPECT_FALSE(Pattern("file:///foo/bar/file.*").IsValid());
EXPECT_TRUE(Pattern("file:///tmp/test.html").IsValid());
- EXPECT_STREQ("file:///tmp/file.html",
- Pattern("file:///tmp/file.html").ToString().c_str());
+ EXPECT_EQ("file:///tmp/file.html",
+ Pattern("file:///tmp/file.html").ToString());
EXPECT_TRUE(Pattern("file:///tmp/test.html").Matches(
GURL("file:///tmp/test.html")));
EXPECT_FALSE(Pattern("file:///tmp/test.html").Matches(
GURL("file:///tmp/other.html")));
EXPECT_FALSE(Pattern("file:///tmp/test.html").Matches(
GURL("http://example.org/")));
+
+ EXPECT_TRUE(Pattern("file:///*").Matches(GURL("file:///tmp/test.html")));
+ EXPECT_TRUE(Pattern("file:///*").Matches(
+ GURL("file://localhost/tmp/test.html")));
}
TEST(ContentSettingsPatternTest, FromString_ExtensionPatterns) {
EXPECT_TRUE(Pattern("chrome-extension://peoadpeiejnhkmpaakpnompolbglelel/")
.IsValid());
- EXPECT_STREQ("chrome-extension://peoadpeiejnhkmpaakpnompolbglelel/",
+ EXPECT_EQ("chrome-extension://peoadpeiejnhkmpaakpnompolbglelel/",
Pattern("chrome-extension://peoadpeiejnhkmpaakpnompolbglelel/")
- .ToString().c_str());
+ .ToString());
EXPECT_TRUE(Pattern("chrome-extension://peoadpeiejnhkmpaakpnompolbglelel/")
.Matches(GURL("chrome-extension://peoadpeiejnhkmpaakpnompolbglelel/")));
}

Powered by Google App Engine
This is Rietveld 408576698