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

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: Add new test. Created 6 years, 4 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_keybinding_apitest.cc
diff --git a/chrome/browser/extensions/extension_keybinding_apitest.cc b/chrome/browser/extensions/extension_keybinding_apitest.cc
index e62129a35f98e48000da35c48721cfd3d799e0f1..9543abd2c56e768bbda35cbcaa9fdfbfb1a11110 100644
--- a/chrome/browser/extensions/extension_keybinding_apitest.cc
+++ b/chrome/browser/extensions/extension_keybinding_apitest.cc
@@ -701,4 +701,31 @@ 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(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 keydown
+ // and notify the background page.
Finnur 2014/08/28 11:15:38 I think it would help the casual reader to explain
David Tseng 2014/08/28 23:37:11 Done.
+ 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 |onCommands| event listener.
+ // Send the same key, but the |onCommands| 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 |onCommands| 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

Powered by Google App Engine
This is Rietveld 408576698