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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 232 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
235 tab, | 233 tab, |
236 "setInterval(function() {" | 234 "setInterval(function() {" |
237 " if (document.body.bgColor == 'blue') {" | 235 " if (document.body.bgColor == 'blue') {" |
238 " window.domAutomationController.send(true)}}, 100)", | 236 " window.domAutomationController.send(true)}}, 100)", |
239 &result)); | 237 &result)); |
240 ASSERT_TRUE(result); | 238 ASSERT_TRUE(result); |
241 } | 239 } |
242 | 240 |
243 } // namespace extensions | 241 } // namespace extensions |
OLD | NEW |