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

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

Issue 16174005: Implement externally_connectable! Web pages can now communicate directly with (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: no find copies Created 7 years, 6 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/extensions/manifest_handlers/externally_connectable_unittest.cc
diff --git a/chrome/common/extensions/manifest_handlers/externally_connectable_unittest.cc b/chrome/common/extensions/manifest_handlers/externally_connectable_unittest.cc
index e24d4f65a0b9df63db60e71c31b18dbaacefb226..58af5d829402802e2aad37903b97f48af75b2adf 100644
--- a/chrome/common/extensions/manifest_handlers/externally_connectable_unittest.cc
+++ b/chrome/common/extensions/manifest_handlers/externally_connectable_unittest.cc
@@ -156,6 +156,33 @@ TEST_F(ExternallyConnectableTest, AllIDs) {
EXPECT_FALSE(info->matches.MatchesURL(GURL("http://google.com/index.html")));
}
+TEST_F(ExternallyConnectableTest, MatchesIdOrAllIds) {
+ // Not in order to test that ExternallyConnectableInfo sorts it.
+ std::string matches_ids_array[] = { "g", "h", "c", "i", "a", "z", "b" };
+ std::vector<std::string> matches_ids(
+ matches_ids_array, matches_ids_array + arraysize(matches_ids_array));
+
+ std::string nomatches_ids_array[] = { "2", "3", "1" };
+
+ // matches_all_ids = false.
+ {
+ ExternallyConnectableInfo info(URLPatternSet(), matches_ids, false);
+ for (size_t i = 0; i < matches_ids.size(); ++i)
+ EXPECT_TRUE(info.MatchesIdOrAllIds(matches_ids[i]));
+ for (size_t i = 0; i < arraysize(nomatches_ids_array); ++i)
+ EXPECT_FALSE(info.MatchesIdOrAllIds(nomatches_ids_array[i]));
+ }
+
+ // matches_all_ids = true.
+ {
+ ExternallyConnectableInfo info(URLPatternSet(), matches_ids, true);
+ for (size_t i = 0; i < matches_ids.size(); ++i)
+ EXPECT_TRUE(info.MatchesIdOrAllIds(matches_ids[i]));
+ for (size_t i = 0; i < arraysize(nomatches_ids_array); ++i)
+ EXPECT_TRUE(info.MatchesIdOrAllIds(nomatches_ids_array[i]));
+ }
+}
+
TEST_F(ExternallyConnectableTest, ErrorWrongFormat) {
RunTestcase(Testcase("externally_connectable_error_wrong_format.json",
errors::kErrorInvalid),

Powered by Google App Engine
This is Rietveld 408576698