diff options
author | asargent <asargent@chromium.org> | 2015-01-16 13:34:16 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-16 21:34:55 +0000 |
commit | 12a9cab7ee804fd898dca62004f750cc5a1ad685 (patch) | |
tree | 6734137f0cc7c889fa7c5f4059d12c43642b30d0 | |
parent | 79126efc4e18a879657667f39b438b6e58523e58 (diff) | |
download | chromium_src-12a9cab7ee804fd898dca62004f750cc5a1ad685.zip chromium_src-12a9cab7ee804fd898dca62004f750cc5a1ad685.tar.gz chromium_src-12a9cab7ee804fd898dca62004f750cc5a1ad685.tar.bz2 |
Move unpacker_unittests.cc and data files from chrome/ to extensions/
Most of the changes here are just moves, with only a few more notable
changes:
Add "manifest_version : 2" and change from theme to extension
-extensions/test/data/unpacker/bad_zip/manifest.json
-extensions/test/data/unpacker/bad_image/manifest.json
-extensions/test/data/unpacker/good_package/manifest.json
Changed BadPathError test and misc cleanup
-extensions/utility/unpacker_unittest.cc
Support for changes to the above mentioned BadPathError test
-extensions/test/test_extensions_client.h
-extensions/test/test_extensions_client.cc
Entire directory just deleted, not moved
-chrome/test/data/extensions/unpacker/bad_path/
BUG=447014
Review URL: https://codereview.chromium.org/849803004
Cr-Commit-Position: refs/heads/master@{#311954}
-rw-r--r-- | chrome/browser/extensions/sandboxed_unpacker_unittest.cc | 7 | ||||
-rw-r--r-- | chrome/chrome_tests_unit.gypi | 1 | ||||
-rw-r--r-- | chrome/test/data/extensions/unpacker/bad_image.crx | bin | 841 -> 0 bytes | |||
-rw-r--r-- | chrome/test/data/extensions/unpacker/bad_path.crx | bin | 12933 -> 0 bytes | |||
-rw-r--r-- | chrome/test/data/extensions/unpacker/bad_path/bad_path.pem | 16 | ||||
-rwxr-xr-x | chrome/test/data/extensions/unpacker/bad_path/bad_path.sh | 39 | ||||
-rw-r--r-- | chrome/test/data/extensions/unpacker/bad_path/manifest.json | 6 | ||||
-rw-r--r-- | chrome/test/data/extensions/unpacker/bad_zip.crx | bin | 8498 -> 0 bytes | |||
-rw-r--r-- | chrome/test/data/extensions/unpacker/bad_zip/background.js | 5 | ||||
-rw-r--r-- | extensions/BUILD.gn | 1 | ||||
-rw-r--r-- | extensions/extensions.gyp | 1 | ||||
-rw-r--r-- | extensions/test/data/unpacker/bad_image.crx | bin | 0 -> 1243 bytes | |||
-rw-r--r-- | extensions/test/data/unpacker/bad_image/background.js (renamed from chrome/test/data/extensions/unpacker/bad_image/background.js) | 0 | ||||
-rw-r--r-- | extensions/test/data/unpacker/bad_image/manifest.json (renamed from chrome/test/data/extensions/unpacker/bad_image/manifest.json) | 3 | ||||
-rw-r--r-- | extensions/test/data/unpacker/bad_image/not_really_an_image.png (renamed from chrome/test/data/extensions/unpacker/bad_image/not_really_an_image.png) | 0 | ||||
-rw-r--r-- | extensions/test/data/unpacker/bad_zip.crx (renamed from chrome/test/data/extensions/unpacker/good_package/product_logo_128.png) | bin | 10100 -> 8498 bytes | |||
-rw-r--r-- | extensions/test/data/unpacker/bad_zip/background.js (renamed from chrome/test/data/extensions/unpacker/bad_path/background.js) | 0 | ||||
-rw-r--r-- | extensions/test/data/unpacker/bad_zip/bad_zip.pem (renamed from chrome/test/data/extensions/unpacker/bad_zip/bad_zip.pem) | 0 | ||||
-rwxr-xr-x | extensions/test/data/unpacker/bad_zip/bad_zip.sh (renamed from chrome/test/data/extensions/unpacker/bad_zip/bad_zip.sh) | 0 | ||||
-rw-r--r-- | extensions/test/data/unpacker/bad_zip/manifest.json (renamed from chrome/test/data/extensions/unpacker/bad_zip/manifest.json) | 5 | ||||
-rw-r--r-- | extensions/test/data/unpacker/bad_zip/product_logo_128.png (renamed from chrome/test/data/extensions/unpacker/bad_path/product_logo_128.png) | bin | 10100 -> 10100 bytes | |||
-rw-r--r-- | extensions/test/data/unpacker/empty_default_locale.crx (renamed from chrome/test/data/extensions/unpacker/empty_default_locale.crx) | bin | 521 -> 521 bytes | |||
-rw-r--r-- | extensions/test/data/unpacker/empty_default_locale/manifest.json (renamed from chrome/test/data/extensions/unpacker/empty_default_locale/manifest.json) | 0 | ||||
-rw-r--r-- | extensions/test/data/unpacker/good_l10n.crx (renamed from chrome/test/data/extensions/unpacker/good_l10n.crx) | bin | 1185 -> 1185 bytes | |||
-rw-r--r-- | extensions/test/data/unpacker/good_l10n/_locales/en_US/messages.json (renamed from chrome/test/data/extensions/unpacker/good_l10n/_locales/en_US/messages.json) | 0 | ||||
-rw-r--r-- | extensions/test/data/unpacker/good_l10n/_locales/sr/messages.json (renamed from chrome/test/data/extensions/unpacker/good_l10n/_locales/sr/messages.json) | 0 | ||||
-rw-r--r-- | extensions/test/data/unpacker/good_l10n/manifest.json (renamed from chrome/test/data/extensions/unpacker/good_l10n/manifest.json) | 0 | ||||
-rw-r--r-- | extensions/test/data/unpacker/good_package.crx (renamed from chrome/test/data/extensions/unpacker/good_package.crx) | bin | 10784 -> 11054 bytes | |||
-rw-r--r-- | extensions/test/data/unpacker/good_package/manifest.json (renamed from chrome/test/data/extensions/unpacker/good_package/manifest.json) | 5 | ||||
-rw-r--r-- | extensions/test/data/unpacker/good_package/product_logo_128.png (renamed from chrome/test/data/extensions/unpacker/bad_zip/product_logo_128.png) | bin | 10100 -> 10100 bytes | |||
-rw-r--r-- | extensions/test/data/unpacker/has_default_missing_locales.crx (renamed from chrome/test/data/extensions/unpacker/has_default_missing_locales.crx) | bin | 539 -> 539 bytes | |||
-rw-r--r-- | extensions/test/data/unpacker/has_default_missing_locales/manifest.json (renamed from chrome/test/data/extensions/unpacker/has_default_missing_locales/manifest.json) | 0 | ||||
-rw-r--r-- | extensions/test/data/unpacker/invalid_default_locale.crx (renamed from chrome/test/data/extensions/unpacker/invalid_default_locale.crx) | bin | 542 -> 542 bytes | |||
-rw-r--r-- | extensions/test/data/unpacker/invalid_default_locale/manifest.json (renamed from chrome/test/data/extensions/unpacker/invalid_default_locale/manifest.json) | 0 | ||||
-rw-r--r-- | extensions/test/data/unpacker/invalid_messages_file.crx (renamed from chrome/test/data/extensions/unpacker/invalid_messages_file.crx) | bin | 911 -> 911 bytes | |||
-rw-r--r-- | extensions/test/data/unpacker/invalid_messages_file/_locales/en_US/messages.json (renamed from chrome/test/data/extensions/unpacker/invalid_messages_file/_locales/en_US/messages.json) | 0 | ||||
-rw-r--r-- | extensions/test/data/unpacker/invalid_messages_file/manifest.json (renamed from chrome/test/data/extensions/unpacker/invalid_messages_file/manifest.json) | 0 | ||||
-rw-r--r-- | extensions/test/data/unpacker/missing_default_data.crx (renamed from chrome/test/data/extensions/unpacker/missing_default_data.crx) | bin | 924 -> 924 bytes | |||
-rw-r--r-- | extensions/test/data/unpacker/missing_default_data/_locales/en_US/messages.json (renamed from chrome/test/data/extensions/unpacker/missing_default_data/_locales/en_US/messages.json) | 0 | ||||
-rw-r--r-- | extensions/test/data/unpacker/missing_default_data/manifest.json (renamed from chrome/test/data/extensions/unpacker/missing_default_data/manifest.json) | 0 | ||||
-rw-r--r-- | extensions/test/data/unpacker/missing_default_has_locales.crx (renamed from chrome/test/data/extensions/unpacker/missing_default_has_locales.crx) | bin | 634 -> 634 bytes | |||
-rw-r--r-- | extensions/test/data/unpacker/missing_default_has_locales/manifest.json (renamed from chrome/test/data/extensions/unpacker/missing_default_has_locales/manifest.json) | 0 | ||||
-rw-r--r-- | extensions/test/data/unpacker/missing_messages_file.crx (renamed from chrome/test/data/extensions/unpacker/missing_messages_file.crx) | bin | 748 -> 748 bytes | |||
-rw-r--r-- | extensions/test/data/unpacker/missing_messages_file/manifest.json (renamed from chrome/test/data/extensions/unpacker/missing_messages_file/manifest.json) | 0 | ||||
-rw-r--r-- | extensions/test/data/unpacker/no_l10n.crx (renamed from chrome/test/data/extensions/unpacker/no_l10n.crx) | bin | 513 -> 513 bytes | |||
-rw-r--r-- | extensions/test/data/unpacker/no_l10n/manifest.json (renamed from chrome/test/data/extensions/unpacker/no_l10n/manifest.json) | 0 | ||||
-rw-r--r-- | extensions/test/data/unpacker/no_locale_data.crx (renamed from chrome/test/data/extensions/unpacker/no_locale_data.crx) | bin | 620 -> 620 bytes | |||
-rw-r--r-- | extensions/test/data/unpacker/no_locale_data/manifest.json (renamed from chrome/test/data/extensions/unpacker/no_locale_data/manifest.json) | 0 | ||||
-rw-r--r-- | extensions/test/test_extensions_client.cc | 20 | ||||
-rw-r--r-- | extensions/test/test_extensions_client.h | 15 | ||||
-rw-r--r-- | extensions/utility/unpacker_unittest.cc (renamed from chrome/utility/extensions/unpacker_unittest.cc) | 49 |
51 files changed, 90 insertions, 83 deletions
diff --git a/chrome/browser/extensions/sandboxed_unpacker_unittest.cc b/chrome/browser/extensions/sandboxed_unpacker_unittest.cc index 8b70ccf..4d46e7c 100644 --- a/chrome/browser/extensions/sandboxed_unpacker_unittest.cc +++ b/chrome/browser/extensions/sandboxed_unpacker_unittest.cc @@ -16,6 +16,7 @@ #include "content/public/test/test_utils.h" #include "extensions/common/constants.h" #include "extensions/common/extension.h" +#include "extensions/common/extension_paths.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkBitmap.h" @@ -75,10 +76,8 @@ class SandboxedUnpackerTest : public testing::Test { void SetupUnpacker(const std::string& crx_name) { base::FilePath original_path; - ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &original_path)); - original_path = original_path.AppendASCII("extensions") - .AppendASCII("unpacker") - .AppendASCII(crx_name); + ASSERT_TRUE(PathService::Get(extensions::DIR_TEST_DATA, &original_path)); + original_path = original_path.AppendASCII("unpacker").AppendASCII(crx_name); ASSERT_TRUE(base::PathExists(original_path)) << original_path.value(); sandboxed_unpacker_ = new SandboxedUnpacker( diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi index 68aa276..e8ee39e 100644 --- a/chrome/chrome_tests_unit.gypi +++ b/chrome/chrome_tests_unit.gypi @@ -926,7 +926,6 @@ 'renderer/extensions/extension_localization_peer_unittest.cc', 'renderer/extensions/renderer_permissions_policy_delegate_unittest.cc', 'renderer/media/cast_ipc_dispatcher_unittest.cc', - 'utility/extensions/unpacker_unittest.cc', 'utility/image_writer/image_writer_unittest.cc', 'utility/media_galleries/image_metadata_extractor_unittest.cc', ], diff --git a/chrome/test/data/extensions/unpacker/bad_image.crx b/chrome/test/data/extensions/unpacker/bad_image.crx Binary files differdeleted file mode 100644 index 044c0a4..0000000 --- a/chrome/test/data/extensions/unpacker/bad_image.crx +++ /dev/null diff --git a/chrome/test/data/extensions/unpacker/bad_path.crx b/chrome/test/data/extensions/unpacker/bad_path.crx Binary files differdeleted file mode 100644 index dbdcb22..0000000 --- a/chrome/test/data/extensions/unpacker/bad_path.crx +++ /dev/null diff --git a/chrome/test/data/extensions/unpacker/bad_path/bad_path.pem b/chrome/test/data/extensions/unpacker/bad_path/bad_path.pem deleted file mode 100644 index e338fc8..0000000 --- a/chrome/test/data/extensions/unpacker/bad_path/bad_path.pem +++ /dev/null @@ -1,16 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAMHOSbN+rhH8WhvmM -e0l7CwJ8+K0ZmYwKFuJIgQTJIMBZhsZyMYse0l6jrurgr0n8UkCqWfOEvyxFxqtxp -osb7bm3AKg/SsdiDDzZQLwQK5Sy6gBh3hXk+K4aLVv3rQsdRRMQPhgDvZJGBEWsjQ -kJ3dalslli/cEpbwm0USp1fWtAgMBAAECgYEAlqR/OysjqM1LSVZTxm7stYqC7Num -oJWcORJNw3cRsVbcBAK1wfx/VC0UVyHIfLlYXpTYEtzme043lEAxGFOj/N/3+9tH0 -0HhuVnAPh8JAfCXVZfGy/C3DWzatLx4iZMctBSE+3ViNscZtJHP65bgfqVBatAiyK -IrPPz7xe/GGS0CQQDjqBKM/9IvWvpRw1YMoX9f4jC7lp3FDfr7MtBLj/sq9d+QtTb -MArTQzwVlb4WZ0jVe7ceUl/ZG8VWs5FAYM0RvAkEA2e9RCYiIpfJCTt1pxfN5lBIi -vrwkwUtxnKzfvl7YEJEV4WMUnIwpdjuHaSIXBRf3D29Vw1s7Mmz/kdFSKiRNowJBA -JPRGKJ2pMncv7YBKEkxP1xJqKzUwgIl7rXWK4s0pLgjR5NVJoxWoYMHOJDBVbUn2U -GXEMS52s37e060PBFKkH8CQD8SgtqGeD3GsigO7mjKwTn4UbPv0ZdblULpyUtYOaH -5y2JSgYmZCvrb2aG0qwLfX7JI34JNagF7CDAUa3okzY8CQQCr8/LcdzM24XjJXySN -AqWAtBk8iAp5DheO7GHgS1Xyrcbl3VRWctjYJjQlFBkIKvMAI5dXl+FCM1+mZD5+2 -qPu ------END PRIVATE KEY----- diff --git a/chrome/test/data/extensions/unpacker/bad_path/bad_path.sh b/chrome/test/data/extensions/unpacker/bad_path/bad_path.sh deleted file mode 100755 index 96371cb..0000000 --- a/chrome/test/data/extensions/unpacker/bad_path/bad_path.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -e - -## Copyright (c) 2012 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Purpose: Create a Chromium crx even if paths are invalid. -if test $# -ne 2; then - echo "Usage: bad_path.sh <extension dir> <pem path>" - exit 1 -fi -dir=$1 -key=$2 -name=$(basename "$dir") -crx="$name.crx" -pub="$name.pub" -sig="$name.sig" -zip="$name.zip" -trap 'rm -f "$pub" "$sig" "$zip"' EXIT -# zip up the crx dir -cwd=$(pwd -P) -(cd "$dir" && zip -qr -9 -X "$cwd/$zip" .) -# signature -openssl sha1 -sha1 -binary -sign "$key" < "$zip" > "$sig" -# public key -openssl rsa -pubout -outform DER < "$key" > "$pub" 2>/dev/null -byte_swap () { - # Take "abcdefgh" and return it as "ghefcdab" - echo "${1:6:2}${1:4:2}${1:2:2}${1:0:2}" -} -crmagic_hex="4372 3234" # Cr24 -version_hex="0200 0000" # 2 -pub_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$pub" | awk '{print $5}'))) -sig_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$sig" | awk '{print $5}'))) -( - echo "$crmagic_hex $version_hex $pub_len_hex $sig_len_hex" | xxd -r -p - cat "$pub" "$sig" "$zip" -) > "$crx" -echo "Wrote $crx with possibly invalid path" diff --git a/chrome/test/data/extensions/unpacker/bad_path/manifest.json b/chrome/test/data/extensions/unpacker/bad_path/manifest.json deleted file mode 100644 index d19b7f8..0000000 --- a/chrome/test/data/extensions/unpacker/bad_path/manifest.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "Bad Path", - "version": "1.0", - "description": "Package with an invalid path to be used for unit testing. The path below is carefully chosen so: 1) it contains '..'; and 2) it resolves to a valid file at package installation time so no invalid-image-error is raised before the invalid-image-path-error one is. Because of the invalid path, this package needs to be packaged with bad_path.sh rather than Chromium.", - "theme": {"images" : {"bad_path" : "../CRX_INSTALL/product_logo_128.png"}} -} diff --git a/chrome/test/data/extensions/unpacker/bad_zip.crx b/chrome/test/data/extensions/unpacker/bad_zip.crx Binary files differdeleted file mode 100644 index 6bf7f1f..0000000 --- a/chrome/test/data/extensions/unpacker/bad_zip.crx +++ /dev/null diff --git a/chrome/test/data/extensions/unpacker/bad_zip/background.js b/chrome/test/data/extensions/unpacker/bad_zip/background.js deleted file mode 100644 index 8c00bb1..0000000 --- a/chrome/test/data/extensions/unpacker/bad_zip/background.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Not doing anything. diff --git a/extensions/BUILD.gn b/extensions/BUILD.gn index 0006144..c900458 100644 --- a/extensions/BUILD.gn +++ b/extensions/BUILD.gn @@ -255,6 +255,7 @@ if (false) { "renderer/script_context_unittest.cc", "renderer/utils_unittest.cc", "test/extensions_unittests_main.cc", + "utility/unpacker_unittest.cc", ] deps = [ diff --git a/extensions/extensions.gyp b/extensions/extensions.gyp index a31f302..a1f2f8b 100644 --- a/extensions/extensions.gyp +++ b/extensions/extensions.gyp @@ -1304,6 +1304,7 @@ 'renderer/script_context_unittest.cc', 'renderer/utils_unittest.cc', 'test/extensions_unittests_main.cc', + 'utility/unpacker_unittest.cc', ], # Disable c4267 warnings until we fix size_t to int truncations. 'msvs_disabled_warnings': [ 4267, ], diff --git a/extensions/test/data/unpacker/bad_image.crx b/extensions/test/data/unpacker/bad_image.crx Binary files differnew file mode 100644 index 0000000..192bd09 --- /dev/null +++ b/extensions/test/data/unpacker/bad_image.crx diff --git a/chrome/test/data/extensions/unpacker/bad_image/background.js b/extensions/test/data/unpacker/bad_image/background.js index 8c00bb1..8c00bb1 100644 --- a/chrome/test/data/extensions/unpacker/bad_image/background.js +++ b/extensions/test/data/unpacker/bad_image/background.js diff --git a/chrome/test/data/extensions/unpacker/bad_image/manifest.json b/extensions/test/data/unpacker/bad_image/manifest.json index b3b7fa9..9048606 100644 --- a/chrome/test/data/extensions/unpacker/bad_image/manifest.json +++ b/extensions/test/data/unpacker/bad_image/manifest.json @@ -1,6 +1,7 @@ { "name": "Bad Image", "version": "1.0", + "manifest_version": 2, "description": "Package with a bad image to be used for unit testing.", - "theme": {"images" : {"bad" : "not_really_an_image.png"}} + "icons": { "128": "not_really_an_image.png" } } diff --git a/chrome/test/data/extensions/unpacker/bad_image/not_really_an_image.png b/extensions/test/data/unpacker/bad_image/not_really_an_image.png index 9516805..9516805 100644 --- a/chrome/test/data/extensions/unpacker/bad_image/not_really_an_image.png +++ b/extensions/test/data/unpacker/bad_image/not_really_an_image.png diff --git a/chrome/test/data/extensions/unpacker/good_package/product_logo_128.png b/extensions/test/data/unpacker/bad_zip.crx Binary files differindex b70cd25..3bd8ed7 100644 --- a/chrome/test/data/extensions/unpacker/good_package/product_logo_128.png +++ b/extensions/test/data/unpacker/bad_zip.crx diff --git a/chrome/test/data/extensions/unpacker/bad_path/background.js b/extensions/test/data/unpacker/bad_zip/background.js index 8c00bb1..8c00bb1 100644 --- a/chrome/test/data/extensions/unpacker/bad_path/background.js +++ b/extensions/test/data/unpacker/bad_zip/background.js diff --git a/chrome/test/data/extensions/unpacker/bad_zip/bad_zip.pem b/extensions/test/data/unpacker/bad_zip/bad_zip.pem index 0599802..0599802 100644 --- a/chrome/test/data/extensions/unpacker/bad_zip/bad_zip.pem +++ b/extensions/test/data/unpacker/bad_zip/bad_zip.pem diff --git a/chrome/test/data/extensions/unpacker/bad_zip/bad_zip.sh b/extensions/test/data/unpacker/bad_zip/bad_zip.sh index bb147f2..bb147f2 100755 --- a/chrome/test/data/extensions/unpacker/bad_zip/bad_zip.sh +++ b/extensions/test/data/unpacker/bad_zip/bad_zip.sh diff --git a/chrome/test/data/extensions/unpacker/bad_zip/manifest.json b/extensions/test/data/unpacker/bad_zip/manifest.json index 5df0fb5..5bed7ba 100644 --- a/chrome/test/data/extensions/unpacker/bad_zip/manifest.json +++ b/extensions/test/data/unpacker/bad_zip/manifest.json @@ -1,6 +1,9 @@ { "name": "Bad ZIP", + "manifest_version": 2, "version": "1.0", "description": "Good package to be mangled by bad_zip.sh for unit testing.", - "theme": {"images" : {"logo" : "product_logo_128.png"}} + "icons": { + "128" : "product_logo_128.png" + } } diff --git a/chrome/test/data/extensions/unpacker/bad_path/product_logo_128.png b/extensions/test/data/unpacker/bad_zip/product_logo_128.png Binary files differindex b70cd25..b70cd25 100644 --- a/chrome/test/data/extensions/unpacker/bad_path/product_logo_128.png +++ b/extensions/test/data/unpacker/bad_zip/product_logo_128.png diff --git a/chrome/test/data/extensions/unpacker/empty_default_locale.crx b/extensions/test/data/unpacker/empty_default_locale.crx Binary files differindex d8f1e0e..d8f1e0e 100644 --- a/chrome/test/data/extensions/unpacker/empty_default_locale.crx +++ b/extensions/test/data/unpacker/empty_default_locale.crx diff --git a/chrome/test/data/extensions/unpacker/empty_default_locale/manifest.json b/extensions/test/data/unpacker/empty_default_locale/manifest.json index 6f43cf2..6f43cf2 100644 --- a/chrome/test/data/extensions/unpacker/empty_default_locale/manifest.json +++ b/extensions/test/data/unpacker/empty_default_locale/manifest.json diff --git a/chrome/test/data/extensions/unpacker/good_l10n.crx b/extensions/test/data/unpacker/good_l10n.crx Binary files differindex ee56569..ee56569 100644 --- a/chrome/test/data/extensions/unpacker/good_l10n.crx +++ b/extensions/test/data/unpacker/good_l10n.crx diff --git a/chrome/test/data/extensions/unpacker/good_l10n/_locales/en_US/messages.json b/extensions/test/data/unpacker/good_l10n/_locales/en_US/messages.json index b5b53c6..b5b53c6 100644 --- a/chrome/test/data/extensions/unpacker/good_l10n/_locales/en_US/messages.json +++ b/extensions/test/data/unpacker/good_l10n/_locales/en_US/messages.json diff --git a/chrome/test/data/extensions/unpacker/good_l10n/_locales/sr/messages.json b/extensions/test/data/unpacker/good_l10n/_locales/sr/messages.json index b5b53c6..b5b53c6 100644 --- a/chrome/test/data/extensions/unpacker/good_l10n/_locales/sr/messages.json +++ b/extensions/test/data/unpacker/good_l10n/_locales/sr/messages.json diff --git a/chrome/test/data/extensions/unpacker/good_l10n/manifest.json b/extensions/test/data/unpacker/good_l10n/manifest.json index cf2e2a9..cf2e2a9 100644 --- a/chrome/test/data/extensions/unpacker/good_l10n/manifest.json +++ b/extensions/test/data/unpacker/good_l10n/manifest.json diff --git a/chrome/test/data/extensions/unpacker/good_package.crx b/extensions/test/data/unpacker/good_package.crx Binary files differindex e9d4114..c77e191 100644 --- a/chrome/test/data/extensions/unpacker/good_package.crx +++ b/extensions/test/data/unpacker/good_package.crx diff --git a/chrome/test/data/extensions/unpacker/good_package/manifest.json b/extensions/test/data/unpacker/good_package/manifest.json index 0a185bc..f1aa747 100644 --- a/chrome/test/data/extensions/unpacker/good_package/manifest.json +++ b/extensions/test/data/unpacker/good_package/manifest.json @@ -1,6 +1,9 @@ { "name": "Good Package", + "manifest_version": 2, "version": "1.0", "description": "Good (valid) package to be used for unit testing.", - "theme": {"images" : {"logo" : "product_logo_128.png"}} + "icons": { + "128": "product_logo_128.png" + } } diff --git a/chrome/test/data/extensions/unpacker/bad_zip/product_logo_128.png b/extensions/test/data/unpacker/good_package/product_logo_128.png Binary files differindex b70cd25..b70cd25 100644 --- a/chrome/test/data/extensions/unpacker/bad_zip/product_logo_128.png +++ b/extensions/test/data/unpacker/good_package/product_logo_128.png diff --git a/chrome/test/data/extensions/unpacker/has_default_missing_locales.crx b/extensions/test/data/unpacker/has_default_missing_locales.crx Binary files differindex 8d2808e..8d2808e 100644 --- a/chrome/test/data/extensions/unpacker/has_default_missing_locales.crx +++ b/extensions/test/data/unpacker/has_default_missing_locales.crx diff --git a/chrome/test/data/extensions/unpacker/has_default_missing_locales/manifest.json b/extensions/test/data/unpacker/has_default_missing_locales/manifest.json index e572fc2..e572fc2 100644 --- a/chrome/test/data/extensions/unpacker/has_default_missing_locales/manifest.json +++ b/extensions/test/data/unpacker/has_default_missing_locales/manifest.json diff --git a/chrome/test/data/extensions/unpacker/invalid_default_locale.crx b/extensions/test/data/unpacker/invalid_default_locale.crx Binary files differindex 8a426c9..8a426c9 100644 --- a/chrome/test/data/extensions/unpacker/invalid_default_locale.crx +++ b/extensions/test/data/unpacker/invalid_default_locale.crx diff --git a/chrome/test/data/extensions/unpacker/invalid_default_locale/manifest.json b/extensions/test/data/unpacker/invalid_default_locale/manifest.json index ecf7d82..ecf7d82 100644 --- a/chrome/test/data/extensions/unpacker/invalid_default_locale/manifest.json +++ b/extensions/test/data/unpacker/invalid_default_locale/manifest.json diff --git a/chrome/test/data/extensions/unpacker/invalid_messages_file.crx b/extensions/test/data/unpacker/invalid_messages_file.crx Binary files differindex 15691d4..15691d4 100644 --- a/chrome/test/data/extensions/unpacker/invalid_messages_file.crx +++ b/extensions/test/data/unpacker/invalid_messages_file.crx diff --git a/chrome/test/data/extensions/unpacker/invalid_messages_file/_locales/en_US/messages.json b/extensions/test/data/unpacker/invalid_messages_file/_locales/en_US/messages.json index a992f8f..a992f8f 100644 --- a/chrome/test/data/extensions/unpacker/invalid_messages_file/_locales/en_US/messages.json +++ b/extensions/test/data/unpacker/invalid_messages_file/_locales/en_US/messages.json diff --git a/chrome/test/data/extensions/unpacker/invalid_messages_file/manifest.json b/extensions/test/data/unpacker/invalid_messages_file/manifest.json index 7a4b9ef..7a4b9ef 100644 --- a/chrome/test/data/extensions/unpacker/invalid_messages_file/manifest.json +++ b/extensions/test/data/unpacker/invalid_messages_file/manifest.json diff --git a/chrome/test/data/extensions/unpacker/missing_default_data.crx b/extensions/test/data/unpacker/missing_default_data.crx Binary files differindex eeb76fe..eeb76fe 100644 --- a/chrome/test/data/extensions/unpacker/missing_default_data.crx +++ b/extensions/test/data/unpacker/missing_default_data.crx diff --git a/chrome/test/data/extensions/unpacker/missing_default_data/_locales/en_US/messages.json b/extensions/test/data/unpacker/missing_default_data/_locales/en_US/messages.json index b5b53c6..b5b53c6 100644 --- a/chrome/test/data/extensions/unpacker/missing_default_data/_locales/en_US/messages.json +++ b/extensions/test/data/unpacker/missing_default_data/_locales/en_US/messages.json diff --git a/chrome/test/data/extensions/unpacker/missing_default_data/manifest.json b/extensions/test/data/unpacker/missing_default_data/manifest.json index 03ecc4a..03ecc4a 100644 --- a/chrome/test/data/extensions/unpacker/missing_default_data/manifest.json +++ b/extensions/test/data/unpacker/missing_default_data/manifest.json diff --git a/chrome/test/data/extensions/unpacker/missing_default_has_locales.crx b/extensions/test/data/unpacker/missing_default_has_locales.crx Binary files differindex 0bf345d..0bf345d 100644 --- a/chrome/test/data/extensions/unpacker/missing_default_has_locales.crx +++ b/extensions/test/data/unpacker/missing_default_has_locales.crx diff --git a/chrome/test/data/extensions/unpacker/missing_default_has_locales/manifest.json b/extensions/test/data/unpacker/missing_default_has_locales/manifest.json index 13a5d4b..13a5d4b 100644 --- a/chrome/test/data/extensions/unpacker/missing_default_has_locales/manifest.json +++ b/extensions/test/data/unpacker/missing_default_has_locales/manifest.json diff --git a/chrome/test/data/extensions/unpacker/missing_messages_file.crx b/extensions/test/data/unpacker/missing_messages_file.crx Binary files differindex 4ca3634..4ca3634 100644 --- a/chrome/test/data/extensions/unpacker/missing_messages_file.crx +++ b/extensions/test/data/unpacker/missing_messages_file.crx diff --git a/chrome/test/data/extensions/unpacker/missing_messages_file/manifest.json b/extensions/test/data/unpacker/missing_messages_file/manifest.json index a3ccf4b..a3ccf4b 100644 --- a/chrome/test/data/extensions/unpacker/missing_messages_file/manifest.json +++ b/extensions/test/data/unpacker/missing_messages_file/manifest.json diff --git a/chrome/test/data/extensions/unpacker/no_l10n.crx b/extensions/test/data/unpacker/no_l10n.crx Binary files differindex d9edd9e..d9edd9e 100644 --- a/chrome/test/data/extensions/unpacker/no_l10n.crx +++ b/extensions/test/data/unpacker/no_l10n.crx diff --git a/chrome/test/data/extensions/unpacker/no_l10n/manifest.json b/extensions/test/data/unpacker/no_l10n/manifest.json index 8ba809f..8ba809f 100644 --- a/chrome/test/data/extensions/unpacker/no_l10n/manifest.json +++ b/extensions/test/data/unpacker/no_l10n/manifest.json diff --git a/chrome/test/data/extensions/unpacker/no_locale_data.crx b/extensions/test/data/unpacker/no_locale_data.crx Binary files differindex 30a8f40..30a8f40 100644 --- a/chrome/test/data/extensions/unpacker/no_locale_data.crx +++ b/extensions/test/data/unpacker/no_locale_data.crx diff --git a/chrome/test/data/extensions/unpacker/no_locale_data/manifest.json b/extensions/test/data/unpacker/no_locale_data/manifest.json index c4d68b4..c4d68b4 100644 --- a/chrome/test/data/extensions/unpacker/no_locale_data/manifest.json +++ b/extensions/test/data/unpacker/no_locale_data/manifest.json diff --git a/extensions/test/test_extensions_client.cc b/extensions/test/test_extensions_client.cc index bc3fd49..bd64c58 100644 --- a/extensions/test/test_extensions_client.cc +++ b/extensions/test/test_extensions_client.cc @@ -4,6 +4,7 @@ #include "extensions/test/test_extensions_client.h" +#include "base/stl_util.h" #include "extensions/common/api/generated_schemas.h" #include "extensions/common/common_manifest_handlers.h" #include "extensions/common/extension_urls.h" @@ -38,6 +39,16 @@ TestExtensionsClient::TestExtensionsClient() { TestExtensionsClient::~TestExtensionsClient() { } +void TestExtensionsClient::AddBrowserImagePathsFilter( + BrowserImagePathsFilter* filter) { + browser_image_filters_.insert(filter); +} + +void TestExtensionsClient::RemoveBrowserImagePathsFilter( + BrowserImagePathsFilter* filter) { + browser_image_filters_.erase(filter); +} + void TestExtensionsClient::Initialize() { // Registration could already be finalized in unit tests, where the utility // thread runs in-process. @@ -167,4 +178,13 @@ bool TestExtensionsClient::IsBlacklistUpdateURL(const GURL& url) const { return true; } +std::set<base::FilePath> TestExtensionsClient::GetBrowserImagePaths( + const Extension* extension) { + std::set<base::FilePath> result = + ExtensionsClient::GetBrowserImagePaths(extension); + for (auto filter : browser_image_filters_) + filter->Filter(extension, &result); + return result; +} + } // namespace extensions diff --git a/extensions/test/test_extensions_client.h b/extensions/test/test_extensions_client.h index bc8fe7c..964cbf9 100644 --- a/extensions/test/test_extensions_client.h +++ b/extensions/test/test_extensions_client.h @@ -12,9 +12,20 @@ namespace extensions { class TestExtensionsClient : public ExtensionsClient { public: + // An interface that lets tests change the set of image paths before they are + // returned by TestExtensionClient::GetBrowserImagePaths. + class BrowserImagePathsFilter { + public: + virtual void Filter(const Extension* extension, + std::set<base::FilePath>* paths) = 0; + }; + TestExtensionsClient(); ~TestExtensionsClient() override; + void AddBrowserImagePathsFilter(BrowserImagePathsFilter* filter); + void RemoveBrowserImagePathsFilter(BrowserImagePathsFilter* filter); + private: void Initialize() override; const PermissionMessageProvider& GetPermissionMessageProvider() @@ -44,6 +55,8 @@ class TestExtensionsClient : public ExtensionsClient { std::string GetWebstoreBaseURL() const override; std::string GetWebstoreUpdateURL() const override; bool IsBlacklistUpdateURL(const GURL& url) const override; + std::set<base::FilePath> GetBrowserImagePaths( + const Extension* extension) override; // A whitelist of extensions that can script anywhere. Do not add to this // list (except in tests) without consulting the Extensions team first. @@ -51,6 +64,8 @@ class TestExtensionsClient : public ExtensionsClient { // added to this list. ScriptingWhitelist scripting_whitelist_; + std::set<BrowserImagePathsFilter*> browser_image_filters_; + DISALLOW_COPY_AND_ASSIGN(TestExtensionsClient); }; diff --git a/chrome/utility/extensions/unpacker_unittest.cc b/extensions/utility/unpacker_unittest.cc index 891d15c..917f66e 100644 --- a/chrome/utility/extensions/unpacker_unittest.cc +++ b/extensions/utility/unpacker_unittest.cc @@ -8,10 +8,11 @@ #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "base/values.h" -#include "chrome/common/chrome_paths.h" #include "extensions/common/constants.h" #include "extensions/common/extension.h" +#include "extensions/common/extension_paths.h" #include "extensions/common/manifest_constants.h" +#include "extensions/test/test_extensions_client.h" #include "extensions/utility/unpacker.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkBitmap.h" @@ -26,17 +27,14 @@ namespace keys = manifest_keys; class UnpackerTest : public testing::Test { public: ~UnpackerTest() override { - LOG(WARNING) << "Deleting temp dir: " - << temp_dir_.path().LossyDisplayName(); - LOG(WARNING) << temp_dir_.Delete(); + VLOG(1) << "Deleting temp dir: " << temp_dir_.path().LossyDisplayName(); + VLOG(1) << temp_dir_.Delete(); } void SetupUnpacker(const std::string& crx_name) { base::FilePath original_path; - ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &original_path)); - original_path = original_path.AppendASCII("extensions") - .AppendASCII("unpacker") - .AppendASCII(crx_name); + ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &original_path)); + original_path = original_path.AppendASCII("unpacker").AppendASCII(crx_name); ASSERT_TRUE(base::PathExists(original_path)) << original_path.value(); // Try bots won't let us write into DIR_TEST_DATA, so we have to create @@ -151,9 +149,42 @@ TEST_F(UnpackerTest, UnzipError) { EXPECT_EQ(ASCIIToUTF16(kExpected), unpacker_->error_message()); } +namespace { + +// Inserts an illegal path into the browser images returned by +// TestExtensionsClient for any extension. +class IllegalImagePathInserter + : public TestExtensionsClient::BrowserImagePathsFilter { + public: + IllegalImagePathInserter(TestExtensionsClient* client) : client_(client) { + client_->AddBrowserImagePathsFilter(this); + } + + virtual ~IllegalImagePathInserter() { + client_->RemoveBrowserImagePathsFilter(this); + } + + void Filter(const Extension* extension, + std::set<base::FilePath>* paths) override { + base::FilePath illegal_path = + base::FilePath(base::FilePath::kParentDirectory) + .AppendASCII(kTempExtensionName) + .AppendASCII("product_logo_128.png"); + paths->insert(illegal_path); + } + + private: + TestExtensionsClient* client_; +}; + +} // namespace + TEST_F(UnpackerTest, BadPathError) { const char kExpected[] = "Illegal path (absolute or relative with '..'): "; - SetupUnpacker("bad_path.crx"); + SetupUnpacker("good_package.crx"); + IllegalImagePathInserter inserter( + static_cast<TestExtensionsClient*>(ExtensionsClient::Get())); + EXPECT_FALSE(unpacker_->Run()); EXPECT_TRUE( StartsWith(unpacker_->error_message(), ASCIIToUTF16(kExpected), false)) |