Index: chrome/common/extensions/url_pattern_unittest.cc |
diff --git a/chrome/common/extensions/url_pattern_unittest.cc b/chrome/common/extensions/url_pattern_unittest.cc |
index 3996b999380fe39cf6ff3aa33c4819fbfd32ed3c..f8f8826c4145ee0c68912c887c3b4755de39e13a 100644 |
--- a/chrome/common/extensions/url_pattern_unittest.cc |
+++ b/chrome/common/extensions/url_pattern_unittest.cc |
@@ -34,6 +34,9 @@ TEST(ExtensionURLPatternTest, ParseInvalid) { |
{ "http://fo.*.ba:123/baz", URLPattern::PARSE_ERROR_INVALID_HOST_WILDCARD }, |
{ "http:/bar", URLPattern::PARSE_ERROR_WRONG_SCHEME_SEPARATOR }, |
{ "http://bar", URLPattern::PARSE_ERROR_EMPTY_PATH }, |
+ { "http:filesystem://bar", URLPattern::PARSE_ERROR_WRONG_SCHEME_SEPARATOR }, |
+ { "filesystem://bar", URLPattern::PARSE_ERROR_MISSING_SCHEME_SEPARATOR }, |
+ { "filesystem:filesystem:///bar", URLPattern::PARSE_ERROR_INVALID_SCHEME }, |
}; |
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kInvalidPatterns); ++i) { |
@@ -63,6 +66,7 @@ TEST(ExtensionURLPatternTest, Ports) { |
{ "http://foo:80:80/monkey", URLPattern::PARSE_ERROR_INVALID_PORT, "*" }, |
{ "file://foo:1234/bar", URLPattern::PARSE_SUCCESS, "*" }, |
{ "chrome://foo:1234/bar", URLPattern::PARSE_ERROR_INVALID_PORT, "*" }, |
+ { "filesystem:http://foo:1234/", URLPattern::PARSE_SUCCESS, "1234" }, |
// Port-like strings in the path should not trigger a warning. |
{ "http://*/:1234", URLPattern::PARSE_SUCCESS, "*" }, |
@@ -95,6 +99,7 @@ TEST(ExtensionURLPatternTest, Match1) { |
EXPECT_TRUE(pattern.MatchesURL(GURL("http://google.com/foo"))); |
EXPECT_FALSE(pattern.MatchesURL(GURL("https://google.com"))); |
EXPECT_TRUE(pattern.MatchesURL(GURL("http://74.125.127.100/search"))); |
+ EXPECT_FALSE(pattern.MatchesURL(GURL("filesystem:http://google.com"))); |
} |
// all domains |
@@ -107,6 +112,8 @@ TEST(ExtensionURLPatternTest, Match2) { |
EXPECT_FALSE(pattern.match_all_urls()); |
EXPECT_EQ("/foo*", pattern.path()); |
EXPECT_TRUE(pattern.MatchesURL(GURL("https://www.google.com/foo"))); |
+ EXPECT_FALSE( |
+ pattern.MatchesURL(GURL("filesystem:https://www.google.com/foo"))); |
EXPECT_TRUE(pattern.MatchesURL(GURL("https://www.google.com/foobar"))); |
EXPECT_FALSE(pattern.MatchesURL(GURL("http://www.google.com/foo"))); |
EXPECT_FALSE(pattern.MatchesURL(GURL("https://www.google.com/"))); |
@@ -209,6 +216,7 @@ TEST(ExtensionURLPatternTest, Match10) { |
EXPECT_FALSE(pattern.MatchesScheme("chrome")); |
EXPECT_FALSE(pattern.MatchesScheme("file")); |
EXPECT_FALSE(pattern.MatchesScheme("ftp")); |
+ EXPECT_FALSE(pattern.MatchesScheme("filesystem")); |
EXPECT_TRUE(pattern.match_subdomains()); |
EXPECT_FALSE(pattern.match_all_urls()); |
EXPECT_EQ("/*", pattern.path()); |
@@ -226,6 +234,7 @@ TEST(ExtensionURLPatternTest, Match11) { |
EXPECT_TRUE(pattern.MatchesScheme("http")); |
EXPECT_TRUE(pattern.MatchesScheme("https")); |
EXPECT_TRUE(pattern.MatchesScheme("file")); |
+ EXPECT_TRUE(pattern.MatchesScheme("filesystem")); |
EXPECT_TRUE(pattern.MatchesScheme("chrome-extension")); |
EXPECT_TRUE(pattern.match_subdomains()); |
EXPECT_TRUE(pattern.match_all_urls()); |
@@ -234,6 +243,9 @@ TEST(ExtensionURLPatternTest, Match11) { |
EXPECT_TRUE(pattern.MatchesURL(GURL("http://127.0.0.1"))); |
EXPECT_TRUE(pattern.MatchesURL(GURL("file:///foo/bar"))); |
EXPECT_TRUE(pattern.MatchesURL(GURL("file://localhost/foo/bar"))); |
+ EXPECT_TRUE(pattern.MatchesURL(GURL("filesystem:file:///temporary/foo/bar"))); |
+ EXPECT_TRUE(pattern.MatchesURL( |
+ GURL("filesystem:http://google.com/temporary/foo/bar"))); |
// Make sure the properties are the same when creating an <all_urls> pattern |
// via SetMatchAllURLs and by parsing <all_urls>. |
@@ -257,6 +269,7 @@ TEST(ExtensionURLPatternTest, Match12) { |
EXPECT_TRUE(pattern.MatchesScheme("http")); |
EXPECT_TRUE(pattern.MatchesScheme("https")); |
EXPECT_TRUE(pattern.MatchesScheme("file")); |
+ EXPECT_TRUE(pattern.MatchesScheme("filesystem")); |
EXPECT_TRUE(pattern.MatchesScheme("javascript")); |
EXPECT_TRUE(pattern.MatchesScheme("data")); |
EXPECT_TRUE(pattern.MatchesScheme("about")); |
@@ -268,6 +281,8 @@ TEST(ExtensionURLPatternTest, Match12) { |
EXPECT_TRUE(pattern.MatchesURL(GURL("http://127.0.0.1"))); |
EXPECT_TRUE(pattern.MatchesURL(GURL("file:///foo/bar"))); |
EXPECT_TRUE(pattern.MatchesURL(GURL("file://localhost/foo/bar"))); |
+ EXPECT_TRUE(pattern.MatchesURL( |
+ GURL("filesystem:file:///persistent/foo/bar"))); |
EXPECT_TRUE(pattern.MatchesURL(GURL("chrome://newtab"))); |
EXPECT_TRUE(pattern.MatchesURL(GURL("about:blank"))); |
EXPECT_TRUE(pattern.MatchesURL(GURL("about:version"))); |
@@ -284,6 +299,7 @@ static const struct MatchPatterns { |
{"about:*", "about:version"}, |
{"chrome-extension://*/*", "chrome-extension://FTW"}, |
{"data:*", "data:monkey"}, |
+ {"filesystem:http://*/*", "filesystem:http://monkey.com/t/f.txt"}, |
{"javascript:*", "javascript:atemyhomework"}, |
}; |
@@ -404,6 +420,48 @@ TEST(ExtensionURLPatternTest, Match19) { |
EXPECT_FALSE(pattern.MatchesURL(GURL("chrome-extension://foobar"))); |
}; |
+// filesystem:http:// |
+TEST(ExtensionURLPatternTest, Match20) { |
+ URLPattern pattern(kAllSchemes); |
+ EXPECT_EQ(URLPattern::PARSE_SUCCESS, |
+ pattern.Parse("filesystem:http://foo.com/t/*")); |
+ EXPECT_EQ("filesystem", pattern.scheme()); |
+ EXPECT_EQ("http", pattern.inner_scheme()); |
+ EXPECT_EQ("foo.com", pattern.host()); |
+ EXPECT_FALSE(pattern.match_subdomains()); |
+ EXPECT_FALSE(pattern.match_all_urls()); |
+ EXPECT_EQ("/t/*", pattern.path()); |
+ EXPECT_TRUE(pattern.MatchesURL(GURL("filesystem:http://foo.com/t/blah"))); |
+ EXPECT_TRUE(pattern.MatchesURL(GURL("filesystem:http://foo.com/t/bar"))); |
+ EXPECT_FALSE(pattern.MatchesURL(GURL("filesystem:https://foo.com/t/bar"))); |
+ EXPECT_FALSE(pattern.MatchesURL(GURL("filesystem:file://foo.com/t/bar"))); |
+ EXPECT_FALSE(pattern.MatchesURL(GURL("filesystem:http://bar.com/t/bar"))); |
+ EXPECT_FALSE(pattern.MatchesURL(GURL("filesystem:http://foo.com/p/bar"))); |
+ EXPECT_FALSE(pattern.MatchesURL(GURL("filesystem:http://foo.com/t"))); |
+}; |
+ |
+// filesystem:chrome-extension:// |
+TEST(ExtensionURLPatternTest, Match22) { |
+ URLPattern pattern(kAllSchemes); |
+ EXPECT_EQ(URLPattern::PARSE_SUCCESS, |
+ pattern.Parse("filesystem:chrome-extension://*/*.txt")); |
+ EXPECT_EQ("filesystem", pattern.scheme()); |
+ EXPECT_EQ("chrome-extension", pattern.inner_scheme()); |
+ EXPECT_EQ("", pattern.host()); |
+ EXPECT_TRUE(pattern.match_subdomains()); |
+ EXPECT_FALSE(pattern.match_all_urls()); |
+ EXPECT_EQ("/*.txt", pattern.path()); |
+ EXPECT_FALSE(pattern.MatchesURL( |
+ GURL("filesystem:chrome-extension://39804298/t/blah"))); |
+ // This is FALSE because 't' becomes the host [the extension id], which makes |
+ // 'bar.txt' the storage specifier of the filesystem URL, so there's no path |
+ // left. |
+ EXPECT_FALSE(pattern.MatchesURL( |
+ GURL("filesystem:chrome-extension://t/bar.txt"))); |
+ EXPECT_TRUE(pattern.MatchesURL( |
+ GURL("filesystem:chrome-extension://t/t/bar.txt"))); |
+}; |
+ |
static const struct GetAsStringPatterns { |
const char* pattern; |
} kGetAsStringTestCases[] = { |
@@ -420,6 +478,10 @@ static const struct GetAsStringPatterns { |
{ "javascript:*" }, |
{ "javascript:atemyhomework" }, |
{ "http://www.example.com:8080/foo" }, |
+ { "filesystem:http://www.example.com:8080/foo" }, |
+ { "filesystem:file:///foo" }, |
+ { "filesystem:*://foo/bar" }, |
+ { "file:///foo" }, |
}; |
TEST(ExtensionURLPatternTest, GetAsString) { |
@@ -604,6 +666,16 @@ TEST(ExtensionURLPatternTest, Equals) { |
{ "<all_urls>", |
"http://*/*", |
false |
+ }, |
+ |
+ // filesystem inner_schemes |
+ { "filesystem:file://foo/*", |
+ "filesystem:file://foo/*", |
+ true |
+ }, |
+ { "filesystem:http://foo/*", |
+ "filesystem:file://foo/*", |
+ false |
} |
}; |
@@ -621,24 +693,3 @@ TEST(ExtensionURLPatternTest, Equals) { |
<< message; |
} |
} |
- |
-TEST(ExtensionURLPatternTest, CanReusePatternWithParse) { |
ericu
2012/02/23 01:39:13
This looks like a merge botch; I'll put it back.
|
- URLPattern pattern1(URLPattern::SCHEME_ALL); |
- EXPECT_EQ(URLPattern::PARSE_SUCCESS, pattern1.Parse("http://aa.com/*")); |
- EXPECT_EQ(URLPattern::PARSE_SUCCESS, pattern1.Parse("http://bb.com/*")); |
- |
- EXPECT_TRUE(pattern1.MatchesURL(GURL("http://bb.com/path"))); |
- EXPECT_FALSE(pattern1.MatchesURL(GURL("http://aa.com/path"))); |
- |
- URLPattern pattern2(URLPattern::SCHEME_ALL, URLPattern::kAllUrlsPattern); |
- EXPECT_EQ(URLPattern::PARSE_SUCCESS, pattern2.Parse("http://aa.com/*")); |
- |
- EXPECT_FALSE(pattern2.MatchesURL(GURL("http://bb.com/path"))); |
- EXPECT_TRUE(pattern2.MatchesURL(GURL("http://aa.com/path"))); |
- EXPECT_FALSE(pattern2.MatchesURL(GURL("http://sub.aa.com/path"))); |
- |
- URLPattern pattern3(URLPattern::SCHEME_ALL, "http://aa.com/*"); |
- EXPECT_EQ(URLPattern::PARSE_SUCCESS, pattern3.Parse("http://aa.com:88/*")); |
- EXPECT_FALSE(pattern3.MatchesURL(GURL("http://aa.com/path"))); |
- EXPECT_TRUE(pattern3.MatchesURL(GURL("http://aa.com:88/path"))); |
-} |