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

Unified Diff: content/test/test_render_frame_host.cc

Issue 2345053006: Remove IsSynchronous API from NavigationHandle. (Closed)
Patch Set: Addressed review comments. Created 4 years, 2 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
« no previous file with comments | « content/test/test_render_frame_host.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/test_render_frame_host.cc
diff --git a/content/test/test_render_frame_host.cc b/content/test/test_render_frame_host.cc
index 2aced691760742d41c2c17acd630916e5af61826..c7d0d6f4bca4d3bf1935e3a48be416d0fa7b2a34 100644
--- a/content/test/test_render_frame_host.cc
+++ b/content/test/test_render_frame_host.cc
@@ -64,7 +64,8 @@ TestRenderFrameHost::TestRenderFrameHost(SiteInstance* site_instance,
flags),
child_creation_observer_(delegate ? delegate->GetAsWebContents() : NULL),
contents_mime_type_("text/html"),
- simulate_history_list_was_cleared_(false) {}
+ simulate_history_list_was_cleared_(false),
+ last_commit_was_error_page_(false) {}
TestRenderFrameHost::~TestRenderFrameHost() {
}
@@ -156,9 +157,14 @@ void TestRenderFrameHost::SimulateNavigationCommit(const GURL& url) {
url::Replacements<char> replacements;
replacements.ClearRef();
+
+ // This approach to determining whether a navigation is to be treated as
+ // same page is not robust, as it will not handle pushState type navigation.
+ // Do not use elsewhere!
params.was_within_same_page =
- url.ReplaceComponents(replacements) ==
- GetLastCommittedURL().ReplaceComponents(replacements);
+ (GetLastCommittedURL().is_valid() && !last_commit_was_error_page_ &&
+ url.ReplaceComponents(replacements) ==
+ GetLastCommittedURL().ReplaceComponents(replacements));
params.page_state = PageState::CreateForTesting(url, false, nullptr, nullptr);
@@ -350,11 +356,16 @@ void TestRenderFrameHost::SendNavigateWithParameters(
url::Replacements<char> replacements;
replacements.ClearRef();
+
+ // This approach to determining whether a navigation is to be treated as
+ // same page is not robust, as it will not handle pushState type navigation.
+ // Do not use elsewhere!
params.was_within_same_page =
!ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD) &&
!ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_TYPED) &&
- url_copy.ReplaceComponents(replacements) ==
- GetLastCommittedURL().ReplaceComponents(replacements);
+ (GetLastCommittedURL().is_valid() && !last_commit_was_error_page_ &&
+ url_copy.ReplaceComponents(replacements) ==
+ GetLastCommittedURL().ReplaceComponents(replacements));
params.page_state =
PageState::CreateForTesting(url_copy, false, nullptr, nullptr);
@@ -369,6 +380,7 @@ void TestRenderFrameHost::SendNavigateWithParams(
FrameHostMsg_DidCommitProvisionalLoad_Params* params) {
FrameHostMsg_DidCommitProvisionalLoad msg(GetRoutingID(), *params);
OnDidCommitProvisionalLoad(msg);
+ last_commit_was_error_page_ = params->url_is_unreachable;
}
void TestRenderFrameHost::SendRendererInitiatedNavigationRequest(
« no previous file with comments | « content/test/test_render_frame_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698