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

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

Issue 143493005: Allow extensions to remove and override the bookmark shortcut key (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 6 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_keybinding_apitest.cc
diff --git a/chrome/browser/extensions/extension_keybinding_apitest.cc b/chrome/browser/extensions/extension_keybinding_apitest.cc
index 3b672188db5900253e1d7f713d87167c1d9654fe..dd34f2edeb62fc43040f33125da5406f39c88665 100644
--- a/chrome/browser/extensions/extension_keybinding_apitest.cc
+++ b/chrome/browser/extensions/extension_keybinding_apitest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/command_line.h"
#include "chrome/browser/extensions/active_tab_permission_granter.h"
#include "chrome/browser/extensions/browser_action_test_util.h"
#include "chrome/browser/extensions/extension_action.h"
@@ -188,7 +189,7 @@ IN_PROC_BROWSER_TEST_F(CommandsApiTest, MAYBE_DontOverwriteSystemShortcuts) {
WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(tab);
- // Activate the shortcut (Alt+Shift+F) to make page blue.
+ // Activate the shortcut (Alt+Shift+F) to make the page blue.
{
ResultCatcher catcher;
ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
@@ -205,7 +206,22 @@ IN_PROC_BROWSER_TEST_F(CommandsApiTest, MAYBE_DontOverwriteSystemShortcuts) {
&result));
ASSERT_TRUE(result);
- // Activate the shortcut (Ctrl+F) to make page red (should not work).
+ // Activate the bookmark shortcut (Ctrl+D) to make the page green (should not
+ // work without requesting via chrome_settings_overrides).
+ ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
+ browser(), ui::VKEY_D, 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);
+
+ // Activate the shortcut (Ctrl+F) to make the page red (should not work).
ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
browser(), ui::VKEY_F, true, false, false, false));
@@ -220,6 +236,45 @@ IN_PROC_BROWSER_TEST_F(CommandsApiTest, MAYBE_DontOverwriteSystemShortcuts) {
ASSERT_TRUE(result);
}
+// This test validates that an extension can override the Chrome bookmark
+// shortcut if it has requested to do so.
+IN_PROC_BROWSER_TEST_F(CommandsApiTest, OverwriteBookmarkShortcut) {
+ ASSERT_TRUE(test_server()->Start());
+
+ ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
+
+ // This functionality requires a feature flag.
+ CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ "--enable-override-bookmarks-ui",
+ "1");
+
+ ASSERT_TRUE(RunExtensionTest("keybinding/overwrite_bookmark_shortcut"))
+ << 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 (Ctrl+D) to make the page green.
+ {
+ ResultCatcher catcher;
+ ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
+ browser(), ui::VKEY_D, true, false, false, false));
+ ASSERT_TRUE(catcher.GetNextResult());
+ }
+
+ bool result = false;
+ ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
+ tab,
+ "setInterval(function() {"
+ " if (document.body.bgColor == 'green') {"
+ " window.domAutomationController.send(true)}}, 100)",
+ &result));
+ ASSERT_TRUE(result);
+}
+
#if defined(OS_WIN)
// Currently this feature is implemented on Windows only.
#define MAYBE_AllowDuplicatedMediaKeys AllowDuplicatedMediaKeys

Powered by Google App Engine
This is Rietveld 408576698