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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_keybinding_registry.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "chrome/browser/extensions/active_tab_permission_granter.h" 6 #include "chrome/browser/extensions/active_tab_permission_granter.h"
7 #include "chrome/browser/extensions/api/commands/command_service.h" 7 #include "chrome/browser/extensions/api/commands/command_service.h"
8 #include "chrome/browser/extensions/browser_action_test_util.h" 8 #include "chrome/browser/extensions/browser_action_test_util.h"
9 #include "chrome/browser/extensions/extension_action.h" 9 #include "chrome/browser/extensions/extension_action.h"
10 #include "chrome/browser/extensions/extension_action_manager.h" 10 #include "chrome/browser/extensions/extension_action_manager.h"
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 694
695 // Verify the keybinding is still set. 695 // Verify the keybinding is still set.
696 accelerator = command_service->FindCommandByName( 696 accelerator = command_service->FindCommandByName(
697 kId, manifest_values::kBrowserActionCommandEvent).accelerator(); 697 kId, manifest_values::kBrowserActionCommandEvent).accelerator();
698 EXPECT_EQ(ui::VKEY_G, accelerator.key_code()); 698 EXPECT_EQ(ui::VKEY_G, accelerator.key_code());
699 EXPECT_FALSE(accelerator.IsCtrlDown()); 699 EXPECT_FALSE(accelerator.IsCtrlDown());
700 EXPECT_TRUE(accelerator.IsShiftDown()); 700 EXPECT_TRUE(accelerator.IsShiftDown());
701 EXPECT_TRUE(accelerator.IsAltDown()); 701 EXPECT_TRUE(accelerator.IsAltDown());
702 } 702 }
703 703
704 IN_PROC_BROWSER_TEST_F(CommandsApiTest, ContinuePropagation) {
705 // Setup the environment.
706 ASSERT_TRUE(test_server()->Start());
707 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
708 ASSERT_TRUE(RunExtensionTest("keybinding/continue_propagation")) << message_;
709 ui_test_utils::NavigateToURL(
710 browser(), test_server()->GetURL("files/extensions/test_file.txt"));
711
712 ResultCatcher catcher;
713
714 // Activate the shortcut (Ctrl+Shift+F). The page should capture the
715 // keystroke and not the extension since |onCommand| has no event listener
716 // initially.
717 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
718 browser(), ui::VKEY_F, true, true, false, false));
719 ASSERT_TRUE(catcher.GetNextResult());
720
721 // Now, the extension should have added an |onCommand| event listener.
722 // Send the same key, but the |onCommand| listener should now receive it.
723 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
724 browser(), ui::VKEY_F, true, true, false, false));
725 ASSERT_TRUE(catcher.GetNextResult());
726
727 // The extension should now have removed its |onCommand| event listener.
728 // Finally, the page should again receive the key.
729 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
730 browser(), ui::VKEY_F, true, true, false, false));
731 ASSERT_TRUE(catcher.GetNextResult());
732 }
733
704 } // namespace extensions 734 } // namespace extensions
OLDNEW
« 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