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

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 116653)
+++ chrome/common/content_settings_pattern_unittest.cc (working copy)
@@ -172,18 +172,28 @@
}
TEST(ContentSettingsPatternTest, FromString_FilePatterns) {
+ // "/" is an invalid file path.
EXPECT_FALSE(Pattern("file:///").IsValid());
// 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());
markusheintz_ 2012/01/09 15:01:00 Maybe we could also add: EXPECT_FALSE(Pattern("fi
Francois 2012/01/09 15:33:01 Done, but added it a few lines further down.
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_STREQ("file:///*", Pattern("file:///*").ToString().c_str());
Bernhard Bauer 2012/01/09 13:23:41 You can use EXPECT_EQ and remove the |.c_str()|.
Francois 2012/01/09 14:51:03 Done.
+
+ // Wildcards are not allowed anywhere in the file path.
+ EXPECT_FALSE(Pattern("file:///*/bar/file.html").IsValid());
+ EXPECT_FALSE(Pattern("file:///f*o/bar/file.html").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_FALSE(Pattern("file:///foo/bar/*").IsValid());
EXPECT_TRUE(Pattern("file:///tmp/test.html").IsValid());
@@ -195,6 +205,10 @@
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) {

Powered by Google App Engine
This is Rietveld 408576698