Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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(RunExtensionTest("keybinding/continue_propagation")) << message_; | |
| 708 ui_test_utils::NavigateToURL( | |
| 709 browser(), test_server()->GetURL("files/extensions/test_file.txt")); | |
| 710 | |
| 711 ResultCatcher catcher; | |
| 712 // Activate the shortcut (Ctrl+Shift+F). The page should capture the keydown | |
| 713 // 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.
| |
| 714 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | |
| 715 browser(), ui::VKEY_F, true, true, false, false)); | |
| 716 ASSERT_TRUE(catcher.GetNextResult()); | |
| 717 | |
| 718 // Now, the extension should have added an |onCommands| event listener. | |
| 719 // Send the same key, but the |onCommands| listener should now receive it. | |
| 720 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | |
| 721 browser(), ui::VKEY_F, true, true, false, false)); | |
| 722 ASSERT_TRUE(catcher.GetNextResult()); | |
| 723 | |
| 724 // The extension should now have removed its |onCommands| event listener. | |
| 725 // Finally, the page should again receive the key. | |
| 726 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | |
| 727 browser(), ui::VKEY_F, true, true, false, false)); | |
| 728 ASSERT_TRUE(catcher.GetNextResult()); | |
| 729 } | |
| 730 | |
| 704 } // namespace extensions | 731 } // namespace extensions |
| OLD | NEW |