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

Unified Diff: content/public/test/browser_test_utils.h

Issue 2052633002: Extend the ToRenderFrameHost magic to FrameTreeNode* and Shell* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix induced script bug. Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: content/public/test/browser_test_utils.h
diff --git a/content/public/test/browser_test_utils.h b/content/public/test/browser_test_utils.h
index c3812dceb81f2ff1fff5f2bb7d0b4e1b4371b48c..cf2bdc633478fc9d0081c984d03b52fbb5061598 100644
--- a/content/public/test/browser_test_utils.h
+++ b/content/public/test/browser_test_utils.h
@@ -166,20 +166,26 @@ void SimulateKeyPress(WebContents* web_contents,
// Allow ExecuteScript* methods to target either a WebContents or a
// RenderFrameHost. Targetting a WebContents means executing the script in the
-// RenderFrameHost returned by WebContents::GetMainFrame(), which is the
-// main frame. Pass a specific RenderFrameHost to target it.
+// RenderFrameHost returned by WebContents::GetMainFrame(), which is the main
+// frame. Pass a specific RenderFrameHost to target it. Embedders may declare
+// additional ConvertToRenderFrameHost functions for convenience.
class ToRenderFrameHost {
public:
- ToRenderFrameHost(WebContents* web_contents);
- ToRenderFrameHost(RenderViewHost* render_view_host);
- ToRenderFrameHost(RenderFrameHost* render_frame_host);
+ template <typename T>
+ ToRenderFrameHost(T* frame_convertible_value)
+ : render_frame_host_(ConvertToRenderFrameHost(frame_convertible_value)) {}
+ // Extract the underlying frame.
RenderFrameHost* render_frame_host() const { return render_frame_host_; }
private:
RenderFrameHost* render_frame_host_;
};
+RenderFrameHost* ConvertToRenderFrameHost(RenderViewHost* render_view_host);
+RenderFrameHost* ConvertToRenderFrameHost(RenderFrameHost* render_view_host);
+RenderFrameHost* ConvertToRenderFrameHost(WebContents* web_contents);
+
// Executes the passed |script| in the specified frame. The |script| should not
// invoke domAutomationController.send(); otherwise, your test will hang or be
// flaky. If you want to extract a result, use one of the below functions.

Powered by Google App Engine
This is Rietveld 408576698