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

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: Fix ExtensionContextMenuBrowserTest.UpdateOnclick test Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/renderer/resources/extensions/web_view/chrome_web_view_internal_custom_bindings.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..bb5eeb342717f88a83a268e626fd2a5a42086565 100644
--- a/chrome/browser/extensions/extension_context_menu_browsertest.cc
+++ b/chrome/browser/extensions/extension_context_menu_browsertest.cc
@@ -215,6 +215,54 @@ IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, Simple) {
ASSERT_TRUE(listener2.WaitUntilSatisfied());
}
+// Tests that previous onclick is not fired after updating the menu's onclick,
+// and whether setting onclick to null removes the handler.
+IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, UpdateOnclick) {
+ ExtensionTestMessageListener listener_error1("onclick1-unexpected", false);
+ ExtensionTestMessageListener listener_error2("onclick2-unexpected", false);
+ ExtensionTestMessageListener listener_update1("update1", true);
+ ExtensionTestMessageListener listener_update2("update2", false);
+ ExtensionTestMessageListener listener_done("onclick2", false);
+
+ const extensions::Extension* extension =
+ LoadContextMenuExtension("onclick_null");
+ ASSERT_TRUE(extension);
+
+ // 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.
+ MenuItem::Id id(false, MenuItem::ExtensionKey(extension->id()));
+ id.string_uid = "id1";
+ int command_id = -1;
+ ASSERT_TRUE(FindCommandId(menu.get(), id, &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());
+
+ // Rebuild the context menu and click on the second extension item.
+ menu.reset(TestRenderViewContextMenu::Create(GetWebContents(), page_url,
+ GURL(), GURL()));
+ id.string_uid = "id2";
+ ASSERT_TRUE(FindCommandId(menu.get(), id, &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) {
« no previous file with comments | « no previous file | chrome/renderer/resources/extensions/web_view/chrome_web_view_internal_custom_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698