| 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 198 // This test validates that an extension cannot request a shortcut that is |
| 199 // already in use by Chrome. | 199 // already in use by Chrome. |
| 200 // Flaky, see http://crbug.com/233372. | 200 IN_PROC_BROWSER_TEST_F(CommandsApiTest, DontOverwriteSystemShortcuts) { |
| 201 IN_PROC_BROWSER_TEST_F(CommandsApiTest, DISABLED_DontOverwriteSystemShortcuts) { | |
| 202 ASSERT_TRUE(test_server()->Start()); | 201 ASSERT_TRUE(test_server()->Start()); |
| 202 |
| 203 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 204 |
| 203 ASSERT_TRUE(RunExtensionTest("keybinding/dont_overwrite_system")) << message_; | 205 ASSERT_TRUE(RunExtensionTest("keybinding/dont_overwrite_system")) << message_; |
| 204 | 206 |
| 205 ui_test_utils::NavigateToURL(browser(), | 207 ui_test_utils::NavigateToURL(browser(), |
| 206 test_server()->GetURL("files/extensions/test_file.txt")); | 208 test_server()->GetURL("files/extensions/test_file.txt")); |
| 207 | 209 |
| 208 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 210 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 209 ASSERT_TRUE(tab); | 211 ASSERT_TRUE(tab); |
| 210 | 212 |
| 211 // Activate the shortcut (Alt+Shift+F) to make page blue. | 213 // Activate the shortcut (Alt+Shift+F) to make page blue. |
| 212 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 214 { |
| 213 browser(), ui::VKEY_F, false, true, true, false)); | 215 ResultCatcher catcher; |
| 216 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
| 217 browser(), ui::VKEY_F, false, true, true, false)); |
| 218 ASSERT_TRUE(catcher.GetNextResult()); |
| 219 } |
| 214 | 220 |
| 215 bool result = false; | 221 bool result = false; |
| 216 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 222 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 217 tab, | 223 tab, |
| 218 "setInterval(function() {" | 224 "setInterval(function() {" |
| 219 " if (document.body.bgColor == 'blue') {" | 225 " if (document.body.bgColor == 'blue') {" |
| 220 " window.domAutomationController.send(true)}}, 100)", | 226 " window.domAutomationController.send(true)}}, 100)", |
| 221 &result)); | 227 &result)); |
| 222 ASSERT_TRUE(result); | 228 ASSERT_TRUE(result); |
| 223 | 229 |
| 224 // Activate the shortcut (Ctrl+F) to make page red (should not work). | 230 // Activate the shortcut (Ctrl+F) to make page red (should not work). |
| 225 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 231 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
| 226 browser(), ui::VKEY_F, true, false, false, false)); | 232 browser(), ui::VKEY_F, true, false, false, false)); |
| 227 | 233 |
| 228 // The page should still be blue. | 234 // The page should still be blue. |
| 229 result = false; | 235 result = false; |
| 230 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 236 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 231 tab, | 237 tab, |
| 232 "setInterval(function() {" | 238 "setInterval(function() {" |
| 233 " if (document.body.bgColor == 'blue') {" | 239 " if (document.body.bgColor == 'blue') {" |
| 234 " window.domAutomationController.send(true)}}, 100)", | 240 " window.domAutomationController.send(true)}}, 100)", |
| 235 &result)); | 241 &result)); |
| 236 ASSERT_TRUE(result); | 242 ASSERT_TRUE(result); |
| 237 } | 243 } |
| 238 | 244 |
| 239 } // extensions | 245 } // extensions |
| OLD | NEW |