| 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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( | 361 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( |
| 362 ViewHostMsg_UpdateState::ID)); | 362 ViewHostMsg_UpdateState::ID)); |
| 363 } | 363 } |
| 364 | 364 |
| 365 TEST_F(RenderViewImplTest, OnNavigationHttpPost) { | 365 TEST_F(RenderViewImplTest, OnNavigationHttpPost) { |
| 366 FrameMsg_Navigate_Params nav_params; | 366 FrameMsg_Navigate_Params nav_params; |
| 367 | 367 |
| 368 // An http url will trigger a resource load so cannot be used here. | 368 // An http url will trigger a resource load so cannot be used here. |
| 369 nav_params.url = GURL("data:text/html,<div>Page</div>"); | 369 nav_params.url = GURL("data:text/html,<div>Page</div>"); |
| 370 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 370 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 371 nav_params.transition = PAGE_TRANSITION_TYPED; | 371 nav_params.transition = ui::PAGE_TRANSITION_TYPED; |
| 372 nav_params.page_id = -1; | 372 nav_params.page_id = -1; |
| 373 nav_params.is_post = true; | 373 nav_params.is_post = true; |
| 374 nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 374 nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); |
| 375 | 375 |
| 376 // Set up post data. | 376 // Set up post data. |
| 377 const unsigned char* raw_data = reinterpret_cast<const unsigned char*>( | 377 const unsigned char* raw_data = reinterpret_cast<const unsigned char*>( |
| 378 "post \0\ndata"); | 378 "post \0\ndata"); |
| 379 const unsigned int length = 11; | 379 const unsigned int length = 11; |
| 380 const std::vector<unsigned char> post_data(raw_data, raw_data + length); | 380 const std::vector<unsigned char> post_data(raw_data, raw_data + length); |
| 381 nav_params.browser_initiated_post_data = post_data; | 381 nav_params.browser_initiated_post_data = post_data; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId); | 566 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId); |
| 567 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching( | 567 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching( |
| 568 FrameHostMsg_SwapOut_ACK::ID); | 568 FrameHostMsg_SwapOut_ACK::ID); |
| 569 ASSERT_TRUE(msg2); | 569 ASSERT_TRUE(msg2); |
| 570 | 570 |
| 571 // If we navigate back to this RenderView, ensure we don't send a state | 571 // If we navigate back to this RenderView, ensure we don't send a state |
| 572 // update for the swapped out URL. (http://crbug.com/72235) | 572 // update for the swapped out URL. (http://crbug.com/72235) |
| 573 FrameMsg_Navigate_Params nav_params; | 573 FrameMsg_Navigate_Params nav_params; |
| 574 nav_params.url = GURL("data:text/html,<div>Page B</div>"); | 574 nav_params.url = GURL("data:text/html,<div>Page B</div>"); |
| 575 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 575 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 576 nav_params.transition = PAGE_TRANSITION_TYPED; | 576 nav_params.transition = ui::PAGE_TRANSITION_TYPED; |
| 577 nav_params.current_history_list_length = 1; | 577 nav_params.current_history_list_length = 1; |
| 578 nav_params.current_history_list_offset = 0; | 578 nav_params.current_history_list_offset = 0; |
| 579 nav_params.pending_history_list_offset = 1; | 579 nav_params.pending_history_list_offset = 1; |
| 580 nav_params.page_id = -1; | 580 nav_params.page_id = -1; |
| 581 nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 581 nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); |
| 582 frame()->OnNavigate(nav_params); | 582 frame()->OnNavigate(nav_params); |
| 583 ProcessPendingMessages(); | 583 ProcessPendingMessages(); |
| 584 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching( | 584 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching( |
| 585 ViewHostMsg_UpdateState::ID); | 585 ViewHostMsg_UpdateState::ID); |
| 586 EXPECT_FALSE(msg3); | 586 EXPECT_FALSE(msg3); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 603 ViewHostMsg_UpdateState::Param params; | 603 ViewHostMsg_UpdateState::Param params; |
| 604 ViewHostMsg_UpdateState::Read(msg_A, ¶ms); | 604 ViewHostMsg_UpdateState::Read(msg_A, ¶ms); |
| 605 int page_id_A = params.a; | 605 int page_id_A = params.a; |
| 606 PageState state_A = params.b; | 606 PageState state_A = params.b; |
| 607 EXPECT_EQ(1, page_id_A); | 607 EXPECT_EQ(1, page_id_A); |
| 608 render_thread_->sink().ClearMessages(); | 608 render_thread_->sink().ClearMessages(); |
| 609 | 609 |
| 610 // Back to page A (page_id 1) and commit. | 610 // Back to page A (page_id 1) and commit. |
| 611 FrameMsg_Navigate_Params params_A; | 611 FrameMsg_Navigate_Params params_A; |
| 612 params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 612 params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 613 params_A.transition = PAGE_TRANSITION_FORWARD_BACK; | 613 params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 614 params_A.current_history_list_length = 2; | 614 params_A.current_history_list_length = 2; |
| 615 params_A.current_history_list_offset = 1; | 615 params_A.current_history_list_offset = 1; |
| 616 params_A.pending_history_list_offset = 0; | 616 params_A.pending_history_list_offset = 0; |
| 617 params_A.page_id = 1; | 617 params_A.page_id = 1; |
| 618 params_A.page_state = state_A; | 618 params_A.page_state = state_A; |
| 619 params_A.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 619 params_A.browser_navigation_start = base::TimeTicks::FromInternalValue(1); |
| 620 frame()->OnNavigate(params_A); | 620 frame()->OnNavigate(params_A); |
| 621 ProcessPendingMessages(); | 621 ProcessPendingMessages(); |
| 622 | 622 |
| 623 // Respond to a swap out request. | 623 // Respond to a swap out request. |
| 624 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId); | 624 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId); |
| 625 | 625 |
| 626 // Check for a OnSwapOutACK. | 626 // Check for a OnSwapOutACK. |
| 627 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | 627 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
| 628 FrameHostMsg_SwapOut_ACK::ID); | 628 FrameHostMsg_SwapOut_ACK::ID); |
| 629 ASSERT_TRUE(msg); | 629 ASSERT_TRUE(msg); |
| 630 render_thread_->sink().ClearMessages(); | 630 render_thread_->sink().ClearMessages(); |
| 631 | 631 |
| 632 // It is possible to get a reload request at this point, containing the | 632 // It is possible to get a reload request at this point, containing the |
| 633 // params.page_state of the initial page (e.g., if the new page fails the | 633 // params.page_state of the initial page (e.g., if the new page fails the |
| 634 // provisional load in the renderer process, after we unload the old page). | 634 // provisional load in the renderer process, after we unload the old page). |
| 635 // Ensure the old page gets reloaded, not swappedout://. | 635 // Ensure the old page gets reloaded, not swappedout://. |
| 636 FrameMsg_Navigate_Params nav_params; | 636 FrameMsg_Navigate_Params nav_params; |
| 637 nav_params.url = GURL("data:text/html,<div>Page A</div>"); | 637 nav_params.url = GURL("data:text/html,<div>Page A</div>"); |
| 638 nav_params.navigation_type = FrameMsg_Navigate_Type::RELOAD; | 638 nav_params.navigation_type = FrameMsg_Navigate_Type::RELOAD; |
| 639 nav_params.transition = PAGE_TRANSITION_RELOAD; | 639 nav_params.transition = ui::PAGE_TRANSITION_RELOAD; |
| 640 nav_params.current_history_list_length = 2; | 640 nav_params.current_history_list_length = 2; |
| 641 nav_params.current_history_list_offset = 0; | 641 nav_params.current_history_list_offset = 0; |
| 642 nav_params.pending_history_list_offset = 0; | 642 nav_params.pending_history_list_offset = 0; |
| 643 nav_params.page_id = 1; | 643 nav_params.page_id = 1; |
| 644 nav_params.page_state = state_A; | 644 nav_params.page_state = state_A; |
| 645 nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 645 nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); |
| 646 frame()->OnNavigate(nav_params); | 646 frame()->OnNavigate(nav_params); |
| 647 ProcessPendingMessages(); | 647 ProcessPendingMessages(); |
| 648 | 648 |
| 649 // Verify page A committed, not swappedout://. | 649 // Verify page A committed, not swappedout://. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 ViewHostMsg_UpdateState::Read(msg_C, ¶m); | 708 ViewHostMsg_UpdateState::Read(msg_C, ¶m); |
| 709 int page_id_C = param.a; | 709 int page_id_C = param.a; |
| 710 PageState state_C = param.b; | 710 PageState state_C = param.b; |
| 711 EXPECT_EQ(3, page_id_C); | 711 EXPECT_EQ(3, page_id_C); |
| 712 EXPECT_NE(state_B, state_C); | 712 EXPECT_NE(state_B, state_C); |
| 713 render_thread_->sink().ClearMessages(); | 713 render_thread_->sink().ClearMessages(); |
| 714 | 714 |
| 715 // Go back to C and commit, preparing for our real test. | 715 // Go back to C and commit, preparing for our real test. |
| 716 FrameMsg_Navigate_Params params_C; | 716 FrameMsg_Navigate_Params params_C; |
| 717 params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 717 params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 718 params_C.transition = PAGE_TRANSITION_FORWARD_BACK; | 718 params_C.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 719 params_C.current_history_list_length = 4; | 719 params_C.current_history_list_length = 4; |
| 720 params_C.current_history_list_offset = 3; | 720 params_C.current_history_list_offset = 3; |
| 721 params_C.pending_history_list_offset = 2; | 721 params_C.pending_history_list_offset = 2; |
| 722 params_C.page_id = 3; | 722 params_C.page_id = 3; |
| 723 params_C.page_state = state_C; | 723 params_C.page_state = state_C; |
| 724 params_C.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 724 params_C.browser_navigation_start = base::TimeTicks::FromInternalValue(1); |
| 725 frame()->OnNavigate(params_C); | 725 frame()->OnNavigate(params_C); |
| 726 ProcessPendingMessages(); | 726 ProcessPendingMessages(); |
| 727 render_thread_->sink().ClearMessages(); | 727 render_thread_->sink().ClearMessages(); |
| 728 | 728 |
| 729 // Go back twice quickly, such that page B does not have a chance to commit. | 729 // Go back twice quickly, such that page B does not have a chance to commit. |
| 730 // This leads to two changes to the back/forward list but only one change to | 730 // This leads to two changes to the back/forward list but only one change to |
| 731 // the RenderView's page ID. | 731 // the RenderView's page ID. |
| 732 | 732 |
| 733 // Back to page B (page_id 2), without committing. | 733 // Back to page B (page_id 2), without committing. |
| 734 FrameMsg_Navigate_Params params_B; | 734 FrameMsg_Navigate_Params params_B; |
| 735 params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 735 params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 736 params_B.transition = PAGE_TRANSITION_FORWARD_BACK; | 736 params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 737 params_B.current_history_list_length = 4; | 737 params_B.current_history_list_length = 4; |
| 738 params_B.current_history_list_offset = 2; | 738 params_B.current_history_list_offset = 2; |
| 739 params_B.pending_history_list_offset = 1; | 739 params_B.pending_history_list_offset = 1; |
| 740 params_B.page_id = 2; | 740 params_B.page_id = 2; |
| 741 params_B.page_state = state_B; | 741 params_B.page_state = state_B; |
| 742 params_B.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 742 params_B.browser_navigation_start = base::TimeTicks::FromInternalValue(1); |
| 743 frame()->OnNavigate(params_B); | 743 frame()->OnNavigate(params_B); |
| 744 | 744 |
| 745 // Back to page A (page_id 1) and commit. | 745 // Back to page A (page_id 1) and commit. |
| 746 FrameMsg_Navigate_Params params; | 746 FrameMsg_Navigate_Params params; |
| 747 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 747 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 748 params.transition = PAGE_TRANSITION_FORWARD_BACK; | 748 params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 749 params_B.current_history_list_length = 4; | 749 params_B.current_history_list_length = 4; |
| 750 params_B.current_history_list_offset = 2; | 750 params_B.current_history_list_offset = 2; |
| 751 params_B.pending_history_list_offset = 0; | 751 params_B.pending_history_list_offset = 0; |
| 752 params.page_id = 1; | 752 params.page_id = 1; |
| 753 params.page_state = state_A; | 753 params.page_state = state_A; |
| 754 params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 754 params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); |
| 755 frame()->OnNavigate(params); | 755 frame()->OnNavigate(params); |
| 756 ProcessPendingMessages(); | 756 ProcessPendingMessages(); |
| 757 | 757 |
| 758 // Now ensure that the UpdateState message we receive is consistent | 758 // Now ensure that the UpdateState message we receive is consistent |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 ViewHostMsg_UpdateState::Param param; | 793 ViewHostMsg_UpdateState::Param param; |
| 794 ViewHostMsg_UpdateState::Read(msg_A, ¶m); | 794 ViewHostMsg_UpdateState::Read(msg_A, ¶m); |
| 795 int page_id_A = param.a; | 795 int page_id_A = param.a; |
| 796 PageState state_A = param.b; | 796 PageState state_A = param.b; |
| 797 EXPECT_EQ(1, page_id_A); | 797 EXPECT_EQ(1, page_id_A); |
| 798 render_thread_->sink().ClearMessages(); | 798 render_thread_->sink().ClearMessages(); |
| 799 | 799 |
| 800 // Back to page A (page_id 1) and commit. | 800 // Back to page A (page_id 1) and commit. |
| 801 FrameMsg_Navigate_Params params_A; | 801 FrameMsg_Navigate_Params params_A; |
| 802 params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 802 params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 803 params_A.transition = PAGE_TRANSITION_FORWARD_BACK; | 803 params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 804 params_A.current_history_list_length = 2; | 804 params_A.current_history_list_length = 2; |
| 805 params_A.current_history_list_offset = 1; | 805 params_A.current_history_list_offset = 1; |
| 806 params_A.pending_history_list_offset = 0; | 806 params_A.pending_history_list_offset = 0; |
| 807 params_A.page_id = 1; | 807 params_A.page_id = 1; |
| 808 params_A.page_state = state_A; | 808 params_A.page_state = state_A; |
| 809 params_A.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 809 params_A.browser_navigation_start = base::TimeTicks::FromInternalValue(1); |
| 810 frame()->OnNavigate(params_A); | 810 frame()->OnNavigate(params_A); |
| 811 ProcessPendingMessages(); | 811 ProcessPendingMessages(); |
| 812 | 812 |
| 813 // A new navigation commits, clearing the forward history. | 813 // A new navigation commits, clearing the forward history. |
| 814 LoadHTML("<div>Page C</div>"); | 814 LoadHTML("<div>Page C</div>"); |
| 815 EXPECT_EQ(2, view()->history_list_length_); | 815 EXPECT_EQ(2, view()->history_list_length_); |
| 816 EXPECT_EQ(1, view()->history_list_offset_); | 816 EXPECT_EQ(1, view()->history_list_offset_); |
| 817 EXPECT_EQ(3, view()->history_page_ids_[1]); | 817 EXPECT_EQ(3, view()->history_page_ids_[1]); |
| 818 | 818 |
| 819 // The browser then sends a stale navigation to B, which should be ignored. | 819 // The browser then sends a stale navigation to B, which should be ignored. |
| 820 FrameMsg_Navigate_Params params_B; | 820 FrameMsg_Navigate_Params params_B; |
| 821 params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 821 params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 822 params_B.transition = PAGE_TRANSITION_FORWARD_BACK; | 822 params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 823 params_B.current_history_list_length = 2; | 823 params_B.current_history_list_length = 2; |
| 824 params_B.current_history_list_offset = 0; | 824 params_B.current_history_list_offset = 0; |
| 825 params_B.pending_history_list_offset = 1; | 825 params_B.pending_history_list_offset = 1; |
| 826 params_B.page_id = 2; | 826 params_B.page_id = 2; |
| 827 params_B.page_state = state_A; // Doesn't matter, just has to be present. | 827 params_B.page_state = state_A; // Doesn't matter, just has to be present. |
| 828 params_B.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 828 params_B.browser_navigation_start = base::TimeTicks::FromInternalValue(1); |
| 829 frame()->OnNavigate(params_B); | 829 frame()->OnNavigate(params_B); |
| 830 | 830 |
| 831 // State should be unchanged. | 831 // State should be unchanged. |
| 832 EXPECT_EQ(2, view()->history_list_length_); | 832 EXPECT_EQ(2, view()->history_list_length_); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 int page_id_B = param.a; | 880 int page_id_B = param.a; |
| 881 PageState state_B = param.b; | 881 PageState state_B = param.b; |
| 882 EXPECT_EQ(2, page_id_B); | 882 EXPECT_EQ(2, page_id_B); |
| 883 render_thread_->sink().ClearMessages(); | 883 render_thread_->sink().ClearMessages(); |
| 884 | 884 |
| 885 // Suppose the browser has limited the number of NavigationEntries to 2. | 885 // Suppose the browser has limited the number of NavigationEntries to 2. |
| 886 // It has now dropped the first entry, but the renderer isn't notified. | 886 // It has now dropped the first entry, but the renderer isn't notified. |
| 887 // Ensure that going back to page B (page_id 2) at offset 0 is successful. | 887 // Ensure that going back to page B (page_id 2) at offset 0 is successful. |
| 888 FrameMsg_Navigate_Params params_B; | 888 FrameMsg_Navigate_Params params_B; |
| 889 params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 889 params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 890 params_B.transition = PAGE_TRANSITION_FORWARD_BACK; | 890 params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 891 params_B.current_history_list_length = 2; | 891 params_B.current_history_list_length = 2; |
| 892 params_B.current_history_list_offset = 1; | 892 params_B.current_history_list_offset = 1; |
| 893 params_B.pending_history_list_offset = 0; | 893 params_B.pending_history_list_offset = 0; |
| 894 params_B.page_id = 2; | 894 params_B.page_id = 2; |
| 895 params_B.page_state = state_B; | 895 params_B.page_state = state_B; |
| 896 params_B.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 896 params_B.browser_navigation_start = base::TimeTicks::FromInternalValue(1); |
| 897 frame()->OnNavigate(params_B); | 897 frame()->OnNavigate(params_B); |
| 898 ProcessPendingMessages(); | 898 ProcessPendingMessages(); |
| 899 | 899 |
| 900 EXPECT_EQ(2, view()->history_list_length_); | 900 EXPECT_EQ(2, view()->history_list_length_); |
| (...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2077 | 2077 |
| 2078 // Test that the navigating specific frames works correctly. | 2078 // Test that the navigating specific frames works correctly. |
| 2079 TEST_F(RenderViewImplTest, NavigateFrame) { | 2079 TEST_F(RenderViewImplTest, NavigateFrame) { |
| 2080 // Load page A. | 2080 // Load page A. |
| 2081 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); | 2081 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); |
| 2082 | 2082 |
| 2083 // Navigate the frame only. | 2083 // Navigate the frame only. |
| 2084 FrameMsg_Navigate_Params nav_params; | 2084 FrameMsg_Navigate_Params nav_params; |
| 2085 nav_params.url = GURL("data:text/html,world"); | 2085 nav_params.url = GURL("data:text/html,world"); |
| 2086 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2086 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2087 nav_params.transition = PAGE_TRANSITION_TYPED; | 2087 nav_params.transition = ui::PAGE_TRANSITION_TYPED; |
| 2088 nav_params.current_history_list_length = 1; | 2088 nav_params.current_history_list_length = 1; |
| 2089 nav_params.current_history_list_offset = 0; | 2089 nav_params.current_history_list_offset = 0; |
| 2090 nav_params.pending_history_list_offset = 1; | 2090 nav_params.pending_history_list_offset = 1; |
| 2091 nav_params.page_id = -1; | 2091 nav_params.page_id = -1; |
| 2092 nav_params.frame_to_navigate = "frame"; | 2092 nav_params.frame_to_navigate = "frame"; |
| 2093 nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 2093 nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); |
| 2094 frame()->OnNavigate(nav_params); | 2094 frame()->OnNavigate(nav_params); |
| 2095 FrameLoadWaiter( | 2095 FrameLoadWaiter( |
| 2096 RenderFrame::FromWebFrame(frame()->GetWebFrame()->firstChild())).Wait(); | 2096 RenderFrame::FromWebFrame(frame()->GetWebFrame()->firstChild())).Wait(); |
| 2097 | 2097 |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2446 // are asserting only most basic constraints, as TimeTicks (passed as the | 2446 // are asserting only most basic constraints, as TimeTicks (passed as the |
| 2447 // override) are not comparable with the wall time (returned by the Blink API). | 2447 // override) are not comparable with the wall time (returned by the Blink API). |
| 2448 TEST_F(RenderViewImplTest, NavigationStartOverride) { | 2448 TEST_F(RenderViewImplTest, NavigationStartOverride) { |
| 2449 // Verify that a navigation that claims to have started at the earliest | 2449 // Verify that a navigation that claims to have started at the earliest |
| 2450 // possible TimeTicks is indeed reported as one that started before | 2450 // possible TimeTicks is indeed reported as one that started before |
| 2451 // OnNavigate() is called. | 2451 // OnNavigate() is called. |
| 2452 base::Time before_navigation = base::Time::Now(); | 2452 base::Time before_navigation = base::Time::Now(); |
| 2453 FrameMsg_Navigate_Params early_nav_params; | 2453 FrameMsg_Navigate_Params early_nav_params; |
| 2454 early_nav_params.url = GURL("data:text/html,<div>Page</div>"); | 2454 early_nav_params.url = GURL("data:text/html,<div>Page</div>"); |
| 2455 early_nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2455 early_nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2456 early_nav_params.transition = PAGE_TRANSITION_TYPED; | 2456 early_nav_params.transition = ui::PAGE_TRANSITION_TYPED; |
| 2457 early_nav_params.page_id = -1; | 2457 early_nav_params.page_id = -1; |
| 2458 early_nav_params.is_post = true; | 2458 early_nav_params.is_post = true; |
| 2459 early_nav_params.browser_navigation_start = | 2459 early_nav_params.browser_navigation_start = |
| 2460 base::TimeTicks::FromInternalValue(1); | 2460 base::TimeTicks::FromInternalValue(1); |
| 2461 | 2461 |
| 2462 frame()->OnNavigate(early_nav_params); | 2462 frame()->OnNavigate(early_nav_params); |
| 2463 ProcessPendingMessages(); | 2463 ProcessPendingMessages(); |
| 2464 | 2464 |
| 2465 base::Time early_nav_reported_start = | 2465 base::Time early_nav_reported_start = |
| 2466 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); | 2466 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); |
| 2467 EXPECT_LT(early_nav_reported_start, before_navigation); | 2467 EXPECT_LT(early_nav_reported_start, before_navigation); |
| 2468 | 2468 |
| 2469 // Verify that a navigation that claims to have started in the future - 42 | 2469 // Verify that a navigation that claims to have started in the future - 42 |
| 2470 // days from now is *not* reported as one that starts in the future; as we | 2470 // days from now is *not* reported as one that starts in the future; as we |
| 2471 // sanitize the override allowing a maximum of ::Now(). | 2471 // sanitize the override allowing a maximum of ::Now(). |
| 2472 FrameMsg_Navigate_Params late_nav_params; | 2472 FrameMsg_Navigate_Params late_nav_params; |
| 2473 late_nav_params.url = GURL("data:text/html,<div>Another page</div>"); | 2473 late_nav_params.url = GURL("data:text/html,<div>Another page</div>"); |
| 2474 late_nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2474 late_nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2475 late_nav_params.transition = PAGE_TRANSITION_TYPED; | 2475 late_nav_params.transition = ui::PAGE_TRANSITION_TYPED; |
| 2476 late_nav_params.page_id = -1; | 2476 late_nav_params.page_id = -1; |
| 2477 late_nav_params.is_post = true; | 2477 late_nav_params.is_post = true; |
| 2478 late_nav_params.browser_navigation_start = | 2478 late_nav_params.browser_navigation_start = |
| 2479 base::TimeTicks::Now() + base::TimeDelta::FromDays(42); | 2479 base::TimeTicks::Now() + base::TimeDelta::FromDays(42); |
| 2480 | 2480 |
| 2481 frame()->OnNavigate(late_nav_params); | 2481 frame()->OnNavigate(late_nav_params); |
| 2482 ProcessPendingMessages(); | 2482 ProcessPendingMessages(); |
| 2483 base::Time after_navigation = | 2483 base::Time after_navigation = |
| 2484 base::Time::Now() + base::TimeDelta::FromDays(1); | 2484 base::Time::Now() + base::TimeDelta::FromDays(1); |
| 2485 | 2485 |
| 2486 base::Time late_nav_reported_start = | 2486 base::Time late_nav_reported_start = |
| 2487 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); | 2487 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); |
| 2488 EXPECT_LE(late_nav_reported_start, after_navigation); | 2488 EXPECT_LE(late_nav_reported_start, after_navigation); |
| 2489 } | 2489 } |
| 2490 | 2490 |
| 2491 } // namespace content | 2491 } // namespace content |
| OLD | NEW |