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

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

Issue 523132: Allow an empty list of page actions. (Closed)
Patch Set: '' Created 10 years, 11 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
« no previous file with comments | « chrome/common/extensions/extension_constants.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/extension_unittest.cc
===================================================================
--- chrome/common/extensions/extension_unittest.cc (revision 35891)
+++ chrome/common/extensions/extension_unittest.cc (working copy)
@@ -223,17 +223,29 @@
EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error));
EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidPrivacyBlacklistsPath));
- // Test invalid UI surface count (both page action and browser action).
+ // Multiple page actions are not allowed.
input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
DictionaryValue* action = new DictionaryValue;
action->SetString(keys::kPageActionId, "MyExtensionActionId");
action->SetString(keys::kName, "MyExtensionActionName");
ListValue* action_list = new ListValue;
action_list->Append(action->DeepCopy());
+ action_list->Append(action);
input_value->Set(keys::kPageActions, action_list);
+ EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error));
+ EXPECT_STREQ(errors::kInvalidPageActionsListSize, error.c_str());
+
+ // Test invalid UI surface count (both page action and browser action).
+ input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
+ action = new DictionaryValue;
+ action->SetString(keys::kPageActionId, "MyExtensionActionId");
+ action->SetString(keys::kName, "MyExtensionActionName");
+ action_list = new ListValue;
+ action_list->Append(action->DeepCopy());
+ input_value->Set(keys::kPageActions, action_list);
input_value->Set(keys::kBrowserAction, action);
EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error));
- EXPECT_STREQ(error.c_str(), errors::kOneUISurfaceOnly);
+ EXPECT_STREQ(errors::kOneUISurfaceOnly, error.c_str());
// Test invalid options page url.
input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
@@ -295,6 +307,13 @@
EXPECT_EQ("chrome-extension", extension.options_url().scheme());
EXPECT_EQ("/options.html", extension.options_url().path());
+ // Test that an empty list of page actions does not stop a browser action
+ // from being loaded.
+ ListValue* empty_list = new ListValue;
+ input_value.Set(keys::kPageActions, empty_list);
+ EXPECT_TRUE(extension.InitFromValue(input_value, false, &error));
+ EXPECT_EQ("", error);
+
#if !defined(OS_MACOSX)
// TODO(aa): The version isn't stamped into the unit test binary on mac.
// Test with a minimum_chrome_version.
« no previous file with comments | « chrome/common/extensions/extension_constants.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698