Index: content/test/content_browser_test_utils_internal.cc |
diff --git a/content/test/content_browser_test_utils_internal.cc b/content/test/content_browser_test_utils_internal.cc |
index 9097a8955fe6a5e4fbc0791d04f124d981adb587..ea1d17ebce72a4954d21d6112dec0270f3acb683 100644 |
--- a/content/test/content_browser_test_utils_internal.cc |
+++ b/content/test/content_browser_test_utils_internal.cc |
@@ -13,6 +13,9 @@ |
#include "content/browser/frame_host/frame_tree_node.h" |
#include "content/browser/frame_host/navigator.h" |
#include "content/browser/frame_host/render_frame_proxy_host.h" |
+#include "content/public/test/browser_test_utils.h" |
+#include "content/public/test/content_browser_test_utils.h" |
+#include "content/shell/browser/shell.h" |
#include "content/test/test_frame_navigation_observer.h" |
#include "url/gurl.h" |
@@ -219,4 +222,22 @@ std::string FrameTreeVisualizer::GetName(SiteInstance* site_instance) { |
return base::StringPrintf("Z%d", static_cast<int>(index - 25)); |
} |
+Shell* OpenPopup(const ToRenderFrameHost& opener, |
+ const GURL& url, |
+ const std::string& name) { |
+ ShellAddedObserver new_shell_observer; |
+ bool did_create_popup = false; |
+ bool did_execute_script = ExecuteScriptAndExtractBool( |
+ opener, |
+ "window.domAutomationController.send(" |
+ " !!window.open('" + url.spec() + "', '" + name + "'));", |
+ &did_create_popup); |
+ if (!did_execute_script || !did_create_popup) |
+ return nullptr; |
+ |
+ Shell* new_shell = new_shell_observer.GetShell(); |
+ WaitForLoadStop(new_shell->web_contents()); |
+ return new_shell; |
+} |
+ |
} // namespace content |