Index: content/browser/frame_host/navigation_controller_impl_unittest.cc |
diff --git a/content/browser/frame_host/navigation_controller_impl_unittest.cc b/content/browser/frame_host/navigation_controller_impl_unittest.cc |
index 3b0796a2d32a0618f32a80ab6df9fe00e2e1a368..30bfe4b547c509899f5f4a0d5413142e0399725d 100644 |
--- a/content/browser/frame_host/navigation_controller_impl_unittest.cc |
+++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc |
@@ -4,6 +4,7 @@ |
#include "base/basictypes.h" |
#include "base/bind.h" |
+#include "base/command_line.h" |
#include "base/files/file_util.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/stl_util.h" |
@@ -25,6 +26,7 @@ |
#include "content/public/browser/render_view_host.h" |
#include "content/public/browser/web_contents_delegate.h" |
#include "content/public/browser/web_contents_observer.h" |
+#include "content/public/common/content_switches.h" |
#include "content/public/common/page_state.h" |
#include "content/public/common/url_constants.h" |
#include "content/public/test/mock_render_process_host.h" |
@@ -414,7 +416,12 @@ TEST_F(NavigationControllerTest, LoadURL) { |
// Simulate the beforeunload ack for the cross-site transition, and then the |
// commit. |
- main_test_rfh()->SendBeforeUnloadACK(true); |
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
nasko
2014/12/16 01:40:26
This code pattern appears few times in this file.
clamy
2014/12/17 15:47:57
Done.
|
+ switches::kEnableBrowserSideNavigation)) { |
+ main_test_rfh()->SimulateIOThread(controller.GetPendingEntry()->GetURL()); |
+ } else { |
+ main_test_rfh()->SendBeforeUnloadACK(true); |
+ } |
contents()->GetPendingMainFrame()->SendNavigate(1, url2); |
EXPECT_EQ(1U, navigation_entry_committed_counter_); |
navigation_entry_committed_counter_ = 0; |
@@ -752,9 +759,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()->SendBeforeUnloadACK(true); |
+ main_test_rfh()->SendRendererResponseToNavigation(true, kExistingURL2); |
const GURL kNewURL("http://see"); |
- contents()->GetPendingMainFrame()->SendNavigate(3, kNewURL); |
+ contents()->GetMainFrame()->SendNavigate(3, kNewURL); |
clamy
2014/12/15 17:01:39
I modified this line because the description of th
Charlie Reis
2014/12/16 23:17:34
Yes, I appear to have broken this in https://coder
|
// There should no longer be any pending entry, and the third navigation we |
// just made should be committed. |
@@ -797,7 +804,6 @@ TEST_F(NavigationControllerTest, LoadURL_ExistingPending) { |
// Before that commits, do a new navigation. |
const GURL kNewURL("http://foo/see"); |
- LoadCommittedDetails details; |
main_test_rfh()->SendNavigate(3, kNewURL); |
// There should no longer be any pending entry, and the third navigation we |
@@ -831,7 +837,12 @@ TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) { |
const GURL kExistingURL2("http://foo/eh"); |
controller.LoadURL( |
kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
- main_test_rfh()->SendBeforeUnloadACK(true); |
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableBrowserSideNavigation)) { |
+ main_test_rfh()->SimulateIOThread(kExistingURL2); |
+ } else { |
+ main_test_rfh()->SendBeforeUnloadACK(true); |
+ } |
TestRenderFrameHost* foo_rfh = contents()->GetPendingMainFrame(); |
foo_rfh->SendNavigate(1, kExistingURL2); |
EXPECT_EQ(1U, navigation_entry_committed_counter_); |
@@ -849,7 +860,6 @@ TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) { |
// Before that commits, do a new navigation. |
const GURL kNewURL("http://foo/bee"); |
- LoadCommittedDetails details; |
foo_rfh->SendNavigate(3, kNewURL); |
// There should no longer be any pending entry, and the third navigation we |
@@ -1102,7 +1112,12 @@ TEST_F(NavigationControllerTest, LoadURL_WithBindings) { |
// privileged url. |
controller.LoadURL( |
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
- orig_rfh->SendBeforeUnloadACK(true); |
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableBrowserSideNavigation)) { |
+ orig_rfh->SimulateIOThread(url2); |
+ } else { |
+ orig_rfh->SendBeforeUnloadACK(true); |
+ } |
TestRenderFrameHost* new_rfh = contents()->GetPendingMainFrame(); |
new_rfh->GetRenderViewHost()->AllowBindings(1); |
new_rfh->SendNavigate(1, url2); |
@@ -3895,6 +3910,7 @@ TEST_F(NavigationControllerTest, HistoryNavigate) { |
NavigateAndCommit(url3); |
controller.GoBack(); |
contents()->CommitPendingNavigation(); |
+ process()->sink().ClearMessages(); |
// Simulate the page calling history.back(). It should create a pending entry. |
contents()->OnGoToEntryAtOffset(-1); |
@@ -3903,12 +3919,24 @@ TEST_F(NavigationControllerTest, HistoryNavigate) { |
// it unloaded, simulate that. |
contents()->ProceedWithCrossSiteNavigation(); |
// Also make sure we told the page to navigate. |
- const IPC::Message* message = |
- process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID); |
- ASSERT_TRUE(message != NULL); |
- Tuple1<FrameMsg_Navigate_Params> nav_params; |
- FrameMsg_Navigate::Read(message, &nav_params); |
- EXPECT_EQ(url1, nav_params.a.common_params.url); |
+ GURL nav_url; |
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableBrowserSideNavigation)) { |
+ const IPC::Message* message = process()->sink().GetFirstMessageMatching( |
nasko
2014/12/16 01:40:26
It seems that this branching logic can be put in a
clamy
2014/12/17 15:47:57
Done.
|
+ FrameMsg_RequestNavigation::ID); |
+ ASSERT_TRUE(message != NULL); |
+ Tuple2<CommonNavigationParams, RequestNavigationParams> nav_params; |
+ FrameMsg_RequestNavigation::Read(message, &nav_params); |
+ nav_url = nav_params.a.url; |
+ } else { |
+ const IPC::Message* message = |
+ process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID); |
+ ASSERT_TRUE(message != NULL); |
+ Tuple1<FrameMsg_Navigate_Params> nav_params; |
+ FrameMsg_Navigate::Read(message, &nav_params); |
+ nav_url = nav_params.a.common_params.url; |
+ } |
+ EXPECT_EQ(url1, nav_url); |
process()->sink().ClearMessages(); |
// Now test history.forward() |
@@ -3917,10 +3945,23 @@ TEST_F(NavigationControllerTest, HistoryNavigate) { |
// The actual cross-navigation is suspended until the current RVH tells us |
// it unloaded, simulate that. |
contents()->ProceedWithCrossSiteNavigation(); |
- message = process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID); |
- ASSERT_TRUE(message != NULL); |
- FrameMsg_Navigate::Read(message, &nav_params); |
- EXPECT_EQ(url3, nav_params.a.common_params.url); |
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableBrowserSideNavigation)) { |
+ const IPC::Message* message = process()->sink().GetFirstMessageMatching( |
+ FrameMsg_RequestNavigation::ID); |
+ ASSERT_TRUE(message != NULL); |
+ Tuple2<CommonNavigationParams, RequestNavigationParams> nav_params; |
+ FrameMsg_RequestNavigation::Read(message, &nav_params); |
+ nav_url = nav_params.a.url; |
+ } else { |
+ const IPC::Message* message = |
+ process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID); |
+ ASSERT_TRUE(message != NULL); |
+ Tuple1<FrameMsg_Navigate_Params> nav_params; |
+ FrameMsg_Navigate::Read(message, &nav_params); |
+ nav_url = nav_params.a.common_params.url; |
+ } |
+ EXPECT_EQ(url3, nav_url); |
process()->sink().ClearMessages(); |
controller.DiscardNonCommittedEntries(); |
@@ -3928,8 +3969,16 @@ TEST_F(NavigationControllerTest, HistoryNavigate) { |
// Make sure an extravagant history.go() doesn't break. |
contents()->OnGoToEntryAtOffset(120); // Out of bounds. |
EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
- message = process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID); |
- EXPECT_TRUE(message == NULL); |
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableBrowserSideNavigation)) { |
+ const IPC::Message* message = process()->sink().GetFirstMessageMatching( |
+ FrameMsg_RequestNavigation::ID); |
+ EXPECT_TRUE(message == NULL); |
+ } else { |
+ const IPC::Message* message = |
+ process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID); |
+ EXPECT_TRUE(message == NULL); |
+ } |
} |
// Test call to PruneAllButLastCommitted for the only entry. |
@@ -4315,6 +4364,10 @@ TEST_F(NavigationControllerTest, ClearHistoryList) { |
EXPECT_TRUE(entry->should_clear_history_list()); |
// Assume that the RF correctly cleared its history and commit the navigation. |
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableBrowserSideNavigation)) { |
+ contents()->GetMainFrame()->SimulateIOThread(entry->GetURL()); |
+ } |
contents()->GetPendingMainFrame()-> |
set_simulate_history_list_was_cleared(true); |
contents()->CommitPendingNavigation(); |