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 "chrome/browser/extensions/active_tab_permission_granter.h" | 5 #include "chrome/browser/extensions/active_tab_permission_granter.h" |
6 #include "chrome/browser/extensions/browser_action_test_util.h" | 6 #include "chrome/browser/extensions/browser_action_test_util.h" |
7 #include "chrome/browser/extensions/extension_action.h" | 7 #include "chrome/browser/extensions/extension_action.h" |
8 #include "chrome/browser/extensions/extension_action_manager.h" | 8 #include "chrome/browser/extensions/extension_action_manager.h" |
9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
10 #include "chrome/browser/extensions/tab_helper.h" | 10 #include "chrome/browser/extensions/tab_helper.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 } | 188 } |
189 | 189 |
190 // This test validates that the getAll query API function returns registered | 190 // This test validates that the getAll query API function returns registered |
191 // commands as well as synthesized ones and that inactive commands (like the | 191 // commands as well as synthesized ones and that inactive commands (like the |
192 // synthesized ones are in nature) have no shortcuts. | 192 // synthesized ones are in nature) have no shortcuts. |
193 IN_PROC_BROWSER_TEST_F(CommandsApiTest, SynthesizedCommand) { | 193 IN_PROC_BROWSER_TEST_F(CommandsApiTest, SynthesizedCommand) { |
194 ASSERT_TRUE(test_server()->Start()); | 194 ASSERT_TRUE(test_server()->Start()); |
195 ASSERT_TRUE(RunExtensionTest("keybinding/synthesized")) << message_; | 195 ASSERT_TRUE(RunExtensionTest("keybinding/synthesized")) << message_; |
196 } | 196 } |
197 | 197 |
198 // This test validates that an extension cannot request a shortcut that is | |
199 // already in use by Chrome. | |
200 IN_PROC_BROWSER_TEST_F(CommandsApiTest, DontOverwriteSystemShortcuts) { | |
201 ASSERT_TRUE(test_server()->Start()); | |
202 ASSERT_TRUE(RunExtensionTest("keybinding/dont_overwrite_system")) << message_; | |
203 | |
204 ui_test_utils::NavigateToURL(browser(), | |
205 test_server()->GetURL("files/extensions/test_file.txt")); | |
206 | |
207 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | |
208 ASSERT_TRUE(tab); | |
209 | |
210 // Activate the shortcut (Alt+Shift+F) to make page blue. | |
211 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | |
212 browser(), ui::VKEY_F, false, true, true, false)); | |
213 | |
214 bool result = false; | |
215 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | |
216 tab, | |
217 "setInterval(function() {" | |
218 " if (document.body.bgColor == 'blue') {" | |
219 " window.domAutomationController.send(true)}}, 100)", | |
220 &result)); | |
221 ASSERT_TRUE(result); | |
222 | |
223 // Activate the shortcut (Ctrl+F) to make page red (should not work). | |
224 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | |
225 browser(), ui::VKEY_F, true, false, false, false)); | |
226 | |
227 // The page should still be blue. | |
228 result = false; | |
229 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | |
230 tab, | |
231 "setInterval(function() {" | |
232 " if (document.body.bgColor == 'blue') {" | |
233 " window.domAutomationController.send(true)}}, 100)", | |
234 &result)); | |
235 ASSERT_TRUE(result); | |
236 } | |
237 | |
238 } // extensions | 198 } // extensions |
OLD | NEW |