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

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

Issue 148083013: Move browser initiated navigation from RenderViewHost to RenderFrameHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ASAN builds. Try 2. Created 6 years, 10 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 | Annotate | Revision Log
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 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 432
433 // Change the value of the input. We should have gotten an update state 433 // Change the value of the input. We should have gotten an update state
434 // notification. We need to spin the message loop to catch this update. 434 // notification. We need to spin the message loop to catch this update.
435 ExecuteJavaScript("document.getElementById('elt_text').value = 'foo';"); 435 ExecuteJavaScript("document.getElementById('elt_text').value = 'foo';");
436 ProcessPendingMessages(); 436 ProcessPendingMessages();
437 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( 437 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching(
438 ViewHostMsg_UpdateState::ID)); 438 ViewHostMsg_UpdateState::ID));
439 } 439 }
440 440
441 TEST_F(RenderViewImplTest, OnNavigationHttpPost) { 441 TEST_F(RenderViewImplTest, OnNavigationHttpPost) {
442 ViewMsg_Navigate_Params nav_params; 442 FrameMsg_Navigate_Params nav_params;
443 443
444 // An http url will trigger a resource load so cannot be used here. 444 // An http url will trigger a resource load so cannot be used here.
445 nav_params.url = GURL("data:text/html,<div>Page</div>"); 445 nav_params.url = GURL("data:text/html,<div>Page</div>");
446 nav_params.navigation_type = ViewMsg_Navigate_Type::NORMAL; 446 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
447 nav_params.transition = PAGE_TRANSITION_TYPED; 447 nav_params.transition = PAGE_TRANSITION_TYPED;
448 nav_params.page_id = -1; 448 nav_params.page_id = -1;
449 nav_params.is_post = true; 449 nav_params.is_post = true;
450 450
451 // Set up post data. 451 // Set up post data.
452 const unsigned char* raw_data = reinterpret_cast<const unsigned char*>( 452 const unsigned char* raw_data = reinterpret_cast<const unsigned char*>(
453 "post \0\ndata"); 453 "post \0\ndata");
454 const unsigned int length = 11; 454 const unsigned int length = 11;
455 const std::vector<unsigned char> post_data(raw_data, raw_data + length); 455 const std::vector<unsigned char> post_data(raw_data, raw_data + length);
456 nav_params.browser_initiated_post_data = post_data; 456 nav_params.browser_initiated_post_data = post_data;
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 // It is possible to get another swap out request. Ensure that we send 637 // It is possible to get another swap out request. Ensure that we send
638 // an ACK, even if we don't have to do anything else. 638 // an ACK, even if we don't have to do anything else.
639 render_thread_->sink().ClearMessages(); 639 render_thread_->sink().ClearMessages();
640 view()->OnSwapOut(); 640 view()->OnSwapOut();
641 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching( 641 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching(
642 ViewHostMsg_SwapOut_ACK::ID); 642 ViewHostMsg_SwapOut_ACK::ID);
643 ASSERT_TRUE(msg2); 643 ASSERT_TRUE(msg2);
644 644
645 // If we navigate back to this RenderView, ensure we don't send a state 645 // If we navigate back to this RenderView, ensure we don't send a state
646 // update for the swapped out URL. (http://crbug.com/72235) 646 // update for the swapped out URL. (http://crbug.com/72235)
647 ViewMsg_Navigate_Params nav_params; 647 FrameMsg_Navigate_Params nav_params;
648 nav_params.url = GURL("data:text/html,<div>Page B</div>"); 648 nav_params.url = GURL("data:text/html,<div>Page B</div>");
649 nav_params.navigation_type = ViewMsg_Navigate_Type::NORMAL; 649 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
650 nav_params.transition = PAGE_TRANSITION_TYPED; 650 nav_params.transition = PAGE_TRANSITION_TYPED;
651 nav_params.current_history_list_length = 1; 651 nav_params.current_history_list_length = 1;
652 nav_params.current_history_list_offset = 0; 652 nav_params.current_history_list_offset = 0;
653 nav_params.pending_history_list_offset = 1; 653 nav_params.pending_history_list_offset = 1;
654 nav_params.page_id = -1; 654 nav_params.page_id = -1;
655 view()->OnNavigate(nav_params); 655 view()->OnNavigate(nav_params);
656 ProcessPendingMessages(); 656 ProcessPendingMessages();
657 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching( 657 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching(
658 ViewHostMsg_UpdateState::ID); 658 ViewHostMsg_UpdateState::ID);
659 EXPECT_FALSE(msg3); 659 EXPECT_FALSE(msg3);
(...skipping 13 matching lines...) Expand all
673 const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching( 673 const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching(
674 ViewHostMsg_UpdateState::ID); 674 ViewHostMsg_UpdateState::ID);
675 ASSERT_TRUE(msg_A); 675 ASSERT_TRUE(msg_A);
676 int page_id_A; 676 int page_id_A;
677 PageState state_A; 677 PageState state_A;
678 ViewHostMsg_UpdateState::Read(msg_A, &page_id_A, &state_A); 678 ViewHostMsg_UpdateState::Read(msg_A, &page_id_A, &state_A);
679 EXPECT_EQ(1, page_id_A); 679 EXPECT_EQ(1, page_id_A);
680 render_thread_->sink().ClearMessages(); 680 render_thread_->sink().ClearMessages();
681 681
682 // Back to page A (page_id 1) and commit. 682 // Back to page A (page_id 1) and commit.
683 ViewMsg_Navigate_Params params_A; 683 FrameMsg_Navigate_Params params_A;
684 params_A.navigation_type = ViewMsg_Navigate_Type::NORMAL; 684 params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL;
685 params_A.transition = PAGE_TRANSITION_FORWARD_BACK; 685 params_A.transition = PAGE_TRANSITION_FORWARD_BACK;
686 params_A.current_history_list_length = 2; 686 params_A.current_history_list_length = 2;
687 params_A.current_history_list_offset = 1; 687 params_A.current_history_list_offset = 1;
688 params_A.pending_history_list_offset = 0; 688 params_A.pending_history_list_offset = 0;
689 params_A.page_id = 1; 689 params_A.page_id = 1;
690 params_A.page_state = state_A; 690 params_A.page_state = state_A;
691 view()->OnNavigate(params_A); 691 view()->OnNavigate(params_A);
692 ProcessPendingMessages(); 692 ProcessPendingMessages();
693 693
694 // Respond to a swap out request. 694 // Respond to a swap out request.
695 view()->OnSwapOut(); 695 view()->OnSwapOut();
696 696
697 // Check for a OnSwapOutACK. 697 // Check for a OnSwapOutACK.
698 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( 698 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching(
699 ViewHostMsg_SwapOut_ACK::ID); 699 ViewHostMsg_SwapOut_ACK::ID);
700 ASSERT_TRUE(msg); 700 ASSERT_TRUE(msg);
701 render_thread_->sink().ClearMessages(); 701 render_thread_->sink().ClearMessages();
702 702
703 // 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
704 // 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
705 // 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).
706 // Ensure the old page gets reloaded, not swappedout://. 706 // Ensure the old page gets reloaded, not swappedout://.
707 ViewMsg_Navigate_Params nav_params; 707 FrameMsg_Navigate_Params nav_params;
708 nav_params.url = GURL("data:text/html,<div>Page A</div>"); 708 nav_params.url = GURL("data:text/html,<div>Page A</div>");
709 nav_params.navigation_type = ViewMsg_Navigate_Type::RELOAD; 709 nav_params.navigation_type = FrameMsg_Navigate_Type::RELOAD;
710 nav_params.transition = PAGE_TRANSITION_RELOAD; 710 nav_params.transition = PAGE_TRANSITION_RELOAD;
711 nav_params.current_history_list_length = 2; 711 nav_params.current_history_list_length = 2;
712 nav_params.current_history_list_offset = 0; 712 nav_params.current_history_list_offset = 0;
713 nav_params.pending_history_list_offset = 0; 713 nav_params.pending_history_list_offset = 0;
714 nav_params.page_id = 1; 714 nav_params.page_id = 1;
715 nav_params.page_state = state_A; 715 nav_params.page_state = state_A;
716 view()->OnNavigate(nav_params); 716 view()->OnNavigate(nav_params);
717 ProcessPendingMessages(); 717 ProcessPendingMessages();
718 718
719 // Verify page A committed, not swappedout://. 719 // Verify page A committed, not swappedout://.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 ViewHostMsg_UpdateState::ID); 775 ViewHostMsg_UpdateState::ID);
776 ASSERT_TRUE(msg_C); 776 ASSERT_TRUE(msg_C);
777 int page_id_C; 777 int page_id_C;
778 PageState state_C; 778 PageState state_C;
779 ViewHostMsg_UpdateState::Read(msg_C, &page_id_C, &state_C); 779 ViewHostMsg_UpdateState::Read(msg_C, &page_id_C, &state_C);
780 EXPECT_EQ(3, page_id_C); 780 EXPECT_EQ(3, page_id_C);
781 EXPECT_NE(state_B, state_C); 781 EXPECT_NE(state_B, state_C);
782 render_thread_->sink().ClearMessages(); 782 render_thread_->sink().ClearMessages();
783 783
784 // Go back to C and commit, preparing for our real test. 784 // Go back to C and commit, preparing for our real test.
785 ViewMsg_Navigate_Params params_C; 785 FrameMsg_Navigate_Params params_C;
786 params_C.navigation_type = ViewMsg_Navigate_Type::NORMAL; 786 params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL;
787 params_C.transition = PAGE_TRANSITION_FORWARD_BACK; 787 params_C.transition = PAGE_TRANSITION_FORWARD_BACK;
788 params_C.current_history_list_length = 4; 788 params_C.current_history_list_length = 4;
789 params_C.current_history_list_offset = 3; 789 params_C.current_history_list_offset = 3;
790 params_C.pending_history_list_offset = 2; 790 params_C.pending_history_list_offset = 2;
791 params_C.page_id = 3; 791 params_C.page_id = 3;
792 params_C.page_state = state_C; 792 params_C.page_state = state_C;
793 view()->OnNavigate(params_C); 793 view()->OnNavigate(params_C);
794 ProcessPendingMessages(); 794 ProcessPendingMessages();
795 render_thread_->sink().ClearMessages(); 795 render_thread_->sink().ClearMessages();
796 796
797 // Go back twice quickly, such that page B does not have a chance to commit. 797 // Go back twice quickly, such that page B does not have a chance to commit.
798 // This leads to two changes to the back/forward list but only one change to 798 // This leads to two changes to the back/forward list but only one change to
799 // the RenderView's page ID. 799 // the RenderView's page ID.
800 800
801 // Back to page B (page_id 2), without committing. 801 // Back to page B (page_id 2), without committing.
802 ViewMsg_Navigate_Params params_B; 802 FrameMsg_Navigate_Params params_B;
803 params_B.navigation_type = ViewMsg_Navigate_Type::NORMAL; 803 params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL;
804 params_B.transition = PAGE_TRANSITION_FORWARD_BACK; 804 params_B.transition = PAGE_TRANSITION_FORWARD_BACK;
805 params_B.current_history_list_length = 4; 805 params_B.current_history_list_length = 4;
806 params_B.current_history_list_offset = 2; 806 params_B.current_history_list_offset = 2;
807 params_B.pending_history_list_offset = 1; 807 params_B.pending_history_list_offset = 1;
808 params_B.page_id = 2; 808 params_B.page_id = 2;
809 params_B.page_state = state_B; 809 params_B.page_state = state_B;
810 view()->OnNavigate(params_B); 810 view()->OnNavigate(params_B);
811 811
812 // Back to page A (page_id 1) and commit. 812 // Back to page A (page_id 1) and commit.
813 ViewMsg_Navigate_Params params; 813 FrameMsg_Navigate_Params params;
814 params.navigation_type = ViewMsg_Navigate_Type::NORMAL; 814 params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
815 params.transition = PAGE_TRANSITION_FORWARD_BACK; 815 params.transition = PAGE_TRANSITION_FORWARD_BACK;
816 params_B.current_history_list_length = 4; 816 params_B.current_history_list_length = 4;
817 params_B.current_history_list_offset = 2; 817 params_B.current_history_list_offset = 2;
818 params_B.pending_history_list_offset = 0; 818 params_B.pending_history_list_offset = 0;
819 params.page_id = 1; 819 params.page_id = 1;
820 params.page_state = state_A; 820 params.page_state = state_A;
821 view()->OnNavigate(params); 821 view()->OnNavigate(params);
822 ProcessPendingMessages(); 822 ProcessPendingMessages();
823 823
824 // Now ensure that the UpdateState message we receive is consistent 824 // Now ensure that the UpdateState message we receive is consistent
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching( 856 const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching(
857 ViewHostMsg_UpdateState::ID); 857 ViewHostMsg_UpdateState::ID);
858 ASSERT_TRUE(msg_A); 858 ASSERT_TRUE(msg_A);
859 int page_id_A; 859 int page_id_A;
860 PageState state_A; 860 PageState state_A;
861 ViewHostMsg_UpdateState::Read(msg_A, &page_id_A, &state_A); 861 ViewHostMsg_UpdateState::Read(msg_A, &page_id_A, &state_A);
862 EXPECT_EQ(1, page_id_A); 862 EXPECT_EQ(1, page_id_A);
863 render_thread_->sink().ClearMessages(); 863 render_thread_->sink().ClearMessages();
864 864
865 // Back to page A (page_id 1) and commit. 865 // Back to page A (page_id 1) and commit.
866 ViewMsg_Navigate_Params params_A; 866 FrameMsg_Navigate_Params params_A;
867 params_A.navigation_type = ViewMsg_Navigate_Type::NORMAL; 867 params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL;
868 params_A.transition = PAGE_TRANSITION_FORWARD_BACK; 868 params_A.transition = PAGE_TRANSITION_FORWARD_BACK;
869 params_A.current_history_list_length = 2; 869 params_A.current_history_list_length = 2;
870 params_A.current_history_list_offset = 1; 870 params_A.current_history_list_offset = 1;
871 params_A.pending_history_list_offset = 0; 871 params_A.pending_history_list_offset = 0;
872 params_A.page_id = 1; 872 params_A.page_id = 1;
873 params_A.page_state = state_A; 873 params_A.page_state = state_A;
874 view()->OnNavigate(params_A); 874 view()->OnNavigate(params_A);
875 ProcessPendingMessages(); 875 ProcessPendingMessages();
876 876
877 // A new navigation commits, clearing the forward history. 877 // A new navigation commits, clearing the forward history.
878 LoadHTML("<div>Page C</div>"); 878 LoadHTML("<div>Page C</div>");
879 EXPECT_EQ(2, view()->history_list_length_); 879 EXPECT_EQ(2, view()->history_list_length_);
880 EXPECT_EQ(1, view()->history_list_offset_); 880 EXPECT_EQ(1, view()->history_list_offset_);
881 EXPECT_EQ(3, view()->history_page_ids_[1]); 881 EXPECT_EQ(3, view()->history_page_ids_[1]);
882 882
883 // The browser then sends a stale navigation to B, which should be ignored. 883 // The browser then sends a stale navigation to B, which should be ignored.
884 ViewMsg_Navigate_Params params_B; 884 FrameMsg_Navigate_Params params_B;
885 params_B.navigation_type = ViewMsg_Navigate_Type::NORMAL; 885 params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL;
886 params_B.transition = PAGE_TRANSITION_FORWARD_BACK; 886 params_B.transition = PAGE_TRANSITION_FORWARD_BACK;
887 params_B.current_history_list_length = 2; 887 params_B.current_history_list_length = 2;
888 params_B.current_history_list_offset = 0; 888 params_B.current_history_list_offset = 0;
889 params_B.pending_history_list_offset = 1; 889 params_B.pending_history_list_offset = 1;
890 params_B.page_id = 2; 890 params_B.page_id = 2;
891 params_B.page_state = state_A; // Doesn't matter, just has to be present. 891 params_B.page_state = state_A; // Doesn't matter, just has to be present.
892 view()->OnNavigate(params_B); 892 view()->OnNavigate(params_B);
893 893
894 // State should be unchanged. 894 // State should be unchanged.
895 EXPECT_EQ(2, view()->history_list_length_); 895 EXPECT_EQ(2, view()->history_list_length_);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 ASSERT_TRUE(msg_B); 940 ASSERT_TRUE(msg_B);
941 int page_id_B; 941 int page_id_B;
942 PageState state_B; 942 PageState state_B;
943 ViewHostMsg_UpdateState::Read(msg_B, &page_id_B, &state_B); 943 ViewHostMsg_UpdateState::Read(msg_B, &page_id_B, &state_B);
944 EXPECT_EQ(2, page_id_B); 944 EXPECT_EQ(2, page_id_B);
945 render_thread_->sink().ClearMessages(); 945 render_thread_->sink().ClearMessages();
946 946
947 // Suppose the browser has limited the number of NavigationEntries to 2. 947 // Suppose the browser has limited the number of NavigationEntries to 2.
948 // It has now dropped the first entry, but the renderer isn't notified. 948 // It has now dropped the first entry, but the renderer isn't notified.
949 // Ensure that going back to page B (page_id 2) at offset 0 is successful. 949 // Ensure that going back to page B (page_id 2) at offset 0 is successful.
950 ViewMsg_Navigate_Params params_B; 950 FrameMsg_Navigate_Params params_B;
951 params_B.navigation_type = ViewMsg_Navigate_Type::NORMAL; 951 params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL;
952 params_B.transition = PAGE_TRANSITION_FORWARD_BACK; 952 params_B.transition = PAGE_TRANSITION_FORWARD_BACK;
953 params_B.current_history_list_length = 2; 953 params_B.current_history_list_length = 2;
954 params_B.current_history_list_offset = 1; 954 params_B.current_history_list_offset = 1;
955 params_B.pending_history_list_offset = 0; 955 params_B.pending_history_list_offset = 0;
956 params_B.page_id = 2; 956 params_B.page_id = 2;
957 params_B.page_state = state_B; 957 params_B.page_state = state_B;
958 view()->OnNavigate(params_B); 958 view()->OnNavigate(params_B);
959 ProcessPendingMessages(); 959 ProcessPendingMessages();
960 960
961 EXPECT_EQ(2, view()->history_list_length_); 961 EXPECT_EQ(2, view()->history_list_length_);
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 TEST_F(RenderViewImplTest, DISABLED_DidFailProvisionalLoadWithErrorForError) { 1659 TEST_F(RenderViewImplTest, DISABLED_DidFailProvisionalLoadWithErrorForError) {
1660 GetMainFrame()->enableViewSourceMode(true); 1660 GetMainFrame()->enableViewSourceMode(true);
1661 WebURLError error; 1661 WebURLError error;
1662 error.domain = WebString::fromUTF8(net::kErrorDomain); 1662 error.domain = WebString::fromUTF8(net::kErrorDomain);
1663 error.reason = net::ERR_FILE_NOT_FOUND; 1663 error.reason = net::ERR_FILE_NOT_FOUND;
1664 error.unreachableURL = GURL("http://foo"); 1664 error.unreachableURL = GURL("http://foo");
1665 WebFrame* web_frame = GetMainFrame(); 1665 WebFrame* web_frame = GetMainFrame();
1666 1666
1667 // Start a load that will reach provisional state synchronously, 1667 // Start a load that will reach provisional state synchronously,
1668 // but won't complete synchronously. 1668 // but won't complete synchronously.
1669 ViewMsg_Navigate_Params params; 1669 FrameMsg_Navigate_Params params;
1670 params.page_id = -1; 1670 params.page_id = -1;
1671 params.navigation_type = ViewMsg_Navigate_Type::NORMAL; 1671 params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
1672 params.url = GURL("data:text/html,test data"); 1672 params.url = GURL("data:text/html,test data");
1673 view()->OnNavigate(params); 1673 view()->OnNavigate(params);
1674 1674
1675 // An error occurred. 1675 // An error occurred.
1676 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error); 1676 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error);
1677 // Frame should exit view-source mode. 1677 // Frame should exit view-source mode.
1678 EXPECT_FALSE(web_frame->isViewSourceModeEnabled()); 1678 EXPECT_FALSE(web_frame->isViewSourceModeEnabled());
1679 } 1679 }
1680 1680
1681 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) { 1681 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) {
1682 GetMainFrame()->enableViewSourceMode(true); 1682 GetMainFrame()->enableViewSourceMode(true);
1683 WebURLError error; 1683 WebURLError error;
1684 error.domain = WebString::fromUTF8(net::kErrorDomain); 1684 error.domain = WebString::fromUTF8(net::kErrorDomain);
1685 error.reason = net::ERR_ABORTED; 1685 error.reason = net::ERR_ABORTED;
1686 error.unreachableURL = GURL("http://foo"); 1686 error.unreachableURL = GURL("http://foo");
1687 WebFrame* web_frame = GetMainFrame(); 1687 WebFrame* web_frame = GetMainFrame();
1688 1688
1689 // Start a load that will reach provisional state synchronously, 1689 // Start a load that will reach provisional state synchronously,
1690 // but won't complete synchronously. 1690 // but won't complete synchronously.
1691 ViewMsg_Navigate_Params params; 1691 FrameMsg_Navigate_Params params;
1692 params.page_id = -1; 1692 params.page_id = -1;
1693 params.navigation_type = ViewMsg_Navigate_Type::NORMAL; 1693 params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
1694 params.url = GURL("data:text/html,test data"); 1694 params.url = GURL("data:text/html,test data");
1695 view()->OnNavigate(params); 1695 view()->OnNavigate(params);
1696 1696
1697 // A cancellation occurred. 1697 // A cancellation occurred.
1698 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error); 1698 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error);
1699 // Frame should stay in view-source mode. 1699 // Frame should stay in view-source mode.
1700 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); 1700 EXPECT_TRUE(web_frame->isViewSourceModeEnabled());
1701 } 1701 }
1702 1702
1703 // Regression test for http://crbug.com/41562 1703 // Regression test for http://crbug.com/41562
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
2014 } 2014 }
2015 view()->OnImeConfirmComposition( 2015 view()->OnImeConfirmComposition(
2016 empty_string, gfx::Range::InvalidRange(), false); 2016 empty_string, gfx::Range::InvalidRange(), false);
2017 } 2017 }
2018 #endif 2018 #endif
2019 2019
2020 TEST_F(RenderViewImplTest, ZoomLimit) { 2020 TEST_F(RenderViewImplTest, ZoomLimit) {
2021 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor); 2021 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor);
2022 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor); 2022 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor);
2023 2023
2024 ViewMsg_Navigate_Params params; 2024 FrameMsg_Navigate_Params params;
2025 params.page_id = -1; 2025 params.page_id = -1;
2026 params.navigation_type = ViewMsg_Navigate_Type::NORMAL; 2026 params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2027 2027
2028 // Verifies navigation to a URL with preset zoom level indeed sets the level. 2028 // Verifies navigation to a URL with preset zoom level indeed sets the level.
2029 // Regression test for http://crbug.com/139559, where the level was not 2029 // Regression test for http://crbug.com/139559, where the level was not
2030 // properly set when it is out of the default zoom limits of WebView. 2030 // properly set when it is out of the default zoom limits of WebView.
2031 params.url = GURL("data:text/html,min_zoomlimit_test"); 2031 params.url = GURL("data:text/html,min_zoomlimit_test");
2032 view()->OnSetZoomLevelForLoadingURL(params.url, kMinZoomLevel); 2032 view()->OnSetZoomLevelForLoadingURL(params.url, kMinZoomLevel);
2033 view()->OnNavigate(params); 2033 view()->OnNavigate(params);
2034 ProcessPendingMessages(); 2034 ProcessPendingMessages();
2035 EXPECT_DOUBLE_EQ(kMinZoomLevel, view()->GetWebView()->zoomLevel()); 2035 EXPECT_DOUBLE_EQ(kMinZoomLevel, view()->GetWebView()->zoomLevel());
2036 2036
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2092 EXPECT_EQ(2, info.selectionStart); 2092 EXPECT_EQ(2, info.selectionStart);
2093 EXPECT_EQ(2, info.selectionEnd); 2093 EXPECT_EQ(2, info.selectionEnd);
2094 } 2094 }
2095 2095
2096 // Test that the navigating specific frames works correctly. 2096 // Test that the navigating specific frames works correctly.
2097 TEST_F(RenderViewImplTest, NavigateFrame) { 2097 TEST_F(RenderViewImplTest, NavigateFrame) {
2098 // Load page A. 2098 // Load page A.
2099 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); 2099 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>");
2100 2100
2101 // Navigate the frame only. 2101 // Navigate the frame only.
2102 ViewMsg_Navigate_Params nav_params; 2102 FrameMsg_Navigate_Params nav_params;
2103 nav_params.url = GURL("data:text/html,world"); 2103 nav_params.url = GURL("data:text/html,world");
2104 nav_params.navigation_type = ViewMsg_Navigate_Type::NORMAL; 2104 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2105 nav_params.transition = PAGE_TRANSITION_TYPED; 2105 nav_params.transition = PAGE_TRANSITION_TYPED;
2106 nav_params.current_history_list_length = 1; 2106 nav_params.current_history_list_length = 1;
2107 nav_params.current_history_list_offset = 0; 2107 nav_params.current_history_list_offset = 0;
2108 nav_params.pending_history_list_offset = 1; 2108 nav_params.pending_history_list_offset = 1;
2109 nav_params.page_id = -1; 2109 nav_params.page_id = -1;
2110 nav_params.frame_to_navigate = "frame"; 2110 nav_params.frame_to_navigate = "frame";
2111 view()->OnNavigate(nav_params); 2111 view()->OnNavigate(nav_params);
2112 ProcessPendingMessages(); 2112 ProcessPendingMessages();
2113 2113
2114 // Copy the document content to std::wstring and compare with the 2114 // Copy the document content to std::wstring and compare with the
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
2214 2214
2215 TEST_F(SuppressErrorPageTest, MAYBE_Suppresses) { 2215 TEST_F(SuppressErrorPageTest, MAYBE_Suppresses) {
2216 WebURLError error; 2216 WebURLError error;
2217 error.domain = WebString::fromUTF8(net::kErrorDomain); 2217 error.domain = WebString::fromUTF8(net::kErrorDomain);
2218 error.reason = net::ERR_FILE_NOT_FOUND; 2218 error.reason = net::ERR_FILE_NOT_FOUND;
2219 error.unreachableURL = GURL("http://example.com/suppress"); 2219 error.unreachableURL = GURL("http://example.com/suppress");
2220 WebFrame* web_frame = GetMainFrame(); 2220 WebFrame* web_frame = GetMainFrame();
2221 2221
2222 // Start a load that will reach provisional state synchronously, 2222 // Start a load that will reach provisional state synchronously,
2223 // but won't complete synchronously. 2223 // but won't complete synchronously.
2224 ViewMsg_Navigate_Params params; 2224 FrameMsg_Navigate_Params params;
2225 params.page_id = -1; 2225 params.page_id = -1;
2226 params.navigation_type = ViewMsg_Navigate_Type::NORMAL; 2226 params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2227 params.url = GURL("data:text/html,test data"); 2227 params.url = GURL("data:text/html,test data");
2228 view()->OnNavigate(params); 2228 view()->OnNavigate(params);
2229 2229
2230 // An error occurred. 2230 // An error occurred.
2231 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error); 2231 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error);
2232 const int kMaxOutputCharacters = 22; 2232 const int kMaxOutputCharacters = 22;
2233 EXPECT_EQ("", UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); 2233 EXPECT_EQ("", UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
2234 } 2234 }
2235 2235
2236 #if defined(OS_ANDROID) 2236 #if defined(OS_ANDROID)
2237 // Crashing on Android: http://crbug.com/311341 2237 // Crashing on Android: http://crbug.com/311341
2238 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress 2238 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress
2239 #else 2239 #else
2240 #define MAYBE_DoesNotSuppress DoesNotSuppress 2240 #define MAYBE_DoesNotSuppress DoesNotSuppress
2241 #endif 2241 #endif
2242 2242
2243 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) { 2243 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) {
2244 WebURLError error; 2244 WebURLError error;
2245 error.domain = WebString::fromUTF8(net::kErrorDomain); 2245 error.domain = WebString::fromUTF8(net::kErrorDomain);
2246 error.reason = net::ERR_FILE_NOT_FOUND; 2246 error.reason = net::ERR_FILE_NOT_FOUND;
2247 error.unreachableURL = GURL("http://example.com/dont-suppress"); 2247 error.unreachableURL = GURL("http://example.com/dont-suppress");
2248 WebFrame* web_frame = GetMainFrame(); 2248 WebFrame* web_frame = GetMainFrame();
2249 2249
2250 // Start a load that will reach provisional state synchronously, 2250 // Start a load that will reach provisional state synchronously,
2251 // but won't complete synchronously. 2251 // but won't complete synchronously.
2252 ViewMsg_Navigate_Params params; 2252 FrameMsg_Navigate_Params params;
2253 params.page_id = -1; 2253 params.page_id = -1;
2254 params.navigation_type = ViewMsg_Navigate_Type::NORMAL; 2254 params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2255 params.url = GURL("data:text/html,test data"); 2255 params.url = GURL("data:text/html,test data");
2256 view()->OnNavigate(params); 2256 view()->OnNavigate(params);
2257 2257
2258 // An error occurred. 2258 // An error occurred.
2259 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error); 2259 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error);
2260 ProcessPendingMessages(); 2260 ProcessPendingMessages();
2261 const int kMaxOutputCharacters = 22; 2261 const int kMaxOutputCharacters = 22;
2262 EXPECT_EQ("A suffusion of yellow.", 2262 EXPECT_EQ("A suffusion of yellow.",
2263 UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); 2263 UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
2264 } 2264 }
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
2466 2466
2467 error_code = net::OK; 2467 error_code = net::OK;
2468 stale_cache_entry_present = true; 2468 stale_cache_entry_present = true;
2469 ASSERT_TRUE(GetLatestErrorFromRendererClient( 2469 ASSERT_TRUE(GetLatestErrorFromRendererClient(
2470 &error_code, &stale_cache_entry_present)); 2470 &error_code, &stale_cache_entry_present));
2471 EXPECT_EQ(net::ERR_FAILED, error_code); 2471 EXPECT_EQ(net::ERR_FAILED, error_code);
2472 EXPECT_FALSE(stale_cache_entry_present); 2472 EXPECT_FALSE(stale_cache_entry_present);
2473 } 2473 }
2474 2474
2475 } // namespace content 2475 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698