Chromium Code Reviews| 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..41b95528fc6d497d2abec7a779c43459e2d63bb6 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" |
| @@ -205,6 +206,21 @@ IN_PROC_BROWSER_TEST_F(CommandsApiTest, MAYBE_DontOverwriteSystemShortcuts) { |
| &result)); |
| ASSERT_TRUE(result); |
| + // Activate the bookmark shortcut (Ctrl+D) to make page green (should not work |
|
Finnur
2014/02/10 10:14:18
nit: the page
Mike Wittman
2014/02/11 23:09:45
Done.
|
| + // 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 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 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 |