summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorclamy <clamy@chromium.org>2016-03-23 15:13:47 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-23 22:14:58 +0000
commit2c11358348eb568cfddf14ef7c7c7b891607e148 (patch)
tree3e484f4eaeb3d024a160c5a3d20f5796bfa89d31 /content
parent2a2656a67bd2ce190df4d918f609bdb4449a64fe (diff)
downloadchromium_src-2c11358348eb568cfddf14ef7c7c7b891607e148.zip
chromium_src-2c11358348eb568cfddf14ef7c7c7b891607e148.tar.gz
chromium_src-2c11358348eb568cfddf14ef7c7c7b891607e148.tar.bz2
PlzNavigate: fix two RenderViewImplTests related to history
This CL fixes RenderViewImplTest.BrowserNavigationStartNotUsedForHistoryNavigation and RenderViewImplTest.TestBackForward. Properly simulatin ghistory navigations with PlzNavigate enabled requires providing a url in the CommonNavigationParams, which was not being done. BUG=475027 Review URL: https://codereview.chromium.org/1797393008 Cr-Commit-Position: refs/heads/master@{#382940}
Diffstat (limited to 'content')
-rw-r--r--content/public/test/render_view_test.cc14
-rw-r--r--content/public/test/render_view_test.h6
-rw-r--r--content/renderer/render_view_browsertest.cc47
3 files changed, 43 insertions, 24 deletions
diff --git a/content/public/test/render_view_test.cc b/content/public/test/render_view_test.cc
index 572e008..b9e869f 100644
--- a/content/public/test/render_view_test.cc
+++ b/content/public/test/render_view_test.cc
@@ -280,12 +280,12 @@ PageState RenderViewTest::GetCurrentPageState() {
}
}
-void RenderViewTest::GoBack(const PageState& state) {
- GoToOffset(-1, state);
+void RenderViewTest::GoBack(const GURL& url, const PageState& state) {
+ GoToOffset(-1, url, state);
}
-void RenderViewTest::GoForward(const PageState& state) {
- GoToOffset(1, state);
+void RenderViewTest::GoForward(const GURL& url, const PageState& state) {
+ GoToOffset(1, url, state);
}
void RenderViewTest::SetUp() {
@@ -697,7 +697,9 @@ scoped_ptr<ResizeParams> RenderViewTest::InitialSizeParams() {
return make_scoped_ptr(new ResizeParams());
}
-void RenderViewTest::GoToOffset(int offset, const PageState& state) {
+void RenderViewTest::GoToOffset(int offset,
+ const GURL& url,
+ const PageState& state) {
RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_);
int history_list_length = impl->historyBackListCount() +
@@ -705,7 +707,7 @@ void RenderViewTest::GoToOffset(int offset, const PageState& state) {
int pending_offset = offset + impl->history_list_offset_;
CommonNavigationParams common_params(
- GURL(), Referrer(), ui::PAGE_TRANSITION_FORWARD_BACK,
+ url, Referrer(), ui::PAGE_TRANSITION_FORWARD_BACK,
FrameMsg_Navigate_Type::NORMAL, true, false, base::TimeTicks(),
FrameMsg_UILoadMetricsReportType::NO_REPORT, GURL(), GURL(),
LOFI_UNSPECIFIED, base::TimeTicks::Now(), "GET");
diff --git a/content/public/test/render_view_test.h b/content/public/test/render_view_test.h
index 3c3b3f8..7fb7653 100644
--- a/content/public/test/render_view_test.h
+++ b/content/public/test/render_view_test.h
@@ -103,8 +103,8 @@ class RenderViewTest : public testing::Test, blink::WebLeakDetectorClient {
// Navigates the main frame back or forward in session history and commits.
// The caller must capture a PageState for the target page.
- void GoBack(const PageState& state);
- void GoForward(const PageState& state);
+ void GoBack(const GURL& url, const PageState& state);
+ void GoForward(const GURL& url, const PageState& state);
// Sends one native key event over IPC.
void SendNativeKeyEvent(const NativeWebKeyboardEvent& key_event);
@@ -213,7 +213,7 @@ class RenderViewTest : public testing::Test, blink::WebLeakDetectorClient {
#endif
private:
- void GoToOffset(int offset, const PageState& state);
+ void GoToOffset(int offset, const GURL& url, const PageState& state);
};
} // namespace content
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
index 7682b4b..0695669 100644
--- a/content/renderer/render_view_browsertest.cc
+++ b/content/renderer/render_view_browsertest.cc
@@ -1456,26 +1456,38 @@ TEST_F(RenderViewImplTest, TestBackForward) {
EXPECT_EQ(1, was_page_c);
PageState forward_state = GetCurrentPageState();
- GoBack(back_state);
+
+ // Go back.
+ GoBack(GURL("data:text/html;charset=utf-8,<div id=pagename>Page B</div>"),
+ back_state);
+
EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b));
EXPECT_EQ(1, was_page_b);
-
PageState back_state2 = GetCurrentPageState();
- GoForward(forward_state);
+ // Go forward.
+ GoForward(GURL("data:text/html;charset=utf-8,<div id=pagename>Page C</div>"),
+ forward_state);
EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_c, &was_page_c));
EXPECT_EQ(1, was_page_c);
- GoBack(back_state2);
+ // Go back.
+ GoBack(GURL("data:text/html;charset=utf-8,<div id=pagename>Page B</div>"),
+ back_state2);
EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b));
EXPECT_EQ(1, was_page_b);
forward_state = GetCurrentPageState();
- GoBack(page_a_state);
+
+ // Go back.
+ GoBack(GURL("data:text/html;charset=utf-8,<div id=pagename>Page A</div>"),
+ page_a_state);
EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_a, &was_page_a));
EXPECT_EQ(1, was_page_a);
- GoForward(forward_state);
+ // Go forward.
+ GoForward(GURL("data:text/html;charset=utf-8,<div id=pagename>Page B</div>"),
+ forward_state);
EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b));
EXPECT_EQ(1, was_page_b);
}
@@ -2046,25 +2058,30 @@ TEST_F(RenderViewImplTest, BrowserNavigationStartNotUsedForHistoryNavigation) {
ProcessPendingMessages();
render_thread_->sink().ClearMessages();
- CommonNavigationParams common_params;
- common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
// Go back.
- GoToOffsetWithParams(-1, back_state, common_params, StartNavigationParams(),
- RequestNavigationParams());
+ CommonNavigationParams common_params_back;
+ common_params_back.url =
+ GURL("data:text/html;charset=utf-8,<div id=pagename>Page B</div>");
+ common_params_back.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
+ GoToOffsetWithParams(-1, back_state, common_params_back,
+ StartNavigationParams(), RequestNavigationParams());
FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params =
ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>();
EXPECT_PRED2(TimeTicksGT, base::get<1>(host_nav_params),
- common_params.navigation_start);
+ common_params_back.navigation_start);
render_thread_->sink().ClearMessages();
// Go forward.
- GoToOffsetWithParams(1, forward_state, common_params,
- StartNavigationParams(),
- RequestNavigationParams());
+ CommonNavigationParams common_params_forward;
+ common_params_forward.url =
+ GURL("data:text/html;charset=utf-8,<div id=pagename>Page C</div>");
+ common_params_forward.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
+ GoToOffsetWithParams(1, forward_state, common_params_forward,
+ StartNavigationParams(), RequestNavigationParams());
FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params2 =
ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>();
EXPECT_PRED2(TimeTicksGT, base::get<1>(host_nav_params2),
- common_params.navigation_start);
+ common_params_forward.navigation_start);
}
TEST_F(RenderViewImplTest, BrowserNavigationStartSuccessfullyTransmitted) {