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

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

Issue 10690016: Check zero-length icon files during extension validation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: icon removed Created 8 years, 5 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/extension_file_util_unittest.cc
diff --git a/chrome/common/extensions/extension_file_util_unittest.cc b/chrome/common/extensions/extension_file_util_unittest.cc
index 5551db146e1fa68c382723868828085db8de9cfc..6ce5c89475f0fd2dfe2ad6b8c01f99cb2046c9c2 100644
--- a/chrome/common/extensions/extension_file_util_unittest.cc
+++ b/chrome/common/extensions/extension_file_util_unittest.cc
@@ -528,6 +528,48 @@ TEST(ExtensionFileUtil, WarnOnPrivateKey) {
"extension includes the key file.*ext_root.a_key.pem"));
}
+TEST(ExtensionFileUtil, CheckZeroLengthImageFile) {
+ FilePath install_dir;
+ ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir));
+
+ // Try to install an extension with a zero-length icon file.
+ FilePath ext_dir = install_dir.AppendASCII("extensions")
+ .AppendASCII("bad")
+ .AppendASCII("Extensions")
+ .AppendASCII("ffffffffffffffffffffffffffffffff");
+
+ std::string error;
+ scoped_refptr<Extension> extension(extension_file_util::LoadExtension(
+ ext_dir, Extension::LOAD, Extension::NO_FLAGS, &error));
+ ASSERT_TRUE(extension == NULL);
+ ASSERT_STREQ("Could not load extension icon 'icon.png'.",
+ error.c_str());
+
+ // Try to install an extension with a zero-length browser action icon file.
+ ext_dir = install_dir.AppendASCII("extensions")
+ .AppendASCII("bad")
+ .AppendASCII("Extensions")
+ .AppendASCII("gggggggggggggggggggggggggggggggg");
+
+ scoped_refptr<Extension> extension2(extension_file_util::LoadExtension(
+ ext_dir, Extension::LOAD, Extension::NO_FLAGS, &error));
+ ASSERT_TRUE(extension2 == NULL);
+ ASSERT_STREQ("Could not load icon 'icon.png' for browser action.",
+ error.c_str());
+
+ // Try to install an extension with a zero-length page action icon file.
+ ext_dir = install_dir.AppendASCII("extensions")
+ .AppendASCII("bad")
+ .AppendASCII("Extensions")
+ .AppendASCII("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
+
+ scoped_refptr<Extension> extension3(extension_file_util::LoadExtension(
+ ext_dir, Extension::LOAD, Extension::NO_FLAGS, &error));
+ ASSERT_TRUE(extension3 == NULL);
+ ASSERT_STREQ("Could not load icon 'icon.png' for page action.",
+ error.c_str());
+}
+
// TODO(aa): More tests as motivation allows. Maybe steal some from
// ExtensionService? Many of them could probably be tested here without the
// MessageLoop shenanigans.

Powered by Google App Engine
This is Rietveld 408576698