summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/frame_host/navigation_controller_impl_unittest.cc24
-rw-r--r--content/browser/renderer_host/render_view_host_unittest.cc18
2 files changed, 36 insertions, 6 deletions
diff --git a/content/browser/frame_host/navigation_controller_impl_unittest.cc b/content/browser/frame_host/navigation_controller_impl_unittest.cc
index f813393..2e6d1a6 100644
--- a/content/browser/frame_host/navigation_controller_impl_unittest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc
@@ -1332,6 +1332,13 @@ TEST_F(NavigationControllerTest, ReloadWithGuest) {
}
#if !defined(OS_ANDROID) // http://crbug.com/157428
+namespace {
+void SetOriginalURL(const GURL& url,
+ FrameHostMsg_DidCommitProvisionalLoad_Params* params) {
+ params->original_request_url = url;
+}
+}
+
TEST_F(NavigationControllerTest, ReloadOriginalRequestURL) {
NavigationControllerImpl& controller = controller_impl();
TestNotificationTracker notifications;
@@ -1339,6 +1346,7 @@ TEST_F(NavigationControllerTest, ReloadOriginalRequestURL) {
const GURL original_url("http://foo1");
const GURL final_url("http://foo2");
+ auto set_original_url_callback = base::Bind(SetOriginalURL, original_url);
// Load up the original URL, but get redirected.
controller.LoadURL(
@@ -1346,8 +1354,8 @@ TEST_F(NavigationControllerTest, ReloadOriginalRequestURL) {
int entry_id = controller.GetPendingEntry()->GetUniqueID();
EXPECT_EQ(0U, notifications.size());
main_test_rfh()->PrepareForCommitWithServerRedirect(final_url);
- main_test_rfh()->SendNavigateWithOriginalRequestURL(0, entry_id, true,
- final_url, original_url);
+ main_test_rfh()->SendNavigateWithModificationCallback(
+ 0, entry_id, true, final_url, set_original_url_callback);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
entry_id = controller.GetLastCommittedEntry()->GetUniqueID();
@@ -1453,6 +1461,13 @@ TEST_F(NavigationControllerTest, ResetEntryValuesAfterCommit) {
EXPECT_FALSE(committed_entry->should_clear_history_list());
}
+namespace {
+void SetRedirects(const std::vector<GURL>& redirects,
+ FrameHostMsg_DidCommitProvisionalLoad_Params* params) {
+ params->redirects = redirects;
+}
+}
+
// Test that Redirects are preserved after a commit.
TEST_F(NavigationControllerTest, RedirectsAreNotResetByCommit) {
NavigationControllerImpl& controller = controller_impl();
@@ -1465,6 +1480,7 @@ TEST_F(NavigationControllerTest, RedirectsAreNotResetByCommit) {
// Set up some redirect values.
std::vector<GURL> redirects;
redirects.push_back(url2);
+ auto set_redirects_callback = base::Bind(SetRedirects, redirects);
// Set redirects on the pending entry.
NavigationEntryImpl* pending_entry = controller.GetPendingEntry();
@@ -1474,8 +1490,8 @@ TEST_F(NavigationControllerTest, RedirectsAreNotResetByCommit) {
// Normal navigation will preserve redirects in the committed entry.
main_test_rfh()->PrepareForCommitWithServerRedirect(url2);
- main_test_rfh()->SendNavigateWithRedirects(0, entry_id, true, url1,
- redirects);
+ main_test_rfh()->SendNavigateWithModificationCallback(0, entry_id, true, url1,
+ set_redirects_callback);
NavigationEntryImpl* committed_entry = controller.GetLastCommittedEntry();
ASSERT_EQ(1U, committed_entry->GetRedirectChain().size());
EXPECT_EQ(url2, committed_entry->GetRedirectChain()[0]);
diff --git a/content/browser/renderer_host/render_view_host_unittest.cc b/content/browser/renderer_host/render_view_host_unittest.cc
index 8b396b9..edf12f1 100644
--- a/content/browser/renderer_host/render_view_host_unittest.cc
+++ b/content/browser/renderer_host/render_view_host_unittest.cc
@@ -9,6 +9,7 @@
#include "content/browser/renderer_host/render_message_filter.h"
#include "content/browser/renderer_host/render_view_host_delegate_view.h"
#include "content/browser/renderer_host/render_widget_helper.h"
+#include "content/common/frame_messages.h"
#include "content/common/input_messages.h"
#include "content/common/view_messages.h"
#include "content/public/browser/browser_context.h"
@@ -227,22 +228,35 @@ TEST_F(RenderViewHostTest, MessageWithBadHistoryItemFiles) {
EXPECT_EQ(1, process()->bad_msg_count());
}
+namespace {
+void SetBadFilePath(const GURL& url,
+ const base::FilePath& file_path,
+ FrameHostMsg_DidCommitProvisionalLoad_Params* params) {
+ params->page_state =
+ PageState::CreateForTesting(url, false, "data", &file_path);
+}
+}
+
TEST_F(RenderViewHostTest, NavigationWithBadHistoryItemFiles) {
GURL url("http://www.google.com");
base::FilePath file_path;
EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file_path));
file_path = file_path.AppendASCII("bar");
+ auto set_bad_file_path_callback = base::Bind(SetBadFilePath, url, file_path);
+
EXPECT_EQ(0, process()->bad_msg_count());
main_test_rfh()->SendRendererInitiatedNavigationRequest(url, false);
main_test_rfh()->PrepareForCommit();
- contents()->GetMainFrame()->SendNavigateWithFile(1, 1, true, url, file_path);
+ contents()->GetMainFrame()->SendNavigateWithModificationCallback(
+ 1, 1, true, url, set_bad_file_path_callback);
EXPECT_EQ(1, process()->bad_msg_count());
ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile(
process()->GetID(), file_path);
main_test_rfh()->SendRendererInitiatedNavigationRequest(url, false);
main_test_rfh()->PrepareForCommit();
- contents()->GetMainFrame()->SendNavigateWithFile(2, 2, true, url, file_path);
+ contents()->GetMainFrame()->SendNavigateWithModificationCallback(
+ 2, 2, true, url, set_bad_file_path_callback);
EXPECT_EQ(1, process()->bad_msg_count());
}