| Index: chrome/common/extensions/extension_permission_set_unittest.cc
|
| diff --git a/chrome/common/extensions/extension_permission_set_unittest.cc b/chrome/common/extensions/extension_permission_set_unittest.cc
|
| index 9cfa6980c31f2f62a2ec1a2d73856658910dc72b..6140bec273f144569a1a93cb3722add3ec2dc1a9 100644
|
| --- a/chrome/common/extensions/extension_permission_set_unittest.cc
|
| +++ b/chrome/common/extensions/extension_permission_set_unittest.cc
|
| @@ -58,23 +58,6 @@ static void AddPattern(URLPatternSet* extent, const std::string& pattern) {
|
| extent->AddPattern(URLPattern(schemes, pattern));
|
| }
|
|
|
| -static void AssertEqualExtents(const URLPatternSet& extent1,
|
| - const URLPatternSet& extent2) {
|
| - URLPatternList patterns1 = extent1.patterns();
|
| - URLPatternList patterns2 = extent2.patterns();
|
| - std::set<std::string> strings1;
|
| - EXPECT_EQ(patterns1.size(), patterns2.size());
|
| -
|
| - for (size_t i = 0; i < patterns1.size(); ++i)
|
| - strings1.insert(patterns1.at(i).GetAsString());
|
| -
|
| - std::set<std::string> strings2;
|
| - for (size_t i = 0; i < patterns2.size(); ++i)
|
| - strings2.insert(patterns2.at(i).GetAsString());
|
| -
|
| - EXPECT_EQ(strings1, strings2);
|
| -}
|
| -
|
| } // namespace
|
|
|
| class ExtensionAPIPermissionTest : public testing::Test {
|
| @@ -336,9 +319,9 @@ TEST(ExtensionPermissionSetTest, CreateUnion) {
|
|
|
| EXPECT_FALSE(union_set->HasEffectiveFullAccess());
|
| EXPECT_EQ(expected_apis, union_set->apis());
|
| - AssertEqualExtents(expected_explicit_hosts, union_set->explicit_hosts());
|
| - AssertEqualExtents(expected_scriptable_hosts, union_set->scriptable_hosts());
|
| - AssertEqualExtents(expected_explicit_hosts, union_set->effective_hosts());
|
| + EXPECT_EQ(expected_explicit_hosts, union_set->explicit_hosts());
|
| + EXPECT_EQ(expected_scriptable_hosts, union_set->scriptable_hosts());
|
| + EXPECT_EQ(expected_explicit_hosts, union_set->effective_hosts());
|
|
|
| // Now use a real second set.
|
| apis2.insert(ExtensionAPIPermission::kTab);
|
| @@ -364,9 +347,9 @@ TEST(ExtensionPermissionSetTest, CreateUnion) {
|
| EXPECT_TRUE(union_set->HasEffectiveFullAccess());
|
| EXPECT_TRUE(union_set->HasEffectiveAccessToAllHosts());
|
| EXPECT_EQ(expected_apis, union_set->apis());
|
| - AssertEqualExtents(expected_explicit_hosts, union_set->explicit_hosts());
|
| - AssertEqualExtents(expected_scriptable_hosts, union_set->scriptable_hosts());
|
| - AssertEqualExtents(effective_hosts, union_set->effective_hosts());
|
| + EXPECT_EQ(expected_explicit_hosts, union_set->explicit_hosts());
|
| + EXPECT_EQ(expected_scriptable_hosts, union_set->scriptable_hosts());
|
| + EXPECT_EQ(effective_hosts, union_set->effective_hosts());
|
| }
|
|
|
| TEST(ExtensionPermissionSetTest, HasLessPrivilegesThan) {
|
| @@ -564,7 +547,7 @@ TEST(ExtensionPermissionSetTest, GetWarningMessages_ManyHosts) {
|
| std::vector<string16> warnings =
|
| extension->permission_set()->GetWarningMessages();
|
| ASSERT_EQ(1u, warnings.size());
|
| - EXPECT_EQ("Your data on www.google.com and encrypted.google.com",
|
| + EXPECT_EQ("Your data on encrypted.google.com and www.google.com",
|
| UTF16ToUTF8(warnings[0]));
|
| }
|
|
|
| @@ -589,10 +572,10 @@ TEST(ExtensionPermissionSetTest, GetWarningMessages_Plugins) {
|
| TEST(ExtensionPermissionSetTest, GetDistinctHostsForDisplay) {
|
| scoped_ptr<ExtensionPermissionSet> perm_set;
|
| ExtensionAPIPermissionSet empty_perms;
|
| - std::vector<std::string> expected;
|
| - expected.push_back("www.foo.com");
|
| - expected.push_back("www.bar.com");
|
| - expected.push_back("www.baz.com");
|
| + std::set<std::string> expected;
|
| + expected.insert("www.foo.com");
|
| + expected.insert("www.bar.com");
|
| + expected.insert("www.baz.com");
|
| URLPatternSet explicit_hosts;
|
| URLPatternSet scriptable_hosts;
|
|
|
| @@ -608,7 +591,7 @@ TEST(ExtensionPermissionSetTest, GetDistinctHostsForDisplay) {
|
| URLPattern(URLPattern::SCHEME_HTTP, "http://www.baz.com/path"));
|
| perm_set.reset(new ExtensionPermissionSet(
|
| empty_perms, explicit_hosts, scriptable_hosts));
|
| - CompareLists(expected, perm_set->GetDistinctHostsForDisplay());
|
| + EXPECT_EQ(expected, perm_set->GetDistinctHostsForDisplay());
|
| }
|
|
|
| {
|
| @@ -621,7 +604,7 @@ TEST(ExtensionPermissionSetTest, GetDistinctHostsForDisplay) {
|
| URLPattern(URLPattern::SCHEME_HTTP, "http://www.baz.com/path"));
|
| perm_set.reset(new ExtensionPermissionSet(
|
| empty_perms, explicit_hosts, scriptable_hosts));
|
| - CompareLists(expected, perm_set->GetDistinctHostsForDisplay());
|
| + EXPECT_EQ(expected, perm_set->GetDistinctHostsForDisplay());
|
| }
|
|
|
| {
|
| @@ -632,7 +615,7 @@ TEST(ExtensionPermissionSetTest, GetDistinctHostsForDisplay) {
|
| URLPattern(URLPattern::SCHEME_HTTPS, "https://www.bar.com/path"));
|
| perm_set.reset(new ExtensionPermissionSet(
|
| empty_perms, explicit_hosts, scriptable_hosts));
|
| - CompareLists(expected, perm_set->GetDistinctHostsForDisplay());
|
| + EXPECT_EQ(expected, perm_set->GetDistinctHostsForDisplay());
|
| }
|
|
|
| {
|
| @@ -643,7 +626,7 @@ TEST(ExtensionPermissionSetTest, GetDistinctHostsForDisplay) {
|
| URLPattern(URLPattern::SCHEME_HTTP, "http://www.bar.com/pathypath"));
|
| perm_set.reset(new ExtensionPermissionSet(
|
| empty_perms, explicit_hosts, scriptable_hosts));
|
| - CompareLists(expected, perm_set->GetDistinctHostsForDisplay());
|
| + EXPECT_EQ(expected, perm_set->GetDistinctHostsForDisplay());
|
| }
|
|
|
| {
|
| @@ -655,12 +638,12 @@ TEST(ExtensionPermissionSetTest, GetDistinctHostsForDisplay) {
|
| explicit_hosts.AddPattern(
|
| URLPattern(URLPattern::SCHEME_HTTP, "http://bar.com/path"));
|
|
|
| - expected.push_back("monkey.www.bar.com");
|
| - expected.push_back("bar.com");
|
| + expected.insert("monkey.www.bar.com");
|
| + expected.insert("bar.com");
|
|
|
| perm_set.reset(new ExtensionPermissionSet(
|
| empty_perms, explicit_hosts, scriptable_hosts));
|
| - CompareLists(expected, perm_set->GetDistinctHostsForDisplay());
|
| + EXPECT_EQ(expected, perm_set->GetDistinctHostsForDisplay());
|
| }
|
|
|
| {
|
| @@ -687,11 +670,11 @@ TEST(ExtensionPermissionSetTest, GetDistinctHostsForDisplay) {
|
| explicit_hosts.AddPattern(
|
| URLPattern(URLPattern::SCHEME_HTTP, "http://www.foo.xyzzy/path"));
|
|
|
| - expected.push_back("www.foo.xyzzy");
|
| + expected.insert("www.foo.xyzzy");
|
|
|
| perm_set.reset(new ExtensionPermissionSet(
|
| empty_perms, explicit_hosts, scriptable_hosts));
|
| - CompareLists(expected, perm_set->GetDistinctHostsForDisplay());
|
| + EXPECT_EQ(expected, perm_set->GetDistinctHostsForDisplay());
|
| }
|
|
|
| {
|
| @@ -700,11 +683,11 @@ TEST(ExtensionPermissionSetTest, GetDistinctHostsForDisplay) {
|
| explicit_hosts.AddPattern(
|
| URLPattern(URLPattern::SCHEME_HTTP, "http://*.google.com/*"));
|
|
|
| - expected.push_back("*.google.com");
|
| + expected.insert("*.google.com");
|
|
|
| perm_set.reset(new ExtensionPermissionSet(
|
| empty_perms, explicit_hosts, scriptable_hosts));
|
| - CompareLists(expected, perm_set->GetDistinctHostsForDisplay());
|
| + EXPECT_EQ(expected, perm_set->GetDistinctHostsForDisplay());
|
| }
|
|
|
| {
|
| @@ -718,12 +701,12 @@ TEST(ExtensionPermissionSetTest, GetDistinctHostsForDisplay) {
|
| scriptable_hosts.AddPattern(
|
| URLPattern(URLPattern::SCHEME_HTTP, "http://*.example.com/*"));
|
|
|
| - expected.push_back("*.google.com");
|
| - expected.push_back("*.example.com");
|
| + expected.insert("*.google.com");
|
| + expected.insert("*.example.com");
|
|
|
| perm_set.reset(new ExtensionPermissionSet(
|
| empty_perms, explicit_hosts, scriptable_hosts));
|
| - CompareLists(expected, perm_set->GetDistinctHostsForDisplay());
|
| + EXPECT_EQ(expected, perm_set->GetDistinctHostsForDisplay());
|
| }
|
| }
|
|
|
| @@ -745,11 +728,11 @@ TEST(ExtensionPermissionSetTest, GetDistinctHostsForDisplay_ComIsBestRcd) {
|
| explicit_hosts.AddPattern(
|
| URLPattern(URLPattern::SCHEME_HTTP, "http://www.foo.com/path"));
|
|
|
| - std::vector<std::string> expected;
|
| - expected.push_back("www.foo.com");
|
| + std::set<std::string> expected;
|
| + expected.insert("www.foo.com");
|
| perm_set.reset(new ExtensionPermissionSet(
|
| empty_perms, explicit_hosts, scriptable_hosts));
|
| - CompareLists(expected, perm_set->GetDistinctHostsForDisplay());
|
| + EXPECT_EQ(expected, perm_set->GetDistinctHostsForDisplay());
|
| }
|
|
|
| TEST(ExtensionPermissionSetTest, GetDistinctHostsForDisplay_NetIs2ndBestRcd) {
|
| @@ -769,11 +752,11 @@ TEST(ExtensionPermissionSetTest, GetDistinctHostsForDisplay_NetIs2ndBestRcd) {
|
| URLPattern(URLPattern::SCHEME_HTTP, "http://www.foo.jp/path"));
|
| // No http://www.foo.com/path
|
|
|
| - std::vector<std::string> expected;
|
| - expected.push_back("www.foo.net");
|
| + std::set<std::string> expected;
|
| + expected.insert("www.foo.net");
|
| perm_set.reset(new ExtensionPermissionSet(
|
| empty_perms, explicit_hosts, scriptable_hosts));
|
| - CompareLists(expected, perm_set->GetDistinctHostsForDisplay());
|
| + EXPECT_EQ(expected, perm_set->GetDistinctHostsForDisplay());
|
| }
|
|
|
| TEST(ExtensionPermissionSetTest,
|
| @@ -793,11 +776,11 @@ TEST(ExtensionPermissionSetTest,
|
| URLPattern(URLPattern::SCHEME_HTTP, "http://www.foo.jp/path"));
|
| // No http://www.foo.com/path
|
|
|
| - std::vector<std::string> expected;
|
| - expected.push_back("www.foo.org");
|
| + std::set<std::string> expected;
|
| + expected.insert("www.foo.org");
|
| perm_set.reset(new ExtensionPermissionSet(
|
| empty_perms, explicit_hosts, scriptable_hosts));
|
| - CompareLists(expected, perm_set->GetDistinctHostsForDisplay());
|
| + EXPECT_EQ(expected, perm_set->GetDistinctHostsForDisplay());
|
| }
|
|
|
| TEST(ExtensionPermissionSetTest,
|
| @@ -816,11 +799,11 @@ TEST(ExtensionPermissionSetTest,
|
| URLPattern(URLPattern::SCHEME_HTTP, "http://www.foo.jp/path"));
|
| // No http://www.foo.com/path
|
|
|
| - std::vector<std::string> expected;
|
| - expected.push_back("www.foo.ca");
|
| + std::set<std::string> expected;
|
| + expected.insert("www.foo.ca");
|
| perm_set.reset(new ExtensionPermissionSet(
|
| empty_perms, explicit_hosts, scriptable_hosts));
|
| - CompareLists(expected, perm_set->GetDistinctHostsForDisplay());
|
| + EXPECT_EQ(expected, perm_set->GetDistinctHostsForDisplay());
|
| }
|
|
|
| TEST(ExtensionPermissionSetTest, HasLessHostPrivilegesThan) {
|
|
|