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, |
| 289 const StartNavigationParams& start_params, |
| 290 const RequestNavigationParams& request_params) { |
| 291 // PlzNavigate |
| 292 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 293 switches::kEnableBrowserSideNavigation)) { |
| 294 frame()->OnCommitNavigation(ResourceResponseHead(), common_params.url, |
| 295 common_params, request_params); |
| 296 return; |
| 297 } |
| 298 frame()->OnNavigate(common_params, start_params, request_params); |
| 299 } |
| 300 |
288 private: | 301 private: |
289 scoped_ptr<MockKeyboard> mock_keyboard_; | 302 scoped_ptr<MockKeyboard> mock_keyboard_; |
290 }; | 303 }; |
291 | 304 |
292 class DevToolsAgentTest : public RenderViewImplTest { | 305 class DevToolsAgentTest : public RenderViewImplTest { |
293 public: | 306 public: |
294 void Attach() { | 307 void Attach() { |
295 std::string host_id = "host_id"; | 308 std::string host_id = "host_id"; |
296 agent()->OnAttach(host_id); | 309 agent()->OnAttach(host_id); |
297 } | 310 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 request_params.page_id = -1; | 438 request_params.page_id = -1; |
426 | 439 |
427 // Set up post data. | 440 // Set up post data. |
428 const unsigned char* raw_data = reinterpret_cast<const unsigned char*>( | 441 const unsigned char* raw_data = reinterpret_cast<const unsigned char*>( |
429 "post \0\ndata"); | 442 "post \0\ndata"); |
430 const unsigned int length = 11; | 443 const unsigned int length = 11; |
431 const std::vector<unsigned char> post_data(raw_data, raw_data + length); | 444 const std::vector<unsigned char> post_data(raw_data, raw_data + length); |
432 start_params.is_post = true; | 445 start_params.is_post = true; |
433 start_params.browser_initiated_post_data = post_data; | 446 start_params.browser_initiated_post_data = post_data; |
434 | 447 |
435 frame()->OnNavigate(common_params, start_params, request_params); | 448 NavigateFrame(common_params, start_params, request_params); |
436 ProcessPendingMessages(); | 449 ProcessPendingMessages(); |
437 | 450 |
438 const IPC::Message* frame_navigate_msg = | 451 const IPC::Message* frame_navigate_msg = |
439 render_thread_->sink().GetUniqueMessageMatching( | 452 render_thread_->sink().GetUniqueMessageMatching( |
440 FrameHostMsg_DidCommitProvisionalLoad::ID); | 453 FrameHostMsg_DidCommitProvisionalLoad::ID); |
441 EXPECT_TRUE(frame_navigate_msg); | 454 EXPECT_TRUE(frame_navigate_msg); |
442 | 455 |
443 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params; | 456 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params; |
444 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg, | 457 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg, |
445 &host_nav_params); | 458 &host_nav_params); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 // update for the swapped out URL. (http://crbug.com/72235) | 639 // update for the swapped out URL. (http://crbug.com/72235) |
627 CommonNavigationParams common_params; | 640 CommonNavigationParams common_params; |
628 RequestNavigationParams request_params; | 641 RequestNavigationParams request_params; |
629 common_params.url = GURL("data:text/html,<div>Page B</div>"); | 642 common_params.url = GURL("data:text/html,<div>Page B</div>"); |
630 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 643 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
631 common_params.transition = ui::PAGE_TRANSITION_TYPED; | 644 common_params.transition = ui::PAGE_TRANSITION_TYPED; |
632 request_params.current_history_list_length = 1; | 645 request_params.current_history_list_length = 1; |
633 request_params.current_history_list_offset = 0; | 646 request_params.current_history_list_offset = 0; |
634 request_params.pending_history_list_offset = 1; | 647 request_params.pending_history_list_offset = 1; |
635 request_params.page_id = -1; | 648 request_params.page_id = -1; |
636 frame()->OnNavigate(common_params, StartNavigationParams(), request_params); | 649 NavigateFrame(common_params, StartNavigationParams(), request_params); |
637 ProcessPendingMessages(); | 650 ProcessPendingMessages(); |
638 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching( | 651 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching( |
639 ViewHostMsg_UpdateState::ID); | 652 ViewHostMsg_UpdateState::ID); |
640 EXPECT_FALSE(msg3); | 653 EXPECT_FALSE(msg3); |
641 } | 654 } |
642 | 655 |
643 // Ensure the RenderViewImpl reloads the previous page if a reload request | 656 // Ensure the RenderViewImpl reloads the previous page if a reload request |
644 // arrives while it is showing swappedout://. http://crbug.com/143155. | 657 // arrives while it is showing swappedout://. http://crbug.com/143155. |
645 TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) { | 658 TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) { |
646 // Load page A. | 659 // Load page A. |
(...skipping 17 matching lines...) Expand all Loading... |
664 // Back to page A (page_id 1) and commit. | 677 // Back to page A (page_id 1) and commit. |
665 CommonNavigationParams common_params_A; | 678 CommonNavigationParams common_params_A; |
666 RequestNavigationParams request_params_A; | 679 RequestNavigationParams request_params_A; |
667 common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 680 common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
668 common_params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 681 common_params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
669 request_params_A.current_history_list_length = 2; | 682 request_params_A.current_history_list_length = 2; |
670 request_params_A.current_history_list_offset = 1; | 683 request_params_A.current_history_list_offset = 1; |
671 request_params_A.pending_history_list_offset = 0; | 684 request_params_A.pending_history_list_offset = 0; |
672 request_params_A.page_id = 1; | 685 request_params_A.page_id = 1; |
673 request_params_A.page_state = state_A; | 686 request_params_A.page_state = state_A; |
674 frame()->OnNavigate(common_params_A, StartNavigationParams(), | 687 NavigateFrame(common_params_A, StartNavigationParams(), request_params_A); |
675 request_params_A); | |
676 EXPECT_EQ(1, view()->historyBackListCount()); | 688 EXPECT_EQ(1, view()->historyBackListCount()); |
677 EXPECT_EQ(2, view()->historyBackListCount() + | 689 EXPECT_EQ(2, view()->historyBackListCount() + |
678 view()->historyForwardListCount() + 1); | 690 view()->historyForwardListCount() + 1); |
679 ProcessPendingMessages(); | 691 ProcessPendingMessages(); |
680 | 692 |
681 // Respond to a swap out request. | 693 // Respond to a swap out request. |
682 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId, true, | 694 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId, true, |
683 content::FrameReplicationState()); | 695 content::FrameReplicationState()); |
684 | 696 |
685 // Check for a OnSwapOutACK. | 697 // Check for a OnSwapOutACK. |
686 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | 698 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
687 FrameHostMsg_SwapOut_ACK::ID); | 699 FrameHostMsg_SwapOut_ACK::ID); |
688 ASSERT_TRUE(msg); | 700 ASSERT_TRUE(msg); |
689 render_thread_->sink().ClearMessages(); | 701 render_thread_->sink().ClearMessages(); |
690 | 702 |
691 // It is possible to get a reload request at this point, containing the | 703 // It is possible to get a reload request at this point, containing the |
692 // params.page_state of the initial page (e.g., if the new page fails the | 704 // params.page_state of the initial page (e.g., if the new page fails the |
693 // provisional load in the renderer process, after we unload the old page). | 705 // provisional load in the renderer process, after we unload the old page). |
694 // Ensure the old page gets reloaded, not swappedout://. | 706 // Ensure the old page gets reloaded, not swappedout://. |
695 CommonNavigationParams common_params; | 707 CommonNavigationParams common_params; |
696 RequestNavigationParams request_params; | 708 RequestNavigationParams request_params; |
697 common_params.url = GURL("data:text/html,<div>Page A</div>"); | 709 common_params.url = GURL("data:text/html,<div>Page A</div>"); |
698 common_params.navigation_type = FrameMsg_Navigate_Type::RELOAD; | 710 common_params.navigation_type = FrameMsg_Navigate_Type::RELOAD; |
699 common_params.transition = ui::PAGE_TRANSITION_RELOAD; | 711 common_params.transition = ui::PAGE_TRANSITION_RELOAD; |
700 request_params.current_history_list_length = 2; | 712 request_params.current_history_list_length = 2; |
701 request_params.current_history_list_offset = 0; | 713 request_params.current_history_list_offset = 0; |
702 request_params.pending_history_list_offset = 0; | 714 request_params.pending_history_list_offset = 0; |
703 request_params.page_id = 1; | 715 request_params.page_id = 1; |
704 request_params.page_state = state_A; | 716 request_params.page_state = state_A; |
705 frame()->OnNavigate(common_params, StartNavigationParams(), request_params); | 717 NavigateFrame(common_params, StartNavigationParams(), request_params); |
706 ProcessPendingMessages(); | 718 ProcessPendingMessages(); |
707 | 719 |
708 // Verify page A committed, not swappedout://. | 720 // Verify page A committed, not swappedout://. |
709 const IPC::Message* frame_navigate_msg = | 721 const IPC::Message* frame_navigate_msg = |
710 render_thread_->sink().GetUniqueMessageMatching( | 722 render_thread_->sink().GetUniqueMessageMatching( |
711 FrameHostMsg_DidCommitProvisionalLoad::ID); | 723 FrameHostMsg_DidCommitProvisionalLoad::ID); |
712 EXPECT_TRUE(frame_navigate_msg); | 724 EXPECT_TRUE(frame_navigate_msg); |
713 | 725 |
714 // Read URL out of the parent trait of the params object. | 726 // Read URL out of the parent trait of the params object. |
715 FrameHostMsg_DidCommitProvisionalLoad::Param commit_load_params; | 727 FrameHostMsg_DidCommitProvisionalLoad::Param commit_load_params; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 // Go back to C and commit, preparing for our real test. | 825 // Go back to C and commit, preparing for our real test. |
814 CommonNavigationParams common_params_C; | 826 CommonNavigationParams common_params_C; |
815 RequestNavigationParams request_params_C; | 827 RequestNavigationParams request_params_C; |
816 common_params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 828 common_params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
817 common_params_C.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 829 common_params_C.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
818 request_params_C.current_history_list_length = 4; | 830 request_params_C.current_history_list_length = 4; |
819 request_params_C.current_history_list_offset = 3; | 831 request_params_C.current_history_list_offset = 3; |
820 request_params_C.pending_history_list_offset = 2; | 832 request_params_C.pending_history_list_offset = 2; |
821 request_params_C.page_id = 3; | 833 request_params_C.page_id = 3; |
822 request_params_C.page_state = state_C; | 834 request_params_C.page_state = state_C; |
823 frame()->OnNavigate(common_params_C, StartNavigationParams(), | 835 NavigateFrame(common_params_C, StartNavigationParams(), request_params_C); |
824 request_params_C); | |
825 ProcessPendingMessages(); | 836 ProcessPendingMessages(); |
826 render_thread_->sink().ClearMessages(); | 837 render_thread_->sink().ClearMessages(); |
827 | 838 |
828 // Go back twice quickly, such that page B does not have a chance to commit. | 839 // Go back twice quickly, such that page B does not have a chance to commit. |
829 // This leads to two changes to the back/forward list but only one change to | 840 // This leads to two changes to the back/forward list but only one change to |
830 // the RenderView's page ID. | 841 // the RenderView's page ID. |
831 | 842 |
832 // Back to page B (page_id 2), without committing. | 843 // Back to page B (page_id 2), without committing. |
833 CommonNavigationParams common_params_B; | 844 CommonNavigationParams common_params_B; |
834 RequestNavigationParams request_params_B; | 845 RequestNavigationParams request_params_B; |
835 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 846 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
836 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 847 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
837 request_params_B.current_history_list_length = 4; | 848 request_params_B.current_history_list_length = 4; |
838 request_params_B.current_history_list_offset = 2; | 849 request_params_B.current_history_list_offset = 2; |
839 request_params_B.pending_history_list_offset = 1; | 850 request_params_B.pending_history_list_offset = 1; |
840 request_params_B.page_id = 2; | 851 request_params_B.page_id = 2; |
841 request_params_B.page_state = state_B; | 852 request_params_B.page_state = state_B; |
842 frame()->OnNavigate(common_params_B, StartNavigationParams(), | 853 NavigateFrame(common_params_B, StartNavigationParams(), request_params_B); |
843 request_params_B); | |
844 | 854 |
845 // Back to page A (page_id 1) and commit. | 855 // Back to page A (page_id 1) and commit. |
846 CommonNavigationParams common_params; | 856 CommonNavigationParams common_params; |
847 RequestNavigationParams request_params; | 857 RequestNavigationParams request_params; |
848 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 858 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
849 common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 859 common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
850 request_params.current_history_list_length = 4; | 860 request_params.current_history_list_length = 4; |
851 request_params.current_history_list_offset = 2; | 861 request_params.current_history_list_offset = 2; |
852 request_params.pending_history_list_offset = 0; | 862 request_params.pending_history_list_offset = 0; |
853 request_params.page_id = 1; | 863 request_params.page_id = 1; |
854 request_params.page_state = state_A; | 864 request_params.page_state = state_A; |
855 frame()->OnNavigate(common_params, StartNavigationParams(), request_params); | 865 NavigateFrame(common_params, StartNavigationParams(), request_params); |
856 ProcessPendingMessages(); | 866 ProcessPendingMessages(); |
857 | 867 |
858 // Now ensure that the UpdateState message we receive is consistent | 868 // Now ensure that the UpdateState message we receive is consistent |
859 // and represents page C in both page_id and state. | 869 // and represents page C in both page_id and state. |
860 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | 870 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
861 ViewHostMsg_UpdateState::ID); | 871 ViewHostMsg_UpdateState::ID); |
862 ASSERT_TRUE(msg); | 872 ASSERT_TRUE(msg); |
863 ViewHostMsg_UpdateState::Read(msg, ¶m); | 873 ViewHostMsg_UpdateState::Read(msg, ¶m); |
864 int page_id = get<0>(param); | 874 int page_id = get<0>(param); |
865 PageState state = get<1>(param); | 875 PageState state = get<1>(param); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 // Back to page A (page_id 1) and commit. | 907 // Back to page A (page_id 1) and commit. |
898 CommonNavigationParams common_params_A; | 908 CommonNavigationParams common_params_A; |
899 RequestNavigationParams request_params_A; | 909 RequestNavigationParams request_params_A; |
900 common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 910 common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
901 common_params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 911 common_params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
902 request_params_A.current_history_list_length = 2; | 912 request_params_A.current_history_list_length = 2; |
903 request_params_A.current_history_list_offset = 1; | 913 request_params_A.current_history_list_offset = 1; |
904 request_params_A.pending_history_list_offset = 0; | 914 request_params_A.pending_history_list_offset = 0; |
905 request_params_A.page_id = 1; | 915 request_params_A.page_id = 1; |
906 request_params_A.page_state = state_A; | 916 request_params_A.page_state = state_A; |
907 frame()->OnNavigate(common_params_A, StartNavigationParams(), | 917 NavigateFrame(common_params_A, StartNavigationParams(), request_params_A); |
908 request_params_A); | |
909 ProcessPendingMessages(); | 918 ProcessPendingMessages(); |
910 | 919 |
911 // A new navigation commits, clearing the forward history. | 920 // A new navigation commits, clearing the forward history. |
912 LoadHTML("<div>Page C</div>"); | 921 LoadHTML("<div>Page C</div>"); |
913 EXPECT_EQ(2, view()->history_list_length_); | 922 EXPECT_EQ(2, view()->history_list_length_); |
914 EXPECT_EQ(1, view()->history_list_offset_); | 923 EXPECT_EQ(1, view()->history_list_offset_); |
915 EXPECT_EQ(3, view()->page_id_); // page C is now page id 3 | 924 EXPECT_EQ(3, view()->page_id_); // page C is now page id 3 |
916 | 925 |
917 // The browser then sends a stale navigation to B, which should be ignored. | 926 // The browser then sends a stale navigation to B, which should be ignored. |
918 CommonNavigationParams common_params_B; | 927 CommonNavigationParams common_params_B; |
919 RequestNavigationParams request_params_B; | 928 RequestNavigationParams request_params_B; |
920 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 929 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
921 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 930 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
922 request_params_B.current_history_list_length = 2; | 931 request_params_B.current_history_list_length = 2; |
923 request_params_B.current_history_list_offset = 0; | 932 request_params_B.current_history_list_offset = 0; |
924 request_params_B.pending_history_list_offset = 1; | 933 request_params_B.pending_history_list_offset = 1; |
925 request_params_B.page_id = 2; | 934 request_params_B.page_id = 2; |
926 request_params_B.page_state = | 935 request_params_B.page_state = |
927 state_A; // Doesn't matter, just has to be present. | 936 state_A; // Doesn't matter, just has to be present. |
928 frame()->OnNavigate(common_params_B, StartNavigationParams(), | 937 NavigateFrame(common_params_B, StartNavigationParams(), request_params_B); |
929 request_params_B); | |
930 | 938 |
931 // State should be unchanged. | 939 // State should be unchanged. |
932 EXPECT_EQ(2, view()->history_list_length_); | 940 EXPECT_EQ(2, view()->history_list_length_); |
933 EXPECT_EQ(1, view()->history_list_offset_); | 941 EXPECT_EQ(1, view()->history_list_offset_); |
934 EXPECT_EQ(3, view()->page_id_); // page C, not page B | 942 EXPECT_EQ(3, view()->page_id_); // page C, not page B |
935 | 943 |
936 // Check for a valid DidDropNavigation message. | 944 // Check for a valid DidDropNavigation message. |
937 ProcessPendingMessages(); | 945 ProcessPendingMessages(); |
938 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | 946 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
939 FrameHostMsg_DidDropNavigation::ID); | 947 FrameHostMsg_DidDropNavigation::ID); |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1634 error.domain = WebString::fromUTF8(net::kErrorDomain); | 1642 error.domain = WebString::fromUTF8(net::kErrorDomain); |
1635 error.reason = net::ERR_FILE_NOT_FOUND; | 1643 error.reason = net::ERR_FILE_NOT_FOUND; |
1636 error.unreachableURL = GURL("http://foo"); | 1644 error.unreachableURL = GURL("http://foo"); |
1637 WebLocalFrame* web_frame = GetMainFrame(); | 1645 WebLocalFrame* web_frame = GetMainFrame(); |
1638 | 1646 |
1639 // Start a load that will reach provisional state synchronously, | 1647 // Start a load that will reach provisional state synchronously, |
1640 // but won't complete synchronously. | 1648 // but won't complete synchronously. |
1641 CommonNavigationParams common_params; | 1649 CommonNavigationParams common_params; |
1642 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1650 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
1643 common_params.url = GURL("data:text/html,test data"); | 1651 common_params.url = GURL("data:text/html,test data"); |
1644 frame()->OnNavigate(common_params, StartNavigationParams(), | 1652 NavigateFrame(common_params, StartNavigationParams(), |
1645 RequestNavigationParams()); | 1653 RequestNavigationParams()); |
1646 | 1654 |
1647 // An error occurred. | 1655 // An error occurred. |
1648 view()->GetMainRenderFrame()->didFailProvisionalLoad( | 1656 view()->GetMainRenderFrame()->didFailProvisionalLoad( |
1649 web_frame, error, blink::WebStandardCommit); | 1657 web_frame, error, blink::WebStandardCommit); |
1650 // Frame should exit view-source mode. | 1658 // Frame should exit view-source mode. |
1651 EXPECT_FALSE(web_frame->isViewSourceModeEnabled()); | 1659 EXPECT_FALSE(web_frame->isViewSourceModeEnabled()); |
1652 } | 1660 } |
1653 | 1661 |
1654 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) { | 1662 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) { |
1655 GetMainFrame()->enableViewSourceMode(true); | 1663 GetMainFrame()->enableViewSourceMode(true); |
1656 WebURLError error; | 1664 WebURLError error; |
1657 error.domain = WebString::fromUTF8(net::kErrorDomain); | 1665 error.domain = WebString::fromUTF8(net::kErrorDomain); |
1658 error.reason = net::ERR_ABORTED; | 1666 error.reason = net::ERR_ABORTED; |
1659 error.unreachableURL = GURL("http://foo"); | 1667 error.unreachableURL = GURL("http://foo"); |
1660 WebLocalFrame* web_frame = GetMainFrame(); | 1668 WebLocalFrame* web_frame = GetMainFrame(); |
1661 | 1669 |
1662 // Start a load that will reach provisional state synchronously, | 1670 // Start a load that will reach provisional state synchronously, |
1663 // but won't complete synchronously. | 1671 // but won't complete synchronously. |
1664 CommonNavigationParams common_params; | 1672 CommonNavigationParams common_params; |
1665 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1673 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
1666 common_params.url = GURL("data:text/html,test data"); | 1674 common_params.url = GURL("data:text/html,test data"); |
1667 frame()->OnNavigate(common_params, StartNavigationParams(), | 1675 NavigateFrame(common_params, StartNavigationParams(), |
1668 RequestNavigationParams()); | 1676 RequestNavigationParams()); |
1669 | 1677 |
1670 // A cancellation occurred. | 1678 // A cancellation occurred. |
1671 view()->GetMainRenderFrame()->didFailProvisionalLoad( | 1679 view()->GetMainRenderFrame()->didFailProvisionalLoad( |
1672 web_frame, error, blink::WebStandardCommit); | 1680 web_frame, error, blink::WebStandardCommit); |
1673 // Frame should stay in view-source mode. | 1681 // Frame should stay in view-source mode. |
1674 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); | 1682 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); |
1675 } | 1683 } |
1676 | 1684 |
1677 // Regression test for http://crbug.com/41562 | 1685 // Regression test for http://crbug.com/41562 |
1678 TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) { | 1686 TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) { |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1855 TEST_F(RenderViewImplTest, ZoomLimit) { | 1863 TEST_F(RenderViewImplTest, ZoomLimit) { |
1856 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor); | 1864 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor); |
1857 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor); | 1865 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor); |
1858 | 1866 |
1859 // Verifies navigation to a URL with preset zoom level indeed sets the level. | 1867 // Verifies navigation to a URL with preset zoom level indeed sets the level. |
1860 // Regression test for http://crbug.com/139559, where the level was not | 1868 // Regression test for http://crbug.com/139559, where the level was not |
1861 // properly set when it is out of the default zoom limits of WebView. | 1869 // properly set when it is out of the default zoom limits of WebView. |
1862 CommonNavigationParams common_params; | 1870 CommonNavigationParams common_params; |
1863 common_params.url = GURL("data:text/html,min_zoomlimit_test"); | 1871 common_params.url = GURL("data:text/html,min_zoomlimit_test"); |
1864 view()->OnSetZoomLevelForLoadingURL(common_params.url, kMinZoomLevel); | 1872 view()->OnSetZoomLevelForLoadingURL(common_params.url, kMinZoomLevel); |
1865 frame()->OnNavigate(common_params, StartNavigationParams(), | 1873 NavigateFrame(common_params, StartNavigationParams(), |
1866 RequestNavigationParams()); | 1874 RequestNavigationParams()); |
1867 ProcessPendingMessages(); | 1875 ProcessPendingMessages(); |
1868 EXPECT_DOUBLE_EQ(kMinZoomLevel, view()->GetWebView()->zoomLevel()); | 1876 EXPECT_DOUBLE_EQ(kMinZoomLevel, view()->GetWebView()->zoomLevel()); |
1869 | 1877 |
1870 // It should work even when the zoom limit is temporarily changed in the page. | 1878 // It should work even when the zoom limit is temporarily changed in the page. |
1871 view()->GetWebView()->zoomLimitsChanged(ZoomFactorToZoomLevel(1.0), | 1879 view()->GetWebView()->zoomLimitsChanged(ZoomFactorToZoomLevel(1.0), |
1872 ZoomFactorToZoomLevel(1.0)); | 1880 ZoomFactorToZoomLevel(1.0)); |
1873 common_params.url = GURL("data:text/html,max_zoomlimit_test"); | 1881 common_params.url = GURL("data:text/html,max_zoomlimit_test"); |
1874 view()->OnSetZoomLevelForLoadingURL(common_params.url, kMaxZoomLevel); | 1882 view()->OnSetZoomLevelForLoadingURL(common_params.url, kMaxZoomLevel); |
1875 frame()->OnNavigate(common_params, StartNavigationParams(), | 1883 NavigateFrame(common_params, StartNavigationParams(), |
1876 RequestNavigationParams()); | 1884 RequestNavigationParams()); |
1877 ProcessPendingMessages(); | 1885 ProcessPendingMessages(); |
1878 EXPECT_DOUBLE_EQ(kMaxZoomLevel, view()->GetWebView()->zoomLevel()); | 1886 EXPECT_DOUBLE_EQ(kMaxZoomLevel, view()->GetWebView()->zoomLevel()); |
1879 } | 1887 } |
1880 | 1888 |
1881 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) { | 1889 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) { |
1882 // Load an HTML page consisting of an input field. | 1890 // Load an HTML page consisting of an input field. |
1883 LoadHTML("<html>" | 1891 LoadHTML("<html>" |
1884 "<head>" | 1892 "<head>" |
1885 "</head>" | 1893 "</head>" |
1886 "<body>" | 1894 "<body>" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1938 common_params.url = GURL("data:text/html,world"); | 1946 common_params.url = GURL("data:text/html,world"); |
1939 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1947 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
1940 common_params.transition = ui::PAGE_TRANSITION_TYPED; | 1948 common_params.transition = ui::PAGE_TRANSITION_TYPED; |
1941 request_params.current_history_list_length = 1; | 1949 request_params.current_history_list_length = 1; |
1942 request_params.current_history_list_offset = 0; | 1950 request_params.current_history_list_offset = 0; |
1943 request_params.pending_history_list_offset = 1; | 1951 request_params.pending_history_list_offset = 1; |
1944 request_params.page_id = -1; | 1952 request_params.page_id = -1; |
1945 request_params.frame_to_navigate = "frame"; | 1953 request_params.frame_to_navigate = "frame"; |
1946 request_params.browser_navigation_start = | 1954 request_params.browser_navigation_start = |
1947 base::TimeTicks::FromInternalValue(1); | 1955 base::TimeTicks::FromInternalValue(1); |
1948 frame()->OnNavigate(common_params, StartNavigationParams(), request_params); | 1956 NavigateFrame(common_params, StartNavigationParams(), request_params); |
1949 FrameLoadWaiter( | 1957 FrameLoadWaiter( |
1950 RenderFrame::FromWebFrame(frame()->GetWebFrame()->firstChild())).Wait(); | 1958 RenderFrame::FromWebFrame(frame()->GetWebFrame()->firstChild())).Wait(); |
1951 | 1959 |
1952 // Copy the document content to std::wstring and compare with the | 1960 // Copy the document content to std::wstring and compare with the |
1953 // expected result. | 1961 // expected result. |
1954 const int kMaxOutputCharacters = 256; | 1962 const int kMaxOutputCharacters = 256; |
1955 std::string output = base::UTF16ToUTF8( | 1963 std::string output = base::UTF16ToUTF8( |
1956 GetMainFrame()->contentAsText(kMaxOutputCharacters)); | 1964 GetMainFrame()->contentAsText(kMaxOutputCharacters)); |
1957 EXPECT_EQ(output, "hello \n\nworld"); | 1965 EXPECT_EQ(output, "hello \n\nworld"); |
1958 } | 1966 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2002 } | 2010 } |
2003 } | 2011 } |
2004 | 2012 |
2005 EXPECT_TRUE(is_input_type_called); | 2013 EXPECT_TRUE(is_input_type_called); |
2006 EXPECT_TRUE(is_selection_called); | 2014 EXPECT_TRUE(is_selection_called); |
2007 | 2015 |
2008 // InputTypeChange shold be called earlier than SelectionChanged. | 2016 // InputTypeChange shold be called earlier than SelectionChanged. |
2009 EXPECT_LT(last_input_type, last_selection); | 2017 EXPECT_LT(last_input_type, last_selection); |
2010 } | 2018 } |
2011 | 2019 |
2012 class SuppressErrorPageTest : public RenderViewTest { | 2020 class SuppressErrorPageTest : public RenderViewImplTest { |
2013 public: | 2021 public: |
2014 ContentRendererClient* CreateContentRendererClient() override { | 2022 ContentRendererClient* CreateContentRendererClient() override { |
2015 return new TestContentRendererClient; | 2023 return new TestContentRendererClient; |
2016 } | 2024 } |
2017 | 2025 |
2018 RenderViewImpl* view() { | 2026 RenderViewImpl* view() { |
2019 return static_cast<RenderViewImpl*>(view_); | 2027 return static_cast<RenderViewImpl*>(view_); |
2020 } | 2028 } |
2021 | 2029 |
2022 RenderFrameImpl* frame() { | 2030 RenderFrameImpl* frame() { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2055 error.domain = WebString::fromUTF8(net::kErrorDomain); | 2063 error.domain = WebString::fromUTF8(net::kErrorDomain); |
2056 error.reason = net::ERR_FILE_NOT_FOUND; | 2064 error.reason = net::ERR_FILE_NOT_FOUND; |
2057 error.unreachableURL = GURL("http://example.com/suppress"); | 2065 error.unreachableURL = GURL("http://example.com/suppress"); |
2058 WebLocalFrame* web_frame = GetMainFrame(); | 2066 WebLocalFrame* web_frame = GetMainFrame(); |
2059 | 2067 |
2060 // Start a load that will reach provisional state synchronously, | 2068 // Start a load that will reach provisional state synchronously, |
2061 // but won't complete synchronously. | 2069 // but won't complete synchronously. |
2062 CommonNavigationParams common_params; | 2070 CommonNavigationParams common_params; |
2063 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2071 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
2064 common_params.url = GURL("data:text/html,test data"); | 2072 common_params.url = GURL("data:text/html,test data"); |
2065 frame()->OnNavigate(common_params, StartNavigationParams(), | 2073 NavigateFrame(common_params, StartNavigationParams(), |
2066 RequestNavigationParams()); | 2074 RequestNavigationParams()); |
2067 | 2075 |
2068 // An error occurred. | 2076 // An error occurred. |
2069 view()->GetMainRenderFrame()->didFailProvisionalLoad( | 2077 view()->GetMainRenderFrame()->didFailProvisionalLoad( |
2070 web_frame, error, blink::WebStandardCommit); | 2078 web_frame, error, blink::WebStandardCommit); |
2071 const int kMaxOutputCharacters = 22; | 2079 const int kMaxOutputCharacters = 22; |
2072 EXPECT_EQ("", | 2080 EXPECT_EQ("", |
2073 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); | 2081 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); |
2074 } | 2082 } |
2075 | 2083 |
2076 #if defined(OS_ANDROID) | 2084 #if defined(OS_ANDROID) |
2077 // Crashing on Android: http://crbug.com/311341 | 2085 // Crashing on Android: http://crbug.com/311341 |
2078 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress | 2086 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress |
2079 #else | 2087 #else |
2080 #define MAYBE_DoesNotSuppress DoesNotSuppress | 2088 #define MAYBE_DoesNotSuppress DoesNotSuppress |
2081 #endif | 2089 #endif |
2082 | 2090 |
2083 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) { | 2091 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) { |
2084 WebURLError error; | 2092 WebURLError error; |
2085 error.domain = WebString::fromUTF8(net::kErrorDomain); | 2093 error.domain = WebString::fromUTF8(net::kErrorDomain); |
2086 error.reason = net::ERR_FILE_NOT_FOUND; | 2094 error.reason = net::ERR_FILE_NOT_FOUND; |
2087 error.unreachableURL = GURL("http://example.com/dont-suppress"); | 2095 error.unreachableURL = GURL("http://example.com/dont-suppress"); |
2088 WebLocalFrame* web_frame = GetMainFrame(); | 2096 WebLocalFrame* web_frame = GetMainFrame(); |
2089 | 2097 |
2090 // Start a load that will reach provisional state synchronously, | 2098 // Start a load that will reach provisional state synchronously, |
2091 // but won't complete synchronously. | 2099 // but won't complete synchronously. |
2092 CommonNavigationParams common_params; | 2100 CommonNavigationParams common_params; |
2093 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2101 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
2094 common_params.url = GURL("data:text/html,test data"); | 2102 common_params.url = GURL("data:text/html,test data"); |
2095 frame()->OnNavigate(common_params, StartNavigationParams(), | 2103 NavigateFrame(common_params, StartNavigationParams(), |
2096 RequestNavigationParams()); | 2104 RequestNavigationParams()); |
2097 | 2105 |
2098 // An error occurred. | 2106 // An error occurred. |
2099 view()->GetMainRenderFrame()->didFailProvisionalLoad( | 2107 view()->GetMainRenderFrame()->didFailProvisionalLoad( |
2100 web_frame, error, blink::WebStandardCommit); | 2108 web_frame, error, blink::WebStandardCommit); |
2101 // The error page itself is loaded asynchronously. | 2109 // The error page itself is loaded asynchronously. |
2102 FrameLoadWaiter(frame()).Wait(); | 2110 FrameLoadWaiter(frame()).Wait(); |
2103 const int kMaxOutputCharacters = 22; | 2111 const int kMaxOutputCharacters = 22; |
2104 EXPECT_EQ("A suffusion of yellow.", | 2112 EXPECT_EQ("A suffusion of yellow.", |
2105 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); | 2113 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); |
2106 } | 2114 } |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2296 CommonNavigationParams early_common_params; | 2304 CommonNavigationParams early_common_params; |
2297 StartNavigationParams early_start_params; | 2305 StartNavigationParams early_start_params; |
2298 RequestNavigationParams early_request_params; | 2306 RequestNavigationParams early_request_params; |
2299 early_common_params.url = GURL("data:text/html,<div>Page</div>"); | 2307 early_common_params.url = GURL("data:text/html,<div>Page</div>"); |
2300 early_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2308 early_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
2301 early_common_params.transition = ui::PAGE_TRANSITION_TYPED; | 2309 early_common_params.transition = ui::PAGE_TRANSITION_TYPED; |
2302 early_start_params.is_post = true; | 2310 early_start_params.is_post = true; |
2303 early_request_params.browser_navigation_start = | 2311 early_request_params.browser_navigation_start = |
2304 base::TimeTicks::FromInternalValue(1); | 2312 base::TimeTicks::FromInternalValue(1); |
2305 | 2313 |
2306 frame()->OnNavigate(early_common_params, early_start_params, | 2314 NavigateFrame(early_common_params, early_start_params, early_request_params); |
2307 early_request_params); | |
2308 ProcessPendingMessages(); | 2315 ProcessPendingMessages(); |
2309 | 2316 |
2310 base::Time early_nav_reported_start = | 2317 base::Time early_nav_reported_start = |
2311 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); | 2318 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); |
2312 EXPECT_LT(early_nav_reported_start, before_navigation); | 2319 EXPECT_LT(early_nav_reported_start, before_navigation); |
2313 | 2320 |
2314 // Verify that a navigation that claims to have started in the future - 42 | 2321 // Verify that a navigation that claims to have started in the future - 42 |
2315 // days from now is *not* reported as one that starts in the future; as we | 2322 // days from now is *not* reported as one that starts in the future; as we |
2316 // sanitize the override allowing a maximum of ::Now(). | 2323 // sanitize the override allowing a maximum of ::Now(). |
2317 CommonNavigationParams late_common_params; | 2324 CommonNavigationParams late_common_params; |
2318 RequestNavigationParams late_request_params; | 2325 RequestNavigationParams late_request_params; |
2319 StartNavigationParams late_start_params; | 2326 StartNavigationParams late_start_params; |
2320 late_common_params.url = GURL("data:text/html,<div>Another page</div>"); | 2327 late_common_params.url = GURL("data:text/html,<div>Another page</div>"); |
2321 late_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2328 late_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
2322 late_common_params.transition = ui::PAGE_TRANSITION_TYPED; | 2329 late_common_params.transition = ui::PAGE_TRANSITION_TYPED; |
2323 late_start_params.is_post = true; | 2330 late_start_params.is_post = true; |
2324 late_request_params.browser_navigation_start = | 2331 late_request_params.browser_navigation_start = |
2325 base::TimeTicks::Now() + base::TimeDelta::FromDays(42); | 2332 base::TimeTicks::Now() + base::TimeDelta::FromDays(42); |
2326 | 2333 |
2327 frame()->OnNavigate(late_common_params, late_start_params, | 2334 NavigateFrame(late_common_params, late_start_params, late_request_params); |
2328 late_request_params); | |
2329 ProcessPendingMessages(); | 2335 ProcessPendingMessages(); |
2330 base::Time after_navigation = | 2336 base::Time after_navigation = |
2331 base::Time::Now() + base::TimeDelta::FromDays(1); | 2337 base::Time::Now() + base::TimeDelta::FromDays(1); |
2332 | 2338 |
2333 base::Time late_nav_reported_start = | 2339 base::Time late_nav_reported_start = |
2334 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); | 2340 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); |
2335 EXPECT_LE(late_nav_reported_start, after_navigation); | 2341 EXPECT_LE(late_nav_reported_start, after_navigation); |
2336 } | 2342 } |
2337 | 2343 |
2338 TEST_F(RenderViewImplTest, PreferredSizeZoomed) { | 2344 TEST_F(RenderViewImplTest, PreferredSizeZoomed) { |
(...skipping 16 matching lines...) Expand all Loading... |
2355 EXPECT_EQ(0, view()->historyBackListCount()); | 2361 EXPECT_EQ(0, view()->historyBackListCount()); |
2356 EXPECT_EQ(0, view()->historyBackListCount() + | 2362 EXPECT_EQ(0, view()->historyBackListCount() + |
2357 view()->historyForwardListCount() + 1); | 2363 view()->historyForwardListCount() + 1); |
2358 | 2364 |
2359 // Receive a Navigate message with history parameters. | 2365 // Receive a Navigate message with history parameters. |
2360 RequestNavigationParams request_params; | 2366 RequestNavigationParams request_params; |
2361 request_params.current_history_list_length = 2; | 2367 request_params.current_history_list_length = 2; |
2362 request_params.current_history_list_offset = 1; | 2368 request_params.current_history_list_offset = 1; |
2363 request_params.pending_history_list_offset = 2; | 2369 request_params.pending_history_list_offset = 2; |
2364 request_params.page_id = -1; | 2370 request_params.page_id = -1; |
2365 frame()->OnNavigate(CommonNavigationParams(), StartNavigationParams(), | 2371 NavigateFrame(CommonNavigationParams(), StartNavigationParams(), |
2366 request_params); | 2372 request_params); |
2367 | 2373 |
2368 // The history list in RenderView should have been updated. | 2374 // The history list in RenderView should have been updated. |
2369 EXPECT_EQ(1, view()->historyBackListCount()); | 2375 EXPECT_EQ(1, view()->historyBackListCount()); |
2370 EXPECT_EQ(2, view()->historyBackListCount() + | 2376 EXPECT_EQ(2, view()->historyBackListCount() + |
2371 view()->historyForwardListCount() + 1); | 2377 view()->historyForwardListCount() + 1); |
2372 } | 2378 } |
2373 | 2379 |
2374 TEST_F(DevToolsAgentTest, DevToolsResumeOnClose) { | 2380 TEST_F(DevToolsAgentTest, DevToolsResumeOnClose) { |
2375 Attach(); | 2381 Attach(); |
2376 EXPECT_FALSE(IsPaused()); | 2382 EXPECT_FALSE(IsPaused()); |
2377 DispatchDevToolsMessage("{\"id\":1,\"method\":\"Debugger.enable\"}"); | 2383 DispatchDevToolsMessage("{\"id\":1,\"method\":\"Debugger.enable\"}"); |
2378 | 2384 |
2379 // Executing javascript will pause the thread and create nested message loop. | 2385 // Executing javascript will pause the thread and create nested message loop. |
2380 // Posting task simulates message coming from browser. | 2386 // Posting task simulates message coming from browser. |
2381 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | 2387 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( |
2382 &DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); | 2388 &DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); |
2383 ExecuteJavaScript("debugger;"); | 2389 ExecuteJavaScript("debugger;"); |
2384 | 2390 |
2385 // CloseWhilePaused should resume execution and continue here. | 2391 // CloseWhilePaused should resume execution and continue here. |
2386 EXPECT_FALSE(IsPaused()); | 2392 EXPECT_FALSE(IsPaused()); |
2387 Detach(); | 2393 Detach(); |
2388 } | 2394 } |
2389 | 2395 |
2390 } // namespace content | 2396 } // namespace content |
OLD | NEW |