Index: components/policy/core/browser/url_blacklist_manager_unittest.cc |
diff --git a/components/policy/core/browser/url_blacklist_manager_unittest.cc b/components/policy/core/browser/url_blacklist_manager_unittest.cc |
index 5e6e7f5fdad3f6ce7daf54fda7709e91b0263732..b63826b34636bb44cf65e7fd8a96547f2f04b3d7 100644 |
--- a/components/policy/core/browser/url_blacklist_manager_unittest.cc |
+++ b/components/policy/core/browser/url_blacklist_manager_unittest.cc |
@@ -391,6 +391,16 @@ TEST_F(URLBlacklistManagerTest, Filtering) { |
EXPECT_FALSE(blacklist.IsURLBlocked(GURL("https://ws.aaa.com"))); |
EXPECT_FALSE(blacklist.IsURLBlocked(GURL("ftp://ws.aaa.com"))); |
+ // Filter custom schemes |
Thiemo Nagel
2016/03/08 18:44:35
Please add a period at the end of the sentence.
igorcov1
2016/04/12 07:01:46
Done.
|
+ blocked.reset(new base::ListValue); |
+ blocked->Append(new base::StringValue("custom://*")); |
+ blacklist.Block(blocked.get()); |
+ EXPECT_TRUE(blacklist.IsURLBlocked(GURL("custom://example_app"))); |
+ EXPECT_TRUE(blacklist.IsURLBlocked(GURL("custom:example2_app"))); |
+ EXPECT_FALSE(blacklist.IsURLBlocked(GURL("customs://example_apps"))); |
+ EXPECT_FALSE(blacklist.IsURLBlocked(GURL("cust*://example_ap"))); |
+ EXPECT_FALSE(blacklist.IsURLBlocked(GURL("ecustom:example_app"))); |
+ |
// Test exceptions to path prefixes, and most specific matches. |
blocked.reset(new base::ListValue); |
scoped_ptr<base::ListValue> allowed(new base::ListValue); |
@@ -679,4 +689,42 @@ TEST_F(URLBlacklistManagerTest, DefaultBlacklistExceptions) { |
EXPECT_FALSE((blacklist.IsURLBlocked(GURL("chrome-native://ntp")))); |
} |
+TEST_F(URLBlacklistManagerTest, UseBlacklistState) { |
+ URLBlacklist blacklist(GetSegmentURLCallback()); |
+ scoped_ptr<base::ListValue> blocked(new base::ListValue); |
+ scoped_ptr<base::ListValue> allowed(new base::ListValue); |
+ |
+ // check some types of custom schemes. |
Thiemo Nagel
2016/03/08 18:44:35
Please start sentence with capital letter.
igorcov1
2016/04/12 07:01:46
Done.
|
+ blocked->AppendString("youtube.com"); |
+ blocked->AppendString("custom://*"); |
Thiemo Nagel
2016/03/08 18:44:35
Please include tests with capital letters and lead
igorcov1
2016/04/12 07:01:46
Done.
|
+ allowed->AppendString("ggl://*"); |
+ // this is bad format, we support only custom_scheme://* |
Thiemo Nagel
2016/03/08 18:44:35
Please start sentence with capital letter and end
|
+ allowed->AppendString("wrong://app"); |
+ blacklist.Block(blocked.get()); |
+ blacklist.Allow(allowed.get()); |
+ |
+ EXPECT_TRUE(blacklist.GetURLBlacklistState(GURL("http://www.youtube.com")) == |
+ net::NetworkDelegate::URLBlacklistState::URL_IN_BLACKLIST); |
+ EXPECT_TRUE(blacklist.GetURLBlacklistState(GURL("custom://my_app1")) == |
+ net::NetworkDelegate::URLBlacklistState::URL_IN_BLACKLIST); |
+ EXPECT_TRUE(blacklist.GetURLBlacklistState(GURL("custom://my_app1/play")) == |
+ net::NetworkDelegate::URLBlacklistState::URL_IN_BLACKLIST); |
+ EXPECT_TRUE(blacklist.GetURLBlacklistState(GURL("custom://my_app2:8080")) == |
+ net::NetworkDelegate::URLBlacklistState::URL_IN_BLACKLIST); |
+ EXPECT_TRUE(blacklist.GetURLBlacklistState(GURL("custom:my_app3/path")) == |
+ net::NetworkDelegate::URLBlacklistState::URL_IN_BLACKLIST); |
+ EXPECT_TRUE(blacklist.GetURLBlacklistState(GURL("custom:my_app4_game")) == |
+ net::NetworkDelegate::URLBlacklistState::URL_IN_BLACKLIST); |
+ |
+ // shouldn't match with anything, since the format defined in allowed is not |
Thiemo Nagel
2016/03/08 18:44:35
Same as above.
|
+ // supported |
+ EXPECT_TRUE(blacklist.GetURLBlacklistState(GURL("wrong://app")) == |
+ net::NetworkDelegate::URLBlacklistState::URL_NEUTRAL_STATE); |
+ |
+ EXPECT_TRUE(blacklist.GetURLBlacklistState(GURL("ggl:super_app")) == |
+ net::NetworkDelegate::URLBlacklistState::URL_IN_WHITELIST); |
+ EXPECT_TRUE(blacklist.GetURLBlacklistState(GURL("ggl://app/path:8182")) == |
+ net::NetworkDelegate::URLBlacklistState::URL_IN_WHITELIST); |
+} |
+ |
} // namespace policy |