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

Unified Diff: content/renderer/render_view_browsertest.cc

Issue 1002803002: Classify navigations without page id in parallel to the existing classifier. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase again Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/render_view_browsertest.cc
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
index f01c8928078b7b386cd6f85e4711f7817d488e00..997500d27b71446a85365bc9a93b1ba183be0e74 100644
--- a/content/renderer/render_view_browsertest.cc
+++ b/content/renderer/render_view_browsertest.cc
@@ -709,6 +709,7 @@ TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) {
request_params_A.current_history_list_offset = 1;
request_params_A.pending_history_list_offset = 0;
request_params_A.page_id = 1;
+ request_params_A.nav_entry_id = 1;
request_params_A.page_state = state_A;
NavigateFrame(common_params_A, StartNavigationParams(), request_params_A);
EXPECT_EQ(1, view()->historyBackListCount());
@@ -738,6 +739,7 @@ TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) {
request_params.current_history_list_offset = 0;
request_params.pending_history_list_offset = 0;
request_params.page_id = 1;
+ request_params.nav_entry_id = 1;
request_params.page_state = state_A;
NavigateFrame(common_params, StartNavigationParams(), request_params);
ProcessPendingMessages();
@@ -908,12 +910,12 @@ TEST_F(RenderViewImplTest, DISABLED_LastCommittedUpdateState) {
// ignored. See http://crbug.com/86758.
TEST_F(RenderViewImplTest, StaleNavigationsIgnored) {
// Load page A.
- LoadHTML("<div>Page A</div>");
+ LoadHTML("<div id=pagename>Page A</div>");
EXPECT_EQ(1, view()->history_list_length_);
EXPECT_EQ(0, view()->history_list_offset_);
// Load page B, which will trigger an UpdateState message for page A.
- LoadHTML("<div>Page B</div>");
+ LoadHTML("<div id=pagename>Page B</div>");
EXPECT_EQ(2, view()->history_list_length_);
EXPECT_EQ(1, view()->history_list_offset_);
@@ -929,7 +931,7 @@ TEST_F(RenderViewImplTest, StaleNavigationsIgnored) {
EXPECT_EQ(1, page_id_A);
render_thread_->sink().ClearMessages();
- // Back to page A (page_id 1) and commit.
+ // Back to page A (nav_entry_id 1) and commit.
CommonNavigationParams common_params_A;
RequestNavigationParams request_params_A;
common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL;
@@ -938,15 +940,21 @@ TEST_F(RenderViewImplTest, StaleNavigationsIgnored) {
request_params_A.current_history_list_offset = 1;
request_params_A.pending_history_list_offset = 0;
request_params_A.page_id = 1;
+ request_params_A.nav_entry_id = 1;
request_params_A.page_state = state_A;
NavigateFrame(common_params_A, StartNavigationParams(), request_params_A);
ProcessPendingMessages();
// A new navigation commits, clearing the forward history.
- LoadHTML("<div>Page C</div>");
+ LoadHTML("<div id=pagename>Page C</div>");
EXPECT_EQ(2, view()->history_list_length_);
EXPECT_EQ(1, view()->history_list_offset_);
EXPECT_EQ(3, view()->page_id_); // page C is now page id 3
+ int was_page_c = -1;
+ base::string16 check_page_c = base::ASCIIToUTF16(
+ "Number(document.getElementById('pagename').innerHTML == 'Page C')");
Charlie Reis 2015/04/22 05:27:25 This pattern of returning a bool as an int makes m
Avi (use Gerrit) 2015/04/22 18:31:51 Acknowledged.
+ EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_c, &was_page_c));
+ EXPECT_EQ(1, was_page_c);
// The browser then sends a stale navigation to B, which should be ignored.
CommonNavigationParams common_params_B;
@@ -957,6 +965,7 @@ TEST_F(RenderViewImplTest, StaleNavigationsIgnored) {
request_params_B.current_history_list_offset = 0;
request_params_B.pending_history_list_offset = 1;
request_params_B.page_id = 2;
+ request_params_B.nav_entry_id = 2;
request_params_B.page_state =
state_A; // Doesn't matter, just has to be present.
NavigateFrame(common_params_B, StartNavigationParams(), request_params_B);
@@ -965,6 +974,9 @@ TEST_F(RenderViewImplTest, StaleNavigationsIgnored) {
EXPECT_EQ(2, view()->history_list_length_);
EXPECT_EQ(1, view()->history_list_offset_);
EXPECT_EQ(3, view()->page_id_); // page C, not page B
+ was_page_c = -1;
+ EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_c, &was_page_c));
+ EXPECT_EQ(1, was_page_c);
// Check for a valid DidDropNavigation message.
ProcessPendingMessages();

Powered by Google App Engine
This is Rietveld 408576698