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

Side by Side Diff: content/public/test/browser_test_utils.h

Issue 1224363002: OOPIF: Fix window.open to work from frames with remote parent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove internal:: from ToRenderFrameHost Created 5 years, 5 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
« no previous file with comments | « content/content_tests.gypi ('k') | content/public/test/browser_test_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ 5 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_
6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ 6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // native key code: 0x001e (for Windows). 150 // native key code: 0x001e (for Windows).
151 // native key code: 0x0026 (for Linux). 151 // native key code: 0x0026 (for Linux).
152 void SimulateKeyPressWithCode(WebContents* web_contents, 152 void SimulateKeyPressWithCode(WebContents* web_contents,
153 ui::KeyboardCode key_code, 153 ui::KeyboardCode key_code,
154 const char* code, 154 const char* code,
155 bool control, 155 bool control,
156 bool shift, 156 bool shift,
157 bool alt, 157 bool alt,
158 bool command); 158 bool command);
159 159
160 namespace internal {
161 // Allow ExecuteScript* methods to target either a WebContents or a 160 // Allow ExecuteScript* methods to target either a WebContents or a
162 // RenderFrameHost. Targetting a WebContents means executing the script in the 161 // RenderFrameHost. Targetting a WebContents means executing the script in the
163 // RenderFrameHost returned by WebContents::GetMainFrame(), which is the 162 // RenderFrameHost returned by WebContents::GetMainFrame(), which is the
164 // main frame. Pass a specific RenderFrameHost to target it. 163 // main frame. Pass a specific RenderFrameHost to target it.
165 class ToRenderFrameHost { 164 class ToRenderFrameHost {
166 public: 165 public:
167 ToRenderFrameHost(WebContents* web_contents); 166 ToRenderFrameHost(WebContents* web_contents);
168 ToRenderFrameHost(RenderViewHost* render_view_host); 167 ToRenderFrameHost(RenderViewHost* render_view_host);
169 ToRenderFrameHost(RenderFrameHost* render_frame_host); 168 ToRenderFrameHost(RenderFrameHost* render_frame_host);
170 169
171 RenderFrameHost* render_frame_host() const { return render_frame_host_; } 170 RenderFrameHost* render_frame_host() const { return render_frame_host_; }
172 171
173 private: 172 private:
174 RenderFrameHost* render_frame_host_; 173 RenderFrameHost* render_frame_host_;
175 }; 174 };
176 } // namespace internal
177 175
178 // Executes the passed |script| in the specified frame. The |script| should not 176 // Executes the passed |script| in the specified frame. The |script| should not
179 // invoke domAutomationController.send(); otherwise, your test will hang or be 177 // invoke domAutomationController.send(); otherwise, your test will hang or be
180 // flaky. If you want to extract a result, use one of the below functions. 178 // flaky. If you want to extract a result, use one of the below functions.
181 // Returns true on success. 179 // Returns true on success.
182 bool ExecuteScript(const internal::ToRenderFrameHost& adapter, 180 bool ExecuteScript(const ToRenderFrameHost& adapter,
183 const std::string& script) WARN_UNUSED_RESULT; 181 const std::string& script) WARN_UNUSED_RESULT;
184 182
185 // The following methods executes the passed |script| in the specified frame and 183 // The following methods executes the passed |script| in the specified frame and
186 // sets |result| to the value passed to "window.domAutomationController.send" by 184 // sets |result| to the value passed to "window.domAutomationController.send" by
187 // the executed script. They return true on success, false if the script 185 // the executed script. They return true on success, false if the script
188 // execution failed or did not evaluate to the expected type. 186 // execution failed or did not evaluate to the expected type.
189 bool ExecuteScriptAndExtractInt(const internal::ToRenderFrameHost& adapter, 187 bool ExecuteScriptAndExtractInt(const ToRenderFrameHost& adapter,
190 const std::string& script, 188 const std::string& script,
191 int* result) WARN_UNUSED_RESULT; 189 int* result) WARN_UNUSED_RESULT;
192 bool ExecuteScriptAndExtractBool(const internal::ToRenderFrameHost& adapter, 190 bool ExecuteScriptAndExtractBool(const ToRenderFrameHost& adapter,
193 const std::string& script, 191 const std::string& script,
194 bool* result) WARN_UNUSED_RESULT; 192 bool* result) WARN_UNUSED_RESULT;
195 bool ExecuteScriptAndExtractString(const internal::ToRenderFrameHost& adapter, 193 bool ExecuteScriptAndExtractString(const ToRenderFrameHost& adapter,
196 const std::string& script, 194 const std::string& script,
197 std::string* result) WARN_UNUSED_RESULT; 195 std::string* result) WARN_UNUSED_RESULT;
198 196
199 // Walks the frame tree of the specified WebContents and returns the sole frame 197 // Walks the frame tree of the specified WebContents and returns the sole frame
200 // that matches the specified predicate function. This function will DCHECK if 198 // that matches the specified predicate function. This function will DCHECK if
201 // no frames match the specified predicate, or if more than one frame matches. 199 // no frames match the specified predicate, or if more than one frame matches.
202 RenderFrameHost* FrameMatchingPredicate( 200 RenderFrameHost* FrameMatchingPredicate(
203 WebContents* web_contents, 201 WebContents* web_contents,
204 const base::Callback<bool(RenderFrameHost*)>& predicate); 202 const base::Callback<bool(RenderFrameHost*)>& predicate);
205 203
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 428
431 int frames_to_wait_; 429 int frames_to_wait_;
432 base::Closure quit_; 430 base::Closure quit_;
433 431
434 DISALLOW_COPY_AND_ASSIGN(FrameWatcher); 432 DISALLOW_COPY_AND_ASSIGN(FrameWatcher);
435 }; 433 };
436 434
437 } // namespace content 435 } // namespace content
438 436
439 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ 437 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « content/content_tests.gypi ('k') | content/public/test/browser_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698