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

Side by Side Diff: content/renderer/render_view_browsertest.cc

Issue 1121083004: Revert of Classify navigations without page id in parallel to the existing classifier. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | content/test/test_render_frame_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 709
710 // Back to page A (page_id 1) and commit. 710 // Back to page A (page_id 1) and commit.
711 CommonNavigationParams common_params_A; 711 CommonNavigationParams common_params_A;
712 RequestNavigationParams request_params_A; 712 RequestNavigationParams request_params_A;
713 common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; 713 common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL;
714 common_params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK; 714 common_params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
715 request_params_A.current_history_list_length = 2; 715 request_params_A.current_history_list_length = 2;
716 request_params_A.current_history_list_offset = 1; 716 request_params_A.current_history_list_offset = 1;
717 request_params_A.pending_history_list_offset = 0; 717 request_params_A.pending_history_list_offset = 0;
718 request_params_A.page_id = 1; 718 request_params_A.page_id = 1;
719 request_params_A.nav_entry_id = 1;
720 request_params_A.page_state = state_A; 719 request_params_A.page_state = state_A;
721 NavigateMainFrame(common_params_A, StartNavigationParams(), request_params_A); 720 NavigateMainFrame(common_params_A, StartNavigationParams(), request_params_A);
722 EXPECT_EQ(1, view()->historyBackListCount()); 721 EXPECT_EQ(1, view()->historyBackListCount());
723 EXPECT_EQ(2, view()->historyBackListCount() + 722 EXPECT_EQ(2, view()->historyBackListCount() +
724 view()->historyForwardListCount() + 1); 723 view()->historyForwardListCount() + 1);
725 ProcessPendingMessages(); 724 ProcessPendingMessages();
726 725
727 // Respond to a swap out request. 726 // Respond to a swap out request.
728 SwapOut(frame(), kProxyRoutingId, true, content::FrameReplicationState()); 727 SwapOut(frame(), kProxyRoutingId, true, content::FrameReplicationState());
729 728
730 // Check for a OnSwapOutACK. 729 // Check for a OnSwapOutACK.
731 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( 730 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching(
732 FrameHostMsg_SwapOut_ACK::ID); 731 FrameHostMsg_SwapOut_ACK::ID);
733 ASSERT_TRUE(msg); 732 ASSERT_TRUE(msg);
734 render_thread_->sink().ClearMessages(); 733 render_thread_->sink().ClearMessages();
735 734
736 // It is possible to get a reload request at this point, containing the 735 // It is possible to get a reload request at this point, containing the
737 // params.page_state of the initial page (e.g., if the new page fails the 736 // params.page_state of the initial page (e.g., if the new page fails the
738 // provisional load in the renderer process, after we unload the old page). 737 // provisional load in the renderer process, after we unload the old page).
739 // Ensure the old page gets reloaded, not swappedout://. 738 // Ensure the old page gets reloaded, not swappedout://.
740 CommonNavigationParams common_params; 739 CommonNavigationParams common_params;
741 RequestNavigationParams request_params; 740 RequestNavigationParams request_params;
742 common_params.url = GURL("data:text/html,<div>Page A</div>"); 741 common_params.url = GURL("data:text/html,<div>Page A</div>");
743 common_params.navigation_type = FrameMsg_Navigate_Type::RELOAD; 742 common_params.navigation_type = FrameMsg_Navigate_Type::RELOAD;
744 common_params.transition = ui::PAGE_TRANSITION_RELOAD; 743 common_params.transition = ui::PAGE_TRANSITION_RELOAD;
745 request_params.current_history_list_length = 2; 744 request_params.current_history_list_length = 2;
746 request_params.current_history_list_offset = 0; 745 request_params.current_history_list_offset = 0;
747 request_params.pending_history_list_offset = 0; 746 request_params.pending_history_list_offset = 0;
748 request_params.page_id = 1; 747 request_params.page_id = 1;
749 request_params.nav_entry_id = 1;
750 request_params.page_state = state_A; 748 request_params.page_state = state_A;
751 NavigateMainFrame(common_params, StartNavigationParams(), request_params); 749 NavigateMainFrame(common_params, StartNavigationParams(), request_params);
752 ProcessPendingMessages(); 750 ProcessPendingMessages();
753 751
754 // Verify page A committed, not swappedout://. 752 // Verify page A committed, not swappedout://.
755 const IPC::Message* frame_navigate_msg = 753 const IPC::Message* frame_navigate_msg =
756 render_thread_->sink().GetUniqueMessageMatching( 754 render_thread_->sink().GetUniqueMessageMatching(
757 FrameHostMsg_DidCommitProvisionalLoad::ID); 755 FrameHostMsg_DidCommitProvisionalLoad::ID);
758 EXPECT_TRUE(frame_navigate_msg); 756 EXPECT_TRUE(frame_navigate_msg);
759 757
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 EXPECT_EQ(page_id_C, page_id); 908 EXPECT_EQ(page_id_C, page_id);
911 EXPECT_NE(state_A, state); 909 EXPECT_NE(state_A, state);
912 EXPECT_NE(state_B, state); 910 EXPECT_NE(state_B, state);
913 EXPECT_EQ(state_C, state); 911 EXPECT_EQ(state_C, state);
914 } 912 }
915 913
916 // Test that stale back/forward navigations arriving from the browser are 914 // Test that stale back/forward navigations arriving from the browser are
917 // ignored. See http://crbug.com/86758. 915 // ignored. See http://crbug.com/86758.
918 TEST_F(RenderViewImplTest, StaleNavigationsIgnored) { 916 TEST_F(RenderViewImplTest, StaleNavigationsIgnored) {
919 // Load page A. 917 // Load page A.
920 LoadHTML("<div id=pagename>Page A</div>"); 918 LoadHTML("<div>Page A</div>");
921 EXPECT_EQ(1, view()->history_list_length_); 919 EXPECT_EQ(1, view()->history_list_length_);
922 EXPECT_EQ(0, view()->history_list_offset_); 920 EXPECT_EQ(0, view()->history_list_offset_);
923 921
924 // Load page B, which will trigger an UpdateState message for page A. 922 // Load page B, which will trigger an UpdateState message for page A.
925 LoadHTML("<div id=pagename>Page B</div>"); 923 LoadHTML("<div>Page B</div>");
926 EXPECT_EQ(2, view()->history_list_length_); 924 EXPECT_EQ(2, view()->history_list_length_);
927 EXPECT_EQ(1, view()->history_list_offset_); 925 EXPECT_EQ(1, view()->history_list_offset_);
928 926
929 // Check for a valid UpdateState message for page A. 927 // Check for a valid UpdateState message for page A.
930 ProcessPendingMessages(); 928 ProcessPendingMessages();
931 const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching( 929 const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching(
932 ViewHostMsg_UpdateState::ID); 930 ViewHostMsg_UpdateState::ID);
933 ASSERT_TRUE(msg_A); 931 ASSERT_TRUE(msg_A);
934 ViewHostMsg_UpdateState::Param param; 932 ViewHostMsg_UpdateState::Param param;
935 ViewHostMsg_UpdateState::Read(msg_A, &param); 933 ViewHostMsg_UpdateState::Read(msg_A, &param);
936 int page_id_A = get<0>(param); 934 int page_id_A = get<0>(param);
937 PageState state_A = get<1>(param); 935 PageState state_A = get<1>(param);
938 EXPECT_EQ(1, page_id_A); 936 EXPECT_EQ(1, page_id_A);
939 render_thread_->sink().ClearMessages(); 937 render_thread_->sink().ClearMessages();
940 938
941 // Back to page A (nav_entry_id 1) and commit. 939 // Back to page A (page_id 1) and commit.
942 CommonNavigationParams common_params_A; 940 CommonNavigationParams common_params_A;
943 RequestNavigationParams request_params_A; 941 RequestNavigationParams request_params_A;
944 common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; 942 common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL;
945 common_params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK; 943 common_params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
946 request_params_A.current_history_list_length = 2; 944 request_params_A.current_history_list_length = 2;
947 request_params_A.current_history_list_offset = 1; 945 request_params_A.current_history_list_offset = 1;
948 request_params_A.pending_history_list_offset = 0; 946 request_params_A.pending_history_list_offset = 0;
949 request_params_A.page_id = 1; 947 request_params_A.page_id = 1;
950 request_params_A.nav_entry_id = 1;
951 request_params_A.page_state = state_A; 948 request_params_A.page_state = state_A;
952 NavigateMainFrame(common_params_A, StartNavigationParams(), request_params_A); 949 NavigateMainFrame(common_params_A, StartNavigationParams(), request_params_A);
953 ProcessPendingMessages(); 950 ProcessPendingMessages();
954 951
955 // A new navigation commits, clearing the forward history. 952 // A new navigation commits, clearing the forward history.
956 LoadHTML("<div id=pagename>Page C</div>"); 953 LoadHTML("<div>Page C</div>");
957 EXPECT_EQ(2, view()->history_list_length_); 954 EXPECT_EQ(2, view()->history_list_length_);
958 EXPECT_EQ(1, view()->history_list_offset_); 955 EXPECT_EQ(1, view()->history_list_offset_);
959 EXPECT_EQ(3, view()->page_id_); // page C is now page id 3 956 EXPECT_EQ(3, view()->page_id_); // page C is now page id 3
960 int was_page_c = -1;
961 base::string16 check_page_c = base::ASCIIToUTF16(
962 "Number(document.getElementById('pagename').innerHTML == 'Page C')");
963 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_c, &was_page_c));
964 EXPECT_EQ(1, was_page_c);
965 957
966 // The browser then sends a stale navigation to B, which should be ignored. 958 // The browser then sends a stale navigation to B, which should be ignored.
967 CommonNavigationParams common_params_B; 959 CommonNavigationParams common_params_B;
968 RequestNavigationParams request_params_B; 960 RequestNavigationParams request_params_B;
969 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; 961 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL;
970 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; 962 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
971 request_params_B.current_history_list_length = 2; 963 request_params_B.current_history_list_length = 2;
972 request_params_B.current_history_list_offset = 0; 964 request_params_B.current_history_list_offset = 0;
973 request_params_B.pending_history_list_offset = 1; 965 request_params_B.pending_history_list_offset = 1;
974 request_params_B.page_id = 2; 966 request_params_B.page_id = 2;
975 request_params_B.nav_entry_id = 2;
976 request_params_B.page_state = 967 request_params_B.page_state =
977 state_A; // Doesn't matter, just has to be present. 968 state_A; // Doesn't matter, just has to be present.
978 NavigateMainFrame(common_params_B, StartNavigationParams(), request_params_B); 969 NavigateMainFrame(common_params_B, StartNavigationParams(), request_params_B);
979 970
980 // State should be unchanged. 971 // State should be unchanged.
981 EXPECT_EQ(2, view()->history_list_length_); 972 EXPECT_EQ(2, view()->history_list_length_);
982 EXPECT_EQ(1, view()->history_list_offset_); 973 EXPECT_EQ(1, view()->history_list_offset_);
983 EXPECT_EQ(3, view()->page_id_); // page C, not page B 974 EXPECT_EQ(3, view()->page_id_); // page C, not page B
984 was_page_c = -1;
985 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_c, &was_page_c));
986 EXPECT_EQ(1, was_page_c);
987 975
988 // Check for a valid DidDropNavigation message. 976 // Check for a valid DidDropNavigation message.
989 ProcessPendingMessages(); 977 ProcessPendingMessages();
990 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( 978 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching(
991 FrameHostMsg_DidDropNavigation::ID); 979 FrameHostMsg_DidDropNavigation::ID);
992 ASSERT_TRUE(msg); 980 ASSERT_TRUE(msg);
993 render_thread_->sink().ClearMessages(); 981 render_thread_->sink().ClearMessages();
994 } 982 }
995 983
996 // Test that our IME backend sends a notification message when the input focus 984 // Test that our IME backend sends a notification message when the input focus
(...skipping 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after
2434 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( 2422 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
2435 &DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); 2423 &DevToolsAgentTest::CloseWhilePaused, base::Unretained(this)));
2436 ExecuteJavaScript("debugger;"); 2424 ExecuteJavaScript("debugger;");
2437 2425
2438 // CloseWhilePaused should resume execution and continue here. 2426 // CloseWhilePaused should resume execution and continue here.
2439 EXPECT_FALSE(IsPaused()); 2427 EXPECT_FALSE(IsPaused());
2440 Detach(); 2428 Detach();
2441 } 2429 }
2442 2430
2443 } // namespace content 2431 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | content/test/test_render_frame_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698