summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcarlosk <carlosk@chromium.org>2015-03-04 02:46:17 -0800
committerCommit bot <commit-bot@chromium.org>2015-03-04 10:46:51 +0000
commitd6a4ef36ace903fd35bbe2e6ef2f87f690fb2bc9 (patch)
treeea280ae10466ce3c6ad6d5019d338647e77e9007
parent10f7c9d7b6a1606313f095a569548f39f47200c6 (diff)
downloadchromium_src-d6a4ef36ace903fd35bbe2e6ef2f87f690fb2bc9.zip
chromium_src-d6a4ef36ace903fd35bbe2e6ef2f87f690fb2bc9.tar.gz
chromium_src-d6a4ef36ace903fd35bbe2e6ef2f87f690fb2bc9.tar.bz2
PlzNavigate: test updates post beforeUnload IPC refactor.
This CL adapts several test classes with changes due now that the IPCS for beforeUnload ack and renderer navigation requests are not one and the same anymore. BUG=440266 Review URL: https://codereview.chromium.org/953503002 Cr-Commit-Position: refs/heads/master@{#319049}
-rw-r--r--content/browser/frame_host/navigation_controller_impl_unittest.cc187
-rw-r--r--content/browser/frame_host/navigator_impl_unittest.cc41
-rw-r--r--content/browser/frame_host/render_frame_host_manager_unittest.cc34
-rw-r--r--content/browser/web_contents/web_contents_impl_unittest.cc77
-rw-r--r--content/test/test_navigation_url_loader.cc12
-rw-r--r--content/test/test_navigation_url_loader.h2
-rw-r--r--content/test/test_render_frame_host.cc67
-rw-r--r--content/test/test_render_frame_host.h14
-rw-r--r--content/test/test_web_contents.cc2
9 files changed, 241 insertions, 195 deletions
diff --git a/content/browser/frame_host/navigation_controller_impl_unittest.cc b/content/browser/frame_host/navigation_controller_impl_unittest.cc
index 3492196..cb14e67 100644
--- a/content/browser/frame_host/navigation_controller_impl_unittest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc
@@ -316,7 +316,8 @@ TEST_F(NavigationControllerTest, GoToOffset) {
urls[i] = GURL(base::StringPrintf("http://www.a.com/%d", i));
}
- main_test_rfh()->PrepareForCommit(urls[0]);
+ main_test_rfh()->SendRendererInitiatedNavigationRequest(urls[0], true);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, urls[0]);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -326,7 +327,8 @@ TEST_F(NavigationControllerTest, GoToOffset) {
EXPECT_FALSE(controller.CanGoToOffset(1));
for (int i = 1; i <= 4; ++i) {
- main_test_rfh()->PrepareForCommit(urls[i]);
+ main_test_rfh()->SendRendererInitiatedNavigationRequest(urls[i], true);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(i, urls[i]);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -362,7 +364,7 @@ TEST_F(NavigationControllerTest, GoToOffset) {
url_index += offset;
// Check that the GoToOffset will land on the expected page.
EXPECT_EQ(urls[url_index], controller.GetPendingEntry()->GetVirtualURL());
- main_test_rfh()->PrepareForCommit(urls[url_index]);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(url_index, urls[url_index]);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -407,7 +409,7 @@ TEST_F(NavigationControllerTest, LoadURL) {
// We should have gotten no notifications from the preceeding checks.
EXPECT_EQ(0U, notifications.size());
- main_test_rfh()->PrepareForCommit(url1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -447,7 +449,7 @@ TEST_F(NavigationControllerTest, LoadURL) {
// Simulate the beforeunload ack for the cross-site transition, and then the
// commit.
- main_test_rfh()->PrepareForCommit(url2);
+ main_test_rfh()->PrepareForCommit();
contents()->GetPendingMainFrame()->SendNavigate(1, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -489,7 +491,7 @@ TEST_F(NavigationControllerTest, LoadURLSameTime) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(url1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -500,7 +502,7 @@ TEST_F(NavigationControllerTest, LoadURLSameTime) {
// Simulate the beforeunload ack for the cross-site transition, and then the
// commit.
- main_test_rfh()->PrepareForCommit(url2);
+ main_test_rfh()->PrepareForCommit();
contents()->GetPendingMainFrame()->SendNavigate(1, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -619,7 +621,7 @@ TEST_F(NavigationControllerTest, LoadURL_SamePage) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
EXPECT_EQ(0U, notifications.size());
- main_test_rfh()->PrepareForCommit(url1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -631,7 +633,7 @@ TEST_F(NavigationControllerTest, LoadURL_SamePage) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
EXPECT_EQ(0U, notifications.size());
- main_test_rfh()->PrepareForCommit(url1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -671,7 +673,7 @@ TEST_F(NavigationControllerTest, LoadURL_SamePage_DifferentMethod) {
params.is_post = true;
params.post_id = 123;
params.page_state = PageState::CreateForTesting(url1, false, 0, 0);
- main_test_rfh()->PrepareForCommit(url1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigateWithParams(&params);
// The post data should be visible.
@@ -682,7 +684,7 @@ TEST_F(NavigationControllerTest, LoadURL_SamePage_DifferentMethod) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(url1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, url1);
// We should not have produced a new session history entry.
@@ -773,7 +775,7 @@ TEST_F(NavigationControllerTest, LoadURL_NewPending) {
const GURL kExistingURL1("http://eh");
controller.LoadURL(
kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(kExistingURL1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, kExistingURL1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -785,9 +787,9 @@ TEST_F(NavigationControllerTest, LoadURL_NewPending) {
EXPECT_EQ(0U, notifications.size());
// After the beforeunload but before it commits, do a new navigation.
- main_test_rfh()->PrepareForCommit(kExistingURL2);
+ main_test_rfh()->PrepareForCommit();
const GURL kNewURL("http://see");
- main_test_rfh()->PrepareForCommit(kNewURL);
+ main_test_rfh()->PrepareForCommit();
contents()->GetMainFrame()->SendNavigate(3, kNewURL);
// There should no longer be any pending entry, and the third navigation we
@@ -811,7 +813,7 @@ TEST_F(NavigationControllerTest, LoadURL_ExistingPending) {
const GURL kExistingURL1("http://foo/eh");
controller.LoadURL(
kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(kExistingURL1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, kExistingURL1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -819,7 +821,7 @@ TEST_F(NavigationControllerTest, LoadURL_ExistingPending) {
const GURL kExistingURL2("http://foo/bee");
controller.LoadURL(
kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(kExistingURL2);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(1, kExistingURL2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -833,7 +835,8 @@ TEST_F(NavigationControllerTest, LoadURL_ExistingPending) {
// Before that commits, do a new navigation.
const GURL kNewURL("http://foo/see");
- main_test_rfh()->PrepareForCommit(kNewURL);
+ main_test_rfh()->SendRendererInitiatedNavigationRequest(kNewURL, true);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(3, kNewURL);
// There should no longer be any pending entry, and the third navigation we
@@ -859,7 +862,7 @@ TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) {
kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
// Pretend it has bindings so we can tell if we incorrectly copy it.
main_test_rfh()->GetRenderViewHost()->AllowBindings(2);
- main_test_rfh()->PrepareForCommit(kExistingURL1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, kExistingURL1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -868,7 +871,7 @@ TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) {
const GURL kExistingURL2("http://foo/eh");
controller.LoadURL(
kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(kExistingURL2);
+ main_test_rfh()->PrepareForCommit();
TestRenderFrameHost* foo_rfh = contents()->GetPendingMainFrame();
foo_rfh->SendNavigate(1, kExistingURL2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
@@ -885,7 +888,8 @@ TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) {
// Before that commits, do a new navigation.
const GURL kNewURL("http://foo/bee");
- foo_rfh->PrepareForCommit(kNewURL);
+ foo_rfh->SendRendererInitiatedNavigationRequest(kNewURL, true);
+ foo_rfh->PrepareForCommit();
foo_rfh->SendNavigate(3, kNewURL);
// There should no longer be any pending entry, and the third navigation we
@@ -910,7 +914,7 @@ TEST_F(NavigationControllerTest, LoadURL_BackPreemptsPending) {
const GURL kExistingURL1("http://foo/eh");
controller.LoadURL(
kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(kExistingURL1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, kExistingURL1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -918,7 +922,7 @@ TEST_F(NavigationControllerTest, LoadURL_BackPreemptsPending) {
const GURL kExistingURL2("http://foo/bee");
controller.LoadURL(
kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(kExistingURL2);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(1, kExistingURL2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -932,7 +936,8 @@ TEST_F(NavigationControllerTest, LoadURL_BackPreemptsPending) {
EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
// Before that commits, a back navigation from the renderer commits.
- main_test_rfh()->PrepareForCommit(kExistingURL1);
+ main_test_rfh()->SendRendererInitiatedNavigationRequest(kExistingURL1, true);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, kExistingURL1);
// There should no longer be any pending entry, and the back navigation we
@@ -972,7 +977,8 @@ TEST_F(NavigationControllerTest, LoadURL_IgnorePreemptsPending) {
// Before that commits, a document.write and location.reload can cause the
// renderer to send a FrameNavigate with page_id -1.
- main_test_rfh()->PrepareForCommit(kExistingURL);
+ main_test_rfh()->SendRendererInitiatedNavigationRequest(kExistingURL, true);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(-1, kExistingURL);
// This should clear the pending entry and notify of a navigation state
@@ -1123,7 +1129,7 @@ TEST_F(NavigationControllerTest, LoadURL_WithBindings) {
// Commit.
TestRenderFrameHost* orig_rfh = contents()->GetMainFrame();
- orig_rfh->PrepareForCommit(url1);
+ orig_rfh->PrepareForCommit();
orig_rfh->SendNavigate(0, url1);
EXPECT_EQ(controller.GetEntryCount(), 1);
EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
@@ -1140,7 +1146,7 @@ TEST_F(NavigationControllerTest, LoadURL_WithBindings) {
// privileged url.
controller.LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- orig_rfh->PrepareForCommit(url2);
+ orig_rfh->PrepareForCommit();
TestRenderFrameHost* new_rfh = contents()->GetPendingMainFrame();
new_rfh->GetRenderViewHost()->AllowBindings(1);
new_rfh->SendNavigate(1, url2);
@@ -1153,7 +1159,7 @@ TEST_F(NavigationControllerTest, LoadURL_WithBindings) {
// Going back, the first entry should still appear unprivileged.
controller.GoBack();
- new_rfh->PrepareForCommit(url1);
+ new_rfh->PrepareForCommit();
orig_rfh->SendNavigate(0, url1);
EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
EXPECT_EQ(0, controller.GetLastCommittedEntry()->bindings());
@@ -1169,7 +1175,7 @@ TEST_F(NavigationControllerTest, Reload) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
EXPECT_EQ(0U, notifications.size());
- main_test_rfh()->PrepareForCommit(url1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1194,7 +1200,7 @@ TEST_F(NavigationControllerTest, Reload) {
// See http://crbug.com/96041.
EXPECT_TRUE(controller.GetVisibleEntry()->GetTitle().empty());
- main_test_rfh()->PrepareForCommit(url1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1224,7 +1230,7 @@ TEST_F(NavigationControllerTest, Reload_GeneratesNewPage) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(url1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1232,7 +1238,7 @@ TEST_F(NavigationControllerTest, Reload_GeneratesNewPage) {
controller.Reload(true);
EXPECT_EQ(0U, notifications.size());
- main_test_rfh()->PrepareForCommit(url2);
+ main_test_rfh()->PrepareForCommitWithServerRedirect(url2);
main_test_rfh()->SendNavigate(1, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1290,7 +1296,7 @@ TEST_F(NavigationControllerTest, ReloadOriginalRequestURL) {
controller.LoadURL(
original_url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
EXPECT_EQ(0U, notifications.size());
- main_test_rfh()->PrepareForCommit(final_url);
+ main_test_rfh()->PrepareForCommitWithServerRedirect(final_url);
main_test_rfh()->SendNavigateWithOriginalRequestURL(
0, final_url, original_url);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
@@ -1323,7 +1329,7 @@ TEST_F(NavigationControllerTest, ReloadOriginalRequestURL) {
EXPECT_TRUE(controller.GetVisibleEntry()->GetTitle().empty());
// Send that the navigation has proceeded; say it got redirected again.
- main_test_rfh()->PrepareForCommit(final_url);
+ main_test_rfh()->PrepareForCommitWithServerRedirect(final_url);
main_test_rfh()->SendNavigate(0, final_url);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1487,14 +1493,14 @@ TEST_F(NavigationControllerTest, Back_GeneratesNewPage) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(url1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
controller.LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(url2);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(1, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1511,7 +1517,7 @@ TEST_F(NavigationControllerTest, Back_GeneratesNewPage) {
EXPECT_FALSE(controller.CanGoBack());
EXPECT_TRUE(controller.CanGoForward());
- main_test_rfh()->PrepareForCommit(url3);
+ main_test_rfh()->PrepareForCommitWithServerRedirect(url3);
main_test_rfh()->SendNavigate(2, url3);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1569,15 +1575,19 @@ TEST_F(NavigationControllerTest, Back_OtherBackPending) {
const GURL kUrl3("http://foo/3");
// First navigate three places so we have some back history.
- main_test_rfh()->PrepareForCommit(kUrl1);
+ main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl1, true);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, kUrl1);
- main_test_rfh()->PrepareForCommit(kUrl2);
+ main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, true);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(1, kUrl2);
- main_test_rfh()->PrepareForCommit(kUrl3);
+ main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl3, true);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(2, kUrl3);
// With nothing pending, say we get a navigation to the second entry.
- main_test_rfh()->PrepareForCommit(kUrl2);
+ main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, true);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(1, kUrl2);
// We know all the entries have the same site instance, so we can just grab
@@ -1593,7 +1603,7 @@ TEST_F(NavigationControllerTest, Back_OtherBackPending) {
// Now go forward to the last item again and say it was committed.
controller.GoForward();
- main_test_rfh()->PrepareForCommit(kUrl3);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(2, kUrl3);
// Now start going back one to the second page. It will be pending.
@@ -1601,9 +1611,10 @@ TEST_F(NavigationControllerTest, Back_OtherBackPending) {
EXPECT_EQ(1, controller.GetPendingEntryIndex());
EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
- // Not synthesize a totally new back event to the first page. This will not
+ // Now synthesize a totally new back event to the first page. This will not
// match the pending one.
- main_test_rfh()->PrepareForCommit(kUrl1);
+ main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl1, true);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, kUrl1);
// The committed navigation should clear the pending entry.
@@ -1623,18 +1634,18 @@ TEST_F(NavigationControllerTest, Forward) {
const GURL url1("http://foo1");
const GURL url2("http://foo2");
- main_test_rfh()->PrepareForCommit(url1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
- main_test_rfh()->PrepareForCommit(url2);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(1, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
controller.GoBack();
- main_test_rfh()->PrepareForCommit(url1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1659,7 +1670,7 @@ TEST_F(NavigationControllerTest, Forward) {
EXPECT_GE(controller.GetEntryAtIndex(0)->GetTimestamp(),
controller.GetEntryAtIndex(1)->GetTimestamp());
- main_test_rfh()->PrepareForCommit(url2);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(1, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1692,17 +1703,17 @@ TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) {
const GURL url2("http://foo2");
const GURL url3("http://foo3");
- main_test_rfh()->PrepareForCommit(url1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
- main_test_rfh()->PrepareForCommit(url2);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(1, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
controller.GoBack();
- main_test_rfh()->PrepareForCommit(url1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1719,7 +1730,7 @@ TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) {
EXPECT_TRUE(controller.CanGoBack());
EXPECT_FALSE(controller.CanGoForward());
- main_test_rfh()->PrepareForCommit(url3);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(2, url3);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -2384,7 +2395,7 @@ TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) {
GURL url(base::StringPrintf("http://www.a.com/%d", url_index));
controller.LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(url);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(url_index, url);
}
@@ -2397,7 +2408,7 @@ TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) {
GURL url(base::StringPrintf("http://www.a.com/%d", url_index));
controller.LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(url);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(url_index, url);
url_index++;
@@ -2416,7 +2427,7 @@ TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) {
url = GURL(base::StringPrintf("http:////www.a.com/%d", url_index));
controller.LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(url);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(url_index, url);
url_index++;
}
@@ -2581,18 +2592,18 @@ TEST_F(NavigationControllerTest, Interstitial) {
const GURL url1("http://foo");
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(url1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, url1);
// Now navigate somewhere with an interstitial.
const GURL url2("http://bar");
- controller.LoadURL(
- url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ controller.LoadURL(url2, Referrer(), ui::PAGE_TRANSITION_TYPED,
+ std::string());
controller.GetPendingEntry()->set_page_type(PAGE_TYPE_INTERSTITIAL);
// At this point the interstitial will be displayed and the load will still
// be pending. If the user continues, the load will commit.
- main_test_rfh()->PrepareForCommit(url2);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(1, url2);
// The page should be a normal page again.
@@ -2613,23 +2624,23 @@ TEST_F(NavigationControllerTest, RemoveEntry) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(url1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, url1);
controller.LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(url2);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(1, url2);
controller.LoadURL(
url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(url3);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(2, url3);
controller.LoadURL(
url4, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(url4);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(3, url4);
controller.LoadURL(
url5, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(url5);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(4, url5);
// Try to remove the last entry. Will fail because it is the current entry.
@@ -2644,7 +2655,7 @@ TEST_F(NavigationControllerTest, RemoveEntry) {
EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 2));
// Now commit and delete the last entry.
- main_test_rfh()->PrepareForCommit(url4);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(3, url4);
EXPECT_TRUE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1));
EXPECT_EQ(4, controller.GetEntryCount());
@@ -2675,15 +2686,15 @@ TEST_F(NavigationControllerTest, RemoveEntryWithPending) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(url1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, url1);
controller.LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(url2);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(1, url2);
controller.LoadURL(
url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(url3);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(2, url3);
// Go back, but don't commit yet. Check that we can't delete the current
@@ -2702,7 +2713,7 @@ TEST_F(NavigationControllerTest, RemoveEntryWithPending) {
EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
// Now commit and ensure we land on the right entry.
- main_test_rfh()->PrepareForCommit(url2);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(1, url2);
EXPECT_EQ(2, controller.GetEntryCount());
EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
@@ -2725,11 +2736,11 @@ TEST_F(NavigationControllerTest, TransientEntry) {
controller.LoadURL(
url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(url0);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, url0);
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(url1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(1, url1);
notifications.Reset();
@@ -2756,7 +2767,7 @@ TEST_F(NavigationControllerTest, TransientEntry) {
// Navigate.
controller.LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(url2);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(2, url2);
// We should have navigated, transient entry should be gone.
@@ -2768,7 +2779,8 @@ TEST_F(NavigationControllerTest, TransientEntry) {
transient_entry->SetURL(transient_url);
controller.SetTransientEntry(transient_entry);
EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL());
- main_test_rfh()->PrepareForCommit(url3);
+ main_test_rfh()->SendRendererInitiatedNavigationRequest(url3, true);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(3, url3);
// Transient entry should be gone.
EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL());
@@ -2781,7 +2793,7 @@ TEST_F(NavigationControllerTest, TransientEntry) {
transient_entry->SetURL(transient_url);
controller.SetTransientEntry(transient_entry);
EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL());
- main_test_rfh()->PrepareForCommit(url4);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(4, url4);
EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL());
EXPECT_EQ(controller.GetEntryCount(), 5);
@@ -2797,7 +2809,9 @@ TEST_F(NavigationControllerTest, TransientEntry) {
// Transient entry should be gone.
EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL());
EXPECT_EQ(controller.GetEntryCount(), 5);
- main_test_rfh()->PrepareForCommit(url3);
+
+ main_test_rfh()->SendRendererInitiatedNavigationRequest(url3, false);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(3, url3);
// Add a transient and go to an entry before the current one.
@@ -2811,7 +2825,7 @@ TEST_F(NavigationControllerTest, TransientEntry) {
EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL());
// Visible entry does not update for history navigations until commit.
EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL());
- main_test_rfh()->PrepareForCommit(url1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(1, url1);
EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL());
@@ -2826,7 +2840,7 @@ TEST_F(NavigationControllerTest, TransientEntry) {
// land on url2 (which is visible after the commit).
EXPECT_EQ(url2, controller.GetPendingEntry()->GetURL());
EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL());
- main_test_rfh()->PrepareForCommit(url2);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(2, url2);
EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL());
@@ -2841,7 +2855,7 @@ TEST_F(NavigationControllerTest, TransientEntry) {
EXPECT_FALSE(controller.GetTransientEntry());
EXPECT_EQ(url3, controller.GetPendingEntry()->GetURL());
EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL());
- main_test_rfh()->PrepareForCommit(url3);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(3, url3);
EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL());
@@ -2850,7 +2864,9 @@ TEST_F(NavigationControllerTest, TransientEntry) {
transient_entry->SetURL(transient_url);
controller.SetTransientEntry(transient_entry);
EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL());
- main_test_rfh()->PrepareForCommit(url3_ref);
+
+ main_test_rfh()->SendRendererInitiatedNavigationRequest(url3_ref, false);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(3, url3_ref);
// Transient entry should be gone.
EXPECT_FALSE(controller.GetTransientEntry());
@@ -2875,7 +2891,7 @@ TEST_F(NavigationControllerTest, ReloadTransient) {
// Load |url0|, and start a pending navigation to |url1|.
controller.LoadURL(
url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit(url0);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, url0);
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
@@ -2898,7 +2914,7 @@ TEST_F(NavigationControllerTest, ReloadTransient) {
EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0);
// Load of |transient_url| completes.
- main_test_rfh()->PrepareForCommit(transient_url);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(1, transient_url);
ASSERT_EQ(controller.GetEntryCount(), 2);
EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0);
@@ -2977,7 +2993,7 @@ TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) {
url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
EXPECT_EQ(url0, controller.GetPendingEntry()->GetURL());
EXPECT_EQ(url0, controller.GetVisibleEntry()->GetURL());
- main_test_rfh()->PrepareForCommit(url0);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(0, url0);
// For link clicks (renderer-initiated navigations), the pending entry should
@@ -2991,7 +3007,7 @@ TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) {
// After commit, both visible should be updated, there should be no pending
// entry, and we should no longer treat the entry as renderer-initiated.
- main_test_rfh()->PrepareForCommit(url1);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(1, url1);
EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL());
EXPECT_FALSE(controller.GetPendingEntry());
@@ -4125,7 +4141,7 @@ TEST_F(NavigationControllerTest, PruneAllButLastCommittedForPendingNotInList) {
EXPECT_EQ(1, controller.GetEntryCount());
// Try to commit the pending entry.
- main_test_rfh()->PrepareForCommit(url3);
+ main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigate(2, url3);
EXPECT_EQ(-1, controller.GetPendingEntryIndex());
EXPECT_FALSE(controller.GetPendingEntry());
@@ -4411,10 +4427,11 @@ TEST_F(NavigationControllerTest, ClearHistoryList) {
ASSERT_TRUE(entry);
EXPECT_TRUE(entry->should_clear_history_list());
- // Assume that the RF correctly cleared its history and commit the navigation.
+ // Assume that the RenderFrame correctly cleared its history and commit the
+ // navigation.
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBrowserSideNavigation)) {
- contents()->GetMainFrame()->PrepareForCommit(entry->GetURL());
+ contents()->GetMainFrame()->SendBeforeUnloadACK(true);
}
contents()->GetPendingMainFrame()->
set_simulate_history_list_was_cleared(true);
diff --git a/content/browser/frame_host/navigator_impl_unittest.cc b/content/browser/frame_host/navigator_impl_unittest.cc
index 7eb3be6..d7e41e5 100644
--- a/content/browser/frame_host/navigator_impl_unittest.cc
+++ b/content/browser/frame_host/navigator_impl_unittest.cc
@@ -163,7 +163,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
// Start a renderer-initiated non-user-initiated navigation.
process()->sink().ClearMessages();
- main_test_rfh()->SendBeginNavigationWithURL(kUrl2, false);
+ main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, false);
FrameTreeNode* node = main_test_rfh()->frame_tree_node();
NavigationRequest* request = GetNavigationRequestForFrameTreeNode(node);
ASSERT_TRUE(request);
@@ -421,21 +421,14 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, RedirectCrossSite) {
EXPECT_FALSE(GetSpeculativeRenderFrameHost(node));
// It then redirects to another site.
- net::RedirectInfo redirect_info;
- redirect_info.status_code = 302;
- redirect_info.new_method = "GET";
- redirect_info.new_url = kUrl2;
- redirect_info.new_first_party_for_cookies = kUrl2;
- scoped_refptr<ResourceResponse> response(new ResourceResponse);
- GetLoaderForNavigationRequest(main_request)->CallOnRequestRedirected(
- redirect_info, response);
+ GetLoaderForNavigationRequest(main_request)->SimulateServerRedirect(kUrl2);
// The redirect should have been followed.
EXPECT_EQ(1, GetLoaderForNavigationRequest(main_request)->redirect_count());
EXPECT_FALSE(GetSpeculativeRenderFrameHost(node));
// Have the RenderFrameHost commit the navigation.
- response = new ResourceResponse;
+ scoped_refptr<ResourceResponse> response(new ResourceResponse);
GetLoaderForNavigationRequest(main_request)->CallOnResponseStarted(
response, MakeEmptyStream());
TestRenderFrameHost* final_speculative_rfh =
@@ -556,7 +549,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
// Now receive a renderer-initiated user-initiated request. It should replace
// the current NavigationRequest.
- main_test_rfh()->SendBeginNavigationWithURL(kUrl2, true);
+ main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, true);
NavigationRequest* request2 = GetNavigationRequestForFrameTreeNode(node);
ASSERT_TRUE(request2);
EXPECT_EQ(kUrl2, request2->common_params().url);
@@ -605,7 +598,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
// Start a renderer-initiated user-initiated navigation to the 1st URL.
process()->sink().ClearMessages();
- main_test_rfh()->SendBeginNavigationWithURL(kUrl1, true);
+ main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl1, true);
NavigationRequest* request1 = GetNavigationRequestForFrameTreeNode(node);
ASSERT_TRUE(request1);
EXPECT_EQ(kUrl1, request1->common_params().url);
@@ -615,7 +608,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
// Now receive a renderer-initiated non-user-initiated request. Nothing should
// change.
- main_test_rfh()->SendBeginNavigationWithURL(kUrl2, false);
+ main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, false);
NavigationRequest* request2 = GetNavigationRequestForFrameTreeNode(node);
ASSERT_TRUE(request2);
EXPECT_EQ(request1, request2);
@@ -660,7 +653,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
// Now receive a renderer-initiated non-user-initiated request. Nothing should
// change.
- main_test_rfh()->SendBeginNavigationWithURL(kUrl2, false);
+ main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, false);
NavigationRequest* request2 = GetNavigationRequestForFrameTreeNode(node);
ASSERT_TRUE(request2);
EXPECT_EQ(request1, request2);
@@ -699,7 +692,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
// Start a renderer-initiated non-user-initiated navigation to the 1st URL.
process()->sink().ClearMessages();
- main_test_rfh()->SendBeginNavigationWithURL(kUrl1, false);
+ main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl1, false);
NavigationRequest* request1 = GetNavigationRequestForFrameTreeNode(node);
ASSERT_TRUE(request1);
EXPECT_EQ(kUrl1, request1->common_params().url);
@@ -711,7 +704,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
EXPECT_TRUE(loader1);
// Now receive a 2nd similar request that should replace the current one.
- main_test_rfh()->SendBeginNavigationWithURL(kUrl2, false);
+ main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, false);
NavigationRequest* request2 = GetNavigationRequestForFrameTreeNode(node);
EXPECT_EQ(kUrl2, request2->common_params().url);
EXPECT_FALSE(request2->browser_initiated());
@@ -750,7 +743,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, Reload) {
ASSERT_TRUE(main_request != NULL);
EXPECT_EQ(FrameMsg_Navigate_Type::RELOAD,
main_request->common_params().navigation_type);
- main_test_rfh()->PrepareForCommit(kUrl);
+ main_test_rfh()->PrepareForCommit();
EXPECT_FALSE(GetSpeculativeRenderFrameHost(node));
main_test_rfh()->SendNavigate(0, kUrl);
@@ -765,7 +758,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, Reload) {
ASSERT_TRUE(main_request != NULL);
EXPECT_EQ(FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE,
main_request->common_params().navigation_type);
- main_test_rfh()->PrepareForCommit(kUrl);
+ main_test_rfh()->PrepareForCommit();
EXPECT_FALSE(GetSpeculativeRenderFrameHost(node));
}
@@ -843,14 +836,8 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
NavigationRequest* main_request = GetNavigationRequestForFrameTreeNode(node);
ASSERT_TRUE(main_request);
const GURL kUrlRedirect("https://www.google.com/");
- net::RedirectInfo redirect_info;
- redirect_info.status_code = 302;
- redirect_info.new_method = "GET";
- redirect_info.new_url = kUrlRedirect;
- redirect_info.new_first_party_for_cookies = kUrlRedirect;
- scoped_refptr<ResourceResponse> response(new ResourceResponse);
GetLoaderForNavigationRequest(main_request)
- ->CallOnRequestRedirected(redirect_info, response);
+ ->SimulateServerRedirect(kUrlRedirect);
EXPECT_EQ(init_site_instance_id, main_test_rfh()->GetSiteInstance()->GetId());
speculative_rfh = GetSpeculativeRenderFrameHost(node);
ASSERT_TRUE(speculative_rfh);
@@ -863,7 +850,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
// Commit the navigation with Navigator by simulating the call to
// OnResponseStarted.
- response = new ResourceResponse;
+ scoped_refptr<ResourceResponse> response(new ResourceResponse);
GetLoaderForNavigationRequest(main_request)
->CallOnResponseStarted(response, MakeEmptyStream());
speculative_rfh = GetSpeculativeRenderFrameHost(node);
@@ -975,7 +962,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, DataUrls) {
// Do a renderer-initiated navigation to a data url. The request should not be
// sent to the IO thread, nor committed.
TestRenderFrameHost* main_rfh = main_test_rfh();
- main_rfh->SendBeginNavigationWithURL(kUrl2, true);
+ main_rfh->SendRendererInitiatedNavigationRequest(kUrl2, true);
navigation_request = GetNavigationRequestForFrameTreeNode(node);
ASSERT_TRUE(navigation_request);
EXPECT_EQ(NavigationRequest::RESPONSE_STARTED,
diff --git a/content/browser/frame_host/render_frame_host_manager_unittest.cc b/content/browser/frame_host/render_frame_host_manager_unittest.cc
index 34e48e5..23abd2a 100644
--- a/content/browser/frame_host/render_frame_host_manager_unittest.cc
+++ b/content/browser/frame_host/render_frame_host_manager_unittest.cc
@@ -272,7 +272,7 @@ class RenderFrameHostManagerTest : public RenderViewHostImplTestHarness {
// is replaced without a pending frame being created, and we don't get the
// right values for the RFH to navigate: we try to use the old one that has
// been deleted in the meantime.
- contents()->GetMainFrame()->PrepareForCommit(url);
+ contents()->GetMainFrame()->PrepareForCommit();
TestRenderFrameHost* old_rfh = contents()->GetMainFrame();
TestRenderFrameHost* active_rfh = contents()->GetPendingMainFrame()
@@ -351,7 +351,7 @@ class RenderFrameHostManagerTest : public RenderViewHostImplTestHarness {
// Navigate to a cross-site URL.
contents()->GetController().LoadURL(
kDestUrl, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
- contents()->GetMainFrame()->PrepareForCommit(kDestUrl);
+ contents()->GetMainFrame()->PrepareForCommit();
EXPECT_TRUE(contents()->cross_navigation_pending());
// Manually increase the number of active frames in the
@@ -430,7 +430,7 @@ TEST_F(RenderFrameHostManagerTest, NewTabPageProcesses) {
// we use the committed one.
contents2->GetController().LoadURL(
kChromeUrl, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
- contents2->GetMainFrame()->PrepareForCommit(kChromeUrl);
+ contents2->GetMainFrame()->PrepareForCommit();
TestRenderFrameHost* ntp_rfh2 = contents2->GetMainFrame();
EXPECT_FALSE(contents2->cross_navigation_pending());
ntp_rfh2->SendNavigate(100, kChromeUrl);
@@ -439,7 +439,7 @@ TEST_F(RenderFrameHostManagerTest, NewTabPageProcesses) {
// requiring a beforeunload ack.
contents2->GetController().LoadURL(
kDestUrl, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
- contents2->GetMainFrame()->PrepareForCommit(kDestUrl);
+ contents2->GetMainFrame()->PrepareForCommit();
EXPECT_TRUE(contents2->cross_navigation_pending());
TestRenderFrameHost* dest_rfh2 = contents2->GetPendingMainFrame();
ASSERT_TRUE(dest_rfh2);
@@ -460,7 +460,7 @@ TEST_F(RenderFrameHostManagerTest, NewTabPageProcesses) {
contents2->GetController().LoadURL(
kChromeUrl, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
- contents2->GetMainFrame()->PrepareForCommit(kChromeUrl);
+ contents2->GetMainFrame()->PrepareForCommit();
contents2->GetPendingMainFrame()->SendNavigate(102, kChromeUrl);
EXPECT_NE(contents()->GetMainFrame()->GetSiteInstance(),
@@ -795,7 +795,7 @@ TEST_F(RenderFrameHostManagerTest, AlwaysSendEnableViewSourceMode) {
controller().LoadURL(
kUrl, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
// Simulate response from RenderFrame for DispatchBeforeUnload.
- contents()->GetMainFrame()->PrepareForCommit(kUrl);
+ contents()->GetMainFrame()->PrepareForCommit();
ASSERT_TRUE(contents()->GetPendingMainFrame())
<< "Expected new pending RenderFrameHost to be created.";
RenderFrameHost* last_rfh = contents()->GetPendingMainFrame();
@@ -815,7 +815,7 @@ TEST_F(RenderFrameHostManagerTest, AlwaysSendEnableViewSourceMode) {
// Navigate, again.
controller().LoadURL(
kUrl, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- contents()->GetMainFrame()->PrepareForCommit(kUrl);
+ contents()->GetMainFrame()->PrepareForCommit();
// The same RenderViewHost should be reused.
EXPECT_FALSE(contents()->GetPendingMainFrame());
EXPECT_TRUE(last_rfh == contents()->GetMainFrame());
@@ -1075,7 +1075,7 @@ TEST_F(RenderFrameHostManagerTest, PageDoesBackAndReload) {
// Now let's simulate the evil page calling history.back().
contents()->OnGoToEntryAtOffset(-1);
- contents()->GetMainFrame()->PrepareForCommit(kUrl1);
+ contents()->GetMainFrame()->PrepareForCommit();
// We should have a new pending RFH.
// Note that in this case, the navigation has not committed, so evil_rfh will
// not be deleted yet.
@@ -1160,7 +1160,7 @@ TEST_F(RenderFrameHostManagerTest, NavigateAfterMissingSwapOutACK) {
// (http://crbug.com/93427).
contents()->GetController().GoBack();
EXPECT_TRUE(rfh2->IsWaitingForBeforeUnloadACK());
- contents()->GetMainFrame()->PrepareForCommit(kUrl1);
+ contents()->GetMainFrame()->PrepareForCommit();
EXPECT_FALSE(rfh2->IsWaitingForBeforeUnloadACK());
// The back navigation commits.
@@ -1171,7 +1171,7 @@ TEST_F(RenderFrameHostManagerTest, NavigateAfterMissingSwapOutACK) {
// We should be able to navigate forward.
contents()->GetController().GoForward();
- contents()->GetMainFrame()->PrepareForCommit(kUrl2);
+ contents()->GetMainFrame()->PrepareForCommit();
const NavigationEntry* entry2 = contents()->GetController().GetPendingEntry();
rfh2->SendNavigate(entry2->GetPageID(), entry2->GetURL());
EXPECT_EQ(rfh2, main_test_rfh());
@@ -1342,7 +1342,7 @@ TEST_F(RenderFrameHostManagerTest, DisownOpenerDuringNavigation) {
// Start a back navigation so that rfh1 becomes the pending RFH.
contents()->GetController().GoBack();
- contents()->GetMainFrame()->PrepareForCommit(kUrl1);
+ contents()->GetMainFrame()->PrepareForCommit();
// Disown the opener from rfh2.
rfh2->DidDisownOpener();
@@ -1383,7 +1383,7 @@ TEST_F(RenderFrameHostManagerTest, DisownOpenerAfterNavigation) {
// Commit a back navigation before the DidDisownOpener message arrives.
// rfh1 will be kept alive because of the opener tab.
contents()->GetController().GoBack();
- contents()->GetMainFrame()->PrepareForCommit(kUrl1);
+ contents()->GetMainFrame()->PrepareForCommit();
const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry();
rfh1->SendNavigate(entry1->GetPageID(), entry1->GetURL());
@@ -1449,7 +1449,7 @@ TEST_F(RenderFrameHostManagerTest, CleanUpSwappedOutRVHOnProcessCrash) {
// Reload the initial tab. This should recreate the opener's swapped out RVH
// in the original SiteInstance.
contents()->GetController().Reload(true);
- contents()->GetMainFrame()->PrepareForCommit(kUrl1);
+ contents()->GetMainFrame()->PrepareForCommit();
EXPECT_EQ(opener1_manager->GetSwappedOutRenderViewHost(
rvh1->GetSiteInstance())->GetRoutingID(),
test_rvh()->opener_route_id());
@@ -1644,7 +1644,7 @@ TEST_F(RenderFrameHostManagerTest, CloseWithPendingWhileUnresponsive) {
kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBrowserSideNavigation)) {
- rfh1->PrepareForCommit(kUrl2);
+ rfh1->PrepareForCommit();
}
EXPECT_TRUE(contents()->cross_navigation_pending());
@@ -1669,7 +1669,7 @@ TEST_F(RenderFrameHostManagerTest, DeleteFrameAfterSwapOutACK) {
// Navigate to new site, simulating onbeforeunload approval.
controller().LoadURL(
kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
- contents()->GetMainFrame()->PrepareForCommit(kUrl2);
+ contents()->GetMainFrame()->PrepareForCommit();
EXPECT_TRUE(contents()->cross_navigation_pending());
EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state());
TestRenderFrameHost* rfh2 = contents()->GetPendingMainFrame();
@@ -1717,7 +1717,7 @@ TEST_F(RenderFrameHostManagerTest, SwapOutFrameAfterSwapOutACK) {
// Navigate to new site, simulating onbeforeunload approval.
controller().LoadURL(
kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
- contents()->GetMainFrame()->PrepareForCommit(kUrl2);
+ contents()->GetMainFrame()->PrepareForCommit();
EXPECT_TRUE(contents()->cross_navigation_pending());
EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state());
TestRenderFrameHost* rfh2 = contents()->GetPendingMainFrame();
@@ -1760,7 +1760,7 @@ TEST_F(RenderFrameHostManagerTest,
// Navigate to new site, simulating onbeforeunload approval.
controller().LoadURL(
kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
- rfh1->PrepareForCommit(kUrl2);
+ rfh1->PrepareForCommit();
EXPECT_TRUE(contents()->cross_navigation_pending());
TestRenderFrameHost* rfh2 = contents()->GetPendingMainFrame();
diff --git a/content/browser/web_contents/web_contents_impl_unittest.cc b/content/browser/web_contents/web_contents_impl_unittest.cc
index 187f3c4..5e322ef 100644
--- a/content/browser/web_contents/web_contents_impl_unittest.cc
+++ b/content/browser/web_contents/web_contents_impl_unittest.cc
@@ -483,7 +483,7 @@ TEST_F(WebContentsImplTest, CrossSiteBoundaries) {
const GURL url("http://www.google.com");
controller().LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- orig_rfh->PrepareForCommit(url);
+ orig_rfh->PrepareForCommit();
contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
// Keep the number of active frames in orig_rfh's SiteInstance non-zero so
@@ -501,7 +501,7 @@ TEST_F(WebContentsImplTest, CrossSiteBoundaries) {
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBrowserSideNavigation)) {
- orig_rfh->PrepareForCommit(url2);
+ orig_rfh->PrepareForCommit();
}
EXPECT_TRUE(contents()->cross_navigation_pending());
EXPECT_EQ(url, contents()->GetLastCommittedURL());
@@ -520,7 +520,6 @@ TEST_F(WebContentsImplTest, CrossSiteBoundaries) {
}
// DidNavigate from the pending page
- pending_rfh->PrepareForCommit(url2);
contents()->TestDidNavigate(
pending_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED);
SiteInstance* instance2 = contents()->GetSiteInstance();
@@ -547,7 +546,7 @@ TEST_F(WebContentsImplTest, CrossSiteBoundaries) {
controller().GoBack();
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBrowserSideNavigation)) {
- contents()->GetMainFrame()->PrepareForCommit(url);
+ contents()->GetMainFrame()->PrepareForCommit();
}
TestRenderFrameHost* goback_rfh = contents()->GetPendingMainFrame();
EXPECT_EQ(orig_rfh, goback_rfh);
@@ -591,7 +590,7 @@ TEST_F(WebContentsImplTest, CrossSiteBoundariesAfterCrash) {
const GURL url("http://www.google.com");
controller().LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- contents()->GetMainFrame()->PrepareForCommit(url);
+ contents()->GetMainFrame()->PrepareForCommit();
contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
EXPECT_FALSE(contents()->cross_navigation_pending());
@@ -605,7 +604,7 @@ TEST_F(WebContentsImplTest, CrossSiteBoundariesAfterCrash) {
const GURL url2("http://www.yahoo.com");
controller().LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- contents()->GetMainFrame()->PrepareForCommit(url2);
+ contents()->GetMainFrame()->PrepareForCommit();
TestRenderFrameHost* new_rfh = contents()->GetMainFrame();
EXPECT_FALSE(contents()->cross_navigation_pending());
EXPECT_TRUE(contents()->GetPendingMainFrame() == NULL);
@@ -637,7 +636,7 @@ TEST_F(WebContentsImplTest, NavigateTwoTabsCrossSite) {
const GURL url("http://www.google.com");
controller().LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- contents()->GetMainFrame()->PrepareForCommit(url);
+ contents()->GetMainFrame()->PrepareForCommit();
contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
// Open a new contents with the same SiteInstance, navigated to the same site.
@@ -646,7 +645,7 @@ TEST_F(WebContentsImplTest, NavigateTwoTabsCrossSite) {
contents2->GetController().LoadURL(url, Referrer(),
ui::PAGE_TRANSITION_TYPED,
std::string());
- contents2->GetMainFrame()->PrepareForCommit(url);
+ contents2->GetMainFrame()->PrepareForCommit();
// Need this page id to be 2 since the site instance is the same (which is the
// scope of page IDs) and we want to consider this a new page.
contents2->TestDidNavigate(
@@ -656,7 +655,7 @@ TEST_F(WebContentsImplTest, NavigateTwoTabsCrossSite) {
const GURL url2a("http://www.yahoo.com");
controller().LoadURL(
url2a, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- orig_rfh->PrepareForCommit(url2a);
+ orig_rfh->PrepareForCommit();
TestRenderFrameHost* pending_rfh_a = contents()->GetPendingMainFrame();
contents()->TestDidNavigate(
pending_rfh_a, 1, url2a, ui::PAGE_TRANSITION_TYPED);
@@ -669,7 +668,7 @@ TEST_F(WebContentsImplTest, NavigateTwoTabsCrossSite) {
ui::PAGE_TRANSITION_TYPED,
std::string());
TestRenderFrameHost* rfh2 = contents2->GetMainFrame();
- rfh2->PrepareForCommit(url2b);
+ rfh2->PrepareForCommit();
TestRenderFrameHost* pending_rfh_b = contents2->GetPendingMainFrame();
EXPECT_TRUE(pending_rfh_b != NULL);
EXPECT_TRUE(contents2->cross_navigation_pending());
@@ -704,7 +703,7 @@ TEST_F(WebContentsImplTest, NavigateFromSitelessUrl) {
const GURL native_url("non-site-url://stuffandthings");
controller().LoadURL(
native_url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- contents()->GetMainFrame()->PrepareForCommit(native_url);
+ contents()->GetMainFrame()->PrepareForCommit();
contents()->TestDidNavigate(
orig_rfh, 1, native_url, ui::PAGE_TRANSITION_TYPED);
@@ -721,7 +720,7 @@ TEST_F(WebContentsImplTest, NavigateFromSitelessUrl) {
const GURL url("http://www.google.com");
controller().LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- contents()->GetMainFrame()->PrepareForCommit(url);
+ contents()->GetMainFrame()->PrepareForCommit();
EXPECT_FALSE(contents()->cross_navigation_pending());
EXPECT_EQ(native_url, contents()->GetLastCommittedURL());
EXPECT_EQ(url, contents()->GetVisibleURL());
@@ -744,7 +743,7 @@ TEST_F(WebContentsImplTest, NavigateFromSitelessUrl) {
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBrowserSideNavigation)) {
- orig_rfh->PrepareForCommit(url2);
+ orig_rfh->PrepareForCommit();
}
EXPECT_TRUE(contents()->cross_navigation_pending());
EXPECT_EQ(url, contents()->GetLastCommittedURL());
@@ -854,7 +853,7 @@ TEST_F(WebContentsImplTest, NavigateFromRestoredRegularUrl) {
ASSERT_EQ(0u, entries.size());
ASSERT_EQ(1, controller().GetEntryCount());
controller().GoToIndex(0);
- orig_rfh->PrepareForCommit(regular_url);
+ orig_rfh->PrepareForCommit();
contents()->TestDidNavigate(
orig_rfh, 0, regular_url, ui::PAGE_TRANSITION_RELOAD);
EXPECT_EQ(orig_instance, contents()->GetSiteInstance());
@@ -864,7 +863,7 @@ TEST_F(WebContentsImplTest, NavigateFromRestoredRegularUrl) {
const GURL url("http://www.google.com");
controller().LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- orig_rfh->PrepareForCommit(url);
+ orig_rfh->PrepareForCommit();
contents()->TestDidNavigate(
contents()->GetPendingMainFrame(), 2, url, ui::PAGE_TRANSITION_TYPED);
EXPECT_NE(orig_instance, contents()->GetSiteInstance());
@@ -882,14 +881,14 @@ TEST_F(WebContentsImplTest, FindOpenerRVHWhenPending) {
const GURL url("http://www.google.com");
controller().LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- orig_rfh->PrepareForCommit(url);
+ orig_rfh->PrepareForCommit();
contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
// Start to navigate first tab to a new site, so that it has a pending RVH.
const GURL url2("http://www.yahoo.com");
controller().LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- orig_rfh->PrepareForCommit(url2);
+ orig_rfh->PrepareForCommit();
TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame();
// While it is still pending, simulate opening a new tab with the first tab
@@ -913,7 +912,7 @@ TEST_F(WebContentsImplTest, CrossSiteComparesAgainstCurrentPage) {
const GURL url("http://www.google.com");
controller().LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- contents()->GetMainFrame()->PrepareForCommit(url);
+ contents()->GetMainFrame()->PrepareForCommit();
contents()->TestDidNavigate(
orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
@@ -924,7 +923,7 @@ TEST_F(WebContentsImplTest, CrossSiteComparesAgainstCurrentPage) {
contents2->GetController().LoadURL(url2, Referrer(),
ui::PAGE_TRANSITION_TYPED,
std::string());
- contents2->GetMainFrame()->PrepareForCommit(url2);
+ contents2->GetMainFrame()->PrepareForCommit();
// The first RVH in contents2 isn't live yet, so we shortcut the cross site
// pending.
TestRenderFrameHost* rfh2 = contents2->GetMainFrame();
@@ -948,7 +947,7 @@ TEST_F(WebContentsImplTest, CrossSiteComparesAgainstCurrentPage) {
controller().LoadURL(
url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
EXPECT_FALSE(contents()->cross_navigation_pending());
- contents()->GetMainFrame()->PrepareForCommit(url3);
+ contents()->GetMainFrame()->PrepareForCommit();
contents()->TestDidNavigate(
orig_rfh, 3, url3, ui::PAGE_TRANSITION_TYPED);
SiteInstance* instance4 = contents()->GetSiteInstance();
@@ -965,7 +964,7 @@ TEST_F(WebContentsImplTest, CrossSiteUnloadHandlers) {
const GURL url("http://www.google.com");
controller().LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- contents()->GetMainFrame()->PrepareForCommit(url);
+ contents()->GetMainFrame()->PrepareForCommit();
contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
EXPECT_FALSE(contents()->cross_navigation_pending());
EXPECT_EQ(orig_rfh, contents()->GetMainFrame());
@@ -987,7 +986,7 @@ TEST_F(WebContentsImplTest, CrossSiteUnloadHandlers) {
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK());
now = base::TimeTicks::Now();
- orig_rfh->PrepareForCommit(url2);
+ orig_rfh->PrepareForCommit();
EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK());
EXPECT_TRUE(contents()->cross_navigation_pending());
TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame();
@@ -1015,7 +1014,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationPreempted) {
const GURL url("http://www.google.com");
controller().LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- contents()->GetMainFrame()->PrepareForCommit(url);
+ contents()->GetMainFrame()->PrepareForCommit();
contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
EXPECT_FALSE(contents()->cross_navigation_pending());
EXPECT_EQ(orig_rfh, contents()->GetMainFrame());
@@ -1025,7 +1024,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationPreempted) {
controller().LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK());
- orig_rfh->PrepareForCommit(url2);
+ orig_rfh->PrepareForCommit();
EXPECT_TRUE(contents()->cross_navigation_pending());
// Suppose the original renderer navigates before the new one is ready.
@@ -1046,7 +1045,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationBackPreempted) {
controller().LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
TestRenderFrameHost* ntp_rfh = contents()->GetMainFrame();
- ntp_rfh->PrepareForCommit(url1);
+ ntp_rfh->PrepareForCommit();
contents()->TestDidNavigate(ntp_rfh, 1, url1, ui::PAGE_TRANSITION_TYPED);
NavigationEntry* entry1 = controller().GetLastCommittedEntry();
SiteInstance* instance1 = contents()->GetSiteInstance();
@@ -1069,7 +1068,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationBackPreempted) {
// Simulate beforeunload approval.
EXPECT_TRUE(ntp_rfh->IsWaitingForBeforeUnloadACK());
base::TimeTicks now = base::TimeTicks::Now();
- ntp_rfh->PrepareForCommit(url2);
+ ntp_rfh->PrepareForCommit();
// DidNavigate from the pending page.
contents()->TestDidNavigate(
@@ -1092,7 +1091,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationBackPreempted) {
controller().LoadURL(
url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
EXPECT_FALSE(contents()->cross_navigation_pending());
- contents()->GetMainFrame()->PrepareForCommit(url3);
+ contents()->GetMainFrame()->PrepareForCommit();
contents()->TestDidNavigate(
google_rfh, 2, url3, ui::PAGE_TRANSITION_TYPED);
NavigationEntry* entry3 = controller().GetLastCommittedEntry();
@@ -1120,7 +1119,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationBackPreempted) {
// Simulate beforeunload approval.
EXPECT_TRUE(google_rfh->IsWaitingForBeforeUnloadACK());
now = base::TimeTicks::Now();
- google_rfh->PrepareForCommit(url2);
+ google_rfh->PrepareForCommit();
google_rfh->OnMessageReceived(
FrameHostMsg_BeforeUnload_ACK(0, true, now, now));
@@ -1152,7 +1151,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationNotPreemptedByFrame) {
const GURL url("http://www.google.com");
controller().LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- contents()->GetMainFrame()->PrepareForCommit(url);
+ contents()->GetMainFrame()->PrepareForCommit();
contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
EXPECT_FALSE(contents()->cross_navigation_pending());
EXPECT_EQ(orig_rfh, contents()->GetMainFrame());
@@ -1171,7 +1170,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationNotPreemptedByFrame) {
// Now simulate the onbeforeunload approval and verify the navigation is
// not canceled.
- orig_rfh->PrepareForCommit(url2);
+ orig_rfh->PrepareForCommit();
EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK());
EXPECT_TRUE(contents()->cross_navigation_pending());
}
@@ -1220,7 +1219,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationCanceled) {
const GURL url("http://www.google.com");
controller().LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- contents()->GetMainFrame()->PrepareForCommit(url);
+ contents()->GetMainFrame()->PrepareForCommit();
contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
EXPECT_FALSE(contents()->cross_navigation_pending());
EXPECT_EQ(orig_rfh, contents()->GetMainFrame());
@@ -1230,7 +1229,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationCanceled) {
controller().LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK());
- contents()->GetMainFrame()->PrepareForCommit(url2);
+ contents()->GetMainFrame()->PrepareForCommit();
EXPECT_TRUE(contents()->cross_navigation_pending());
// Simulate swap out message when the response arrives.
@@ -1335,7 +1334,7 @@ TEST_F(WebContentsImplTest, NavigationExitsFullscreen) {
const GURL url("http://www.google.com");
controller().LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- contents()->GetMainFrame()->PrepareForCommit(url);
+ contents()->GetMainFrame()->PrepareForCommit();
contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
EXPECT_EQ(orig_rfh, contents()->GetMainFrame());
@@ -1353,7 +1352,7 @@ TEST_F(WebContentsImplTest, NavigationExitsFullscreen) {
const GURL url2("http://www.yahoo.com");
controller().LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- contents()->GetMainFrame()->PrepareForCommit(url2);
+ contents()->GetMainFrame()->PrepareForCommit();
TestRenderFrameHost* const pending_rfh = contents()->GetPendingMainFrame();
contents()->TestDidNavigate(
pending_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED);
@@ -2700,7 +2699,10 @@ TEST_F(WebContentsImplTest, ActiveContentsCountNavigate) {
Referrer(),
ui::PAGE_TRANSITION_TYPED,
std::string());
- contents->GetMainFrame()->PrepareForCommit(kUrl);
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableBrowserSideNavigation)) {
+ contents->GetMainFrame()->SendBeforeUnloadACK(true);
+ }
EXPECT_TRUE(contents->cross_navigation_pending());
EXPECT_EQ(1u, instance->GetRelatedActiveContentsCount());
contents->CommitPendingNavigation();
@@ -2731,7 +2733,10 @@ TEST_F(WebContentsImplTest, ActiveContentsCountChangeBrowsingInstance) {
Referrer(),
ui::PAGE_TRANSITION_TYPED,
std::string());
- contents->GetMainFrame()->PrepareForCommit(GURL(kTestWebUIUrl));
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableBrowserSideNavigation)) {
+ contents->GetMainFrame()->SendBeforeUnloadACK(true);
+ }
EXPECT_TRUE(contents->cross_navigation_pending());
scoped_refptr<SiteInstance> instance_webui(
contents->GetPendingMainFrame()->GetSiteInstance());
diff --git a/content/test/test_navigation_url_loader.cc b/content/test/test_navigation_url_loader.cc
index 2d14887..6eea8b2 100644
--- a/content/test/test_navigation_url_loader.cc
+++ b/content/test/test_navigation_url_loader.cc
@@ -6,6 +6,8 @@
#include "content/browser/loader/navigation_url_loader_delegate.h"
#include "content/public/browser/stream_handle.h"
+#include "content/public/common/resource_response.h"
+#include "net/url_request/redirect_info.h"
namespace content {
@@ -21,6 +23,16 @@ void TestNavigationURLLoader::FollowRedirect() {
redirect_count_++;
}
+void TestNavigationURLLoader::SimulateServerRedirect(const GURL& redirect_url) {
+ net::RedirectInfo redirect_info;
+ redirect_info.status_code = 302;
+ redirect_info.new_method = "GET";
+ redirect_info.new_url = redirect_url;
+ redirect_info.new_first_party_for_cookies = redirect_url;
+ scoped_refptr<ResourceResponse> response(new ResourceResponse);
+ CallOnRequestRedirected(redirect_info, response);
+}
+
void TestNavigationURLLoader::CallOnRequestRedirected(
const net::RedirectInfo& redirect_info,
const scoped_refptr<ResourceResponse>& response) {
diff --git a/content/test/test_navigation_url_loader.h b/content/test/test_navigation_url_loader.h
index b598464..f5eb288 100644
--- a/content/test/test_navigation_url_loader.h
+++ b/content/test/test_navigation_url_loader.h
@@ -36,6 +36,8 @@ class TestNavigationURLLoader
NavigationRequestInfo* request_info() const { return request_info_.get(); }
+ void SimulateServerRedirect(const GURL& redirect_url);
+
void CallOnRequestRedirected(const net::RedirectInfo& redirect_info,
const scoped_refptr<ResourceResponse>& response);
void CallOnResponseStarted(const scoped_refptr<ResourceResponse>& response,
diff --git a/content/test/test_render_frame_host.cc b/content/test/test_render_frame_host.cc
index 988681c..6ef20c1 100644
--- a/content/test/test_render_frame_host.cc
+++ b/content/test/test_render_frame_host.cc
@@ -200,58 +200,71 @@ void TestRenderFrameHost::SendNavigateWithParameters(
OnDidCommitProvisionalLoad(msg);
}
-void TestRenderFrameHost::SendBeginNavigationWithURL(const GURL& url,
- bool has_user_gesture) {
- BeginNavigationParams begin_params("GET", std::string(), net::LOAD_NORMAL,
- has_user_gesture);
- CommonNavigationParams common_params;
- common_params.url = url;
- common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault);
- common_params.transition = ui::PAGE_TRANSITION_LINK;
- OnBeginNavigation(common_params, begin_params,
- scoped_refptr<ResourceRequestBody>());
+void TestRenderFrameHost::SendRendererInitiatedNavigationRequest(
+ const GURL& url,
+ bool has_user_gesture) {
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableBrowserSideNavigation)) {
+ BeginNavigationParams begin_params("GET", std::string(), net::LOAD_NORMAL,
+ has_user_gesture);
+ CommonNavigationParams common_params;
+ common_params.url = url;
+ common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault);
+ common_params.transition = ui::PAGE_TRANSITION_LINK;
+ OnBeginNavigation(common_params, begin_params,
+ scoped_refptr<ResourceRequestBody>());
+ }
}
void TestRenderFrameHost::DidDisownOpener() {
OnDidDisownOpener();
}
-void TestRenderFrameHost::PrepareForCommit(const GURL& url) {
+void TestRenderFrameHost::PrepareForCommit() {
+ PrepareForCommitWithServerRedirect(GURL());
+}
+
+void TestRenderFrameHost::PrepareForCommitWithServerRedirect(
+ const GURL& redirect_url) {
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBrowserSideNavigation)) {
+ // Non PlzNavigate
SendBeforeUnloadACK(true);
return;
}
// PlzNavigate
- // Simulate the network stack commit without any redirects.
NavigationRequest* request =
static_cast<NavigatorImpl*>(frame_tree_node_->navigator())
->GetNavigationRequestForNodeForTesting(frame_tree_node_);
+ CHECK(request);
- // We are simulating a renderer-initiated user-initiated navigation.
- if (!request) {
- SendBeginNavigationWithURL(url, true);
- request = static_cast<NavigatorImpl*>(frame_tree_node_->navigator())
- ->GetNavigationRequestForNodeForTesting(frame_tree_node_);
- }
- ASSERT_TRUE(request);
-
- // We may not have simulated the renderer response to the navigation request.
- // Do that now.
+ // Simulate a beforeUnload ACK from the renderer if the browser is waiting for
+ // it. If it runs it will update the request state.
if (request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE)
SendBeforeUnloadACK(true);
- // We have already simulated the IO thread commit. Only the
- // DidCommitProvisionalLoad from the renderer is missing.
- if (request->state() == NavigationRequest::RESPONSE_STARTED)
+ // If a network request is not needed for this URL, just check the request is
+ // in the correct state and return.
+ if (!request->ShouldMakeNetworkRequest(request->common_params().url)) {
+ CHECK(request->state() == NavigationRequest::RESPONSE_STARTED);
return;
+ }
+
+ CHECK(request->state() == NavigationRequest::STARTED);
- ASSERT_TRUE(request->state() == NavigationRequest::STARTED);
TestNavigationURLLoader* url_loader =
static_cast<TestNavigationURLLoader*>(request->loader_for_testing());
- ASSERT_TRUE(url_loader);
+ CHECK(url_loader);
+
+ // If a non-empty |redirect_url| was provided, simulate a server redirect.
+ if (!redirect_url.is_empty())
+ url_loader->SimulateServerRedirect(redirect_url);
+
+ // Simulate the network stack commit.
scoped_refptr<ResourceResponse> response(new ResourceResponse);
+ // TODO(carlosk): ideally with PlzNavigate it should be possible someday to
+ // fully commit the navigation at this call to CallOnResponseStarted.
url_loader->CallOnResponseStarted(response, MakeEmptyStream());
}
diff --git a/content/test/test_render_frame_host.h b/content/test/test_render_frame_host.h
index fcf4a74..333c2d7 100644
--- a/content/test/test_render_frame_host.h
+++ b/content/test/test_render_frame_host.h
@@ -85,7 +85,11 @@ class TestRenderFrameHost : public RenderFrameHostImpl,
int response_code,
const base::FilePath* file_path_for_history_item,
const std::vector<GURL>& redirects);
- void SendBeginNavigationWithURL(const GURL& url, bool has_user_gesture);
+
+ // With the current navigation logic this method is a no-op.
+ // PlzNavigate: this method simulates receiving a BeginNavigation IPC.
+ void SendRendererInitiatedNavigationRequest(const GURL& url,
+ bool has_user_gesture);
void DidDisownOpener();
@@ -102,7 +106,13 @@ class TestRenderFrameHost : public RenderFrameHostImpl,
// this simulates a BeforeUnload ACK from the renderer.
// PlzNavigate: this simulates a BeforeUnload ACK from the renderer, and the
// interaction with the IO thread up until the response is ready to commit.
- void PrepareForCommit(const GURL& url);
+ void PrepareForCommit();
+
+ // This method does the same as PrepareForCommit.
+ // PlzNavigate: Beyond doing the same as PrepareForCommit, this method will
+ // also simulate a server redirect to |redirect_url|. If the URL is empty the
+ // redirect step is ignored.
+ void PrepareForCommitWithServerRedirect(const GURL& redirect_url);
// Simulate receiving a FrameHostMsg_BeforeUnloadHandlersPresent.
void SendBeforeUnloadHandlersPresent(bool present);
diff --git a/content/test/test_web_contents.cc b/content/test/test_web_contents.cc
index d3a1c1d..d3f47f6 100644
--- a/content/test/test_web_contents.cc
+++ b/content/test/test_web_contents.cc
@@ -158,7 +158,7 @@ void TestWebContents::CommitPendingNavigation() {
// replaced without a pending frame being created, and we don't get the right
// values for the RFH to navigate: we try to use the old one that has been
// deleted in the meantime.
- GetMainFrame()->PrepareForCommit(entry->GetURL());
+ GetMainFrame()->PrepareForCommit();
TestRenderFrameHost* old_rfh = GetMainFrame();
TestRenderFrameHost* rfh = GetPendingMainFrame();