diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-11 19:30:09 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-11 19:30:09 +0000 |
commit | ac320e7fb8049c8f3983f6d061af8d9c432e1629 (patch) | |
tree | 63718aaad38cb074be97502c9f941e35997366c7 /chrome/common/extensions | |
parent | 56a0662cfdb29f1f67fd742dcb80c7a91fdd5f04 (diff) | |
download | chromium_src-ac320e7fb8049c8f3983f6d061af8d9c432e1629.zip chromium_src-ac320e7fb8049c8f3983f6d061af8d9c432e1629.tar.gz chromium_src-ac320e7fb8049c8f3983f6d061af8d9c432e1629.tar.bz2 |
Add conditional logging to ExtensionUnpacker to help debug crashes in unit
tests.
BUG=108724
TEST=no
Review URL: http://codereview.chromium.org/9181007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117256 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions')
-rw-r--r-- | chrome/common/extensions/extension_unpacker.cc | 25 | ||||
-rw-r--r-- | chrome/common/extensions/extension_unpacker.h | 3 | ||||
-rw-r--r-- | chrome/common/extensions/extension_unpacker_unittest.cc | 28 |
3 files changed, 49 insertions, 7 deletions
diff --git a/chrome/common/extensions/extension_unpacker.cc b/chrome/common/extensions/extension_unpacker.cc index 5e4eec4..ceb94d7 100644 --- a/chrome/common/extensions/extension_unpacker.cc +++ b/chrome/common/extensions/extension_unpacker.cc @@ -26,6 +26,10 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "webkit/glue/image_decoder.h" +// Temporary code to help debug a crashing unit test. +bool g_bug108724_debug = false; +#define BUG108724_LOG() if (g_bug108724_debug) LOG(WARNING) + namespace errors = extension_manifest_errors; namespace keys = extension_manifest_keys; namespace filenames = extension_filenames; @@ -151,7 +155,9 @@ bool ExtensionUnpacker::Run() { // <profile>/Extensions/INSTALL_TEMP/<version> temp_install_dir_ = - extension_path_.DirName().AppendASCII(filenames::kTempExtensionName); + extension_path_.DirName().AppendASCII(filenames::kTempExtensionName); + + BUG108724_LOG() << "ExtensionUnpacker dir: " << temp_install_dir_.value(); if (!file_util::CreateDirectory(temp_install_dir_)) { #if defined(OS_WIN) @@ -160,19 +166,30 @@ bool ExtensionUnpacker::Run() { std::string dir_string = temp_install_dir_.value(); #endif + BUG108724_LOG() << "ExtensionUnpacker CreateDirectory fail."; SetError(kCouldNotCreateDirectoryError + dir_string); return false; } + BUG108724_LOG() << "ExtensionUnpacker Unzip..."; + if (!zip::Unzip(extension_path_, temp_install_dir_)) { + BUG108724_LOG() << "ExtensionUnpacker Unzip fail"; SetError(kCouldNotUnzipExtension); return false; } + BUG108724_LOG() << "ExtensionUnpacker ReadManifest..."; + // Parse the manifest. parsed_manifest_.reset(ReadManifest()); - if (!parsed_manifest_.get()) + if (!parsed_manifest_.get()) { + BUG108724_LOG() << "ExtensionUnpacker ReadManifest fail: " << + error_message_; return false; // Error was already reported. + } + + BUG108724_LOG() << "ExtensionUnpacker CreateExtension..."; // NOTE: Since the unpacker doesn't have the extension's public_id, the // InitFromValue is allowed to generate a temporary id for the extension. @@ -186,11 +203,15 @@ bool ExtensionUnpacker::Run() { creation_flags_, &error)); if (!extension.get()) { + BUG108724_LOG() << "ExtensionUnpacker CreateExtension fail: " << error; SetError(error); return false; } + BUG108724_LOG() << "ExtensionUnpacker ValidateExtension..."; + if (!extension_file_util::ValidateExtension(extension.get(), &error)) { + BUG108724_LOG() << "ExtensionUnpacker ValidateExtension fail: " << error; SetError(error); return false; } diff --git a/chrome/common/extensions/extension_unpacker.h b/chrome/common/extensions/extension_unpacker.h index 27d3cc0..33e7e09 100644 --- a/chrome/common/extensions/extension_unpacker.h +++ b/chrome/common/extensions/extension_unpacker.h @@ -114,4 +114,7 @@ class ExtensionUnpacker { DISALLOW_COPY_AND_ASSIGN(ExtensionUnpacker); }; +// TODO(mpcomplete): remove after debugging http://crbug.com/108724 +extern bool g_bug108724_debug; + #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_UNPACKER_H_ diff --git a/chrome/common/extensions/extension_unpacker_unittest.cc b/chrome/common/extensions/extension_unpacker_unittest.cc index d50eb8c..a732683 100644 --- a/chrome/common/extensions/extension_unpacker_unittest.cc +++ b/chrome/common/extensions/extension_unpacker_unittest.cc @@ -47,44 +47,62 @@ public: }; // Crashes intermittently on Windows, see http://crbug.com/109238 -#if defined(OS_WIN) +// TODO(mpcomplete): Temporary enabled to debug. +#if 0 // defined(OS_WIN) #define MAYBE_EmptyDefaultLocale DISABLED_EmptyDefaultLocale #else #define MAYBE_EmptyDefaultLocale EmptyDefaultLocale #endif TEST_F(ExtensionUnpackerTest, MAYBE_EmptyDefaultLocale) { + g_bug108724_debug = true; + LOG(WARNING) << "Setting up."; SetupUnpacker("empty_default_locale.crx"); + LOG(WARNING) << "Running unpacker."; EXPECT_FALSE(unpacker_->Run()); + LOG(WARNING) << "Done."; EXPECT_EQ(ASCIIToUTF16(errors::kInvalidDefaultLocale), unpacker_->error_message()); + g_bug108724_debug = false; } // Crashes intermittently on Vista, see http://crbug.com/109385 -#if defined(OS_WIN) +// TODO(mpcomplete): Temporary enabled to debug. +#if 0 // defined(OS_WIN) #define MAYBE_HasDefaultLocaleMissingLocalesFolder \ - DISABLED_HasDefaultLocaleMissingLocalesFolder + DISABLED_HasDefaultLocaleMissingLocalesFolder #else #define MAYBE_HasDefaultLocaleMissingLocalesFolder \ - HasDefaultLocaleMissingLocalesFolder + HasDefaultLocaleMissingLocalesFolder #endif TEST_F(ExtensionUnpackerTest, MAYBE_HasDefaultLocaleMissingLocalesFolder) { + g_bug108724_debug = true; + LOG(WARNING) << "Setting up."; SetupUnpacker("has_default_missing_locales.crx"); + LOG(WARNING) << "Running unpacker."; EXPECT_FALSE(unpacker_->Run()); + LOG(WARNING) << "Done."; EXPECT_EQ(ASCIIToUTF16(errors::kLocalesTreeMissing), unpacker_->error_message()); + g_bug108724_debug = false; } // Crashes intermittently on Windows, see http://crbug.com/109238 -#if defined(OS_WIN) +// TODO(mpcomplete): Temporary enabled to debug. +#if 0 // defined(OS_WIN) #define MAYBE_InvalidDefaultLocale DISABLED_InvalidDefaultLocale #else #define MAYBE_InvalidDefaultLocale InvalidDefaultLocale #endif TEST_F(ExtensionUnpackerTest, MAYBE_InvalidDefaultLocale) { + g_bug108724_debug = true; + LOG(WARNING) << "Setting up."; SetupUnpacker("invalid_default_locale.crx"); + LOG(WARNING) << "Running unpacker."; EXPECT_FALSE(unpacker_->Run()); + LOG(WARNING) << "Done."; EXPECT_EQ(ASCIIToUTF16(errors::kInvalidDefaultLocale), unpacker_->error_message()); + g_bug108724_debug = false; } // Crashes intermittently on Windows, see http://crbug.com/109738 |