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

Unified Diff: chrome/common/extensions/manifest_unittest.cc

Issue 10217017: Allow features to refer to subkeys in _manifest_features.json. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Validate gives errors again 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/manifest_unittest.cc
diff --git a/chrome/common/extensions/manifest_unittest.cc b/chrome/common/extensions/manifest_unittest.cc
index 5cabe03e342518c680de4ebe609869f6b5ba6ccc..7cc5973102e8fe625fa768d2c399e4af4f526c75 100644
--- a/chrome/common/extensions/manifest_unittest.cc
+++ b/chrome/common/extensions/manifest_unittest.cc
@@ -58,10 +58,10 @@ TEST_F(ManifestTest, Extension) {
EXPECT_TRUE(manifest->GetString(keys::kBackgroundPageLegacy, &value));
EXPECT_EQ("bg.html", value);
- // The unknown key 'unknown_key' should be inaccesible.
+ // The unknown key 'unknown_key' should be accesible.
value.clear();
- EXPECT_FALSE(manifest->GetString("unknown_key", &value));
- EXPECT_EQ("", value);
+ EXPECT_TRUE(manifest->GetString("unknown_key", &value));
+ EXPECT_EQ("foo", value);
// Set the manifest_version to 2; background_page should stop working.
value.clear();
@@ -77,9 +77,8 @@ TEST_F(ManifestTest, Extension) {
feature.set_name("background_page");
feature.set_max_manifest_version(1);
EXPECT_EQ(ExtensionErrorUtils::FormatErrorMessageUTF16(
- errors::kFeatureNotAllowed,
- "background_page",
- feature.GetErrorMessage(Feature::INVALID_MAX_MANIFEST_VERSION)), error);
+ "*", feature.GetErrorMessage(Feature::INVALID_MAX_MANIFEST_VERSION)),
+ error);
}
// Test DeepCopy and Equals.
@@ -132,65 +131,4 @@ TEST_F(ManifestTest, ExtensionTypes) {
manifest->value()->Remove(keys::kLaunchWebURL, NULL);
};
-// Verifies that the various getters filter unknown and restricted keys.
Aaron Boodman 2012/04/25 21:48:31 Are there any checks of restricted keys here? It l
Matt Perry 2012/04/25 22:28:19 They were all for unknown keys. I added a new test
-TEST_F(ManifestTest, Getters) {
- scoped_ptr<DictionaryValue> value(new DictionaryValue());
- scoped_ptr<Manifest> manifest(
- new Manifest(Extension::INTERNAL, value.Pass()));
- std::string unknown_key = "asdfaskldjf";
-
- // Verify that the key filtering works for each of the getters.
- // Get and GetBoolean
- bool expected_bool = true, actual_bool = false;
- manifest->value()->Set(unknown_key, Value::CreateBooleanValue(expected_bool));
- EXPECT_FALSE(manifest->HasKey(unknown_key));
- EXPECT_FALSE(manifest->GetBoolean(unknown_key, &actual_bool));
- EXPECT_FALSE(actual_bool);
- Value* actual_value = NULL;
- EXPECT_FALSE(manifest->Get(unknown_key, &actual_value));
- EXPECT_TRUE(manifest->value()->Remove(unknown_key, NULL));
-
- // GetInteger
- int expected_int = 5, actual_int = 0;
- manifest->value()->Set(unknown_key, Value::CreateIntegerValue(expected_int));
- EXPECT_FALSE(manifest->GetInteger(unknown_key, &actual_int));
- EXPECT_NE(expected_int, actual_int);
- EXPECT_TRUE(manifest->value()->Remove(unknown_key, NULL));
-
- // GetString
- std::string expected_str = "hello", actual_str;
- manifest->value()->Set(unknown_key, Value::CreateStringValue(expected_str));
- EXPECT_FALSE(manifest->GetString(unknown_key, &actual_str));
- EXPECT_NE(expected_str, actual_str);
- EXPECT_TRUE(manifest->value()->Remove(unknown_key, NULL));
-
- // GetString (string16)
- string16 expected_str16(UTF8ToUTF16("hello")), actual_str16;
- manifest->value()->Set(unknown_key, Value::CreateStringValue(expected_str16));
- EXPECT_FALSE(manifest->GetString(unknown_key, &actual_str16));
- EXPECT_NE(expected_str16, actual_str16);
- EXPECT_TRUE(manifest->value()->Remove(unknown_key, NULL));
-
- // GetDictionary
- DictionaryValue* expected_dict = new DictionaryValue();
- DictionaryValue* actual_dict = NULL;
- expected_dict->Set("foo", Value::CreateStringValue("bar"));
- manifest->value()->Set(unknown_key, expected_dict);
- EXPECT_FALSE(manifest->GetDictionary(unknown_key, &actual_dict));
- EXPECT_EQ(NULL, actual_dict);
- std::string path = unknown_key + ".foo";
- EXPECT_FALSE(manifest->GetString(path, &actual_str));
- EXPECT_NE("bar", actual_str);
- EXPECT_TRUE(manifest->value()->Remove(unknown_key, NULL));
-
- // GetList
- ListValue* expected_list = new ListValue();
- ListValue* actual_list = NULL;
- expected_list->Append(Value::CreateStringValue("blah"));
- manifest->value()->Set(unknown_key, expected_list);
- EXPECT_FALSE(manifest->GetList(unknown_key, &actual_list));
- EXPECT_EQ(NULL, actual_list);
- EXPECT_TRUE(manifest->value()->Remove(unknown_key, NULL));
-}
-
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698