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

Unified Diff: chrome/common/extensions/api/extension_api_unittest.cc

Issue 10025007: Convert tabs, windows, and extension APIs to feature system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blah Created 8 years, 8 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/api/extension_api_unittest.cc
diff --git a/chrome/common/extensions/api/extension_api_unittest.cc b/chrome/common/extensions/api/extension_api_unittest.cc
index e25adb0768bca746cf486fcec4e3cb29ad7c57a5..ff0de63e59583f9b1a887e67993f612be65b8d8a 100644
--- a/chrome/common/extensions/api/extension_api_unittest.cc
+++ b/chrome/common/extensions/api/extension_api_unittest.cc
@@ -99,13 +99,16 @@ TEST(ExtensionAPI, IsPrivileged) {
EXPECT_FALSE(extension_api->IsPrivileged("extension.connect"));
EXPECT_FALSE(extension_api->IsPrivileged("extension.onConnect"));
- // Properties are not supported yet.
- EXPECT_TRUE(extension_api->IsPrivileged("extension.lastError"));
+ // Properties are not supported yet, but the default for this module is
+ // unprivileged, so that's what we see.
+ EXPECT_FALSE(extension_api->IsPrivileged("extension.lastError"));
- // Default unknown names to privileged for paranoia's sake.
+ // Default unknown modules to privileged for paranoia's sake.
EXPECT_TRUE(extension_api->IsPrivileged(""));
EXPECT_TRUE(extension_api->IsPrivileged("<unknown-namespace>"));
- EXPECT_TRUE(extension_api->IsPrivileged("extension.<unknown-member>"));
+
+ // Default unknown names within a module to the parent's value.
+ EXPECT_FALSE(extension_api->IsPrivileged("extension.<unknown-member>"));
// Exists, but privileged.
EXPECT_TRUE(extension_api->IsPrivileged("extension.getViews"));
@@ -134,11 +137,14 @@ TEST(ExtensionAPI, IsPrivilegedFeatures) {
Feature::UNSPECIFIED_CONTEXT },
{ "is_privileged_features_3.json", "test", false,
Feature::UNSPECIFIED_CONTEXT },
- { "is_privileged_features_4.json", "test.bar", false,
- Feature::UNSPECIFIED_CONTEXT },
{ "is_privileged_features_5.json", "test.bar", true,
Feature::BLESSED_EXTENSION_CONTEXT },
- { "is_privileged_features_5.json", "test.bar", false,
+ // These are privileged because a child always depends on its parent. So
+ // even if the child is more permissive than its parent, it still ends up
+ // having the same requirements.
+ { "is_privileged_features_4.json", "test.bar", true,
+ Feature::UNSPECIFIED_CONTEXT },
+ { "is_privileged_features_5.json", "test.bar", true,
Feature::UNBLESSED_EXTENSION_CONTEXT }
};
@@ -350,71 +356,5 @@ TEST(ExtensionAPI, GetAPINameFromFullName) {
}
}
-TEST(ExtensionAPI, DefaultConfigurationFeatures) {
- scoped_ptr<ExtensionAPI> api(ExtensionAPI::CreateWithDefaultConfiguration());
-
- Feature* bookmarks = api->GetFeature("bookmarks");
- Feature* bookmarks_create = api->GetFeature("bookmarks.create");
-
- struct {
- Feature* feature;
- // TODO(aa): More stuff to test over time.
- } test_data[] = {
- { bookmarks },
- { bookmarks_create }
- };
-
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) {
- Feature* feature = test_data[i].feature;
- ASSERT_TRUE(feature) << i;
-
- EXPECT_TRUE(feature->whitelist()->empty());
- EXPECT_TRUE(feature->extension_types()->empty());
-
- EXPECT_EQ(1u, feature->contexts()->size());
- EXPECT_TRUE(feature->contexts()->count(
- Feature::BLESSED_EXTENSION_CONTEXT));
-
- EXPECT_EQ(Feature::UNSPECIFIED_LOCATION, feature->location());
- EXPECT_EQ(Feature::UNSPECIFIED_PLATFORM, feature->platform());
- EXPECT_EQ(0, feature->min_manifest_version());
- EXPECT_EQ(0, feature->max_manifest_version());
- }
-}
-
-TEST(ExtensionAPI, FeaturesRequireContexts) {
- scoped_ptr<ListValue> schema1(new ListValue());
- DictionaryValue* feature_definition = new DictionaryValue();
- schema1->Append(feature_definition);
- feature_definition->SetString("namespace", "test");
- feature_definition->SetBoolean("uses_feature_system", true);
-
- scoped_ptr<ListValue> schema2(schema1->DeepCopy());
-
- ListValue* contexts = new ListValue();
- contexts->Append(Value::CreateStringValue("content_script"));
- feature_definition->Set("contexts", contexts);
-
- struct {
- ListValue* schema;
- bool expect_success;
- } test_data[] = {
- { schema1.get(), true },
- { schema2.get(), false }
- };
-
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) {
- std::string schema_source;
- base::JSONWriter::Write(test_data[i].schema, &schema_source);
-
- ExtensionAPI api;
- api.RegisterSchema("test", base::StringPiece(schema_source));
- api.LoadAllSchemas();
-
- Feature* feature = api.GetFeature("test");
- EXPECT_EQ(test_data[i].expect_success, feature != NULL) << i;
- }
-}
-
} // namespace
} // namespace extensions
« no previous file with comments | « chrome/common/extensions/api/extension_api_feature_unittest.cc ('k') | chrome/common/extensions/api/tabs.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698