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

Side by Side Diff: chrome/browser/extensions/extension_keybinding_apitest.cc

Issue 13044014: Make sure manifest specified shortcut for Extension Command can not override the built-in shortcuts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disabling test for Mac (not implemented yet) Created 7 years, 8 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
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 "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
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 #if !defined(OS_MACOSX)
201 IN_PROC_BROWSER_TEST_F(CommandsApiTest, DontOverwriteSystemShortcuts) {
202 ASSERT_TRUE(test_server()->Start());
203 ASSERT_TRUE(RunExtensionTest("keybinding/dont_overwrite_system")) << message_;
204
205 ui_test_utils::NavigateToURL(browser(),
206 test_server()->GetURL("files/extensions/test_file.txt"));
207
208 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
209 ASSERT_TRUE(tab);
210
211 // Activate the shortcut (Ctrl+Shift+F) to make page blue.
212 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
213 browser(), ui::VKEY_F, true, true, false, false));
214
215 bool result = false;
216 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
217 tab,
218 "setInterval(function() {"
219 " if (document.body.bgColor == 'blue') {"
220 " window.domAutomationController.send(true)}}, 100)",
221 &result));
222 ASSERT_TRUE(result);
223
224 // Activate the shortcut (Ctrl+F) to make page red (should not work).
225 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
226 browser(), ui::VKEY_F, true, false, false, false));
227
228 // The page should still be blue.
229 result = false;
230 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
231 tab,
232 "setInterval(function() {"
233 " if (document.body.bgColor == 'blue') {"
234 " window.domAutomationController.send(true)}}, 100)",
235 &result));
236 ASSERT_TRUE(result);
237 }
238 #endif // !defined(OS_MACOSX)
239
198 } // extensions 240 } // extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698