Commit 7e9bf228 authored by Alex Moshchuk's avatar Alex Moshchuk Committed by Commit Bot

Make tests using OpenPopup more robust.

This CL modifies the OpenPopup (aka window.open helper) to avoid using
unchecked WaitForLoadStop(), replacing it with waiting on a
TestNavigationObserver for the specific URL being opened.

Bug: 1014186
Change-Id: Ib28f9fe251336d1e1f3a0e6326792881e13fd671
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2165578
Commit-Queue: James MacLean <wjmaclean@chromium.org>
Reviewed-by: default avatarJames MacLean <wjmaclean@chromium.org>
Auto-Submit: Alex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#762845}
parent c7e9db3c
...@@ -281,6 +281,10 @@ std::string FrameTreeVisualizer::GetName(SiteInstance* site_instance) { ...@@ -281,6 +281,10 @@ std::string FrameTreeVisualizer::GetName(SiteInstance* site_instance) {
Shell* OpenPopup(const ToRenderFrameHost& opener, Shell* OpenPopup(const ToRenderFrameHost& opener,
const GURL& url, const GURL& url,
const std::string& name) { const std::string& name) {
TestNavigationObserver observer(url);
observer.StartWatchingNewWebContents();
observer.set_ignore_other_urls(true);
ShellAddedObserver new_shell_observer; ShellAddedObserver new_shell_observer;
bool did_create_popup = false; bool did_create_popup = false;
bool did_execute_script = ExecuteScriptAndExtractBool( bool did_execute_script = ExecuteScriptAndExtractBool(
...@@ -291,9 +295,12 @@ Shell* OpenPopup(const ToRenderFrameHost& opener, ...@@ -291,9 +295,12 @@ Shell* OpenPopup(const ToRenderFrameHost& opener,
if (!did_execute_script || !did_create_popup) if (!did_execute_script || !did_create_popup)
return nullptr; return nullptr;
observer.Wait();
Shell* new_shell = new_shell_observer.GetShell(); Shell* new_shell = new_shell_observer.GetShell();
WaitForLoadStop(new_shell->web_contents()); EXPECT_EQ(url,
return new_shell; new_shell->web_contents()->GetMainFrame()->GetLastCommittedURL());
return new_shell_observer.GetShell();
} }
FileChooserDelegate::FileChooserDelegate(const base::FilePath& file, FileChooserDelegate::FileChooserDelegate(const base::FilePath& file,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment