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/api/commands/command_service.h" | 6 #include "chrome/browser/extensions/api/commands/command_service.h" |
7 #include "chrome/browser/extensions/browser_action_test_util.h" | 7 #include "chrome/browser/extensions/browser_action_test_util.h" |
8 #include "chrome/browser/extensions/extension_action.h" | 8 #include "chrome/browser/extensions/extension_action.h" |
9 #include "chrome/browser/extensions/extension_action_manager.h" | 9 #include "chrome/browser/extensions/extension_action_manager.h" |
10 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 // activeTab should now be granted. | 92 // activeTab should now be granted. |
93 EXPECT_TRUE(IsGrantedForTab(extension, tab)); | 93 EXPECT_TRUE(IsGrantedForTab(extension, tab)); |
94 | 94 |
95 // Verify the command worked. | 95 // Verify the command worked. |
96 bool result = false; | 96 bool result = false; |
97 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 97 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
98 tab, | 98 tab, |
99 "setInterval(function(){" | 99 "setInterval(function(){" |
100 " if(document.body.bgColor == 'red'){" | 100 " if(document.body.bgColor == 'red'){" |
101 " window.domAutomationController.setAutomationId(0);" | |
102 " window.domAutomationController.send(true)}}, 100)", | 101 " window.domAutomationController.send(true)}}, 100)", |
103 &result)); | 102 &result)); |
104 ASSERT_TRUE(result); | 103 ASSERT_TRUE(result); |
105 | 104 |
106 // Activate the shortcut (Ctrl+Shift+Y). | 105 // Activate the shortcut (Ctrl+Shift+Y). |
107 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 106 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
108 browser(), ui::VKEY_Y, true, true, false, false)); | 107 browser(), ui::VKEY_Y, true, true, false, false)); |
109 | 108 |
110 result = false; | 109 result = false; |
111 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 110 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
112 tab, | 111 tab, |
113 "setInterval(function(){" | 112 "setInterval(function(){" |
114 " if(document.body.bgColor == 'blue'){" | 113 " if(document.body.bgColor == 'blue'){" |
115 " window.domAutomationController.setAutomationId(0);" | |
116 " window.domAutomationController.send(true)}}, 100)", | 114 " window.domAutomationController.send(true)}}, 100)", |
117 &result)); | 115 &result)); |
118 ASSERT_TRUE(result); | 116 ASSERT_TRUE(result); |
119 } | 117 } |
120 | 118 |
121 // Flaky on linux and chromeos, http://crbug.com/165825 | 119 // Flaky on linux and chromeos, http://crbug.com/165825 |
122 #if defined(OS_MACOSX) || defined(OS_WIN) | 120 #if defined(OS_MACOSX) || defined(OS_WIN) |
123 #define MAYBE_PageAction PageAction | 121 #define MAYBE_PageAction PageAction |
124 #else | 122 #else |
125 #define MAYBE_PageAction DISABLED_PageAction | 123 #define MAYBE_PageAction DISABLED_PageAction |
(...skipping 27 matching lines...) Expand all Loading... |
153 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 151 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
154 browser(), ui::VKEY_F, false, true, true, false)); | 152 browser(), ui::VKEY_F, false, true, true, false)); |
155 | 153 |
156 // Verify the command worked (the page action turns the page red). | 154 // Verify the command worked (the page action turns the page red). |
157 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 155 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
158 bool result = false; | 156 bool result = false; |
159 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 157 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
160 tab, | 158 tab, |
161 "setInterval(function(){" | 159 "setInterval(function(){" |
162 " if(document.body.bgColor == 'red'){" | 160 " if(document.body.bgColor == 'red'){" |
163 " window.domAutomationController.setAutomationId(0);" | |
164 " window.domAutomationController.send(true)}}, 100)", | 161 " window.domAutomationController.send(true)}}, 100)", |
165 &result)); | 162 &result)); |
166 ASSERT_TRUE(result); | 163 ASSERT_TRUE(result); |
167 } | 164 } |
168 | 165 |
169 // Checked-in in a disabled state, because the necessary functionality to | 166 // Checked-in in a disabled state, because the necessary functionality to |
170 // automatically verify that the test works hasn't been implemented for the | 167 // automatically verify that the test works hasn't been implemented for the |
171 // script badges yet (see http://crbug.com/140016). The test results, can be | 168 // script badges yet (see http://crbug.com/140016). The test results, can be |
172 // verified manually by running the test and verifying that the synthesized | 169 // verified manually by running the test and verifying that the synthesized |
173 // popup for script badges appear. When bug 140016 has been fixed, the popup | 170 // popup for script badges appear. When bug 140016 has been fixed, the popup |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 222 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
226 browser(), ui::VKEY_F, false, true, true, false)); | 223 browser(), ui::VKEY_F, false, true, true, false)); |
227 ASSERT_TRUE(catcher.GetNextResult()); | 224 ASSERT_TRUE(catcher.GetNextResult()); |
228 } | 225 } |
229 | 226 |
230 bool result = false; | 227 bool result = false; |
231 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 228 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
232 tab, | 229 tab, |
233 "setInterval(function() {" | 230 "setInterval(function() {" |
234 " if (document.body.bgColor == 'blue') {" | 231 " if (document.body.bgColor == 'blue') {" |
235 " window.domAutomationController.setAutomationId(0);" | |
236 " window.domAutomationController.send(true)}}, 100)", | 232 " window.domAutomationController.send(true)}}, 100)", |
237 &result)); | 233 &result)); |
238 ASSERT_TRUE(result); | 234 ASSERT_TRUE(result); |
239 | 235 |
240 // Activate the shortcut (Ctrl+F) to make page red (should not work). | 236 // Activate the shortcut (Ctrl+F) to make page red (should not work). |
241 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 237 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
242 browser(), ui::VKEY_F, true, false, false, false)); | 238 browser(), ui::VKEY_F, true, false, false, false)); |
243 | 239 |
244 // The page should still be blue. | 240 // The page should still be blue. |
245 result = false; | 241 result = false; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 &named_commands); | 319 &named_commands); |
324 EXPECT_EQ(1u, named_commands.size()); | 320 EXPECT_EQ(1u, named_commands.size()); |
325 | 321 |
326 // Activate the shortcut (Alt+A). | 322 // Activate the shortcut (Alt+A). |
327 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 323 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
328 browser(), ui::VKEY_A, false, false, true, false)); | 324 browser(), ui::VKEY_A, false, false, true, false)); |
329 ASSERT_TRUE(catcher.GetNextResult()) << message_; | 325 ASSERT_TRUE(catcher.GetNextResult()) << message_; |
330 } | 326 } |
331 | 327 |
332 } // namespace extensions | 328 } // namespace extensions |
OLD | NEW |