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

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

Issue 17298002: Allow tabCapture API to be granted for chrome:// pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix tests.. how did it even work before? Created 7 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 | Annotate | Revision Log
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 25 matching lines...) Expand all
36 36
37 class ScriptBadgesCommandsApiTest : public ExtensionApiTest { 37 class ScriptBadgesCommandsApiTest : public ExtensionApiTest {
38 public: 38 public:
39 ScriptBadgesCommandsApiTest() { 39 ScriptBadgesCommandsApiTest() {
40 // We cannot add this to CommandsApiTest because then PageActions get 40 // We cannot add this to CommandsApiTest because then PageActions get
41 // treated like BrowserActions and the PageAction test starts failing. 41 // treated like BrowserActions and the PageAction test starts failing.
42 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 42 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
43 switches::kScriptBadges, "1"); 43 switches::kScriptBadges, "1");
44 } 44 }
45 virtual ~ScriptBadgesCommandsApiTest() {} 45 virtual ~ScriptBadgesCommandsApiTest() {}
46
47 bool IsGrantedForTab(const Extension* extension,
48 const content::WebContents* web_contents) {
49 return PermissionsData::HasAPIPermissionForTab(
50 extension,
51 SessionID::IdForTab(web_contents),
52 APIPermission::kTab);
53 }
46 }; 54 };
47 55
48 // Test the basic functionality of the Keybinding API: 56 // Test the basic functionality of the Keybinding API:
49 // - That pressing the shortcut keys should perform actions (activate the 57 // - That pressing the shortcut keys should perform actions (activate the
50 // browser action or send an event). 58 // browser action or send an event).
51 // - Note: Page action keybindings are tested in PageAction test below. 59 // - Note: Page action keybindings are tested in PageAction test below.
52 // - The shortcut keys taken by one extension are not overwritten by the last 60 // - The shortcut keys taken by one extension are not overwritten by the last
53 // installed extension. 61 // installed extension.
54 IN_PROC_BROWSER_TEST_F(CommandsApiTest, Basic) { 62 IN_PROC_BROWSER_TEST_F(CommandsApiTest, Basic) {
55 ASSERT_TRUE(test_server()->Start()); 63 ASSERT_TRUE(test_server()->Start());
(...skipping 10 matching lines...) Expand all
66 // Test that there are two browser actions in the toolbar. 74 // Test that there are two browser actions in the toolbar.
67 ASSERT_EQ(2, GetBrowserActionsBar().NumberOfBrowserActions()); 75 ASSERT_EQ(2, GetBrowserActionsBar().NumberOfBrowserActions());
68 76
69 ui_test_utils::NavigateToURL(browser(), 77 ui_test_utils::NavigateToURL(browser(),
70 test_server()->GetURL("files/extensions/test_file.txt")); 78 test_server()->GetURL("files/extensions/test_file.txt"));
71 79
72 // activeTab shouldn't have been granted yet. 80 // activeTab shouldn't have been granted yet.
73 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 81 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
74 ASSERT_TRUE(tab); 82 ASSERT_TRUE(tab);
75 83
76 ActiveTabPermissionGranter* granter = 84 EXPECT_FALSE(IsGrantedForTab(extension, tab));
77 TabHelper::FromWebContents(tab)->active_tab_permission_granter();
78 EXPECT_FALSE(granter->IsGranted(extension));
79 85
80 // Activate the shortcut (Ctrl+Shift+F). 86 // Activate the shortcut (Ctrl+Shift+F).
81 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 87 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
82 browser(), ui::VKEY_F, true, true, false, false)); 88 browser(), ui::VKEY_F, true, true, false, false));
83 89
84 // activeTab should now be granted. 90 // activeTab should now be granted.
85 EXPECT_TRUE(granter->IsGranted(extension)); 91 EXPECT_TRUE(IsGrantedForTab(extension, tab));
86 92
87 // Verify the command worked. 93 // Verify the command worked.
88 bool result = false; 94 bool result = false;
89 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( 95 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
90 tab, 96 tab,
91 "setInterval(function(){" 97 "setInterval(function(){"
92 " if(document.body.bgColor == 'red'){" 98 " if(document.body.bgColor == 'red'){"
93 " window.domAutomationController.send(true)}}, 100)", 99 " window.domAutomationController.send(true)}}, 100)",
94 &result)); 100 &result));
95 ASSERT_TRUE(result); 101 ASSERT_TRUE(result);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 193
188 // This test validates that the getAll query API function returns registered 194 // This test validates that the getAll query API function returns registered
189 // commands as well as synthesized ones and that inactive commands (like the 195 // commands as well as synthesized ones and that inactive commands (like the
190 // synthesized ones are in nature) have no shortcuts. 196 // synthesized ones are in nature) have no shortcuts.
191 IN_PROC_BROWSER_TEST_F(CommandsApiTest, SynthesizedCommand) { 197 IN_PROC_BROWSER_TEST_F(CommandsApiTest, SynthesizedCommand) {
192 ASSERT_TRUE(test_server()->Start()); 198 ASSERT_TRUE(test_server()->Start());
193 ASSERT_TRUE(RunExtensionTest("keybinding/synthesized")) << message_; 199 ASSERT_TRUE(RunExtensionTest("keybinding/synthesized")) << message_;
194 } 200 }
195 201
196 } // namespace extensions 202 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_keybinding_apitest.cc ('k') | chrome/common/extensions/api/tab_capture.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698