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

Side by Side Diff: chrome/common/extensions/manifest_tests/extension_manifests_manifest_version_unittest.cc

Issue 10912041: Disallow packing or loading unpacked manifest v1 extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix fix Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" 5 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 9
10 using extensions::Extension; 10 using extensions::Extension;
11 11
12 namespace errors = extension_manifest_errors; 12 namespace errors = extension_manifest_errors;
13 13
14 TEST_F(ExtensionManifestTest, ManifestVersionWarning) { 14 TEST_F(ExtensionManifestTest, ManifestVersionError) {
15 scoped_ptr<DictionaryValue> manifest1(new DictionaryValue()); 15 scoped_ptr<DictionaryValue> manifest1(new DictionaryValue());
16 manifest1->SetString("name", "Miles"); 16 manifest1->SetString("name", "Miles");
17 manifest1->SetString("version", "0.55"); 17 manifest1->SetString("version", "0.55");
18 18
19 scoped_ptr<DictionaryValue> manifest2(manifest1->DeepCopy()); 19 scoped_ptr<DictionaryValue> manifest2(manifest1->DeepCopy());
20 manifest2->SetInteger("manifest_version", 1); 20 manifest2->SetInteger("manifest_version", 1);
21 21
22 scoped_ptr<DictionaryValue> manifest3(manifest1->DeepCopy()); 22 scoped_ptr<DictionaryValue> manifest3(manifest1->DeepCopy());
23 manifest3->SetInteger("manifest_version", 2); 23 manifest3->SetInteger("manifest_version", 2);
24 24
25 struct { 25 struct {
26 const char* test_name; 26 const char* test_name;
27 bool require_modern_manifest_version;
27 DictionaryValue* manifest; 28 DictionaryValue* manifest;
28 bool expect_warning; 29 bool expect_error;
29 } test_data[] = { 30 } test_data[] = {
30 { "default_manifest_version", manifest1.get(), true }, 31 { "require_modern_with_default", true, manifest1.get(), true },
31 { "manifest_version_1", manifest2.get(), true }, 32 { "require_modern_with_v1", true, manifest2.get(), true },
32 { "manifest_version_2", manifest3.get(), false } 33 { "require_modern_with_v2", true, manifest3.get(), false },
34 { "dont_require_modern_with_default", false, manifest1.get(), false },
35 { "dont_require_modern_with_v1", false, manifest2.get(), false },
36 { "dont_require_modern_with_v2", false, manifest3.get(), false },
33 }; 37 };
34 38
35 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) { 39 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) {
36 scoped_refptr<Extension> extension( 40 int create_flags = 0;
Mihai Parparita -not on Chrome 2012/08/31 20:50:16 Nit: Extension::NO_FLAGS instead of 0.
Aaron Boodman 2012/08/31 21:03:17 Done.
37 LoadAndExpectSuccess(Manifest(test_data[i].manifest, 41 if (test_data[i].require_modern_manifest_version)
38 test_data[i].test_name), 42 create_flags |= Extension::REQUIRE_MODERN_MANIFEST_VERSION;
39 Extension::LOAD)); 43 if (test_data[i].expect_error) {
40 if (test_data[i].expect_warning) { 44 LoadAndExpectError(
41 EXPECT_THAT( 45 Manifest(test_data[i].manifest,
42 extension->install_warnings(), 46 test_data[i].test_name),
43 testing::Contains( 47 errors::kInvalidManifestVersionOld,
44 testing::Field( 48 Extension::LOAD,
45 &Extension::InstallWarning::message, 49 create_flags);
46 testing::HasSubstr(
47 "Support for manifest version 1 is being phased out."))))
48 << test_data[i].test_name;
49 } else { 50 } else {
50 EXPECT_THAT( 51 LoadAndExpectSuccess(Manifest(test_data[i].manifest,
51 extension->install_warnings(), 52 test_data[i].test_name),
52 testing::Not( 53 Extension::LOAD,
53 testing::Contains( 54 create_flags);
54 testing::Field(
55 &Extension::InstallWarning::message,
56 testing::HasSubstr(
57 "Support for manifest version 1 is being phased "
58 "out.")))))
59 << test_data[i].test_name;
60 } 55 }
61 } 56 }
62 } 57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698