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

Unified Diff: chrome/browser/extensions/extension_context_menu_model_unittest.cc

Issue 2068313002: [Extensions] Omit the "Inspect popup" menu item for synthesized actions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/browser/extensions/extension_context_menu_model.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_context_menu_model_unittest.cc
diff --git a/chrome/browser/extensions/extension_context_menu_model_unittest.cc b/chrome/browser/extensions/extension_context_menu_model_unittest.cc
index 16aec928b5c2d16b8bfc8ef5e0386a98ee35e83b..38aab7eb835deb2436cce9cd1da860deaa7c0899 100644
--- a/chrome/browser/extensions/extension_context_menu_model_unittest.cc
+++ b/chrome/browser/extensions/extension_context_menu_model_unittest.cc
@@ -158,8 +158,9 @@ const Extension* ExtensionContextMenuModelTest::AddExtensionWithHostPermission(
DictionaryBuilder manifest;
manifest.Set("name", name)
.Set("version", "1")
- .Set("manifest_version", 2)
- .Set(action_key, DictionaryBuilder().Build());
+ .Set("manifest_version", 2);
+ if (action_key)
+ manifest.Set(action_key, DictionaryBuilder().Build());
if (!host_permission.empty())
manifest.Set("permissions", ListBuilder().Append(host_permission).Build());
scoped_refptr<const Extension> extension =
@@ -656,4 +657,43 @@ TEST_F(ExtensionContextMenuModelTest, TestPageAccessSubmenu) {
ExtensionContextMenuModel::PAGE_ACCESS_SUBMENU));
}
+TEST_F(ExtensionContextMenuModelTest, TestInspectPopupPresence) {
+ std::unique_ptr<FeatureSwitch::ScopedOverride> toolbar_redesign_override(
+ new FeatureSwitch::ScopedOverride(
+ FeatureSwitch::extension_action_redesign(), true));
+
+ InitializeEmptyExtensionService();
+ {
+ const Extension* page_action = AddExtension(
+ "page_action", manifest_keys::kPageAction, Manifest::INTERNAL);
+ ASSERT_TRUE(page_action);
+ ExtensionContextMenuModel menu(page_action, GetBrowser(),
+ ExtensionContextMenuModel::VISIBLE, nullptr);
+ int inspect_popup_index =
+ menu.GetIndexOfCommandId(ExtensionContextMenuModel::INSPECT_POPUP);
+ EXPECT_GE(0, inspect_popup_index);
+ }
+ {
+ const Extension* browser_action = AddExtension(
+ "browser_action", manifest_keys::kBrowserAction, Manifest::INTERNAL);
+ ExtensionContextMenuModel menu(browser_action, GetBrowser(),
+ ExtensionContextMenuModel::VISIBLE, nullptr);
+ int inspect_popup_index =
+ menu.GetIndexOfCommandId(ExtensionContextMenuModel::INSPECT_POPUP);
+ EXPECT_GE(0, inspect_popup_index);
+ }
+ {
+ // With the extension toolbar redesign, an extension with no specified
+ // action has one synthesized. However, there will never be a popup to
+ // inspect, so we shouldn't add a menu item.
+ const Extension* no_action = AddExtension(
+ "no_action", nullptr, Manifest::INTERNAL);
+ ExtensionContextMenuModel menu(no_action, GetBrowser(),
+ ExtensionContextMenuModel::VISIBLE, nullptr);
+ int inspect_popup_index =
+ menu.GetIndexOfCommandId(ExtensionContextMenuModel::INSPECT_POPUP);
+ EXPECT_EQ(-1, inspect_popup_index);
+ }
+}
+
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/extension_context_menu_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698