summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/extension_unittest.cc
diff options
context:
space:
mode:
authorandybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-19 15:22:20 +0000
committerandybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-19 15:22:20 +0000
commit9bf14a24e1de759fddfbbee8050d65ef2d95ef18 (patch)
tree24aa03d05b22be52366d8baf06dab96638ecf71b /chrome/common/extensions/extension_unittest.cc
parente685fc4178818c026f1498461edb3f2bfeff5722 (diff)
downloadchromium_src-9bf14a24e1de759fddfbbee8050d65ef2d95ef18.zip
chromium_src-9bf14a24e1de759fddfbbee8050d65ef2d95ef18.tar.gz
chromium_src-9bf14a24e1de759fddfbbee8050d65ef2d95ef18.tar.bz2
Revert 42091 - Refactor apprelated manifest properties so that they don't
include the name 'app'. I think these will be useful for normal extensions, too. Also extract an ExtensionExtent class out of Extension. I think this will be useful for passing by value to the IO thread. Review URL: http://codereview.chromium.org/1025006 TBR=aa@chromium.org Review URL: http://codereview.chromium.org/1120005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42104 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/extension_unittest.cc')
-rw-r--r--chrome/common/extensions/extension_unittest.cc59
1 files changed, 52 insertions, 7 deletions
diff --git a/chrome/common/extensions/extension_unittest.cc b/chrome/common/extensions/extension_unittest.cc
index d046503..4dbb7e3 100644
--- a/chrome/common/extensions/extension_unittest.cc
+++ b/chrome/common/extensions/extension_unittest.cc
@@ -36,13 +36,6 @@ TEST(ExtensionTest, LocationValuesTest) {
ASSERT_EQ(5, Extension::COMPONENT);
}
-
-// Please don't put any more manifest tests here!!
-// Move them to extension_manifest_unittest.cc instead and make them use the
-// more data-driven style there instead.
-// Bug: http://crbug.com/38462
-
-
TEST(ExtensionTest, InitFromValueInvalid) {
#if defined(OS_WIN)
FilePath path(FILE_PATH_LITERAL("c:\\foo"));
@@ -281,6 +274,58 @@ TEST(ExtensionTest, InitFromValueInvalid) {
EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error));
EXPECT_TRUE(MatchPatternASCII(error, errors::kChromeVersionTooLow));
#endif
+
+ // Test invalid app.
+ input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
+ input_value->Set(keys::kApp, Value::CreateIntegerValue(42));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error));
+ EXPECT_EQ(errors::kInvalidApp, error);
+
+ // Test invalid launch URLs.
+ DictionaryValue* app = new DictionaryValue();
+ input_value->Set(keys::kApp, app);
+
+ EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error));
+ EXPECT_EQ(errors::kInvalidAppLaunchUrl, error);
+
+ Value* invalid_launch_urls[] = {
+ Value::CreateStringValue(""),
+ Value::CreateIntegerValue(42),
+ Value::CreateStringValue("foobar")
+ };
+
+ for (size_t i = 0; i < arraysize(invalid_launch_urls); ++i) {
+ app->Set(keys::kAppLaunchUrl, invalid_launch_urls[i]);
+ error.clear();
+ EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error));
+ EXPECT_EQ(errors::kInvalidAppLaunchUrl, error);
+ }
+
+ // Test valid launch URL.
+ app->Set(keys::kAppLaunchUrl,
+ Value::CreateStringValue("http://www.google.com/index.html"));
+ EXPECT_TRUE(extension.InitFromValue(*input_value, true, &error));
+
+ // Test invalid app origins.
+ Value* invalid_origins[] = {
+ Value::CreateStringValue(""),
+ Value::CreateIntegerValue(42),
+ Value::CreateStringValue("foobar"),
+ Value::CreateStringValue("file:///c:/foo.txt"),
+ Value::CreateStringValue("ftp://www.google.com/")
+ };
+
+ for (size_t i = 0; i < arraysize(invalid_origins); ++i) {
+ app->Set(keys::kAppOrigin, invalid_origins[i]);
+ error.clear();
+ EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error));
+ EXPECT_EQ(errors::kInvalidAppOrigin, error);
+ }
+
+ // Test valid origin.
+ app->Set(keys::kAppOrigin,
+ Value::CreateStringValue("http://www.google.com/"));
+ EXPECT_TRUE(extension.InitFromValue(*input_value, true, &error));
}
TEST(ExtensionTest, InitFromValueValid) {