Commit c4631d44 authored by Fergal Daly's avatar Fergal Daly Committed by Commit Bot

Make NavigateFrameToURL return a success value like NavigateToURL.

This is just a convenience. I've simplified one use of this. I'll be
adding another use in a different CL.

https://crrev.com/c/2148914 wraps all calls to this in EXPECT_TRUE but
of course there are failures. It would be a bad idea to submit this
right now with the code-freeze anyway. So I'll come back to it.

Change-Id: I16b170fe8e697d0eb06716e30b877efdaa523869
Bug: 1071297
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2148711
Commit-Queue: Fergal Daly <fergal@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759519}
parent f20adcbd
...@@ -83,10 +83,7 @@ class FindRequestManagerTest : public ContentBrowserTest, ...@@ -83,10 +83,7 @@ class FindRequestManagerTest : public ContentBrowserTest,
GURL url(embedded_test_server()->GetURL( GURL url(embedded_test_server()->GetURL(
"b.com", child->current_url().path())); "b.com", child->current_url().path()));
TestNavigationObserver observer(shell()->web_contents()); EXPECT_TRUE(NavigateFrameToURL(child, url));
NavigateFrameToURL(child, url);
EXPECT_EQ(url, observer.last_navigation_url());
EXPECT_TRUE(observer.last_navigation_succeeded());
} }
void Find(const std::string& search_text, void Find(const std::string& search_text,
......
...@@ -45,13 +45,24 @@ ...@@ -45,13 +45,24 @@
namespace content { namespace content {
void NavigateFrameToURL(FrameTreeNode* node, const GURL& url) { bool NavigateFrameToURL(FrameTreeNode* node, const GURL& url) {
TestFrameNavigationObserver observer(node); TestFrameNavigationObserver observer(node);
NavigationController::LoadURLParams params(url); NavigationController::LoadURLParams params(url);
params.transition_type = ui::PAGE_TRANSITION_LINK; params.transition_type = ui::PAGE_TRANSITION_LINK;
params.frame_tree_node_id = node->frame_tree_node_id(); params.frame_tree_node_id = node->frame_tree_node_id();
node->navigator()->GetController()->LoadURLWithParams(params); node->navigator()->GetController()->LoadURLWithParams(params);
observer.Wait(); observer.Wait();
if (!observer.last_navigation_succeeded()) {
DLOG(WARNING) << "Navigation did not succeed: " << url;
return false;
}
if (url != node->current_url()) {
DLOG(WARNING) << "Expected URL " << url << " but observed "
<< node->current_url();
return false;
}
return true;
} }
void SetShouldProceedOnBeforeUnload(Shell* shell, bool proceed, bool success) { void SetShouldProceedOnBeforeUnload(Shell* shell, bool proceed, bool success) {
......
...@@ -39,8 +39,9 @@ class SiteInstance; ...@@ -39,8 +39,9 @@ class SiteInstance;
class ToRenderFrameHost; class ToRenderFrameHost;
// Navigates the frame represented by |node| to |url|, blocking until the // Navigates the frame represented by |node| to |url|, blocking until the
// navigation finishes. // navigation finishes. Returns true if the navigation succeedd and the final
void NavigateFrameToURL(FrameTreeNode* node, const GURL& url); // URL matches |url|.
bool NavigateFrameToURL(FrameTreeNode* node, const GURL& url);
// Sets the DialogManager to proceed by default or not when showing a // Sets the DialogManager to proceed by default or not when showing a
// BeforeUnload dialog, and if it proceeds, what value to return. // BeforeUnload dialog, and if it proceeds, what value to return.
......
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