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

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

Issue 13044014: Make sure manifest specified shortcut for Extension Command can not override the built-in shortcuts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for ChromeOS (ash) Created 7 years, 8 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 32ae4535cc2ca189e32c35f82812d2d5db3f1251..cc7a6cb35b58d3f311c2651031ca5421764d3970 100644
--- a/chrome/browser/extensions/extension_keybinding_apitest.cc
+++ b/chrome/browser/extensions/extension_keybinding_apitest.cc
@@ -195,4 +195,44 @@ IN_PROC_BROWSER_TEST_F(CommandsApiTest, SynthesizedCommand) {
ASSERT_TRUE(RunExtensionTest("keybinding/synthesized")) << message_;
}
+// This test validates that an extension cannot request a shortcut that is
+// already in use by Chrome.
+IN_PROC_BROWSER_TEST_F(CommandsApiTest, DontOverwriteSystemShortcuts) {
+ ASSERT_TRUE(test_server()->Start());
+ ASSERT_TRUE(RunExtensionTest("keybinding/dont_overwrite_system")) << message_;
+
+ ui_test_utils::NavigateToURL(browser(),
+ test_server()->GetURL("files/extensions/test_file.txt"));
+
+ WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
+ ASSERT_TRUE(tab);
+
+ // Activate the shortcut (Alt+Shift+F) to make page blue.
+ ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
+ browser(), ui::VKEY_F, false, true, true, false));
+
+ bool result = false;
+ ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
+ tab,
+ "setInterval(function() {"
+ " if (document.body.bgColor == 'blue') {"
+ " window.domAutomationController.send(true)}}, 100)",
+ &result));
+ ASSERT_TRUE(result);
+
+ // Activate the shortcut (Ctrl+F) to make page red (should not work).
+ ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
+ browser(), ui::VKEY_F, true, false, false, false));
+
+ // The page should still be blue.
+ result = false;
+ ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
+ tab,
+ "setInterval(function() {"
+ " if (document.body.bgColor == 'blue') {"
+ " window.domAutomationController.send(true)}}, 100)",
+ &result));
+ ASSERT_TRUE(result);
+}
+
} // extensions

Powered by Google App Engine
This is Rietveld 408576698