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

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

Issue 504183004: Continue key propagation for extensions without any listeners to chrome.commands.onCommand. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Change manifest to use MacCtrl. Created 6 years, 3 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/browser/extensions/extension_keybinding_registry.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_keybinding_apitest.cc
diff --git a/chrome/browser/extensions/extension_keybinding_apitest.cc b/chrome/browser/extensions/extension_keybinding_apitest.cc
index e62129a35f98e48000da35c48721cfd3d799e0f1..215a6103261e164649d695ca430a2ee39b1b591e 100644
--- a/chrome/browser/extensions/extension_keybinding_apitest.cc
+++ b/chrome/browser/extensions/extension_keybinding_apitest.cc
@@ -701,4 +701,34 @@ IN_PROC_BROWSER_TEST_F(CommandsApiTest,
EXPECT_TRUE(accelerator.IsAltDown());
}
+IN_PROC_BROWSER_TEST_F(CommandsApiTest, ContinuePropagation) {
+ // Setup the environment.
+ ASSERT_TRUE(test_server()->Start());
+ ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
+ ASSERT_TRUE(RunExtensionTest("keybinding/continue_propagation")) << message_;
+ ui_test_utils::NavigateToURL(
+ browser(), test_server()->GetURL("files/extensions/test_file.txt"));
+
+ ResultCatcher catcher;
+
+ // Activate the shortcut (Ctrl+Shift+F). The page should capture the
+ // keystroke and not the extension since |onCommand| has no event listener
+ // initially.
+ ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
+ browser(), ui::VKEY_F, true, true, false, false));
+ ASSERT_TRUE(catcher.GetNextResult());
+
+ // Now, the extension should have added an |onCommand| event listener.
+ // Send the same key, but the |onCommand| listener should now receive it.
+ ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
+ browser(), ui::VKEY_F, true, true, false, false));
+ ASSERT_TRUE(catcher.GetNextResult());
+
+ // The extension should now have removed its |onCommand| event listener.
+ // Finally, the page should again receive the key.
+ ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
+ browser(), ui::VKEY_F, true, true, false, false));
+ ASSERT_TRUE(catcher.GetNextResult());
+}
+
} // namespace extensions
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_keybinding_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698