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

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

Issue 948243005: Merge custom bindings for context menus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits and tests Created 5 years, 10 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
Index: chrome/browser/extensions/extension_context_menu_browsertest.cc
diff --git a/chrome/browser/extensions/extension_context_menu_browsertest.cc b/chrome/browser/extensions/extension_context_menu_browsertest.cc
index a39d36a751e101a71348e0bc0813e49ac45cb876..3dcf40dd42b080f0a05b00195474868012a037ca 100644
--- a/chrome/browser/extensions/extension_context_menu_browsertest.cc
+++ b/chrome/browser/extensions/extension_context_menu_browsertest.cc
@@ -215,6 +215,46 @@ IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, Simple) {
ASSERT_TRUE(listener2.WaitUntilSatisfied());
}
+// Tests that previous onclick is not fired after updating the menu's onclick.
lazyboy 2015/02/26 00:39:47 // This test also tests that setting onclick handl
robwu 2015/02/26 09:33:46 Done.
+IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, UpdateOnclick) {
+ ExtensionTestMessageListener listener_error1("onclick-unexpected", false);
lazyboy 2015/02/26 00:39:47 "onclick1-unexpected", let's append 1 in all place
robwu 2015/02/26 09:33:46 Done.
+ ExtensionTestMessageListener listener_error2("onclick2-unexpected", false);
+ ExtensionTestMessageListener listener_update1("update1", true);
+ ExtensionTestMessageListener listener_update2("update2", false);
+ ExtensionTestMessageListener listener_done("onclick2", false);
+ ASSERT_TRUE(LoadContextMenuExtension("onclick_null"));
+
+ // Wait till item has been created and updated.
+ ASSERT_TRUE(listener_update1.WaitUntilSatisfied());
+
+ GURL page_url("http://www.google.com");
+
+ // Create and build our test context menu.
+ scoped_ptr<TestRenderViewContextMenu> menu(TestRenderViewContextMenu::Create(
+ GetWebContents(), page_url, GURL(), GURL()));
+
+ // Look for the extension item in the menu, and execute it.
+ int command_id = ContextMenuMatcher::ConvertToExtensionsCustomCommandId(0);
+ ASSERT_TRUE(menu->IsCommandIdEnabled(command_id));
+ menu->ExecuteCommand(command_id, 0);
+
+ // Let the test proceed.
+ listener_update1.Reply("");
+
+ // Wait until the second context menu has been set up.
+ ASSERT_TRUE(listener_update2.WaitUntilSatisfied());
+
+ // Click on the second menu item.
+ command_id = ContextMenuMatcher::ConvertToExtensionsCustomCommandId(1);
+ ASSERT_TRUE(menu->IsCommandIdEnabled(command_id));
+ menu->ExecuteCommand(command_id, 0);
+ ASSERT_TRUE(listener_done.WaitUntilSatisfied());
+
+ // Upon completion, the replaced onclick callbacks should not have fired.
+ ASSERT_FALSE(listener_error1.was_satisfied());
+ ASSERT_FALSE(listener_error2.was_satisfied());
+}
+
// Tests that setting "documentUrlPatterns" for an item properly restricts
// those items to matching pages.
IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, Patterns) {

Powered by Google App Engine
This is Rietveld 408576698