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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // Activate the shortcut (Ctrl+Shift+F). | 83 // Activate the shortcut (Ctrl+Shift+F). |
84 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 84 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
85 browser(), ui::VKEY_F, true, true, false, false)); | 85 browser(), ui::VKEY_F, true, true, false, false)); |
86 | 86 |
87 // activeTab should now be granted. | 87 // activeTab should now be granted. |
88 EXPECT_TRUE(granter->IsGranted(extension)); | 88 EXPECT_TRUE(granter->IsGranted(extension)); |
89 | 89 |
90 // Verify the command worked. | 90 // Verify the command worked. |
91 bool result = false; | 91 bool result = false; |
92 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 92 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
93 tab->GetRenderViewHost(), L"", | 93 tab->GetRenderViewHost(), |
94 L"setInterval(function(){" | 94 "", |
95 L" if(document.body.bgColor == 'red'){" | 95 "setInterval(function(){" |
96 L" window.domAutomationController.send(true)}}, 100)", | 96 " if(document.body.bgColor == 'red'){" |
| 97 " window.domAutomationController.send(true)}}, 100)", |
97 &result)); | 98 &result)); |
98 ASSERT_TRUE(result); | 99 ASSERT_TRUE(result); |
99 | 100 |
100 // Activate the shortcut (Ctrl+Shift+Y). | 101 // Activate the shortcut (Ctrl+Shift+Y). |
101 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 102 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
102 browser(), ui::VKEY_Y, true, true, false, false)); | 103 browser(), ui::VKEY_Y, true, true, false, false)); |
103 | 104 |
104 result = false; | 105 result = false; |
105 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 106 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
106 tab->GetRenderViewHost(), L"", | 107 tab->GetRenderViewHost(), |
107 L"setInterval(function(){" | 108 "", |
108 L" if(document.body.bgColor == 'blue'){" | 109 "setInterval(function(){" |
109 L" window.domAutomationController.send(true)}}, 100)", | 110 " if(document.body.bgColor == 'blue'){" |
| 111 " window.domAutomationController.send(true)}}, 100)", |
110 &result)); | 112 &result)); |
111 ASSERT_TRUE(result); | 113 ASSERT_TRUE(result); |
112 } | 114 } |
113 | 115 |
114 // Flaky on linux and chromeos, http://crbug.com/165825 | 116 // Flaky on linux and chromeos, http://crbug.com/165825 |
115 #if defined(OS_MACOSX) || defined(OS_WIN) | 117 #if defined(OS_MACOSX) || defined(OS_WIN) |
116 #define MAYBE_PageAction PageAction | 118 #define MAYBE_PageAction PageAction |
117 #else | 119 #else |
118 #define MAYBE_PageAction DISABLED_PageAction | 120 #define MAYBE_PageAction DISABLED_PageAction |
119 #endif | 121 #endif |
(...skipping 23 matching lines...) Expand all Loading... |
143 EXPECT_EQ("Make this page red", action->GetTitle(tab_id)); | 145 EXPECT_EQ("Make this page red", action->GetTitle(tab_id)); |
144 | 146 |
145 // Activate the shortcut (Alt+Shift+F). | 147 // Activate the shortcut (Alt+Shift+F). |
146 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 148 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
147 browser(), ui::VKEY_F, false, true, true, false)); | 149 browser(), ui::VKEY_F, false, true, true, false)); |
148 | 150 |
149 // Verify the command worked (the page action turns the page red). | 151 // Verify the command worked (the page action turns the page red). |
150 WebContents* tab = chrome::GetActiveWebContents(browser()); | 152 WebContents* tab = chrome::GetActiveWebContents(browser()); |
151 bool result = false; | 153 bool result = false; |
152 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 154 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
153 tab->GetRenderViewHost(), L"", | 155 tab->GetRenderViewHost(), |
154 L"setInterval(function(){" | 156 "", |
155 L" if(document.body.bgColor == 'red'){" | 157 "setInterval(function(){" |
156 L" window.domAutomationController.send(true)}}, 100)", | 158 " if(document.body.bgColor == 'red'){" |
| 159 " window.domAutomationController.send(true)}}, 100)", |
157 &result)); | 160 &result)); |
158 ASSERT_TRUE(result); | 161 ASSERT_TRUE(result); |
159 } | 162 } |
160 | 163 |
161 // Checked-in in a disabled state, because the necessary functionality to | 164 // Checked-in in a disabled state, because the necessary functionality to |
162 // automatically verify that the test works hasn't been implemented for the | 165 // automatically verify that the test works hasn't been implemented for the |
163 // script badges yet (see http://crbug.com/140016). The test results, can be | 166 // script badges yet (see http://crbug.com/140016). The test results, can be |
164 // verified manually by running the test and verifying that the synthesized | 167 // verified manually by running the test and verifying that the synthesized |
165 // popup for script badges appear. When bug 140016 has been fixed, the popup | 168 // popup for script badges appear. When bug 140016 has been fixed, the popup |
166 // code can signal to the test that the test passed. | 169 // code can signal to the test that the test passed. |
(...skipping 23 matching lines...) Expand all Loading... |
190 | 193 |
191 // This test validates that the getAll query API function returns registered | 194 // This test validates that the getAll query API function returns registered |
192 // 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 |
193 // synthesized ones are in nature) have no shortcuts. | 196 // synthesized ones are in nature) have no shortcuts. |
194 IN_PROC_BROWSER_TEST_F(CommandsApiTest, SynthesizedCommand) { | 197 IN_PROC_BROWSER_TEST_F(CommandsApiTest, SynthesizedCommand) { |
195 ASSERT_TRUE(test_server()->Start()); | 198 ASSERT_TRUE(test_server()->Start()); |
196 ASSERT_TRUE(RunExtensionTest("keybinding/synthesized")) << message_; | 199 ASSERT_TRUE(RunExtensionTest("keybinding/synthesized")) << message_; |
197 } | 200 } |
198 | 201 |
199 } // extensions | 202 } // extensions |
OLD | NEW |