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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // Test that there are two browser actions in the toolbar. | 66 // Test that there are two browser actions in the toolbar. |
67 ASSERT_EQ(2, GetBrowserActionsBar().NumberOfBrowserActions()); | 67 ASSERT_EQ(2, GetBrowserActionsBar().NumberOfBrowserActions()); |
68 | 68 |
69 ui_test_utils::NavigateToURL(browser(), | 69 ui_test_utils::NavigateToURL(browser(), |
70 test_server()->GetURL("files/extensions/test_file.txt")); | 70 test_server()->GetURL("files/extensions/test_file.txt")); |
71 | 71 |
72 // activeTab shouldn't have been granted yet. | 72 // activeTab shouldn't have been granted yet. |
73 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 73 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
74 ASSERT_TRUE(tab); | 74 ASSERT_TRUE(tab); |
75 | 75 |
76 ActiveTabPermissionGranter* granter = | 76 EXPECT_FALSE(ActiveTabPermissionGranter::IsGrantedForTab(extension, tab)); |
77 TabHelper::FromWebContents(tab)->active_tab_permission_granter(); | |
78 EXPECT_FALSE(granter->IsGranted(extension)); | |
79 | 77 |
80 // Activate the shortcut (Ctrl+Shift+F). | 78 // Activate the shortcut (Ctrl+Shift+F). |
81 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 79 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
82 browser(), ui::VKEY_F, true, true, false, false)); | 80 browser(), ui::VKEY_F, true, true, false, false)); |
83 | 81 |
84 // activeTab should now be granted. | 82 // activeTab should now be granted. |
85 EXPECT_TRUE(granter->IsGranted(extension)); | 83 EXPECT_TRUE(ActiveTabPermissionGranter::IsGrantedForTab(extension, tab)); |
86 | 84 |
87 // Verify the command worked. | 85 // Verify the command worked. |
88 bool result = false; | 86 bool result = false; |
89 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 87 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
90 tab, | 88 tab, |
91 "setInterval(function(){" | 89 "setInterval(function(){" |
92 " if(document.body.bgColor == 'red'){" | 90 " if(document.body.bgColor == 'red'){" |
93 " window.domAutomationController.send(true)}}, 100)", | 91 " window.domAutomationController.send(true)}}, 100)", |
94 &result)); | 92 &result)); |
95 ASSERT_TRUE(result); | 93 ASSERT_TRUE(result); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 185 |
188 // This test validates that the getAll query API function returns registered | 186 // This test validates that the getAll query API function returns registered |
189 // commands as well as synthesized ones and that inactive commands (like the | 187 // commands as well as synthesized ones and that inactive commands (like the |
190 // synthesized ones are in nature) have no shortcuts. | 188 // synthesized ones are in nature) have no shortcuts. |
191 IN_PROC_BROWSER_TEST_F(CommandsApiTest, SynthesizedCommand) { | 189 IN_PROC_BROWSER_TEST_F(CommandsApiTest, SynthesizedCommand) { |
192 ASSERT_TRUE(test_server()->Start()); | 190 ASSERT_TRUE(test_server()->Start()); |
193 ASSERT_TRUE(RunExtensionTest("keybinding/synthesized")) << message_; | 191 ASSERT_TRUE(RunExtensionTest("keybinding/synthesized")) << message_; |
194 } | 192 } |
195 | 193 |
196 } // namespace extensions | 194 } // namespace extensions |
OLD | NEW |