| 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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 ExecuteJavaScript("document.getElementById('elt_text').value = 'foo';"); | 379 ExecuteJavaScript("document.getElementById('elt_text').value = 'foo';"); |
| 380 ProcessPendingMessages(); | 380 ProcessPendingMessages(); |
| 381 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( | 381 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( |
| 382 ViewHostMsg_UpdateState::ID)); | 382 ViewHostMsg_UpdateState::ID)); |
| 383 } | 383 } |
| 384 | 384 |
| 385 TEST_F(RenderViewImplTest, OnNavigationHttpPost) { | 385 TEST_F(RenderViewImplTest, OnNavigationHttpPost) { |
| 386 // An http url will trigger a resource load so cannot be used here. | 386 // An http url will trigger a resource load so cannot be used here. |
| 387 CommonNavigationParams common_params; | 387 CommonNavigationParams common_params; |
| 388 StartNavigationParams start_params; | 388 StartNavigationParams start_params; |
| 389 HistoryNavigationParams history_params; | 389 CommitNavigationParams commit_params; |
| 390 common_params.url = GURL("data:text/html,<div>Page</div>"); | 390 common_params.url = GURL("data:text/html,<div>Page</div>"); |
| 391 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 391 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 392 common_params.transition = ui::PAGE_TRANSITION_TYPED; | 392 common_params.transition = ui::PAGE_TRANSITION_TYPED; |
| 393 history_params.page_id = -1; | 393 commit_params.page_id = -1; |
| 394 | 394 |
| 395 // Set up post data. | 395 // Set up post data. |
| 396 const unsigned char* raw_data = reinterpret_cast<const unsigned char*>( | 396 const unsigned char* raw_data = reinterpret_cast<const unsigned char*>( |
| 397 "post \0\ndata"); | 397 "post \0\ndata"); |
| 398 const unsigned int length = 11; | 398 const unsigned int length = 11; |
| 399 const std::vector<unsigned char> post_data(raw_data, raw_data + length); | 399 const std::vector<unsigned char> post_data(raw_data, raw_data + length); |
| 400 start_params.is_post = true; | 400 start_params.is_post = true; |
| 401 start_params.browser_initiated_post_data = post_data; | 401 start_params.browser_initiated_post_data = post_data; |
| 402 | 402 |
| 403 frame()->OnNavigate(common_params, start_params, CommitNavigationParams(), | 403 frame()->OnNavigate(common_params, start_params, commit_params); |
| 404 history_params); | |
| 405 ProcessPendingMessages(); | 404 ProcessPendingMessages(); |
| 406 | 405 |
| 407 const IPC::Message* frame_navigate_msg = | 406 const IPC::Message* frame_navigate_msg = |
| 408 render_thread_->sink().GetUniqueMessageMatching( | 407 render_thread_->sink().GetUniqueMessageMatching( |
| 409 FrameHostMsg_DidCommitProvisionalLoad::ID); | 408 FrameHostMsg_DidCommitProvisionalLoad::ID); |
| 410 EXPECT_TRUE(frame_navigate_msg); | 409 EXPECT_TRUE(frame_navigate_msg); |
| 411 | 410 |
| 412 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params; | 411 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params; |
| 413 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg, | 412 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg, |
| 414 &host_nav_params); | 413 &host_nav_params); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 render_thread_->sink().ClearMessages(); | 586 render_thread_->sink().ClearMessages(); |
| 588 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId, false, | 587 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId, false, |
| 589 content::FrameReplicationState()); | 588 content::FrameReplicationState()); |
| 590 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching( | 589 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching( |
| 591 FrameHostMsg_SwapOut_ACK::ID); | 590 FrameHostMsg_SwapOut_ACK::ID); |
| 592 ASSERT_TRUE(msg2); | 591 ASSERT_TRUE(msg2); |
| 593 | 592 |
| 594 // If we navigate back to this RenderView, ensure we don't send a state | 593 // If we navigate back to this RenderView, ensure we don't send a state |
| 595 // update for the swapped out URL. (http://crbug.com/72235) | 594 // update for the swapped out URL. (http://crbug.com/72235) |
| 596 CommonNavigationParams common_params; | 595 CommonNavigationParams common_params; |
| 597 HistoryNavigationParams history_params; | 596 CommitNavigationParams commit_params; |
| 598 common_params.url = GURL("data:text/html,<div>Page B</div>"); | 597 common_params.url = GURL("data:text/html,<div>Page B</div>"); |
| 599 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 598 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 600 common_params.transition = ui::PAGE_TRANSITION_TYPED; | 599 common_params.transition = ui::PAGE_TRANSITION_TYPED; |
| 601 history_params.current_history_list_length = 1; | 600 commit_params.current_history_list_length = 1; |
| 602 history_params.current_history_list_offset = 0; | 601 commit_params.current_history_list_offset = 0; |
| 603 history_params.pending_history_list_offset = 1; | 602 commit_params.pending_history_list_offset = 1; |
| 604 history_params.page_id = -1; | 603 commit_params.page_id = -1; |
| 605 frame()->OnNavigate(common_params, StartNavigationParams(), | 604 frame()->OnNavigate(common_params, StartNavigationParams(), commit_params); |
| 606 CommitNavigationParams(), history_params); | |
| 607 ProcessPendingMessages(); | 605 ProcessPendingMessages(); |
| 608 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching( | 606 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching( |
| 609 ViewHostMsg_UpdateState::ID); | 607 ViewHostMsg_UpdateState::ID); |
| 610 EXPECT_FALSE(msg3); | 608 EXPECT_FALSE(msg3); |
| 611 } | 609 } |
| 612 | 610 |
| 613 // Ensure the RenderViewImpl reloads the previous page if a reload request | 611 // Ensure the RenderViewImpl reloads the previous page if a reload request |
| 614 // arrives while it is showing swappedout://. http://crbug.com/143155. | 612 // arrives while it is showing swappedout://. http://crbug.com/143155. |
| 615 TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) { | 613 TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) { |
| 616 // Load page A. | 614 // Load page A. |
| 617 LoadHTML("<div>Page A</div>"); | 615 LoadHTML("<div>Page A</div>"); |
| 618 | 616 |
| 619 // Load page B, which will trigger an UpdateState message for page A. | 617 // Load page B, which will trigger an UpdateState message for page A. |
| 620 LoadHTML("<div>Page B</div>"); | 618 LoadHTML("<div>Page B</div>"); |
| 621 | 619 |
| 622 // Check for a valid UpdateState message for page A. | 620 // Check for a valid UpdateState message for page A. |
| 623 ProcessPendingMessages(); | 621 ProcessPendingMessages(); |
| 624 const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching( | 622 const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching( |
| 625 ViewHostMsg_UpdateState::ID); | 623 ViewHostMsg_UpdateState::ID); |
| 626 ASSERT_TRUE(msg_A); | 624 ASSERT_TRUE(msg_A); |
| 627 ViewHostMsg_UpdateState::Param params; | 625 ViewHostMsg_UpdateState::Param params; |
| 628 ViewHostMsg_UpdateState::Read(msg_A, ¶ms); | 626 ViewHostMsg_UpdateState::Read(msg_A, ¶ms); |
| 629 int page_id_A = get<0>(params); | 627 int page_id_A = get<0>(params); |
| 630 PageState state_A = get<1>(params); | 628 PageState state_A = get<1>(params); |
| 631 EXPECT_EQ(1, page_id_A); | 629 EXPECT_EQ(1, page_id_A); |
| 632 render_thread_->sink().ClearMessages(); | 630 render_thread_->sink().ClearMessages(); |
| 633 | 631 |
| 634 // Back to page A (page_id 1) and commit. | 632 // Back to page A (page_id 1) and commit. |
| 635 CommonNavigationParams common_params_A; | 633 CommonNavigationParams common_params_A; |
| 636 HistoryNavigationParams history_params_A; | 634 CommitNavigationParams commit_params_A; |
| 637 common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 635 common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 638 common_params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 636 common_params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 639 history_params_A.current_history_list_length = 2; | 637 commit_params_A.current_history_list_length = 2; |
| 640 history_params_A.current_history_list_offset = 1; | 638 commit_params_A.current_history_list_offset = 1; |
| 641 history_params_A.pending_history_list_offset = 0; | 639 commit_params_A.pending_history_list_offset = 0; |
| 642 history_params_A.page_id = 1; | 640 commit_params_A.page_id = 1; |
| 643 history_params_A.page_state = state_A; | 641 commit_params_A.page_state = state_A; |
| 644 frame()->OnNavigate(common_params_A, StartNavigationParams(), | 642 frame()->OnNavigate(common_params_A, StartNavigationParams(), |
| 645 CommitNavigationParams(), history_params_A); | 643 commit_params_A); |
| 646 EXPECT_EQ(1, view()->historyBackListCount()); | 644 EXPECT_EQ(1, view()->historyBackListCount()); |
| 647 EXPECT_EQ(2, view()->historyBackListCount() + | 645 EXPECT_EQ(2, view()->historyBackListCount() + |
| 648 view()->historyForwardListCount() + 1); | 646 view()->historyForwardListCount() + 1); |
| 649 ProcessPendingMessages(); | 647 ProcessPendingMessages(); |
| 650 | 648 |
| 651 // Respond to a swap out request. | 649 // Respond to a swap out request. |
| 652 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId, true, | 650 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId, true, |
| 653 content::FrameReplicationState()); | 651 content::FrameReplicationState()); |
| 654 | 652 |
| 655 // Check for a OnSwapOutACK. | 653 // Check for a OnSwapOutACK. |
| 656 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | 654 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
| 657 FrameHostMsg_SwapOut_ACK::ID); | 655 FrameHostMsg_SwapOut_ACK::ID); |
| 658 ASSERT_TRUE(msg); | 656 ASSERT_TRUE(msg); |
| 659 render_thread_->sink().ClearMessages(); | 657 render_thread_->sink().ClearMessages(); |
| 660 | 658 |
| 661 // It is possible to get a reload request at this point, containing the | 659 // It is possible to get a reload request at this point, containing the |
| 662 // params.page_state of the initial page (e.g., if the new page fails the | 660 // params.page_state of the initial page (e.g., if the new page fails the |
| 663 // provisional load in the renderer process, after we unload the old page). | 661 // provisional load in the renderer process, after we unload the old page). |
| 664 // Ensure the old page gets reloaded, not swappedout://. | 662 // Ensure the old page gets reloaded, not swappedout://. |
| 665 CommonNavigationParams common_params; | 663 CommonNavigationParams common_params; |
| 666 HistoryNavigationParams history_params; | 664 CommitNavigationParams commit_params; |
| 667 common_params.url = GURL("data:text/html,<div>Page A</div>"); | 665 common_params.url = GURL("data:text/html,<div>Page A</div>"); |
| 668 common_params.navigation_type = FrameMsg_Navigate_Type::RELOAD; | 666 common_params.navigation_type = FrameMsg_Navigate_Type::RELOAD; |
| 669 common_params.transition = ui::PAGE_TRANSITION_RELOAD; | 667 common_params.transition = ui::PAGE_TRANSITION_RELOAD; |
| 670 history_params.current_history_list_length = 2; | 668 commit_params.current_history_list_length = 2; |
| 671 history_params.current_history_list_offset = 0; | 669 commit_params.current_history_list_offset = 0; |
| 672 history_params.pending_history_list_offset = 0; | 670 commit_params.pending_history_list_offset = 0; |
| 673 history_params.page_id = 1; | 671 commit_params.page_id = 1; |
| 674 history_params.page_state = state_A; | 672 commit_params.page_state = state_A; |
| 675 frame()->OnNavigate(common_params, StartNavigationParams(), | 673 frame()->OnNavigate(common_params, StartNavigationParams(), commit_params); |
| 676 CommitNavigationParams(), history_params); | |
| 677 ProcessPendingMessages(); | 674 ProcessPendingMessages(); |
| 678 | 675 |
| 679 // Verify page A committed, not swappedout://. | 676 // Verify page A committed, not swappedout://. |
| 680 const IPC::Message* frame_navigate_msg = | 677 const IPC::Message* frame_navigate_msg = |
| 681 render_thread_->sink().GetUniqueMessageMatching( | 678 render_thread_->sink().GetUniqueMessageMatching( |
| 682 FrameHostMsg_DidCommitProvisionalLoad::ID); | 679 FrameHostMsg_DidCommitProvisionalLoad::ID); |
| 683 EXPECT_TRUE(frame_navigate_msg); | 680 EXPECT_TRUE(frame_navigate_msg); |
| 684 | 681 |
| 685 // Read URL out of the parent trait of the params object. | 682 // Read URL out of the parent trait of the params object. |
| 686 FrameHostMsg_DidCommitProvisionalLoad::Param commit_load_params; | 683 FrameHostMsg_DidCommitProvisionalLoad::Param commit_load_params; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 ASSERT_TRUE(msg_C); | 773 ASSERT_TRUE(msg_C); |
| 777 ViewHostMsg_UpdateState::Read(msg_C, ¶m); | 774 ViewHostMsg_UpdateState::Read(msg_C, ¶m); |
| 778 int page_id_C = get<0>(param); | 775 int page_id_C = get<0>(param); |
| 779 PageState state_C = get<1>(param); | 776 PageState state_C = get<1>(param); |
| 780 EXPECT_EQ(3, page_id_C); | 777 EXPECT_EQ(3, page_id_C); |
| 781 EXPECT_NE(state_B, state_C); | 778 EXPECT_NE(state_B, state_C); |
| 782 render_thread_->sink().ClearMessages(); | 779 render_thread_->sink().ClearMessages(); |
| 783 | 780 |
| 784 // Go back to C and commit, preparing for our real test. | 781 // Go back to C and commit, preparing for our real test. |
| 785 CommonNavigationParams common_params_C; | 782 CommonNavigationParams common_params_C; |
| 786 HistoryNavigationParams history_params_C; | 783 CommitNavigationParams commit_params_C; |
| 787 common_params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 784 common_params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 788 common_params_C.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 785 common_params_C.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 789 history_params_C.current_history_list_length = 4; | 786 commit_params_C.current_history_list_length = 4; |
| 790 history_params_C.current_history_list_offset = 3; | 787 commit_params_C.current_history_list_offset = 3; |
| 791 history_params_C.pending_history_list_offset = 2; | 788 commit_params_C.pending_history_list_offset = 2; |
| 792 history_params_C.page_id = 3; | 789 commit_params_C.page_id = 3; |
| 793 history_params_C.page_state = state_C; | 790 commit_params_C.page_state = state_C; |
| 794 frame()->OnNavigate(common_params_C, StartNavigationParams(), | 791 frame()->OnNavigate(common_params_C, StartNavigationParams(), |
| 795 CommitNavigationParams(), history_params_C); | 792 commit_params_C); |
| 796 ProcessPendingMessages(); | 793 ProcessPendingMessages(); |
| 797 render_thread_->sink().ClearMessages(); | 794 render_thread_->sink().ClearMessages(); |
| 798 | 795 |
| 799 // Go back twice quickly, such that page B does not have a chance to commit. | 796 // Go back twice quickly, such that page B does not have a chance to commit. |
| 800 // This leads to two changes to the back/forward list but only one change to | 797 // This leads to two changes to the back/forward list but only one change to |
| 801 // the RenderView's page ID. | 798 // the RenderView's page ID. |
| 802 | 799 |
| 803 // Back to page B (page_id 2), without committing. | 800 // Back to page B (page_id 2), without committing. |
| 804 CommonNavigationParams common_params_B; | 801 CommonNavigationParams common_params_B; |
| 805 HistoryNavigationParams history_params_B; | 802 CommitNavigationParams commit_params_B; |
| 806 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 803 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 807 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 804 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 808 history_params_B.current_history_list_length = 4; | 805 commit_params_B.current_history_list_length = 4; |
| 809 history_params_B.current_history_list_offset = 2; | 806 commit_params_B.current_history_list_offset = 2; |
| 810 history_params_B.pending_history_list_offset = 1; | 807 commit_params_B.pending_history_list_offset = 1; |
| 811 history_params_B.page_id = 2; | 808 commit_params_B.page_id = 2; |
| 812 history_params_B.page_state = state_B; | 809 commit_params_B.page_state = state_B; |
| 813 frame()->OnNavigate(common_params_B, StartNavigationParams(), | 810 frame()->OnNavigate(common_params_B, StartNavigationParams(), |
| 814 CommitNavigationParams(), history_params_B); | 811 commit_params_B); |
| 815 | 812 |
| 816 // Back to page A (page_id 1) and commit. | 813 // Back to page A (page_id 1) and commit. |
| 817 CommonNavigationParams common_params; | 814 CommonNavigationParams common_params; |
| 818 HistoryNavigationParams history_params; | 815 CommitNavigationParams commit_params; |
| 819 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 816 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 820 common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 817 common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 821 history_params.current_history_list_length = 4; | 818 commit_params.current_history_list_length = 4; |
| 822 history_params.current_history_list_offset = 2; | 819 commit_params.current_history_list_offset = 2; |
| 823 history_params.pending_history_list_offset = 0; | 820 commit_params.pending_history_list_offset = 0; |
| 824 history_params.page_id = 1; | 821 commit_params.page_id = 1; |
| 825 history_params.page_state = state_A; | 822 commit_params.page_state = state_A; |
| 826 frame()->OnNavigate(common_params, StartNavigationParams(), | 823 frame()->OnNavigate(common_params, StartNavigationParams(), commit_params); |
| 827 CommitNavigationParams(), history_params); | |
| 828 ProcessPendingMessages(); | 824 ProcessPendingMessages(); |
| 829 | 825 |
| 830 // Now ensure that the UpdateState message we receive is consistent | 826 // Now ensure that the UpdateState message we receive is consistent |
| 831 // and represents page C in both page_id and state. | 827 // and represents page C in both page_id and state. |
| 832 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | 828 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
| 833 ViewHostMsg_UpdateState::ID); | 829 ViewHostMsg_UpdateState::ID); |
| 834 ASSERT_TRUE(msg); | 830 ASSERT_TRUE(msg); |
| 835 ViewHostMsg_UpdateState::Read(msg, ¶m); | 831 ViewHostMsg_UpdateState::Read(msg, ¶m); |
| 836 int page_id = get<0>(param); | 832 int page_id = get<0>(param); |
| 837 PageState state = get<1>(param); | 833 PageState state = get<1>(param); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 861 ASSERT_TRUE(msg_A); | 857 ASSERT_TRUE(msg_A); |
| 862 ViewHostMsg_UpdateState::Param param; | 858 ViewHostMsg_UpdateState::Param param; |
| 863 ViewHostMsg_UpdateState::Read(msg_A, ¶m); | 859 ViewHostMsg_UpdateState::Read(msg_A, ¶m); |
| 864 int page_id_A = get<0>(param); | 860 int page_id_A = get<0>(param); |
| 865 PageState state_A = get<1>(param); | 861 PageState state_A = get<1>(param); |
| 866 EXPECT_EQ(1, page_id_A); | 862 EXPECT_EQ(1, page_id_A); |
| 867 render_thread_->sink().ClearMessages(); | 863 render_thread_->sink().ClearMessages(); |
| 868 | 864 |
| 869 // Back to page A (page_id 1) and commit. | 865 // Back to page A (page_id 1) and commit. |
| 870 CommonNavigationParams common_params_A; | 866 CommonNavigationParams common_params_A; |
| 871 HistoryNavigationParams history_params_A; | 867 CommitNavigationParams commit_params_A; |
| 872 common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 868 common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 873 common_params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 869 common_params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 874 history_params_A.current_history_list_length = 2; | 870 commit_params_A.current_history_list_length = 2; |
| 875 history_params_A.current_history_list_offset = 1; | 871 commit_params_A.current_history_list_offset = 1; |
| 876 history_params_A.pending_history_list_offset = 0; | 872 commit_params_A.pending_history_list_offset = 0; |
| 877 history_params_A.page_id = 1; | 873 commit_params_A.page_id = 1; |
| 878 history_params_A.page_state = state_A; | 874 commit_params_A.page_state = state_A; |
| 879 frame()->OnNavigate(common_params_A, StartNavigationParams(), | 875 frame()->OnNavigate(common_params_A, StartNavigationParams(), |
| 880 CommitNavigationParams(), history_params_A); | 876 commit_params_A); |
| 881 ProcessPendingMessages(); | 877 ProcessPendingMessages(); |
| 882 | 878 |
| 883 // A new navigation commits, clearing the forward history. | 879 // A new navigation commits, clearing the forward history. |
| 884 LoadHTML("<div>Page C</div>"); | 880 LoadHTML("<div>Page C</div>"); |
| 885 EXPECT_EQ(2, view()->history_list_length_); | 881 EXPECT_EQ(2, view()->history_list_length_); |
| 886 EXPECT_EQ(1, view()->history_list_offset_); | 882 EXPECT_EQ(1, view()->history_list_offset_); |
| 887 EXPECT_EQ(3, view()->page_id_); // page C is now page id 3 | 883 EXPECT_EQ(3, view()->page_id_); // page C is now page id 3 |
| 888 | 884 |
| 889 // The browser then sends a stale navigation to B, which should be ignored. | 885 // The browser then sends a stale navigation to B, which should be ignored. |
| 890 CommonNavigationParams common_params_B; | 886 CommonNavigationParams common_params_B; |
| 891 HistoryNavigationParams history_params_B; | 887 CommitNavigationParams commit_params_B; |
| 892 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 888 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 893 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 889 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 894 history_params_B.current_history_list_length = 2; | 890 commit_params_B.current_history_list_length = 2; |
| 895 history_params_B.current_history_list_offset = 0; | 891 commit_params_B.current_history_list_offset = 0; |
| 896 history_params_B.pending_history_list_offset = 1; | 892 commit_params_B.pending_history_list_offset = 1; |
| 897 history_params_B.page_id = 2; | 893 commit_params_B.page_id = 2; |
| 898 history_params_B.page_state = | 894 commit_params_B.page_state = |
| 899 state_A; // Doesn't matter, just has to be present. | 895 state_A; // Doesn't matter, just has to be present. |
| 900 frame()->OnNavigate(common_params_B, StartNavigationParams(), | 896 frame()->OnNavigate(common_params_B, StartNavigationParams(), |
| 901 CommitNavigationParams(), history_params_B); | 897 commit_params_B); |
| 902 | 898 |
| 903 // State should be unchanged. | 899 // State should be unchanged. |
| 904 EXPECT_EQ(2, view()->history_list_length_); | 900 EXPECT_EQ(2, view()->history_list_length_); |
| 905 EXPECT_EQ(1, view()->history_list_offset_); | 901 EXPECT_EQ(1, view()->history_list_offset_); |
| 906 EXPECT_EQ(3, view()->page_id_); // page C, not page B | 902 EXPECT_EQ(3, view()->page_id_); // page C, not page B |
| 907 | 903 |
| 908 // Check for a valid DidDropNavigation message. | 904 // Check for a valid DidDropNavigation message. |
| 909 ProcessPendingMessages(); | 905 ProcessPendingMessages(); |
| 910 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | 906 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
| 911 FrameHostMsg_DidDropNavigation::ID); | 907 FrameHostMsg_DidDropNavigation::ID); |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1607 error.reason = net::ERR_FILE_NOT_FOUND; | 1603 error.reason = net::ERR_FILE_NOT_FOUND; |
| 1608 error.unreachableURL = GURL("http://foo"); | 1604 error.unreachableURL = GURL("http://foo"); |
| 1609 WebLocalFrame* web_frame = GetMainFrame(); | 1605 WebLocalFrame* web_frame = GetMainFrame(); |
| 1610 | 1606 |
| 1611 // Start a load that will reach provisional state synchronously, | 1607 // Start a load that will reach provisional state synchronously, |
| 1612 // but won't complete synchronously. | 1608 // but won't complete synchronously. |
| 1613 CommonNavigationParams common_params; | 1609 CommonNavigationParams common_params; |
| 1614 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1610 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 1615 common_params.url = GURL("data:text/html,test data"); | 1611 common_params.url = GURL("data:text/html,test data"); |
| 1616 frame()->OnNavigate(common_params, StartNavigationParams(), | 1612 frame()->OnNavigate(common_params, StartNavigationParams(), |
| 1617 CommitNavigationParams(), HistoryNavigationParams()); | 1613 CommitNavigationParams()); |
| 1618 | 1614 |
| 1619 // An error occurred. | 1615 // An error occurred. |
| 1620 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); | 1616 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); |
| 1621 // Frame should exit view-source mode. | 1617 // Frame should exit view-source mode. |
| 1622 EXPECT_FALSE(web_frame->isViewSourceModeEnabled()); | 1618 EXPECT_FALSE(web_frame->isViewSourceModeEnabled()); |
| 1623 } | 1619 } |
| 1624 | 1620 |
| 1625 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) { | 1621 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) { |
| 1626 GetMainFrame()->enableViewSourceMode(true); | 1622 GetMainFrame()->enableViewSourceMode(true); |
| 1627 WebURLError error; | 1623 WebURLError error; |
| 1628 error.domain = WebString::fromUTF8(net::kErrorDomain); | 1624 error.domain = WebString::fromUTF8(net::kErrorDomain); |
| 1629 error.reason = net::ERR_ABORTED; | 1625 error.reason = net::ERR_ABORTED; |
| 1630 error.unreachableURL = GURL("http://foo"); | 1626 error.unreachableURL = GURL("http://foo"); |
| 1631 WebLocalFrame* web_frame = GetMainFrame(); | 1627 WebLocalFrame* web_frame = GetMainFrame(); |
| 1632 | 1628 |
| 1633 // Start a load that will reach provisional state synchronously, | 1629 // Start a load that will reach provisional state synchronously, |
| 1634 // but won't complete synchronously. | 1630 // but won't complete synchronously. |
| 1635 CommonNavigationParams common_params; | 1631 CommonNavigationParams common_params; |
| 1636 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1632 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 1637 common_params.url = GURL("data:text/html,test data"); | 1633 common_params.url = GURL("data:text/html,test data"); |
| 1638 frame()->OnNavigate(common_params, StartNavigationParams(), | 1634 frame()->OnNavigate(common_params, StartNavigationParams(), |
| 1639 CommitNavigationParams(), HistoryNavigationParams()); | 1635 CommitNavigationParams()); |
| 1640 | 1636 |
| 1641 // A cancellation occurred. | 1637 // A cancellation occurred. |
| 1642 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); | 1638 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); |
| 1643 // Frame should stay in view-source mode. | 1639 // Frame should stay in view-source mode. |
| 1644 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); | 1640 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); |
| 1645 } | 1641 } |
| 1646 | 1642 |
| 1647 // Regression test for http://crbug.com/41562 | 1643 // Regression test for http://crbug.com/41562 |
| 1648 TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) { | 1644 TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) { |
| 1649 const GURL invalid_gurl("http://"); | 1645 const GURL invalid_gurl("http://"); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1826 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor); | 1822 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor); |
| 1827 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor); | 1823 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor); |
| 1828 | 1824 |
| 1829 // Verifies navigation to a URL with preset zoom level indeed sets the level. | 1825 // Verifies navigation to a URL with preset zoom level indeed sets the level. |
| 1830 // Regression test for http://crbug.com/139559, where the level was not | 1826 // Regression test for http://crbug.com/139559, where the level was not |
| 1831 // properly set when it is out of the default zoom limits of WebView. | 1827 // properly set when it is out of the default zoom limits of WebView. |
| 1832 CommonNavigationParams common_params; | 1828 CommonNavigationParams common_params; |
| 1833 common_params.url = GURL("data:text/html,min_zoomlimit_test"); | 1829 common_params.url = GURL("data:text/html,min_zoomlimit_test"); |
| 1834 view()->OnSetZoomLevelForLoadingURL(common_params.url, kMinZoomLevel); | 1830 view()->OnSetZoomLevelForLoadingURL(common_params.url, kMinZoomLevel); |
| 1835 frame()->OnNavigate(common_params, StartNavigationParams(), | 1831 frame()->OnNavigate(common_params, StartNavigationParams(), |
| 1836 CommitNavigationParams(), HistoryNavigationParams()); | 1832 CommitNavigationParams()); |
| 1837 ProcessPendingMessages(); | 1833 ProcessPendingMessages(); |
| 1838 EXPECT_DOUBLE_EQ(kMinZoomLevel, view()->GetWebView()->zoomLevel()); | 1834 EXPECT_DOUBLE_EQ(kMinZoomLevel, view()->GetWebView()->zoomLevel()); |
| 1839 | 1835 |
| 1840 // It should work even when the zoom limit is temporarily changed in the page. | 1836 // It should work even when the zoom limit is temporarily changed in the page. |
| 1841 view()->GetWebView()->zoomLimitsChanged(ZoomFactorToZoomLevel(1.0), | 1837 view()->GetWebView()->zoomLimitsChanged(ZoomFactorToZoomLevel(1.0), |
| 1842 ZoomFactorToZoomLevel(1.0)); | 1838 ZoomFactorToZoomLevel(1.0)); |
| 1843 common_params.url = GURL("data:text/html,max_zoomlimit_test"); | 1839 common_params.url = GURL("data:text/html,max_zoomlimit_test"); |
| 1844 view()->OnSetZoomLevelForLoadingURL(common_params.url, kMaxZoomLevel); | 1840 view()->OnSetZoomLevelForLoadingURL(common_params.url, kMaxZoomLevel); |
| 1845 frame()->OnNavigate(common_params, StartNavigationParams(), | 1841 frame()->OnNavigate(common_params, StartNavigationParams(), |
| 1846 CommitNavigationParams(), HistoryNavigationParams()); | 1842 CommitNavigationParams()); |
| 1847 ProcessPendingMessages(); | 1843 ProcessPendingMessages(); |
| 1848 EXPECT_DOUBLE_EQ(kMaxZoomLevel, view()->GetWebView()->zoomLevel()); | 1844 EXPECT_DOUBLE_EQ(kMaxZoomLevel, view()->GetWebView()->zoomLevel()); |
| 1849 } | 1845 } |
| 1850 | 1846 |
| 1851 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) { | 1847 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) { |
| 1852 // Load an HTML page consisting of an input field. | 1848 // Load an HTML page consisting of an input field. |
| 1853 LoadHTML("<html>" | 1849 LoadHTML("<html>" |
| 1854 "<head>" | 1850 "<head>" |
| 1855 "</head>" | 1851 "</head>" |
| 1856 "<body>" | 1852 "<body>" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1898 } | 1894 } |
| 1899 | 1895 |
| 1900 // Test that the navigating specific frames works correctly. | 1896 // Test that the navigating specific frames works correctly. |
| 1901 TEST_F(RenderViewImplTest, NavigateFrame) { | 1897 TEST_F(RenderViewImplTest, NavigateFrame) { |
| 1902 // Load page A. | 1898 // Load page A. |
| 1903 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); | 1899 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); |
| 1904 | 1900 |
| 1905 // Navigate the frame only. | 1901 // Navigate the frame only. |
| 1906 CommonNavigationParams common_params; | 1902 CommonNavigationParams common_params; |
| 1907 CommitNavigationParams commit_params; | 1903 CommitNavigationParams commit_params; |
| 1908 HistoryNavigationParams history_params; | |
| 1909 common_params.url = GURL("data:text/html,world"); | 1904 common_params.url = GURL("data:text/html,world"); |
| 1910 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1905 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 1911 common_params.transition = ui::PAGE_TRANSITION_TYPED; | 1906 common_params.transition = ui::PAGE_TRANSITION_TYPED; |
| 1912 history_params.current_history_list_length = 1; | 1907 commit_params.current_history_list_length = 1; |
| 1913 history_params.current_history_list_offset = 0; | 1908 commit_params.current_history_list_offset = 0; |
| 1914 history_params.pending_history_list_offset = 1; | 1909 commit_params.pending_history_list_offset = 1; |
| 1915 history_params.page_id = -1; | 1910 commit_params.page_id = -1; |
| 1916 commit_params.frame_to_navigate = "frame"; | 1911 commit_params.frame_to_navigate = "frame"; |
| 1917 commit_params.browser_navigation_start = | 1912 commit_params.browser_navigation_start = |
| 1918 base::TimeTicks::FromInternalValue(1); | 1913 base::TimeTicks::FromInternalValue(1); |
| 1919 frame()->OnNavigate(common_params, StartNavigationParams(), commit_params, | 1914 frame()->OnNavigate(common_params, StartNavigationParams(), commit_params); |
| 1920 history_params); | |
| 1921 FrameLoadWaiter( | 1915 FrameLoadWaiter( |
| 1922 RenderFrame::FromWebFrame(frame()->GetWebFrame()->firstChild())).Wait(); | 1916 RenderFrame::FromWebFrame(frame()->GetWebFrame()->firstChild())).Wait(); |
| 1923 | 1917 |
| 1924 // Copy the document content to std::wstring and compare with the | 1918 // Copy the document content to std::wstring and compare with the |
| 1925 // expected result. | 1919 // expected result. |
| 1926 const int kMaxOutputCharacters = 256; | 1920 const int kMaxOutputCharacters = 256; |
| 1927 std::string output = base::UTF16ToUTF8( | 1921 std::string output = base::UTF16ToUTF8( |
| 1928 GetMainFrame()->contentAsText(kMaxOutputCharacters)); | 1922 GetMainFrame()->contentAsText(kMaxOutputCharacters)); |
| 1929 EXPECT_EQ(output, "hello \n\nworld"); | 1923 EXPECT_EQ(output, "hello \n\nworld"); |
| 1930 } | 1924 } |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2028 error.reason = net::ERR_FILE_NOT_FOUND; | 2022 error.reason = net::ERR_FILE_NOT_FOUND; |
| 2029 error.unreachableURL = GURL("http://example.com/suppress"); | 2023 error.unreachableURL = GURL("http://example.com/suppress"); |
| 2030 WebLocalFrame* web_frame = GetMainFrame(); | 2024 WebLocalFrame* web_frame = GetMainFrame(); |
| 2031 | 2025 |
| 2032 // Start a load that will reach provisional state synchronously, | 2026 // Start a load that will reach provisional state synchronously, |
| 2033 // but won't complete synchronously. | 2027 // but won't complete synchronously. |
| 2034 CommonNavigationParams common_params; | 2028 CommonNavigationParams common_params; |
| 2035 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2029 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2036 common_params.url = GURL("data:text/html,test data"); | 2030 common_params.url = GURL("data:text/html,test data"); |
| 2037 frame()->OnNavigate(common_params, StartNavigationParams(), | 2031 frame()->OnNavigate(common_params, StartNavigationParams(), |
| 2038 CommitNavigationParams(), HistoryNavigationParams()); | 2032 CommitNavigationParams()); |
| 2039 | 2033 |
| 2040 // An error occurred. | 2034 // An error occurred. |
| 2041 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); | 2035 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); |
| 2042 const int kMaxOutputCharacters = 22; | 2036 const int kMaxOutputCharacters = 22; |
| 2043 EXPECT_EQ("", | 2037 EXPECT_EQ("", |
| 2044 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); | 2038 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); |
| 2045 } | 2039 } |
| 2046 | 2040 |
| 2047 #if defined(OS_ANDROID) | 2041 #if defined(OS_ANDROID) |
| 2048 // Crashing on Android: http://crbug.com/311341 | 2042 // Crashing on Android: http://crbug.com/311341 |
| 2049 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress | 2043 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress |
| 2050 #else | 2044 #else |
| 2051 #define MAYBE_DoesNotSuppress DoesNotSuppress | 2045 #define MAYBE_DoesNotSuppress DoesNotSuppress |
| 2052 #endif | 2046 #endif |
| 2053 | 2047 |
| 2054 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) { | 2048 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) { |
| 2055 WebURLError error; | 2049 WebURLError error; |
| 2056 error.domain = WebString::fromUTF8(net::kErrorDomain); | 2050 error.domain = WebString::fromUTF8(net::kErrorDomain); |
| 2057 error.reason = net::ERR_FILE_NOT_FOUND; | 2051 error.reason = net::ERR_FILE_NOT_FOUND; |
| 2058 error.unreachableURL = GURL("http://example.com/dont-suppress"); | 2052 error.unreachableURL = GURL("http://example.com/dont-suppress"); |
| 2059 WebLocalFrame* web_frame = GetMainFrame(); | 2053 WebLocalFrame* web_frame = GetMainFrame(); |
| 2060 | 2054 |
| 2061 // Start a load that will reach provisional state synchronously, | 2055 // Start a load that will reach provisional state synchronously, |
| 2062 // but won't complete synchronously. | 2056 // but won't complete synchronously. |
| 2063 CommonNavigationParams common_params; | 2057 CommonNavigationParams common_params; |
| 2064 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2058 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2065 common_params.url = GURL("data:text/html,test data"); | 2059 common_params.url = GURL("data:text/html,test data"); |
| 2066 frame()->OnNavigate(common_params, StartNavigationParams(), | 2060 frame()->OnNavigate(common_params, StartNavigationParams(), |
| 2067 CommitNavigationParams(), HistoryNavigationParams()); | 2061 CommitNavigationParams()); |
| 2068 | 2062 |
| 2069 // An error occurred. | 2063 // An error occurred. |
| 2070 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); | 2064 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); |
| 2071 // The error page itself is loaded asynchronously. | 2065 // The error page itself is loaded asynchronously. |
| 2072 FrameLoadWaiter(frame()).Wait(); | 2066 FrameLoadWaiter(frame()).Wait(); |
| 2073 const int kMaxOutputCharacters = 22; | 2067 const int kMaxOutputCharacters = 22; |
| 2074 EXPECT_EQ("A suffusion of yellow.", | 2068 EXPECT_EQ("A suffusion of yellow.", |
| 2075 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); | 2069 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); |
| 2076 } | 2070 } |
| 2077 | 2071 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2267 StartNavigationParams early_start_params; | 2261 StartNavigationParams early_start_params; |
| 2268 CommitNavigationParams early_commit_params; | 2262 CommitNavigationParams early_commit_params; |
| 2269 early_common_params.url = GURL("data:text/html,<div>Page</div>"); | 2263 early_common_params.url = GURL("data:text/html,<div>Page</div>"); |
| 2270 early_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2264 early_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2271 early_common_params.transition = ui::PAGE_TRANSITION_TYPED; | 2265 early_common_params.transition = ui::PAGE_TRANSITION_TYPED; |
| 2272 early_start_params.is_post = true; | 2266 early_start_params.is_post = true; |
| 2273 early_commit_params.browser_navigation_start = | 2267 early_commit_params.browser_navigation_start = |
| 2274 base::TimeTicks::FromInternalValue(1); | 2268 base::TimeTicks::FromInternalValue(1); |
| 2275 | 2269 |
| 2276 frame()->OnNavigate(early_common_params, early_start_params, | 2270 frame()->OnNavigate(early_common_params, early_start_params, |
| 2277 early_commit_params, HistoryNavigationParams()); | 2271 early_commit_params); |
| 2278 ProcessPendingMessages(); | 2272 ProcessPendingMessages(); |
| 2279 | 2273 |
| 2280 base::Time early_nav_reported_start = | 2274 base::Time early_nav_reported_start = |
| 2281 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); | 2275 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); |
| 2282 EXPECT_LT(early_nav_reported_start, before_navigation); | 2276 EXPECT_LT(early_nav_reported_start, before_navigation); |
| 2283 | 2277 |
| 2284 // Verify that a navigation that claims to have started in the future - 42 | 2278 // Verify that a navigation that claims to have started in the future - 42 |
| 2285 // days from now is *not* reported as one that starts in the future; as we | 2279 // days from now is *not* reported as one that starts in the future; as we |
| 2286 // sanitize the override allowing a maximum of ::Now(). | 2280 // sanitize the override allowing a maximum of ::Now(). |
| 2287 CommonNavigationParams late_common_params; | 2281 CommonNavigationParams late_common_params; |
| 2288 CommitNavigationParams late_commit_params; | 2282 CommitNavigationParams late_commit_params; |
| 2289 StartNavigationParams late_start_params; | 2283 StartNavigationParams late_start_params; |
| 2290 late_common_params.url = GURL("data:text/html,<div>Another page</div>"); | 2284 late_common_params.url = GURL("data:text/html,<div>Another page</div>"); |
| 2291 late_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2285 late_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2292 late_common_params.transition = ui::PAGE_TRANSITION_TYPED; | 2286 late_common_params.transition = ui::PAGE_TRANSITION_TYPED; |
| 2293 late_start_params.is_post = true; | 2287 late_start_params.is_post = true; |
| 2294 late_commit_params.browser_navigation_start = | 2288 late_commit_params.browser_navigation_start = |
| 2295 base::TimeTicks::Now() + base::TimeDelta::FromDays(42); | 2289 base::TimeTicks::Now() + base::TimeDelta::FromDays(42); |
| 2296 | 2290 |
| 2297 frame()->OnNavigate(late_common_params, late_start_params, late_commit_params, | 2291 frame()->OnNavigate(late_common_params, late_start_params, |
| 2298 HistoryNavigationParams()); | 2292 late_commit_params); |
| 2299 ProcessPendingMessages(); | 2293 ProcessPendingMessages(); |
| 2300 base::Time after_navigation = | 2294 base::Time after_navigation = |
| 2301 base::Time::Now() + base::TimeDelta::FromDays(1); | 2295 base::Time::Now() + base::TimeDelta::FromDays(1); |
| 2302 | 2296 |
| 2303 base::Time late_nav_reported_start = | 2297 base::Time late_nav_reported_start = |
| 2304 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); | 2298 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); |
| 2305 EXPECT_LE(late_nav_reported_start, after_navigation); | 2299 EXPECT_LE(late_nav_reported_start, after_navigation); |
| 2306 } | 2300 } |
| 2307 | 2301 |
| 2308 TEST_F(RenderViewImplTest, PreferredSizeZoomed) { | 2302 TEST_F(RenderViewImplTest, PreferredSizeZoomed) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2320 } | 2314 } |
| 2321 | 2315 |
| 2322 // Ensure the RenderViewImpl history list is properly updated when starting a | 2316 // Ensure the RenderViewImpl history list is properly updated when starting a |
| 2323 // new browser-initiated navigation. | 2317 // new browser-initiated navigation. |
| 2324 TEST_F(RenderViewImplTest, HistoryIsProperlyUpdatedOnNavigation) { | 2318 TEST_F(RenderViewImplTest, HistoryIsProperlyUpdatedOnNavigation) { |
| 2325 EXPECT_EQ(0, view()->historyBackListCount()); | 2319 EXPECT_EQ(0, view()->historyBackListCount()); |
| 2326 EXPECT_EQ(0, view()->historyBackListCount() + | 2320 EXPECT_EQ(0, view()->historyBackListCount() + |
| 2327 view()->historyForwardListCount() + 1); | 2321 view()->historyForwardListCount() + 1); |
| 2328 | 2322 |
| 2329 // Receive a Navigate message with history parameters. | 2323 // Receive a Navigate message with history parameters. |
| 2330 HistoryNavigationParams history_params; | 2324 CommitNavigationParams commit_params; |
| 2331 history_params.current_history_list_length = 2; | 2325 commit_params.current_history_list_length = 2; |
| 2332 history_params.current_history_list_offset = 1; | 2326 commit_params.current_history_list_offset = 1; |
| 2333 history_params.pending_history_list_offset = 2; | 2327 commit_params.pending_history_list_offset = 2; |
| 2334 history_params.page_id = -1; | 2328 commit_params.page_id = -1; |
| 2335 frame()->OnNavigate(CommonNavigationParams(), StartNavigationParams(), | 2329 frame()->OnNavigate(CommonNavigationParams(), StartNavigationParams(), |
| 2336 CommitNavigationParams(), history_params); | 2330 commit_params); |
| 2337 | 2331 |
| 2338 // The history list in RenderView should have been updated. | 2332 // The history list in RenderView should have been updated. |
| 2339 EXPECT_EQ(1, view()->historyBackListCount()); | 2333 EXPECT_EQ(1, view()->historyBackListCount()); |
| 2340 EXPECT_EQ(2, view()->historyBackListCount() + | 2334 EXPECT_EQ(2, view()->historyBackListCount() + |
| 2341 view()->historyForwardListCount() + 1); | 2335 view()->historyForwardListCount() + 1); |
| 2342 } | 2336 } |
| 2343 | 2337 |
| 2344 } // namespace content | 2338 } // namespace content |
| OLD | NEW |