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

Unified Diff: extensions/common/manifest_handlers/externally_connectable_unittest.cc

Issue 599163003: Add whitelist for extensions to put <all_urls> in externally_connectable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed permission warnings unittest Created 6 years, 3 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: extensions/common/manifest_handlers/externally_connectable_unittest.cc
diff --git a/extensions/common/manifest_handlers/externally_connectable_unittest.cc b/extensions/common/manifest_handlers/externally_connectable_unittest.cc
index 7064869c3ab36425d4ee96d43a9a7fdf0a98a6a2..9dedff3a4f09a9514dbb37a09019a39bede8a883 100644
--- a/extensions/common/manifest_handlers/externally_connectable_unittest.cc
+++ b/extensions/common/manifest_handlers/externally_connectable_unittest.cc
@@ -253,12 +253,31 @@ TEST_F(ExternallyConnectableTest, WarningNoAllURLs) {
ErrorUtils::FormatErrorMessage(errors::kErrorWildcardHostsNotAllowed,
"<all_urls>"));
ExternallyConnectableInfo* info = GetExternallyConnectableInfo(extension);
+ EXPECT_FALSE(info->matches.MatchesAllURLs());
EXPECT_FALSE(info->matches.ContainsPattern(
URLPattern(URLPattern::SCHEME_ALL, "<all_urls>")));
EXPECT_TRUE(info->matches.MatchesURL(GURL("https://example.com")));
EXPECT_TRUE(info->matches.MatchesURL(GURL("http://build.chromium.org")));
}
+TEST_F(ExternallyConnectableTest, AllURLsNotWhitelisted) {
+ scoped_refptr<Extension> extension = LoadAndExpectSuccess(
+ "externally_connectable_all_urls_not_whitelisted.json");
+ ExternallyConnectableInfo* info = GetExternallyConnectableInfo(extension);
+ EXPECT_FALSE(info->matches.MatchesAllURLs());
+}
+
+TEST_F(ExternallyConnectableTest, AllURLsWhitelisted) {
+ scoped_refptr<Extension> extension =
+ LoadAndExpectSuccess("externally_connectable_all_urls_whitelisted.json");
+ ExternallyConnectableInfo* info = GetExternallyConnectableInfo(extension);
+ EXPECT_TRUE(info->matches.MatchesAllURLs());
+ URLPattern pattern(URLPattern::SCHEME_ALL, "<all_urls>");
+ EXPECT_TRUE(info->matches.ContainsPattern(pattern));
+ EXPECT_TRUE(info->matches.MatchesURL(GURL("https://example.com")));
+ EXPECT_TRUE(info->matches.MatchesURL(GURL("http://build.chromium.org")));
+}
+
TEST_F(ExternallyConnectableTest, WarningWildcardHost) {
scoped_refptr<Extension> extension = LoadAndExpectWarning(
"externally_connectable_error_wildcard_host.json",
« no previous file with comments | « extensions/common/manifest_handlers/externally_connectable.cc ('k') | extensions/common/permissions/api_permission.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698