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

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

Issue 11753009: Simplify ExecuteJavaScript* functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update prerender_browsertest.cc. Created 7 years, 11 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
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::ExecuteScriptAndExtractBool(
93 tab->GetRenderViewHost(), 93 tab,
94 "",
95 "setInterval(function(){" 94 "setInterval(function(){"
96 " if(document.body.bgColor == 'red'){" 95 " if(document.body.bgColor == 'red'){"
97 " window.domAutomationController.send(true)}}, 100)", 96 " window.domAutomationController.send(true)}}, 100)",
98 &result)); 97 &result));
99 ASSERT_TRUE(result); 98 ASSERT_TRUE(result);
100 99
101 // Activate the shortcut (Ctrl+Shift+Y). 100 // Activate the shortcut (Ctrl+Shift+Y).
102 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 101 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
103 browser(), ui::VKEY_Y, true, true, false, false)); 102 browser(), ui::VKEY_Y, true, true, false, false));
104 103
105 result = false; 104 result = false;
106 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( 105 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
107 tab->GetRenderViewHost(), 106 tab,
108 "",
109 "setInterval(function(){" 107 "setInterval(function(){"
110 " if(document.body.bgColor == 'blue'){" 108 " if(document.body.bgColor == 'blue'){"
111 " window.domAutomationController.send(true)}}, 100)", 109 " window.domAutomationController.send(true)}}, 100)",
112 &result)); 110 &result));
113 ASSERT_TRUE(result); 111 ASSERT_TRUE(result);
114 } 112 }
115 113
116 // Flaky on linux and chromeos, http://crbug.com/165825 114 // Flaky on linux and chromeos, http://crbug.com/165825
117 #if defined(OS_MACOSX) || defined(OS_WIN) 115 #if defined(OS_MACOSX) || defined(OS_WIN)
118 #define MAYBE_PageAction PageAction 116 #define MAYBE_PageAction PageAction
(...skipping 25 matching lines...) Expand all
144 ASSERT_TRUE(action); 142 ASSERT_TRUE(action);
145 EXPECT_EQ("Make this page red", action->GetTitle(tab_id)); 143 EXPECT_EQ("Make this page red", action->GetTitle(tab_id));
146 144
147 // Activate the shortcut (Alt+Shift+F). 145 // Activate the shortcut (Alt+Shift+F).
148 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 146 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
149 browser(), ui::VKEY_F, false, true, true, false)); 147 browser(), ui::VKEY_F, false, true, true, false));
150 148
151 // Verify the command worked (the page action turns the page red). 149 // Verify the command worked (the page action turns the page red).
152 WebContents* tab = chrome::GetActiveWebContents(browser()); 150 WebContents* tab = chrome::GetActiveWebContents(browser());
153 bool result = false; 151 bool result = false;
154 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( 152 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
155 tab->GetRenderViewHost(), 153 tab,
156 "",
157 "setInterval(function(){" 154 "setInterval(function(){"
158 " if(document.body.bgColor == 'red'){" 155 " if(document.body.bgColor == 'red'){"
159 " window.domAutomationController.send(true)}}, 100)", 156 " window.domAutomationController.send(true)}}, 100)",
160 &result)); 157 &result));
161 ASSERT_TRUE(result); 158 ASSERT_TRUE(result);
162 } 159 }
163 160
164 // Checked-in in a disabled state, because the necessary functionality to 161 // Checked-in in a disabled state, because the necessary functionality to
165 // automatically verify that the test works hasn't been implemented for the 162 // automatically verify that the test works hasn't been implemented for the
166 // script badges yet (see http://crbug.com/140016). The test results, can be 163 // script badges yet (see http://crbug.com/140016). The test results, can be
(...skipping 26 matching lines...) Expand all
193 190
194 // This test validates that the getAll query API function returns registered 191 // This test validates that the getAll query API function returns registered
195 // commands as well as synthesized ones and that inactive commands (like the 192 // commands as well as synthesized ones and that inactive commands (like the
196 // synthesized ones are in nature) have no shortcuts. 193 // synthesized ones are in nature) have no shortcuts.
197 IN_PROC_BROWSER_TEST_F(CommandsApiTest, SynthesizedCommand) { 194 IN_PROC_BROWSER_TEST_F(CommandsApiTest, SynthesizedCommand) {
198 ASSERT_TRUE(test_server()->Start()); 195 ASSERT_TRUE(test_server()->Start());
199 ASSERT_TRUE(RunExtensionTest("keybinding/synthesized")) << message_; 196 ASSERT_TRUE(RunExtensionTest("keybinding/synthesized")) << message_;
200 } 197 }
201 198
202 } // extensions 199 } // extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_incognito_apitest.cc ('k') | chrome/browser/extensions/extension_nacl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698