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

Side by Side Diff: chrome/common/extensions/manifest_unittest.cc

Issue 9664053: Re-land 125247: Better error messages when using unsupported manifest features. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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
« no previous file with comments | « chrome/common/extensions/manifest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.h" 5 #include "chrome/common/extensions/manifest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 // Set the manifest_version to 2; background_page should stop working. 66 // Set the manifest_version to 2; background_page should stop working.
67 value.clear(); 67 value.clear();
68 manifest->value()->SetInteger(keys::kManifestVersion, 2); 68 manifest->value()->SetInteger(keys::kManifestVersion, 2);
69 EXPECT_FALSE(manifest->GetString("background_page", &value)); 69 EXPECT_FALSE(manifest->GetString("background_page", &value));
70 EXPECT_EQ("", value); 70 EXPECT_EQ("", value);
71 71
72 // Validate should also stop working. 72 // Validate should also stop working.
73 error.clear(); 73 error.clear();
74 EXPECT_FALSE(manifest->ValidateManifest(&error)); 74 EXPECT_FALSE(manifest->ValidateManifest(&error));
75 EXPECT_EQ(ExtensionErrorUtils::FormatErrorMessageUTF16( 75 {
76 errors::kFeatureNotAllowed, "background_page"), error); 76 Feature feature;
77 feature.set_max_manifest_version(1);
78 EXPECT_EQ(ExtensionErrorUtils::FormatErrorMessageUTF16(
79 errors::kFeatureNotAllowed,
80 "background_page",
81 feature.GetErrorMessage(Feature::INVALID_MAX_MANIFEST_VERSION)), error);
82 }
77 83
78 // Test DeepCopy and Equals. 84 // Test DeepCopy and Equals.
79 scoped_ptr<Manifest> manifest2(manifest->DeepCopy()); 85 scoped_ptr<Manifest> manifest2(manifest->DeepCopy());
80 EXPECT_TRUE(manifest->Equals(manifest2.get())); 86 EXPECT_TRUE(manifest->Equals(manifest2.get()));
81 EXPECT_TRUE(manifest2->Equals(manifest.get())); 87 EXPECT_TRUE(manifest2->Equals(manifest.get()));
82 manifest->value()->Set("foo", Value::CreateStringValue("blah")); 88 manifest->value()->Set("foo", Value::CreateStringValue("blah"));
83 EXPECT_FALSE(manifest->Equals(manifest2.get())); 89 EXPECT_FALSE(manifest->Equals(manifest2.get()));
84 } 90 }
85 91
86 // Verifies that key restriction based on type works. 92 // Verifies that key restriction based on type works.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 ListValue* expected_list = new ListValue(); 186 ListValue* expected_list = new ListValue();
181 ListValue* actual_list = NULL; 187 ListValue* actual_list = NULL;
182 expected_list->Append(Value::CreateStringValue("blah")); 188 expected_list->Append(Value::CreateStringValue("blah"));
183 manifest->value()->Set(unknown_key, expected_list); 189 manifest->value()->Set(unknown_key, expected_list);
184 EXPECT_FALSE(manifest->GetList(unknown_key, &actual_list)); 190 EXPECT_FALSE(manifest->GetList(unknown_key, &actual_list));
185 EXPECT_EQ(NULL, actual_list); 191 EXPECT_EQ(NULL, actual_list);
186 EXPECT_TRUE(manifest->value()->Remove(unknown_key, NULL)); 192 EXPECT_TRUE(manifest->value()->Remove(unknown_key, NULL));
187 } 193 }
188 194
189 } // namespace extensions 195 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/manifest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698