| OLD | NEW |
| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 278 |
| 279 const gfx::Size& GetPreferredSize() { | 279 const gfx::Size& GetPreferredSize() { |
| 280 view()->CheckPreferredSize(); | 280 view()->CheckPreferredSize(); |
| 281 return view()->preferred_size_; | 281 return view()->preferred_size_; |
| 282 } | 282 } |
| 283 | 283 |
| 284 void SetZoomLevel(double level) { | 284 void SetZoomLevel(double level) { |
| 285 view()->OnSetZoomLevelForView(false, level); | 285 view()->OnSetZoomLevelForView(false, level); |
| 286 } | 286 } |
| 287 | 287 |
| 288 void NavigateFrame(const CommonNavigationParams& common_params, | 288 void NavigateMainFrame(const CommonNavigationParams& common_params, |
| 289 const StartNavigationParams& start_params, |
| 290 const RequestNavigationParams& request_params) { |
| 291 NavigateFrame(frame(), common_params, start_params, request_params); |
| 292 } |
| 293 |
| 294 void NavigateFrame(RenderFrameImpl* frame, |
| 295 const CommonNavigationParams& common_params, |
| 289 const StartNavigationParams& start_params, | 296 const StartNavigationParams& start_params, |
| 290 const RequestNavigationParams& request_params) { | 297 const RequestNavigationParams& request_params) { |
| 291 // PlzNavigate | 298 // PlzNavigate |
| 292 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 299 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 293 switches::kEnableBrowserSideNavigation)) { | 300 switches::kEnableBrowserSideNavigation)) { |
| 294 frame()->OnCommitNavigation(ResourceResponseHead(), common_params.url, | 301 frame->OnCommitNavigation(ResourceResponseHead(), common_params.url, |
| 295 common_params, request_params); | 302 common_params, request_params); |
| 296 return; | 303 return; |
| 297 } | 304 } |
| 298 frame()->OnNavigate(common_params, start_params, request_params); | 305 frame->OnNavigate(common_params, start_params, request_params); |
| 299 } | 306 } |
| 300 | 307 |
| 301 void SwapOut(RenderFrameImpl* frame, | 308 void SwapOut(RenderFrameImpl* frame, |
| 302 int proxy_routing_id, | 309 int proxy_routing_id, |
| 303 bool is_loading, | 310 bool is_loading, |
| 304 const FrameReplicationState& replicated_frame_state) { | 311 const FrameReplicationState& replicated_frame_state) { |
| 305 frame->OnSwapOut(proxy_routing_id, is_loading, replicated_frame_state); | 312 frame->OnSwapOut(proxy_routing_id, is_loading, replicated_frame_state); |
| 306 } | 313 } |
| 307 | 314 |
| 308 void SetEditableSelectionOffsets(int start, int end) { | 315 void SetEditableSelectionOffsets(int start, int end) { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 request_params.page_id = -1; | 473 request_params.page_id = -1; |
| 467 | 474 |
| 468 // Set up post data. | 475 // Set up post data. |
| 469 const unsigned char* raw_data = reinterpret_cast<const unsigned char*>( | 476 const unsigned char* raw_data = reinterpret_cast<const unsigned char*>( |
| 470 "post \0\ndata"); | 477 "post \0\ndata"); |
| 471 const unsigned int length = 11; | 478 const unsigned int length = 11; |
| 472 const std::vector<unsigned char> post_data(raw_data, raw_data + length); | 479 const std::vector<unsigned char> post_data(raw_data, raw_data + length); |
| 473 start_params.is_post = true; | 480 start_params.is_post = true; |
| 474 start_params.browser_initiated_post_data = post_data; | 481 start_params.browser_initiated_post_data = post_data; |
| 475 | 482 |
| 476 NavigateFrame(common_params, start_params, request_params); | 483 NavigateMainFrame(common_params, start_params, request_params); |
| 477 ProcessPendingMessages(); | 484 ProcessPendingMessages(); |
| 478 | 485 |
| 479 const IPC::Message* frame_navigate_msg = | 486 const IPC::Message* frame_navigate_msg = |
| 480 render_thread_->sink().GetUniqueMessageMatching( | 487 render_thread_->sink().GetUniqueMessageMatching( |
| 481 FrameHostMsg_DidCommitProvisionalLoad::ID); | 488 FrameHostMsg_DidCommitProvisionalLoad::ID); |
| 482 EXPECT_TRUE(frame_navigate_msg); | 489 EXPECT_TRUE(frame_navigate_msg); |
| 483 | 490 |
| 484 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params; | 491 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params; |
| 485 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg, | 492 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg, |
| 486 &host_nav_params); | 493 &host_nav_params); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 // update for the swapped out URL. (http://crbug.com/72235) | 672 // update for the swapped out URL. (http://crbug.com/72235) |
| 666 CommonNavigationParams common_params; | 673 CommonNavigationParams common_params; |
| 667 RequestNavigationParams request_params; | 674 RequestNavigationParams request_params; |
| 668 common_params.url = GURL("data:text/html,<div>Page B</div>"); | 675 common_params.url = GURL("data:text/html,<div>Page B</div>"); |
| 669 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 676 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 670 common_params.transition = ui::PAGE_TRANSITION_TYPED; | 677 common_params.transition = ui::PAGE_TRANSITION_TYPED; |
| 671 request_params.current_history_list_length = 1; | 678 request_params.current_history_list_length = 1; |
| 672 request_params.current_history_list_offset = 0; | 679 request_params.current_history_list_offset = 0; |
| 673 request_params.pending_history_list_offset = 1; | 680 request_params.pending_history_list_offset = 1; |
| 674 request_params.page_id = -1; | 681 request_params.page_id = -1; |
| 675 NavigateFrame(common_params, StartNavigationParams(), request_params); | 682 NavigateMainFrame(common_params, StartNavigationParams(), request_params); |
| 676 ProcessPendingMessages(); | 683 ProcessPendingMessages(); |
| 677 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching( | 684 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching( |
| 678 ViewHostMsg_UpdateState::ID); | 685 ViewHostMsg_UpdateState::ID); |
| 679 EXPECT_FALSE(msg3); | 686 EXPECT_FALSE(msg3); |
| 680 } | 687 } |
| 681 | 688 |
| 682 // Ensure the RenderViewImpl reloads the previous page if a reload request | 689 // Ensure the RenderViewImpl reloads the previous page if a reload request |
| 683 // arrives while it is showing swappedout://. http://crbug.com/143155. | 690 // arrives while it is showing swappedout://. http://crbug.com/143155. |
| 684 TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) { | 691 TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) { |
| 685 // Load page A. | 692 // Load page A. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 703 // Back to page A (page_id 1) and commit. | 710 // Back to page A (page_id 1) and commit. |
| 704 CommonNavigationParams common_params_A; | 711 CommonNavigationParams common_params_A; |
| 705 RequestNavigationParams request_params_A; | 712 RequestNavigationParams request_params_A; |
| 706 common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 713 common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 707 common_params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 714 common_params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 708 request_params_A.current_history_list_length = 2; | 715 request_params_A.current_history_list_length = 2; |
| 709 request_params_A.current_history_list_offset = 1; | 716 request_params_A.current_history_list_offset = 1; |
| 710 request_params_A.pending_history_list_offset = 0; | 717 request_params_A.pending_history_list_offset = 0; |
| 711 request_params_A.page_id = 1; | 718 request_params_A.page_id = 1; |
| 712 request_params_A.page_state = state_A; | 719 request_params_A.page_state = state_A; |
| 713 NavigateFrame(common_params_A, StartNavigationParams(), request_params_A); | 720 NavigateMainFrame(common_params_A, StartNavigationParams(), request_params_A); |
| 714 EXPECT_EQ(1, view()->historyBackListCount()); | 721 EXPECT_EQ(1, view()->historyBackListCount()); |
| 715 EXPECT_EQ(2, view()->historyBackListCount() + | 722 EXPECT_EQ(2, view()->historyBackListCount() + |
| 716 view()->historyForwardListCount() + 1); | 723 view()->historyForwardListCount() + 1); |
| 717 ProcessPendingMessages(); | 724 ProcessPendingMessages(); |
| 718 | 725 |
| 719 // Respond to a swap out request. | 726 // Respond to a swap out request. |
| 720 SwapOut(frame(), kProxyRoutingId, true, content::FrameReplicationState()); | 727 SwapOut(frame(), kProxyRoutingId, true, content::FrameReplicationState()); |
| 721 | 728 |
| 722 // Check for a OnSwapOutACK. | 729 // Check for a OnSwapOutACK. |
| 723 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | 730 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
| 724 FrameHostMsg_SwapOut_ACK::ID); | 731 FrameHostMsg_SwapOut_ACK::ID); |
| 725 ASSERT_TRUE(msg); | 732 ASSERT_TRUE(msg); |
| 726 render_thread_->sink().ClearMessages(); | 733 render_thread_->sink().ClearMessages(); |
| 727 | 734 |
| 728 // 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 |
| 729 // 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 |
| 730 // 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). |
| 731 // Ensure the old page gets reloaded, not swappedout://. | 738 // Ensure the old page gets reloaded, not swappedout://. |
| 732 CommonNavigationParams common_params; | 739 CommonNavigationParams common_params; |
| 733 RequestNavigationParams request_params; | 740 RequestNavigationParams request_params; |
| 734 common_params.url = GURL("data:text/html,<div>Page A</div>"); | 741 common_params.url = GURL("data:text/html,<div>Page A</div>"); |
| 735 common_params.navigation_type = FrameMsg_Navigate_Type::RELOAD; | 742 common_params.navigation_type = FrameMsg_Navigate_Type::RELOAD; |
| 736 common_params.transition = ui::PAGE_TRANSITION_RELOAD; | 743 common_params.transition = ui::PAGE_TRANSITION_RELOAD; |
| 737 request_params.current_history_list_length = 2; | 744 request_params.current_history_list_length = 2; |
| 738 request_params.current_history_list_offset = 0; | 745 request_params.current_history_list_offset = 0; |
| 739 request_params.pending_history_list_offset = 0; | 746 request_params.pending_history_list_offset = 0; |
| 740 request_params.page_id = 1; | 747 request_params.page_id = 1; |
| 741 request_params.page_state = state_A; | 748 request_params.page_state = state_A; |
| 742 NavigateFrame(common_params, StartNavigationParams(), request_params); | 749 NavigateMainFrame(common_params, StartNavigationParams(), request_params); |
| 743 ProcessPendingMessages(); | 750 ProcessPendingMessages(); |
| 744 | 751 |
| 745 // Verify page A committed, not swappedout://. | 752 // Verify page A committed, not swappedout://. |
| 746 const IPC::Message* frame_navigate_msg = | 753 const IPC::Message* frame_navigate_msg = |
| 747 render_thread_->sink().GetUniqueMessageMatching( | 754 render_thread_->sink().GetUniqueMessageMatching( |
| 748 FrameHostMsg_DidCommitProvisionalLoad::ID); | 755 FrameHostMsg_DidCommitProvisionalLoad::ID); |
| 749 EXPECT_TRUE(frame_navigate_msg); | 756 EXPECT_TRUE(frame_navigate_msg); |
| 750 | 757 |
| 751 // Read URL out of the parent trait of the params object. | 758 // Read URL out of the parent trait of the params object. |
| 752 FrameHostMsg_DidCommitProvisionalLoad::Param commit_load_params; | 759 FrameHostMsg_DidCommitProvisionalLoad::Param commit_load_params; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 // Go back to C and commit, preparing for our real test. | 857 // Go back to C and commit, preparing for our real test. |
| 851 CommonNavigationParams common_params_C; | 858 CommonNavigationParams common_params_C; |
| 852 RequestNavigationParams request_params_C; | 859 RequestNavigationParams request_params_C; |
| 853 common_params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 860 common_params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 854 common_params_C.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 861 common_params_C.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 855 request_params_C.current_history_list_length = 4; | 862 request_params_C.current_history_list_length = 4; |
| 856 request_params_C.current_history_list_offset = 3; | 863 request_params_C.current_history_list_offset = 3; |
| 857 request_params_C.pending_history_list_offset = 2; | 864 request_params_C.pending_history_list_offset = 2; |
| 858 request_params_C.page_id = 3; | 865 request_params_C.page_id = 3; |
| 859 request_params_C.page_state = state_C; | 866 request_params_C.page_state = state_C; |
| 860 NavigateFrame(common_params_C, StartNavigationParams(), request_params_C); | 867 NavigateMainFrame(common_params_C, StartNavigationParams(), request_params_C); |
| 861 ProcessPendingMessages(); | 868 ProcessPendingMessages(); |
| 862 render_thread_->sink().ClearMessages(); | 869 render_thread_->sink().ClearMessages(); |
| 863 | 870 |
| 864 // Go back twice quickly, such that page B does not have a chance to commit. | 871 // Go back twice quickly, such that page B does not have a chance to commit. |
| 865 // This leads to two changes to the back/forward list but only one change to | 872 // This leads to two changes to the back/forward list but only one change to |
| 866 // the RenderView's page ID. | 873 // the RenderView's page ID. |
| 867 | 874 |
| 868 // Back to page B (page_id 2), without committing. | 875 // Back to page B (page_id 2), without committing. |
| 869 CommonNavigationParams common_params_B; | 876 CommonNavigationParams common_params_B; |
| 870 RequestNavigationParams request_params_B; | 877 RequestNavigationParams request_params_B; |
| 871 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 878 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 872 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 879 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 873 request_params_B.current_history_list_length = 4; | 880 request_params_B.current_history_list_length = 4; |
| 874 request_params_B.current_history_list_offset = 2; | 881 request_params_B.current_history_list_offset = 2; |
| 875 request_params_B.pending_history_list_offset = 1; | 882 request_params_B.pending_history_list_offset = 1; |
| 876 request_params_B.page_id = 2; | 883 request_params_B.page_id = 2; |
| 877 request_params_B.page_state = state_B; | 884 request_params_B.page_state = state_B; |
| 878 NavigateFrame(common_params_B, StartNavigationParams(), request_params_B); | 885 NavigateMainFrame(common_params_B, StartNavigationParams(), request_params_B); |
| 879 | 886 |
| 880 // Back to page A (page_id 1) and commit. | 887 // Back to page A (page_id 1) and commit. |
| 881 CommonNavigationParams common_params; | 888 CommonNavigationParams common_params; |
| 882 RequestNavigationParams request_params; | 889 RequestNavigationParams request_params; |
| 883 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 890 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 884 common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 891 common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 885 request_params.current_history_list_length = 4; | 892 request_params.current_history_list_length = 4; |
| 886 request_params.current_history_list_offset = 2; | 893 request_params.current_history_list_offset = 2; |
| 887 request_params.pending_history_list_offset = 0; | 894 request_params.pending_history_list_offset = 0; |
| 888 request_params.page_id = 1; | 895 request_params.page_id = 1; |
| 889 request_params.page_state = state_A; | 896 request_params.page_state = state_A; |
| 890 NavigateFrame(common_params, StartNavigationParams(), request_params); | 897 NavigateMainFrame(common_params, StartNavigationParams(), request_params); |
| 891 ProcessPendingMessages(); | 898 ProcessPendingMessages(); |
| 892 | 899 |
| 893 // Now ensure that the UpdateState message we receive is consistent | 900 // Now ensure that the UpdateState message we receive is consistent |
| 894 // and represents page C in both page_id and state. | 901 // and represents page C in both page_id and state. |
| 895 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | 902 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
| 896 ViewHostMsg_UpdateState::ID); | 903 ViewHostMsg_UpdateState::ID); |
| 897 ASSERT_TRUE(msg); | 904 ASSERT_TRUE(msg); |
| 898 ViewHostMsg_UpdateState::Read(msg, ¶m); | 905 ViewHostMsg_UpdateState::Read(msg, ¶m); |
| 899 int page_id = get<0>(param); | 906 int page_id = get<0>(param); |
| 900 PageState state = get<1>(param); | 907 PageState state = get<1>(param); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 // Back to page A (page_id 1) and commit. | 939 // Back to page A (page_id 1) and commit. |
| 933 CommonNavigationParams common_params_A; | 940 CommonNavigationParams common_params_A; |
| 934 RequestNavigationParams request_params_A; | 941 RequestNavigationParams request_params_A; |
| 935 common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 942 common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 936 common_params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 943 common_params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 937 request_params_A.current_history_list_length = 2; | 944 request_params_A.current_history_list_length = 2; |
| 938 request_params_A.current_history_list_offset = 1; | 945 request_params_A.current_history_list_offset = 1; |
| 939 request_params_A.pending_history_list_offset = 0; | 946 request_params_A.pending_history_list_offset = 0; |
| 940 request_params_A.page_id = 1; | 947 request_params_A.page_id = 1; |
| 941 request_params_A.page_state = state_A; | 948 request_params_A.page_state = state_A; |
| 942 NavigateFrame(common_params_A, StartNavigationParams(), request_params_A); | 949 NavigateMainFrame(common_params_A, StartNavigationParams(), request_params_A); |
| 943 ProcessPendingMessages(); | 950 ProcessPendingMessages(); |
| 944 | 951 |
| 945 // A new navigation commits, clearing the forward history. | 952 // A new navigation commits, clearing the forward history. |
| 946 LoadHTML("<div>Page C</div>"); | 953 LoadHTML("<div>Page C</div>"); |
| 947 EXPECT_EQ(2, view()->history_list_length_); | 954 EXPECT_EQ(2, view()->history_list_length_); |
| 948 EXPECT_EQ(1, view()->history_list_offset_); | 955 EXPECT_EQ(1, view()->history_list_offset_); |
| 949 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 |
| 950 | 957 |
| 951 // 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. |
| 952 CommonNavigationParams common_params_B; | 959 CommonNavigationParams common_params_B; |
| 953 RequestNavigationParams request_params_B; | 960 RequestNavigationParams request_params_B; |
| 954 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 961 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 955 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 962 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 956 request_params_B.current_history_list_length = 2; | 963 request_params_B.current_history_list_length = 2; |
| 957 request_params_B.current_history_list_offset = 0; | 964 request_params_B.current_history_list_offset = 0; |
| 958 request_params_B.pending_history_list_offset = 1; | 965 request_params_B.pending_history_list_offset = 1; |
| 959 request_params_B.page_id = 2; | 966 request_params_B.page_id = 2; |
| 960 request_params_B.page_state = | 967 request_params_B.page_state = |
| 961 state_A; // Doesn't matter, just has to be present. | 968 state_A; // Doesn't matter, just has to be present. |
| 962 NavigateFrame(common_params_B, StartNavigationParams(), request_params_B); | 969 NavigateMainFrame(common_params_B, StartNavigationParams(), request_params_B); |
| 963 | 970 |
| 964 // State should be unchanged. | 971 // State should be unchanged. |
| 965 EXPECT_EQ(2, view()->history_list_length_); | 972 EXPECT_EQ(2, view()->history_list_length_); |
| 966 EXPECT_EQ(1, view()->history_list_offset_); | 973 EXPECT_EQ(1, view()->history_list_offset_); |
| 967 EXPECT_EQ(3, view()->page_id_); // page C, not page B | 974 EXPECT_EQ(3, view()->page_id_); // page C, not page B |
| 968 | 975 |
| 969 // Check for a valid DidDropNavigation message. | 976 // Check for a valid DidDropNavigation message. |
| 970 ProcessPendingMessages(); | 977 ProcessPendingMessages(); |
| 971 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | 978 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
| 972 FrameHostMsg_DidDropNavigation::ID); | 979 FrameHostMsg_DidDropNavigation::ID); |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1667 error.domain = WebString::fromUTF8(net::kErrorDomain); | 1674 error.domain = WebString::fromUTF8(net::kErrorDomain); |
| 1668 error.reason = net::ERR_FILE_NOT_FOUND; | 1675 error.reason = net::ERR_FILE_NOT_FOUND; |
| 1669 error.unreachableURL = GURL("http://foo"); | 1676 error.unreachableURL = GURL("http://foo"); |
| 1670 WebLocalFrame* web_frame = GetMainFrame(); | 1677 WebLocalFrame* web_frame = GetMainFrame(); |
| 1671 | 1678 |
| 1672 // Start a load that will reach provisional state synchronously, | 1679 // Start a load that will reach provisional state synchronously, |
| 1673 // but won't complete synchronously. | 1680 // but won't complete synchronously. |
| 1674 CommonNavigationParams common_params; | 1681 CommonNavigationParams common_params; |
| 1675 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1682 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 1676 common_params.url = GURL("data:text/html,test data"); | 1683 common_params.url = GURL("data:text/html,test data"); |
| 1677 NavigateFrame(common_params, StartNavigationParams(), | 1684 NavigateMainFrame(common_params, StartNavigationParams(), |
| 1678 RequestNavigationParams()); | 1685 RequestNavigationParams()); |
| 1679 | 1686 |
| 1680 // An error occurred. | 1687 // An error occurred. |
| 1681 view()->GetMainRenderFrame()->didFailProvisionalLoad( | 1688 view()->GetMainRenderFrame()->didFailProvisionalLoad( |
| 1682 web_frame, error, blink::WebStandardCommit); | 1689 web_frame, error, blink::WebStandardCommit); |
| 1683 // Frame should exit view-source mode. | 1690 // Frame should exit view-source mode. |
| 1684 EXPECT_FALSE(web_frame->isViewSourceModeEnabled()); | 1691 EXPECT_FALSE(web_frame->isViewSourceModeEnabled()); |
| 1685 } | 1692 } |
| 1686 | 1693 |
| 1687 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) { | 1694 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) { |
| 1688 GetMainFrame()->enableViewSourceMode(true); | 1695 GetMainFrame()->enableViewSourceMode(true); |
| 1689 WebURLError error; | 1696 WebURLError error; |
| 1690 error.domain = WebString::fromUTF8(net::kErrorDomain); | 1697 error.domain = WebString::fromUTF8(net::kErrorDomain); |
| 1691 error.reason = net::ERR_ABORTED; | 1698 error.reason = net::ERR_ABORTED; |
| 1692 error.unreachableURL = GURL("http://foo"); | 1699 error.unreachableURL = GURL("http://foo"); |
| 1693 WebLocalFrame* web_frame = GetMainFrame(); | 1700 WebLocalFrame* web_frame = GetMainFrame(); |
| 1694 | 1701 |
| 1695 // Start a load that will reach provisional state synchronously, | 1702 // Start a load that will reach provisional state synchronously, |
| 1696 // but won't complete synchronously. | 1703 // but won't complete synchronously. |
| 1697 CommonNavigationParams common_params; | 1704 CommonNavigationParams common_params; |
| 1698 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1705 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 1699 common_params.url = GURL("data:text/html,test data"); | 1706 common_params.url = GURL("data:text/html,test data"); |
| 1700 NavigateFrame(common_params, StartNavigationParams(), | 1707 NavigateMainFrame(common_params, StartNavigationParams(), |
| 1701 RequestNavigationParams()); | 1708 RequestNavigationParams()); |
| 1702 | 1709 |
| 1703 // A cancellation occurred. | 1710 // A cancellation occurred. |
| 1704 view()->GetMainRenderFrame()->didFailProvisionalLoad( | 1711 view()->GetMainRenderFrame()->didFailProvisionalLoad( |
| 1705 web_frame, error, blink::WebStandardCommit); | 1712 web_frame, error, blink::WebStandardCommit); |
| 1706 // Frame should stay in view-source mode. | 1713 // Frame should stay in view-source mode. |
| 1707 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); | 1714 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); |
| 1708 } | 1715 } |
| 1709 | 1716 |
| 1710 // Regression test for http://crbug.com/41562 | 1717 // Regression test for http://crbug.com/41562 |
| 1711 TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) { | 1718 TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) { |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1888 TEST_F(RenderViewImplTest, ZoomLimit) { | 1895 TEST_F(RenderViewImplTest, ZoomLimit) { |
| 1889 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor); | 1896 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor); |
| 1890 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor); | 1897 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor); |
| 1891 | 1898 |
| 1892 // Verifies navigation to a URL with preset zoom level indeed sets the level. | 1899 // Verifies navigation to a URL with preset zoom level indeed sets the level. |
| 1893 // Regression test for http://crbug.com/139559, where the level was not | 1900 // Regression test for http://crbug.com/139559, where the level was not |
| 1894 // properly set when it is out of the default zoom limits of WebView. | 1901 // properly set when it is out of the default zoom limits of WebView. |
| 1895 CommonNavigationParams common_params; | 1902 CommonNavigationParams common_params; |
| 1896 common_params.url = GURL("data:text/html,min_zoomlimit_test"); | 1903 common_params.url = GURL("data:text/html,min_zoomlimit_test"); |
| 1897 view()->OnSetZoomLevelForLoadingURL(common_params.url, kMinZoomLevel); | 1904 view()->OnSetZoomLevelForLoadingURL(common_params.url, kMinZoomLevel); |
| 1898 NavigateFrame(common_params, StartNavigationParams(), | 1905 NavigateMainFrame(common_params, StartNavigationParams(), |
| 1899 RequestNavigationParams()); | 1906 RequestNavigationParams()); |
| 1900 ProcessPendingMessages(); | 1907 ProcessPendingMessages(); |
| 1901 EXPECT_DOUBLE_EQ(kMinZoomLevel, view()->GetWebView()->zoomLevel()); | 1908 EXPECT_DOUBLE_EQ(kMinZoomLevel, view()->GetWebView()->zoomLevel()); |
| 1902 | 1909 |
| 1903 // It should work even when the zoom limit is temporarily changed in the page. | 1910 // It should work even when the zoom limit is temporarily changed in the page. |
| 1904 view()->GetWebView()->zoomLimitsChanged(ZoomFactorToZoomLevel(1.0), | 1911 view()->GetWebView()->zoomLimitsChanged(ZoomFactorToZoomLevel(1.0), |
| 1905 ZoomFactorToZoomLevel(1.0)); | 1912 ZoomFactorToZoomLevel(1.0)); |
| 1906 common_params.url = GURL("data:text/html,max_zoomlimit_test"); | 1913 common_params.url = GURL("data:text/html,max_zoomlimit_test"); |
| 1907 view()->OnSetZoomLevelForLoadingURL(common_params.url, kMaxZoomLevel); | 1914 view()->OnSetZoomLevelForLoadingURL(common_params.url, kMaxZoomLevel); |
| 1908 NavigateFrame(common_params, StartNavigationParams(), | 1915 NavigateMainFrame(common_params, StartNavigationParams(), |
| 1909 RequestNavigationParams()); | 1916 RequestNavigationParams()); |
| 1910 ProcessPendingMessages(); | 1917 ProcessPendingMessages(); |
| 1911 EXPECT_DOUBLE_EQ(kMaxZoomLevel, view()->GetWebView()->zoomLevel()); | 1918 EXPECT_DOUBLE_EQ(kMaxZoomLevel, view()->GetWebView()->zoomLevel()); |
| 1912 } | 1919 } |
| 1913 | 1920 |
| 1914 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) { | 1921 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) { |
| 1915 // Load an HTML page consisting of an input field. | 1922 // Load an HTML page consisting of an input field. |
| 1916 LoadHTML("<html>" | 1923 LoadHTML("<html>" |
| 1917 "<head>" | 1924 "<head>" |
| 1918 "</head>" | 1925 "</head>" |
| 1919 "<body>" | 1926 "<body>" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1954 EXPECT_EQ(7, info.selectionEnd); | 1961 EXPECT_EQ(7, info.selectionEnd); |
| 1955 SetEditableSelectionOffsets(4, 8); | 1962 SetEditableSelectionOffsets(4, 8); |
| 1956 ExtendSelectionAndDelete(2, 5); | 1963 ExtendSelectionAndDelete(2, 5); |
| 1957 info = view()->webview()->textInputInfo(); | 1964 info = view()->webview()->textInputInfo(); |
| 1958 EXPECT_EQ("abuvwxyz", info.value); | 1965 EXPECT_EQ("abuvwxyz", info.value); |
| 1959 EXPECT_EQ(2, info.selectionStart); | 1966 EXPECT_EQ(2, info.selectionStart); |
| 1960 EXPECT_EQ(2, info.selectionEnd); | 1967 EXPECT_EQ(2, info.selectionEnd); |
| 1961 } | 1968 } |
| 1962 | 1969 |
| 1963 // Test that the navigating specific frames works correctly. | 1970 // Test that the navigating specific frames works correctly. |
| 1964 TEST_F(RenderViewImplTest, NavigateFrame) { | 1971 TEST_F(RenderViewImplTest, NavigateSubframe) { |
| 1965 // Load page A. | 1972 // Load page A. |
| 1966 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); | 1973 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); |
| 1967 | 1974 |
| 1968 // Navigate the frame only. | 1975 // Navigate the frame only. |
| 1969 CommonNavigationParams common_params; | 1976 CommonNavigationParams common_params; |
| 1970 RequestNavigationParams request_params; | 1977 RequestNavigationParams request_params; |
| 1971 common_params.url = GURL("data:text/html,world"); | 1978 common_params.url = GURL("data:text/html,world"); |
| 1972 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1979 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 1973 common_params.transition = ui::PAGE_TRANSITION_TYPED; | 1980 common_params.transition = ui::PAGE_TRANSITION_TYPED; |
| 1974 request_params.current_history_list_length = 1; | 1981 request_params.current_history_list_length = 1; |
| 1975 request_params.current_history_list_offset = 0; | 1982 request_params.current_history_list_offset = 0; |
| 1976 request_params.pending_history_list_offset = 1; | 1983 request_params.pending_history_list_offset = 1; |
| 1977 request_params.page_id = -1; | 1984 request_params.page_id = -1; |
| 1978 request_params.frame_to_navigate = "frame"; | |
| 1979 request_params.browser_navigation_start = | 1985 request_params.browser_navigation_start = |
| 1980 base::TimeTicks::FromInternalValue(1); | 1986 base::TimeTicks::FromInternalValue(1); |
| 1981 NavigateFrame(common_params, StartNavigationParams(), request_params); | 1987 |
| 1982 FrameLoadWaiter( | 1988 RenderFrameImpl* subframe = RenderFrameImpl::FromWebFrame( |
| 1983 RenderFrame::FromWebFrame(frame()->GetWebFrame()->firstChild())).Wait(); | 1989 view()->webview()->findFrameByName("frame")); |
| 1990 NavigateFrame(subframe, common_params, StartNavigationParams(), |
| 1991 request_params); |
| 1992 FrameLoadWaiter(subframe).Wait(); |
| 1984 | 1993 |
| 1985 // Copy the document content to std::wstring and compare with the | 1994 // Copy the document content to std::wstring and compare with the |
| 1986 // expected result. | 1995 // expected result. |
| 1987 const int kMaxOutputCharacters = 256; | 1996 const int kMaxOutputCharacters = 256; |
| 1988 std::string output = base::UTF16ToUTF8( | 1997 std::string output = base::UTF16ToUTF8( |
| 1989 GetMainFrame()->contentAsText(kMaxOutputCharacters)); | 1998 GetMainFrame()->contentAsText(kMaxOutputCharacters)); |
| 1990 EXPECT_EQ(output, "hello \n\nworld"); | 1999 EXPECT_EQ(output, "hello \n\nworld"); |
| 1991 } | 2000 } |
| 1992 | 2001 |
| 1993 // This test ensures that a RenderFrame object is created for the top level | 2002 // This test ensures that a RenderFrame object is created for the top level |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2088 error.domain = WebString::fromUTF8(net::kErrorDomain); | 2097 error.domain = WebString::fromUTF8(net::kErrorDomain); |
| 2089 error.reason = net::ERR_FILE_NOT_FOUND; | 2098 error.reason = net::ERR_FILE_NOT_FOUND; |
| 2090 error.unreachableURL = GURL("http://example.com/suppress"); | 2099 error.unreachableURL = GURL("http://example.com/suppress"); |
| 2091 WebLocalFrame* web_frame = GetMainFrame(); | 2100 WebLocalFrame* web_frame = GetMainFrame(); |
| 2092 | 2101 |
| 2093 // Start a load that will reach provisional state synchronously, | 2102 // Start a load that will reach provisional state synchronously, |
| 2094 // but won't complete synchronously. | 2103 // but won't complete synchronously. |
| 2095 CommonNavigationParams common_params; | 2104 CommonNavigationParams common_params; |
| 2096 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2105 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2097 common_params.url = GURL("data:text/html,test data"); | 2106 common_params.url = GURL("data:text/html,test data"); |
| 2098 NavigateFrame(common_params, StartNavigationParams(), | 2107 NavigateMainFrame(common_params, StartNavigationParams(), |
| 2099 RequestNavigationParams()); | 2108 RequestNavigationParams()); |
| 2100 | 2109 |
| 2101 // An error occurred. | 2110 // An error occurred. |
| 2102 view()->GetMainRenderFrame()->didFailProvisionalLoad( | 2111 view()->GetMainRenderFrame()->didFailProvisionalLoad( |
| 2103 web_frame, error, blink::WebStandardCommit); | 2112 web_frame, error, blink::WebStandardCommit); |
| 2104 const int kMaxOutputCharacters = 22; | 2113 const int kMaxOutputCharacters = 22; |
| 2105 EXPECT_EQ("", | 2114 EXPECT_EQ("", |
| 2106 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); | 2115 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); |
| 2107 } | 2116 } |
| 2108 | 2117 |
| 2109 #if defined(OS_ANDROID) | 2118 #if defined(OS_ANDROID) |
| 2110 // Crashing on Android: http://crbug.com/311341 | 2119 // Crashing on Android: http://crbug.com/311341 |
| 2111 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress | 2120 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress |
| 2112 #else | 2121 #else |
| 2113 #define MAYBE_DoesNotSuppress DoesNotSuppress | 2122 #define MAYBE_DoesNotSuppress DoesNotSuppress |
| 2114 #endif | 2123 #endif |
| 2115 | 2124 |
| 2116 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) { | 2125 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) { |
| 2117 WebURLError error; | 2126 WebURLError error; |
| 2118 error.domain = WebString::fromUTF8(net::kErrorDomain); | 2127 error.domain = WebString::fromUTF8(net::kErrorDomain); |
| 2119 error.reason = net::ERR_FILE_NOT_FOUND; | 2128 error.reason = net::ERR_FILE_NOT_FOUND; |
| 2120 error.unreachableURL = GURL("http://example.com/dont-suppress"); | 2129 error.unreachableURL = GURL("http://example.com/dont-suppress"); |
| 2121 WebLocalFrame* web_frame = GetMainFrame(); | 2130 WebLocalFrame* web_frame = GetMainFrame(); |
| 2122 | 2131 |
| 2123 // Start a load that will reach provisional state synchronously, | 2132 // Start a load that will reach provisional state synchronously, |
| 2124 // but won't complete synchronously. | 2133 // but won't complete synchronously. |
| 2125 CommonNavigationParams common_params; | 2134 CommonNavigationParams common_params; |
| 2126 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2135 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2127 common_params.url = GURL("data:text/html,test data"); | 2136 common_params.url = GURL("data:text/html,test data"); |
| 2128 NavigateFrame(common_params, StartNavigationParams(), | 2137 NavigateMainFrame(common_params, StartNavigationParams(), |
| 2129 RequestNavigationParams()); | 2138 RequestNavigationParams()); |
| 2130 | 2139 |
| 2131 // An error occurred. | 2140 // An error occurred. |
| 2132 view()->GetMainRenderFrame()->didFailProvisionalLoad( | 2141 view()->GetMainRenderFrame()->didFailProvisionalLoad( |
| 2133 web_frame, error, blink::WebStandardCommit); | 2142 web_frame, error, blink::WebStandardCommit); |
| 2134 // The error page itself is loaded asynchronously. | 2143 // The error page itself is loaded asynchronously. |
| 2135 FrameLoadWaiter(frame()).Wait(); | 2144 FrameLoadWaiter(frame()).Wait(); |
| 2136 const int kMaxOutputCharacters = 22; | 2145 const int kMaxOutputCharacters = 22; |
| 2137 EXPECT_EQ("A suffusion of yellow.", | 2146 EXPECT_EQ("A suffusion of yellow.", |
| 2138 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); | 2147 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); |
| 2139 } | 2148 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2329 CommonNavigationParams early_common_params; | 2338 CommonNavigationParams early_common_params; |
| 2330 StartNavigationParams early_start_params; | 2339 StartNavigationParams early_start_params; |
| 2331 RequestNavigationParams early_request_params; | 2340 RequestNavigationParams early_request_params; |
| 2332 early_common_params.url = GURL("data:text/html,<div>Page</div>"); | 2341 early_common_params.url = GURL("data:text/html,<div>Page</div>"); |
| 2333 early_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2342 early_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2334 early_common_params.transition = ui::PAGE_TRANSITION_TYPED; | 2343 early_common_params.transition = ui::PAGE_TRANSITION_TYPED; |
| 2335 early_start_params.is_post = true; | 2344 early_start_params.is_post = true; |
| 2336 early_request_params.browser_navigation_start = | 2345 early_request_params.browser_navigation_start = |
| 2337 base::TimeTicks::FromInternalValue(1); | 2346 base::TimeTicks::FromInternalValue(1); |
| 2338 | 2347 |
| 2339 NavigateFrame(early_common_params, early_start_params, early_request_params); | 2348 NavigateMainFrame(early_common_params, early_start_params, |
| 2349 early_request_params); |
| 2340 ProcessPendingMessages(); | 2350 ProcessPendingMessages(); |
| 2341 | 2351 |
| 2342 base::Time early_nav_reported_start = | 2352 base::Time early_nav_reported_start = |
| 2343 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); | 2353 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); |
| 2344 EXPECT_LT(early_nav_reported_start, before_navigation); | 2354 EXPECT_LT(early_nav_reported_start, before_navigation); |
| 2345 | 2355 |
| 2346 // Verify that a navigation that claims to have started in the future - 42 | 2356 // Verify that a navigation that claims to have started in the future - 42 |
| 2347 // days from now is *not* reported as one that starts in the future; as we | 2357 // days from now is *not* reported as one that starts in the future; as we |
| 2348 // sanitize the override allowing a maximum of ::Now(). | 2358 // sanitize the override allowing a maximum of ::Now(). |
| 2349 CommonNavigationParams late_common_params; | 2359 CommonNavigationParams late_common_params; |
| 2350 RequestNavigationParams late_request_params; | 2360 RequestNavigationParams late_request_params; |
| 2351 StartNavigationParams late_start_params; | 2361 StartNavigationParams late_start_params; |
| 2352 late_common_params.url = GURL("data:text/html,<div>Another page</div>"); | 2362 late_common_params.url = GURL("data:text/html,<div>Another page</div>"); |
| 2353 late_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2363 late_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2354 late_common_params.transition = ui::PAGE_TRANSITION_TYPED; | 2364 late_common_params.transition = ui::PAGE_TRANSITION_TYPED; |
| 2355 late_start_params.is_post = true; | 2365 late_start_params.is_post = true; |
| 2356 late_request_params.browser_navigation_start = | 2366 late_request_params.browser_navigation_start = |
| 2357 base::TimeTicks::Now() + base::TimeDelta::FromDays(42); | 2367 base::TimeTicks::Now() + base::TimeDelta::FromDays(42); |
| 2358 | 2368 |
| 2359 NavigateFrame(late_common_params, late_start_params, late_request_params); | 2369 NavigateMainFrame(late_common_params, late_start_params, late_request_params); |
| 2360 ProcessPendingMessages(); | 2370 ProcessPendingMessages(); |
| 2361 base::Time after_navigation = | 2371 base::Time after_navigation = |
| 2362 base::Time::Now() + base::TimeDelta::FromDays(1); | 2372 base::Time::Now() + base::TimeDelta::FromDays(1); |
| 2363 | 2373 |
| 2364 base::Time late_nav_reported_start = | 2374 base::Time late_nav_reported_start = |
| 2365 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); | 2375 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); |
| 2366 EXPECT_LE(late_nav_reported_start, after_navigation); | 2376 EXPECT_LE(late_nav_reported_start, after_navigation); |
| 2367 } | 2377 } |
| 2368 | 2378 |
| 2369 TEST_F(RenderViewImplTest, PreferredSizeZoomed) { | 2379 TEST_F(RenderViewImplTest, PreferredSizeZoomed) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2386 EXPECT_EQ(0, view()->historyBackListCount()); | 2396 EXPECT_EQ(0, view()->historyBackListCount()); |
| 2387 EXPECT_EQ(0, view()->historyBackListCount() + | 2397 EXPECT_EQ(0, view()->historyBackListCount() + |
| 2388 view()->historyForwardListCount() + 1); | 2398 view()->historyForwardListCount() + 1); |
| 2389 | 2399 |
| 2390 // Receive a Navigate message with history parameters. | 2400 // Receive a Navigate message with history parameters. |
| 2391 RequestNavigationParams request_params; | 2401 RequestNavigationParams request_params; |
| 2392 request_params.current_history_list_length = 2; | 2402 request_params.current_history_list_length = 2; |
| 2393 request_params.current_history_list_offset = 1; | 2403 request_params.current_history_list_offset = 1; |
| 2394 request_params.pending_history_list_offset = 2; | 2404 request_params.pending_history_list_offset = 2; |
| 2395 request_params.page_id = -1; | 2405 request_params.page_id = -1; |
| 2396 NavigateFrame(CommonNavigationParams(), StartNavigationParams(), | 2406 NavigateMainFrame(CommonNavigationParams(), StartNavigationParams(), |
| 2397 request_params); | 2407 request_params); |
| 2398 | 2408 |
| 2399 // The history list in RenderView should have been updated. | 2409 // The history list in RenderView should have been updated. |
| 2400 EXPECT_EQ(1, view()->historyBackListCount()); | 2410 EXPECT_EQ(1, view()->historyBackListCount()); |
| 2401 EXPECT_EQ(2, view()->historyBackListCount() + | 2411 EXPECT_EQ(2, view()->historyBackListCount() + |
| 2402 view()->historyForwardListCount() + 1); | 2412 view()->historyForwardListCount() + 1); |
| 2403 } | 2413 } |
| 2404 | 2414 |
| 2405 TEST_F(DevToolsAgentTest, DevToolsResumeOnClose) { | 2415 TEST_F(DevToolsAgentTest, DevToolsResumeOnClose) { |
| 2406 Attach(); | 2416 Attach(); |
| 2407 EXPECT_FALSE(IsPaused()); | 2417 EXPECT_FALSE(IsPaused()); |
| 2408 DispatchDevToolsMessage("{\"id\":1,\"method\":\"Debugger.enable\"}"); | 2418 DispatchDevToolsMessage("{\"id\":1,\"method\":\"Debugger.enable\"}"); |
| 2409 | 2419 |
| 2410 // Executing javascript will pause the thread and create nested message loop. | 2420 // Executing javascript will pause the thread and create nested message loop. |
| 2411 // Posting task simulates message coming from browser. | 2421 // Posting task simulates message coming from browser. |
| 2412 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | 2422 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( |
| 2413 &DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); | 2423 &DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); |
| 2414 ExecuteJavaScript("debugger;"); | 2424 ExecuteJavaScript("debugger;"); |
| 2415 | 2425 |
| 2416 // CloseWhilePaused should resume execution and continue here. | 2426 // CloseWhilePaused should resume execution and continue here. |
| 2417 EXPECT_FALSE(IsPaused()); | 2427 EXPECT_FALSE(IsPaused()); |
| 2418 Detach(); | 2428 Detach(); |
| 2419 } | 2429 } |
| 2420 | 2430 |
| 2421 } // namespace content | 2431 } // namespace content |
| OLD | NEW |