| 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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 ExecuteJavaScript("document.getElementById('elt_text').value = 'foo';"); | 359 ExecuteJavaScript("document.getElementById('elt_text').value = 'foo';"); |
| 360 ProcessPendingMessages(); | 360 ProcessPendingMessages(); |
| 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.core_params.url = GURL("data:text/html,<div>Page</div>"); |
| 370 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 370 nav_params.core_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 371 nav_params.transition = PAGE_TRANSITION_TYPED; | 371 nav_params.core_params.transition = PAGE_TRANSITION_TYPED; |
| 372 nav_params.page_id = -1; | 372 nav_params.commit_params.page_id = -1; |
| 373 nav_params.is_post = true; | 373 nav_params.request_params.is_post = true; |
| 374 nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 374 nav_params.commit_params.browser_navigation_start = |
| 375 base::TimeTicks::FromInternalValue(1); |
| 375 | 376 |
| 376 // Set up post data. | 377 // Set up post data. |
| 377 const unsigned char* raw_data = reinterpret_cast<const unsigned char*>( | 378 const unsigned char* raw_data = reinterpret_cast<const unsigned char*>( |
| 378 "post \0\ndata"); | 379 "post \0\ndata"); |
| 379 const unsigned int length = 11; | 380 const unsigned int length = 11; |
| 380 const std::vector<unsigned char> post_data(raw_data, raw_data + length); | 381 const std::vector<unsigned char> post_data(raw_data, raw_data + length); |
| 381 nav_params.browser_initiated_post_data = post_data; | 382 nav_params.request_params.browser_initiated_post_data = post_data; |
| 382 | 383 |
| 383 frame()->OnNavigate(nav_params); | 384 frame()->OnNavigate(nav_params); |
| 384 ProcessPendingMessages(); | 385 ProcessPendingMessages(); |
| 385 | 386 |
| 386 const IPC::Message* frame_navigate_msg = | 387 const IPC::Message* frame_navigate_msg = |
| 387 render_thread_->sink().GetUniqueMessageMatching( | 388 render_thread_->sink().GetUniqueMessageMatching( |
| 388 FrameHostMsg_DidCommitProvisionalLoad::ID); | 389 FrameHostMsg_DidCommitProvisionalLoad::ID); |
| 389 EXPECT_TRUE(frame_navigate_msg); | 390 EXPECT_TRUE(frame_navigate_msg); |
| 390 | 391 |
| 391 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params; | 392 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params; |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 // an ACK, even if we don't have to do anything else. | 565 // an ACK, even if we don't have to do anything else. |
| 565 render_thread_->sink().ClearMessages(); | 566 render_thread_->sink().ClearMessages(); |
| 566 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId); | 567 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId); |
| 567 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching( | 568 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching( |
| 568 FrameHostMsg_SwapOut_ACK::ID); | 569 FrameHostMsg_SwapOut_ACK::ID); |
| 569 ASSERT_TRUE(msg2); | 570 ASSERT_TRUE(msg2); |
| 570 | 571 |
| 571 // If we navigate back to this RenderView, ensure we don't send a state | 572 // 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) | 573 // update for the swapped out URL. (http://crbug.com/72235) |
| 573 FrameMsg_Navigate_Params nav_params; | 574 FrameMsg_Navigate_Params nav_params; |
| 574 nav_params.url = GURL("data:text/html,<div>Page B</div>"); | 575 nav_params.core_params.url = GURL("data:text/html,<div>Page B</div>"); |
| 575 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 576 nav_params.core_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 576 nav_params.transition = PAGE_TRANSITION_TYPED; | 577 nav_params.core_params.transition = PAGE_TRANSITION_TYPED; |
| 577 nav_params.current_history_list_length = 1; | 578 nav_params.commit_params.current_history_list_length = 1; |
| 578 nav_params.current_history_list_offset = 0; | 579 nav_params.commit_params.current_history_list_offset = 0; |
| 579 nav_params.pending_history_list_offset = 1; | 580 nav_params.commit_params.pending_history_list_offset = 1; |
| 580 nav_params.page_id = -1; | 581 nav_params.commit_params.page_id = -1; |
| 581 nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 582 nav_params.commit_params.browser_navigation_start = |
| 583 base::TimeTicks::FromInternalValue(1); |
| 582 frame()->OnNavigate(nav_params); | 584 frame()->OnNavigate(nav_params); |
| 583 ProcessPendingMessages(); | 585 ProcessPendingMessages(); |
| 584 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching( | 586 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching( |
| 585 ViewHostMsg_UpdateState::ID); | 587 ViewHostMsg_UpdateState::ID); |
| 586 EXPECT_FALSE(msg3); | 588 EXPECT_FALSE(msg3); |
| 587 } | 589 } |
| 588 | 590 |
| 589 // Ensure the RenderViewImpl reloads the previous page if a reload request | 591 // Ensure the RenderViewImpl reloads the previous page if a reload request |
| 590 // arrives while it is showing swappedout://. http://crbug.com/143155. | 592 // arrives while it is showing swappedout://. http://crbug.com/143155. |
| 591 TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) { | 593 TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 602 ASSERT_TRUE(msg_A); | 604 ASSERT_TRUE(msg_A); |
| 603 ViewHostMsg_UpdateState::Param params; | 605 ViewHostMsg_UpdateState::Param params; |
| 604 ViewHostMsg_UpdateState::Read(msg_A, ¶ms); | 606 ViewHostMsg_UpdateState::Read(msg_A, ¶ms); |
| 605 int page_id_A = params.a; | 607 int page_id_A = params.a; |
| 606 PageState state_A = params.b; | 608 PageState state_A = params.b; |
| 607 EXPECT_EQ(1, page_id_A); | 609 EXPECT_EQ(1, page_id_A); |
| 608 render_thread_->sink().ClearMessages(); | 610 render_thread_->sink().ClearMessages(); |
| 609 | 611 |
| 610 // Back to page A (page_id 1) and commit. | 612 // Back to page A (page_id 1) and commit. |
| 611 FrameMsg_Navigate_Params params_A; | 613 FrameMsg_Navigate_Params params_A; |
| 612 params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 614 params_A.core_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 613 params_A.transition = PAGE_TRANSITION_FORWARD_BACK; | 615 params_A.core_params.transition = PAGE_TRANSITION_FORWARD_BACK; |
| 614 params_A.current_history_list_length = 2; | 616 params_A.commit_params.current_history_list_length = 2; |
| 615 params_A.current_history_list_offset = 1; | 617 params_A.commit_params.current_history_list_offset = 1; |
| 616 params_A.pending_history_list_offset = 0; | 618 params_A.commit_params.pending_history_list_offset = 0; |
| 617 params_A.page_id = 1; | 619 params_A.commit_params.page_id = 1; |
| 618 params_A.page_state = state_A; | 620 params_A.commit_params.page_state = state_A; |
| 619 params_A.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 621 params_A.commit_params.browser_navigation_start = |
| 622 base::TimeTicks::FromInternalValue(1); |
| 620 frame()->OnNavigate(params_A); | 623 frame()->OnNavigate(params_A); |
| 621 ProcessPendingMessages(); | 624 ProcessPendingMessages(); |
| 622 | 625 |
| 623 // Respond to a swap out request. | 626 // Respond to a swap out request. |
| 624 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId); | 627 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId); |
| 625 | 628 |
| 626 // Check for a OnSwapOutACK. | 629 // Check for a OnSwapOutACK. |
| 627 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | 630 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
| 628 FrameHostMsg_SwapOut_ACK::ID); | 631 FrameHostMsg_SwapOut_ACK::ID); |
| 629 ASSERT_TRUE(msg); | 632 ASSERT_TRUE(msg); |
| 630 render_thread_->sink().ClearMessages(); | 633 render_thread_->sink().ClearMessages(); |
| 631 | 634 |
| 632 // It is possible to get a reload request at this point, containing the | 635 // 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 | 636 // 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). | 637 // provisional load in the renderer process, after we unload the old page). |
| 635 // Ensure the old page gets reloaded, not swappedout://. | 638 // Ensure the old page gets reloaded, not swappedout://. |
| 636 FrameMsg_Navigate_Params nav_params; | 639 FrameMsg_Navigate_Params nav_params; |
| 637 nav_params.url = GURL("data:text/html,<div>Page A</div>"); | 640 nav_params.core_params.url = GURL("data:text/html,<div>Page A</div>"); |
| 638 nav_params.navigation_type = FrameMsg_Navigate_Type::RELOAD; | 641 nav_params.core_params.navigation_type = FrameMsg_Navigate_Type::RELOAD; |
| 639 nav_params.transition = PAGE_TRANSITION_RELOAD; | 642 nav_params.core_params.transition = PAGE_TRANSITION_RELOAD; |
| 640 nav_params.current_history_list_length = 2; | 643 nav_params.commit_params.current_history_list_length = 2; |
| 641 nav_params.current_history_list_offset = 0; | 644 nav_params.commit_params.current_history_list_offset = 0; |
| 642 nav_params.pending_history_list_offset = 0; | 645 nav_params.commit_params.pending_history_list_offset = 0; |
| 643 nav_params.page_id = 1; | 646 nav_params.commit_params.page_id = 1; |
| 644 nav_params.page_state = state_A; | 647 nav_params.commit_params.page_state = state_A; |
| 645 nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 648 nav_params.commit_params.browser_navigation_start = |
| 649 base::TimeTicks::FromInternalValue(1); |
| 646 frame()->OnNavigate(nav_params); | 650 frame()->OnNavigate(nav_params); |
| 647 ProcessPendingMessages(); | 651 ProcessPendingMessages(); |
| 648 | 652 |
| 649 // Verify page A committed, not swappedout://. | 653 // Verify page A committed, not swappedout://. |
| 650 const IPC::Message* frame_navigate_msg = | 654 const IPC::Message* frame_navigate_msg = |
| 651 render_thread_->sink().GetUniqueMessageMatching( | 655 render_thread_->sink().GetUniqueMessageMatching( |
| 652 FrameHostMsg_DidCommitProvisionalLoad::ID); | 656 FrameHostMsg_DidCommitProvisionalLoad::ID); |
| 653 EXPECT_TRUE(frame_navigate_msg); | 657 EXPECT_TRUE(frame_navigate_msg); |
| 654 | 658 |
| 655 // Read URL out of the parent trait of the params object. | 659 // Read URL out of the parent trait of the params object. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 ASSERT_TRUE(msg_C); | 711 ASSERT_TRUE(msg_C); |
| 708 ViewHostMsg_UpdateState::Read(msg_C, ¶m); | 712 ViewHostMsg_UpdateState::Read(msg_C, ¶m); |
| 709 int page_id_C = param.a; | 713 int page_id_C = param.a; |
| 710 PageState state_C = param.b; | 714 PageState state_C = param.b; |
| 711 EXPECT_EQ(3, page_id_C); | 715 EXPECT_EQ(3, page_id_C); |
| 712 EXPECT_NE(state_B, state_C); | 716 EXPECT_NE(state_B, state_C); |
| 713 render_thread_->sink().ClearMessages(); | 717 render_thread_->sink().ClearMessages(); |
| 714 | 718 |
| 715 // Go back to C and commit, preparing for our real test. | 719 // Go back to C and commit, preparing for our real test. |
| 716 FrameMsg_Navigate_Params params_C; | 720 FrameMsg_Navigate_Params params_C; |
| 717 params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 721 params_C.core_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 718 params_C.transition = PAGE_TRANSITION_FORWARD_BACK; | 722 params_C.core_params.transition = PAGE_TRANSITION_FORWARD_BACK; |
| 719 params_C.current_history_list_length = 4; | 723 params_C.commit_params.current_history_list_length = 4; |
| 720 params_C.current_history_list_offset = 3; | 724 params_C.commit_params.current_history_list_offset = 3; |
| 721 params_C.pending_history_list_offset = 2; | 725 params_C.commit_params.pending_history_list_offset = 2; |
| 722 params_C.page_id = 3; | 726 params_C.commit_params.page_id = 3; |
| 723 params_C.page_state = state_C; | 727 params_C.commit_params.page_state = state_C; |
| 724 params_C.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 728 params_C.commit_params.browser_navigation_start = |
| 729 base::TimeTicks::FromInternalValue(1); |
| 725 frame()->OnNavigate(params_C); | 730 frame()->OnNavigate(params_C); |
| 726 ProcessPendingMessages(); | 731 ProcessPendingMessages(); |
| 727 render_thread_->sink().ClearMessages(); | 732 render_thread_->sink().ClearMessages(); |
| 728 | 733 |
| 729 // Go back twice quickly, such that page B does not have a chance to commit. | 734 // 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 | 735 // This leads to two changes to the back/forward list but only one change to |
| 731 // the RenderView's page ID. | 736 // the RenderView's page ID. |
| 732 | 737 |
| 733 // Back to page B (page_id 2), without committing. | 738 // Back to page B (page_id 2), without committing. |
| 734 FrameMsg_Navigate_Params params_B; | 739 FrameMsg_Navigate_Params params_B; |
| 735 params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 740 params_B.core_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 736 params_B.transition = PAGE_TRANSITION_FORWARD_BACK; | 741 params_B.core_params.transition = PAGE_TRANSITION_FORWARD_BACK; |
| 737 params_B.current_history_list_length = 4; | 742 params_B.commit_params.current_history_list_length = 4; |
| 738 params_B.current_history_list_offset = 2; | 743 params_B.commit_params.current_history_list_offset = 2; |
| 739 params_B.pending_history_list_offset = 1; | 744 params_B.commit_params.pending_history_list_offset = 1; |
| 740 params_B.page_id = 2; | 745 params_B.commit_params.page_id = 2; |
| 741 params_B.page_state = state_B; | 746 params_B.commit_params.page_state = state_B; |
| 742 params_B.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 747 params_B.commit_params.browser_navigation_start = |
| 748 base::TimeTicks::FromInternalValue(1); |
| 743 frame()->OnNavigate(params_B); | 749 frame()->OnNavigate(params_B); |
| 744 | 750 |
| 745 // Back to page A (page_id 1) and commit. | 751 // Back to page A (page_id 1) and commit. |
| 746 FrameMsg_Navigate_Params params; | 752 FrameMsg_Navigate_Params params; |
| 747 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 753 params.core_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 748 params.transition = PAGE_TRANSITION_FORWARD_BACK; | 754 params.core_params.transition = PAGE_TRANSITION_FORWARD_BACK; |
| 749 params_B.current_history_list_length = 4; | 755 params_B.commit_params.current_history_list_length = 4; |
| 750 params_B.current_history_list_offset = 2; | 756 params_B.commit_params.current_history_list_offset = 2; |
| 751 params_B.pending_history_list_offset = 0; | 757 params_B.commit_params.pending_history_list_offset = 0; |
| 752 params.page_id = 1; | 758 params.commit_params.page_id = 1; |
| 753 params.page_state = state_A; | 759 params.commit_params.page_state = state_A; |
| 754 params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 760 params.commit_params.browser_navigation_start = |
| 761 base::TimeTicks::FromInternalValue(1); |
| 755 frame()->OnNavigate(params); | 762 frame()->OnNavigate(params); |
| 756 ProcessPendingMessages(); | 763 ProcessPendingMessages(); |
| 757 | 764 |
| 758 // Now ensure that the UpdateState message we receive is consistent | 765 // Now ensure that the UpdateState message we receive is consistent |
| 759 // and represents page C in both page_id and state. | 766 // and represents page C in both page_id and state. |
| 760 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | 767 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
| 761 ViewHostMsg_UpdateState::ID); | 768 ViewHostMsg_UpdateState::ID); |
| 762 ASSERT_TRUE(msg); | 769 ASSERT_TRUE(msg); |
| 763 ViewHostMsg_UpdateState::Read(msg, ¶m); | 770 ViewHostMsg_UpdateState::Read(msg, ¶m); |
| 764 int page_id = param.a; | 771 int page_id = param.a; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 792 ASSERT_TRUE(msg_A); | 799 ASSERT_TRUE(msg_A); |
| 793 ViewHostMsg_UpdateState::Param param; | 800 ViewHostMsg_UpdateState::Param param; |
| 794 ViewHostMsg_UpdateState::Read(msg_A, ¶m); | 801 ViewHostMsg_UpdateState::Read(msg_A, ¶m); |
| 795 int page_id_A = param.a; | 802 int page_id_A = param.a; |
| 796 PageState state_A = param.b; | 803 PageState state_A = param.b; |
| 797 EXPECT_EQ(1, page_id_A); | 804 EXPECT_EQ(1, page_id_A); |
| 798 render_thread_->sink().ClearMessages(); | 805 render_thread_->sink().ClearMessages(); |
| 799 | 806 |
| 800 // Back to page A (page_id 1) and commit. | 807 // Back to page A (page_id 1) and commit. |
| 801 FrameMsg_Navigate_Params params_A; | 808 FrameMsg_Navigate_Params params_A; |
| 802 params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 809 params_A.core_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 803 params_A.transition = PAGE_TRANSITION_FORWARD_BACK; | 810 params_A.core_params.transition = PAGE_TRANSITION_FORWARD_BACK; |
| 804 params_A.current_history_list_length = 2; | 811 params_A.commit_params.current_history_list_length = 2; |
| 805 params_A.current_history_list_offset = 1; | 812 params_A.commit_params.current_history_list_offset = 1; |
| 806 params_A.pending_history_list_offset = 0; | 813 params_A.commit_params.pending_history_list_offset = 0; |
| 807 params_A.page_id = 1; | 814 params_A.commit_params.page_id = 1; |
| 808 params_A.page_state = state_A; | 815 params_A.commit_params.page_state = state_A; |
| 809 params_A.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 816 params_A.commit_params.browser_navigation_start = |
| 817 base::TimeTicks::FromInternalValue(1); |
| 810 frame()->OnNavigate(params_A); | 818 frame()->OnNavigate(params_A); |
| 811 ProcessPendingMessages(); | 819 ProcessPendingMessages(); |
| 812 | 820 |
| 813 // A new navigation commits, clearing the forward history. | 821 // A new navigation commits, clearing the forward history. |
| 814 LoadHTML("<div>Page C</div>"); | 822 LoadHTML("<div>Page C</div>"); |
| 815 EXPECT_EQ(2, view()->history_list_length_); | 823 EXPECT_EQ(2, view()->history_list_length_); |
| 816 EXPECT_EQ(1, view()->history_list_offset_); | 824 EXPECT_EQ(1, view()->history_list_offset_); |
| 817 EXPECT_EQ(3, view()->history_page_ids_[1]); | 825 EXPECT_EQ(3, view()->history_page_ids_[1]); |
| 818 | 826 |
| 819 // The browser then sends a stale navigation to B, which should be ignored. | 827 // The browser then sends a stale navigation to B, which should be ignored. |
| 820 FrameMsg_Navigate_Params params_B; | 828 FrameMsg_Navigate_Params params_B; |
| 821 params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 829 params_B.core_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 822 params_B.transition = PAGE_TRANSITION_FORWARD_BACK; | 830 params_B.core_params.transition = PAGE_TRANSITION_FORWARD_BACK; |
| 823 params_B.current_history_list_length = 2; | 831 params_B.commit_params.current_history_list_length = 2; |
| 824 params_B.current_history_list_offset = 0; | 832 params_B.commit_params.current_history_list_offset = 0; |
| 825 params_B.pending_history_list_offset = 1; | 833 params_B.commit_params.pending_history_list_offset = 1; |
| 826 params_B.page_id = 2; | 834 params_B.commit_params.page_id = 2; |
| 827 params_B.page_state = state_A; // Doesn't matter, just has to be present. | 835 params_B.commit_params.page_state = |
| 828 params_B.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 836 state_A; // Doesn't matter, just has to be present. |
| 837 params_B.commit_params.browser_navigation_start = |
| 838 base::TimeTicks::FromInternalValue(1); |
| 829 frame()->OnNavigate(params_B); | 839 frame()->OnNavigate(params_B); |
| 830 | 840 |
| 831 // State should be unchanged. | 841 // State should be unchanged. |
| 832 EXPECT_EQ(2, view()->history_list_length_); | 842 EXPECT_EQ(2, view()->history_list_length_); |
| 833 EXPECT_EQ(1, view()->history_list_offset_); | 843 EXPECT_EQ(1, view()->history_list_offset_); |
| 834 EXPECT_EQ(3, view()->history_page_ids_[1]); | 844 EXPECT_EQ(3, view()->history_page_ids_[1]); |
| 835 } | 845 } |
| 836 | 846 |
| 837 // Test that we do not ignore navigations after the entry limit is reached, | 847 // Test that we do not ignore navigations after the entry limit is reached, |
| 838 // in which case the browser starts dropping entries from the front. In this | 848 // in which case the browser starts dropping entries from the front. In this |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 ViewHostMsg_UpdateState::Read(msg_B, ¶m); | 889 ViewHostMsg_UpdateState::Read(msg_B, ¶m); |
| 880 int page_id_B = param.a; | 890 int page_id_B = param.a; |
| 881 PageState state_B = param.b; | 891 PageState state_B = param.b; |
| 882 EXPECT_EQ(2, page_id_B); | 892 EXPECT_EQ(2, page_id_B); |
| 883 render_thread_->sink().ClearMessages(); | 893 render_thread_->sink().ClearMessages(); |
| 884 | 894 |
| 885 // Suppose the browser has limited the number of NavigationEntries to 2. | 895 // 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. | 896 // 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. | 897 // Ensure that going back to page B (page_id 2) at offset 0 is successful. |
| 888 FrameMsg_Navigate_Params params_B; | 898 FrameMsg_Navigate_Params params_B; |
| 889 params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 899 params_B.core_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 890 params_B.transition = PAGE_TRANSITION_FORWARD_BACK; | 900 params_B.core_params.transition = PAGE_TRANSITION_FORWARD_BACK; |
| 891 params_B.current_history_list_length = 2; | 901 params_B.commit_params.current_history_list_length = 2; |
| 892 params_B.current_history_list_offset = 1; | 902 params_B.commit_params.current_history_list_offset = 1; |
| 893 params_B.pending_history_list_offset = 0; | 903 params_B.commit_params.pending_history_list_offset = 0; |
| 894 params_B.page_id = 2; | 904 params_B.commit_params.page_id = 2; |
| 895 params_B.page_state = state_B; | 905 params_B.commit_params.page_state = state_B; |
| 896 params_B.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 906 params_B.commit_params.browser_navigation_start = |
| 907 base::TimeTicks::FromInternalValue(1); |
| 897 frame()->OnNavigate(params_B); | 908 frame()->OnNavigate(params_B); |
| 898 ProcessPendingMessages(); | 909 ProcessPendingMessages(); |
| 899 | 910 |
| 900 EXPECT_EQ(2, view()->history_list_length_); | 911 EXPECT_EQ(2, view()->history_list_length_); |
| 901 EXPECT_EQ(0, view()->history_list_offset_); | 912 EXPECT_EQ(0, view()->history_list_offset_); |
| 902 EXPECT_EQ(2, view()->history_page_ids_[0]); | 913 EXPECT_EQ(2, view()->history_page_ids_[0]); |
| 903 } | 914 } |
| 904 | 915 |
| 905 // Test that our IME backend sends a notification message when the input focus | 916 // Test that our IME backend sends a notification message when the input focus |
| 906 // changes. | 917 // changes. |
| (...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1591 GetMainFrame()->enableViewSourceMode(true); | 1602 GetMainFrame()->enableViewSourceMode(true); |
| 1592 WebURLError error; | 1603 WebURLError error; |
| 1593 error.domain = WebString::fromUTF8(net::kErrorDomain); | 1604 error.domain = WebString::fromUTF8(net::kErrorDomain); |
| 1594 error.reason = net::ERR_FILE_NOT_FOUND; | 1605 error.reason = net::ERR_FILE_NOT_FOUND; |
| 1595 error.unreachableURL = GURL("http://foo"); | 1606 error.unreachableURL = GURL("http://foo"); |
| 1596 WebLocalFrame* web_frame = GetMainFrame(); | 1607 WebLocalFrame* web_frame = GetMainFrame(); |
| 1597 | 1608 |
| 1598 // Start a load that will reach provisional state synchronously, | 1609 // Start a load that will reach provisional state synchronously, |
| 1599 // but won't complete synchronously. | 1610 // but won't complete synchronously. |
| 1600 FrameMsg_Navigate_Params params; | 1611 FrameMsg_Navigate_Params params; |
| 1601 params.page_id = -1; | 1612 params.commit_params.page_id = -1; |
| 1602 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1613 params.core_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 1603 params.url = GURL("data:text/html,test data"); | 1614 params.core_params.url = GURL("data:text/html,test data"); |
| 1604 params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 1615 params.commit_params.browser_navigation_start = |
| 1616 base::TimeTicks::FromInternalValue(1); |
| 1605 frame()->OnNavigate(params); | 1617 frame()->OnNavigate(params); |
| 1606 | 1618 |
| 1607 // An error occurred. | 1619 // An error occurred. |
| 1608 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); | 1620 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); |
| 1609 // Frame should exit view-source mode. | 1621 // Frame should exit view-source mode. |
| 1610 EXPECT_FALSE(web_frame->isViewSourceModeEnabled()); | 1622 EXPECT_FALSE(web_frame->isViewSourceModeEnabled()); |
| 1611 } | 1623 } |
| 1612 | 1624 |
| 1613 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) { | 1625 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) { |
| 1614 GetMainFrame()->enableViewSourceMode(true); | 1626 GetMainFrame()->enableViewSourceMode(true); |
| 1615 WebURLError error; | 1627 WebURLError error; |
| 1616 error.domain = WebString::fromUTF8(net::kErrorDomain); | 1628 error.domain = WebString::fromUTF8(net::kErrorDomain); |
| 1617 error.reason = net::ERR_ABORTED; | 1629 error.reason = net::ERR_ABORTED; |
| 1618 error.unreachableURL = GURL("http://foo"); | 1630 error.unreachableURL = GURL("http://foo"); |
| 1619 WebLocalFrame* web_frame = GetMainFrame(); | 1631 WebLocalFrame* web_frame = GetMainFrame(); |
| 1620 | 1632 |
| 1621 // Start a load that will reach provisional state synchronously, | 1633 // Start a load that will reach provisional state synchronously, |
| 1622 // but won't complete synchronously. | 1634 // but won't complete synchronously. |
| 1623 FrameMsg_Navigate_Params params; | 1635 FrameMsg_Navigate_Params params; |
| 1624 params.page_id = -1; | 1636 params.commit_params.page_id = -1; |
| 1625 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1637 params.core_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 1626 params.url = GURL("data:text/html,test data"); | 1638 params.core_params.url = GURL("data:text/html,test data"); |
| 1627 params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 1639 params.commit_params.browser_navigation_start = |
| 1640 base::TimeTicks::FromInternalValue(1); |
| 1628 frame()->OnNavigate(params); | 1641 frame()->OnNavigate(params); |
| 1629 | 1642 |
| 1630 // A cancellation occurred. | 1643 // A cancellation occurred. |
| 1631 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); | 1644 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); |
| 1632 // Frame should stay in view-source mode. | 1645 // Frame should stay in view-source mode. |
| 1633 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); | 1646 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); |
| 1634 } | 1647 } |
| 1635 | 1648 |
| 1636 // Regression test for http://crbug.com/41562 | 1649 // Regression test for http://crbug.com/41562 |
| 1637 TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) { | 1650 TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) { |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1996 view()->OnImeConfirmComposition( | 2009 view()->OnImeConfirmComposition( |
| 1997 empty_string, gfx::Range::InvalidRange(), false); | 2010 empty_string, gfx::Range::InvalidRange(), false); |
| 1998 } | 2011 } |
| 1999 #endif | 2012 #endif |
| 2000 | 2013 |
| 2001 TEST_F(RenderViewImplTest, ZoomLimit) { | 2014 TEST_F(RenderViewImplTest, ZoomLimit) { |
| 2002 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor); | 2015 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor); |
| 2003 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor); | 2016 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor); |
| 2004 | 2017 |
| 2005 FrameMsg_Navigate_Params params; | 2018 FrameMsg_Navigate_Params params; |
| 2006 params.page_id = -1; | 2019 params.commit_params.page_id = -1; |
| 2007 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2020 params.core_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2008 params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 2021 params.commit_params.browser_navigation_start = |
| 2022 base::TimeTicks::FromInternalValue(1); |
| 2009 | 2023 |
| 2010 // Verifies navigation to a URL with preset zoom level indeed sets the level. | 2024 // Verifies navigation to a URL with preset zoom level indeed sets the level. |
| 2011 // Regression test for http://crbug.com/139559, where the level was not | 2025 // Regression test for http://crbug.com/139559, where the level was not |
| 2012 // properly set when it is out of the default zoom limits of WebView. | 2026 // properly set when it is out of the default zoom limits of WebView. |
| 2013 params.url = GURL("data:text/html,min_zoomlimit_test"); | 2027 params.core_params.url = GURL("data:text/html,min_zoomlimit_test"); |
| 2014 view()->OnSetZoomLevelForLoadingURL(params.url, kMinZoomLevel); | 2028 view()->OnSetZoomLevelForLoadingURL(params.core_params.url, kMinZoomLevel); |
| 2015 frame()->OnNavigate(params); | 2029 frame()->OnNavigate(params); |
| 2016 ProcessPendingMessages(); | 2030 ProcessPendingMessages(); |
| 2017 EXPECT_DOUBLE_EQ(kMinZoomLevel, view()->GetWebView()->zoomLevel()); | 2031 EXPECT_DOUBLE_EQ(kMinZoomLevel, view()->GetWebView()->zoomLevel()); |
| 2018 | 2032 |
| 2019 // It should work even when the zoom limit is temporarily changed in the page. | 2033 // It should work even when the zoom limit is temporarily changed in the page. |
| 2020 view()->GetWebView()->zoomLimitsChanged(ZoomFactorToZoomLevel(1.0), | 2034 view()->GetWebView()->zoomLimitsChanged(ZoomFactorToZoomLevel(1.0), |
| 2021 ZoomFactorToZoomLevel(1.0)); | 2035 ZoomFactorToZoomLevel(1.0)); |
| 2022 params.url = GURL("data:text/html,max_zoomlimit_test"); | 2036 params.core_params.url = GURL("data:text/html,max_zoomlimit_test"); |
| 2023 view()->OnSetZoomLevelForLoadingURL(params.url, kMaxZoomLevel); | 2037 view()->OnSetZoomLevelForLoadingURL(params.core_params.url, kMaxZoomLevel); |
| 2024 frame()->OnNavigate(params); | 2038 frame()->OnNavigate(params); |
| 2025 ProcessPendingMessages(); | 2039 ProcessPendingMessages(); |
| 2026 EXPECT_DOUBLE_EQ(kMaxZoomLevel, view()->GetWebView()->zoomLevel()); | 2040 EXPECT_DOUBLE_EQ(kMaxZoomLevel, view()->GetWebView()->zoomLevel()); |
| 2027 } | 2041 } |
| 2028 | 2042 |
| 2029 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) { | 2043 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) { |
| 2030 // Load an HTML page consisting of an input field. | 2044 // Load an HTML page consisting of an input field. |
| 2031 LoadHTML("<html>" | 2045 LoadHTML("<html>" |
| 2032 "<head>" | 2046 "<head>" |
| 2033 "</head>" | 2047 "</head>" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2075 EXPECT_EQ(2, info.selectionEnd); | 2089 EXPECT_EQ(2, info.selectionEnd); |
| 2076 } | 2090 } |
| 2077 | 2091 |
| 2078 // Test that the navigating specific frames works correctly. | 2092 // Test that the navigating specific frames works correctly. |
| 2079 TEST_F(RenderViewImplTest, NavigateFrame) { | 2093 TEST_F(RenderViewImplTest, NavigateFrame) { |
| 2080 // Load page A. | 2094 // Load page A. |
| 2081 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); | 2095 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); |
| 2082 | 2096 |
| 2083 // Navigate the frame only. | 2097 // Navigate the frame only. |
| 2084 FrameMsg_Navigate_Params nav_params; | 2098 FrameMsg_Navigate_Params nav_params; |
| 2085 nav_params.url = GURL("data:text/html,world"); | 2099 nav_params.core_params.url = GURL("data:text/html,world"); |
| 2086 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2100 nav_params.core_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2087 nav_params.transition = PAGE_TRANSITION_TYPED; | 2101 nav_params.core_params.transition = PAGE_TRANSITION_TYPED; |
| 2088 nav_params.current_history_list_length = 1; | 2102 nav_params.commit_params.current_history_list_length = 1; |
| 2089 nav_params.current_history_list_offset = 0; | 2103 nav_params.commit_params.current_history_list_offset = 0; |
| 2090 nav_params.pending_history_list_offset = 1; | 2104 nav_params.commit_params.pending_history_list_offset = 1; |
| 2091 nav_params.page_id = -1; | 2105 nav_params.commit_params.page_id = -1; |
| 2092 nav_params.frame_to_navigate = "frame"; | 2106 nav_params.frame_to_navigate = "frame"; |
| 2093 nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 2107 nav_params.commit_params.browser_navigation_start = |
| 2108 base::TimeTicks::FromInternalValue(1); |
| 2094 frame()->OnNavigate(nav_params); | 2109 frame()->OnNavigate(nav_params); |
| 2095 FrameLoadWaiter( | 2110 FrameLoadWaiter( |
| 2096 RenderFrame::FromWebFrame(frame()->GetWebFrame()->firstChild())).Wait(); | 2111 RenderFrame::FromWebFrame(frame()->GetWebFrame()->firstChild())).Wait(); |
| 2097 | 2112 |
| 2098 // Copy the document content to std::wstring and compare with the | 2113 // Copy the document content to std::wstring and compare with the |
| 2099 // expected result. | 2114 // expected result. |
| 2100 const int kMaxOutputCharacters = 256; | 2115 const int kMaxOutputCharacters = 256; |
| 2101 std::string output = base::UTF16ToUTF8( | 2116 std::string output = base::UTF16ToUTF8( |
| 2102 GetMainFrame()->contentAsText(kMaxOutputCharacters)); | 2117 GetMainFrame()->contentAsText(kMaxOutputCharacters)); |
| 2103 EXPECT_EQ(output, "hello \n\nworld"); | 2118 EXPECT_EQ(output, "hello \n\nworld"); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2200 TEST_F(SuppressErrorPageTest, MAYBE_Suppresses) { | 2215 TEST_F(SuppressErrorPageTest, MAYBE_Suppresses) { |
| 2201 WebURLError error; | 2216 WebURLError error; |
| 2202 error.domain = WebString::fromUTF8(net::kErrorDomain); | 2217 error.domain = WebString::fromUTF8(net::kErrorDomain); |
| 2203 error.reason = net::ERR_FILE_NOT_FOUND; | 2218 error.reason = net::ERR_FILE_NOT_FOUND; |
| 2204 error.unreachableURL = GURL("http://example.com/suppress"); | 2219 error.unreachableURL = GURL("http://example.com/suppress"); |
| 2205 WebLocalFrame* web_frame = GetMainFrame(); | 2220 WebLocalFrame* web_frame = GetMainFrame(); |
| 2206 | 2221 |
| 2207 // Start a load that will reach provisional state synchronously, | 2222 // Start a load that will reach provisional state synchronously, |
| 2208 // but won't complete synchronously. | 2223 // but won't complete synchronously. |
| 2209 FrameMsg_Navigate_Params params; | 2224 FrameMsg_Navigate_Params params; |
| 2210 params.page_id = -1; | 2225 params.commit_params.page_id = -1; |
| 2211 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2226 params.core_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2212 params.url = GURL("data:text/html,test data"); | 2227 params.core_params.url = GURL("data:text/html,test data"); |
| 2213 params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 2228 params.commit_params.browser_navigation_start = |
| 2229 base::TimeTicks::FromInternalValue(1); |
| 2214 frame()->OnNavigate(params); | 2230 frame()->OnNavigate(params); |
| 2215 | 2231 |
| 2216 // An error occurred. | 2232 // An error occurred. |
| 2217 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); | 2233 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); |
| 2218 const int kMaxOutputCharacters = 22; | 2234 const int kMaxOutputCharacters = 22; |
| 2219 EXPECT_EQ("", | 2235 EXPECT_EQ("", |
| 2220 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); | 2236 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); |
| 2221 } | 2237 } |
| 2222 | 2238 |
| 2223 #if defined(OS_ANDROID) | 2239 #if defined(OS_ANDROID) |
| 2224 // Crashing on Android: http://crbug.com/311341 | 2240 // Crashing on Android: http://crbug.com/311341 |
| 2225 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress | 2241 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress |
| 2226 #else | 2242 #else |
| 2227 #define MAYBE_DoesNotSuppress DoesNotSuppress | 2243 #define MAYBE_DoesNotSuppress DoesNotSuppress |
| 2228 #endif | 2244 #endif |
| 2229 | 2245 |
| 2230 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) { | 2246 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) { |
| 2231 WebURLError error; | 2247 WebURLError error; |
| 2232 error.domain = WebString::fromUTF8(net::kErrorDomain); | 2248 error.domain = WebString::fromUTF8(net::kErrorDomain); |
| 2233 error.reason = net::ERR_FILE_NOT_FOUND; | 2249 error.reason = net::ERR_FILE_NOT_FOUND; |
| 2234 error.unreachableURL = GURL("http://example.com/dont-suppress"); | 2250 error.unreachableURL = GURL("http://example.com/dont-suppress"); |
| 2235 WebLocalFrame* web_frame = GetMainFrame(); | 2251 WebLocalFrame* web_frame = GetMainFrame(); |
| 2236 | 2252 |
| 2237 // Start a load that will reach provisional state synchronously, | 2253 // Start a load that will reach provisional state synchronously, |
| 2238 // but won't complete synchronously. | 2254 // but won't complete synchronously. |
| 2239 FrameMsg_Navigate_Params params; | 2255 FrameMsg_Navigate_Params params; |
| 2240 params.page_id = -1; | 2256 params.commit_params.page_id = -1; |
| 2241 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2257 params.core_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2242 params.url = GURL("data:text/html,test data"); | 2258 params.core_params.url = GURL("data:text/html,test data"); |
| 2243 params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); | 2259 params.commit_params.browser_navigation_start = |
| 2260 base::TimeTicks::FromInternalValue(1); |
| 2244 frame()->OnNavigate(params); | 2261 frame()->OnNavigate(params); |
| 2245 | 2262 |
| 2246 // An error occurred. | 2263 // An error occurred. |
| 2247 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); | 2264 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); |
| 2248 // The error page itself is loaded asynchronously. | 2265 // The error page itself is loaded asynchronously. |
| 2249 FrameLoadWaiter(frame()).Wait(); | 2266 FrameLoadWaiter(frame()).Wait(); |
| 2250 const int kMaxOutputCharacters = 22; | 2267 const int kMaxOutputCharacters = 22; |
| 2251 EXPECT_EQ("A suffusion of yellow.", | 2268 EXPECT_EQ("A suffusion of yellow.", |
| 2252 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); | 2269 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); |
| 2253 } | 2270 } |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2444 | 2461 |
| 2445 // Sanity checks for the Navigation Timing API |navigationStart| override. We | 2462 // Sanity checks for the Navigation Timing API |navigationStart| override. We |
| 2446 // are asserting only most basic constraints, as TimeTicks (passed as the | 2463 // 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). | 2464 // override) are not comparable with the wall time (returned by the Blink API). |
| 2448 TEST_F(RenderViewImplTest, NavigationStartOverride) { | 2465 TEST_F(RenderViewImplTest, NavigationStartOverride) { |
| 2449 // Verify that a navigation that claims to have started at the earliest | 2466 // Verify that a navigation that claims to have started at the earliest |
| 2450 // possible TimeTicks is indeed reported as one that started before | 2467 // possible TimeTicks is indeed reported as one that started before |
| 2451 // OnNavigate() is called. | 2468 // OnNavigate() is called. |
| 2452 base::Time before_navigation = base::Time::Now(); | 2469 base::Time before_navigation = base::Time::Now(); |
| 2453 FrameMsg_Navigate_Params early_nav_params; | 2470 FrameMsg_Navigate_Params early_nav_params; |
| 2454 early_nav_params.url = GURL("data:text/html,<div>Page</div>"); | 2471 early_nav_params.core_params.url = GURL("data:text/html,<div>Page</div>"); |
| 2455 early_nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2472 early_nav_params.core_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2456 early_nav_params.transition = PAGE_TRANSITION_TYPED; | 2473 early_nav_params.core_params.transition = PAGE_TRANSITION_TYPED; |
| 2457 early_nav_params.page_id = -1; | 2474 early_nav_params.commit_params.page_id = -1; |
| 2458 early_nav_params.is_post = true; | 2475 early_nav_params.request_params.is_post = true; |
| 2459 early_nav_params.browser_navigation_start = | 2476 early_nav_params.commit_params.browser_navigation_start = |
| 2460 base::TimeTicks::FromInternalValue(1); | 2477 base::TimeTicks::FromInternalValue(1); |
| 2461 | 2478 |
| 2462 frame()->OnNavigate(early_nav_params); | 2479 frame()->OnNavigate(early_nav_params); |
| 2463 ProcessPendingMessages(); | 2480 ProcessPendingMessages(); |
| 2464 | 2481 |
| 2465 base::Time early_nav_reported_start = | 2482 base::Time early_nav_reported_start = |
| 2466 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); | 2483 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); |
| 2467 EXPECT_LT(early_nav_reported_start, before_navigation); | 2484 EXPECT_LT(early_nav_reported_start, before_navigation); |
| 2468 | 2485 |
| 2469 // Verify that a navigation that claims to have started in the future - 42 | 2486 // 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 | 2487 // days from now is *not* reported as one that starts in the future; as we |
| 2471 // sanitize the override allowing a maximum of ::Now(). | 2488 // sanitize the override allowing a maximum of ::Now(). |
| 2472 FrameMsg_Navigate_Params late_nav_params; | 2489 FrameMsg_Navigate_Params late_nav_params; |
| 2473 late_nav_params.url = GURL("data:text/html,<div>Another page</div>"); | 2490 late_nav_params.core_params.url = |
| 2474 late_nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2491 GURL("data:text/html,<div>Another page</div>"); |
| 2475 late_nav_params.transition = PAGE_TRANSITION_TYPED; | 2492 late_nav_params.core_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2476 late_nav_params.page_id = -1; | 2493 late_nav_params.core_params.transition = PAGE_TRANSITION_TYPED; |
| 2477 late_nav_params.is_post = true; | 2494 late_nav_params.commit_params.page_id = -1; |
| 2478 late_nav_params.browser_navigation_start = | 2495 late_nav_params.request_params.is_post = true; |
| 2496 late_nav_params.commit_params.browser_navigation_start = |
| 2479 base::TimeTicks::Now() + base::TimeDelta::FromDays(42); | 2497 base::TimeTicks::Now() + base::TimeDelta::FromDays(42); |
| 2480 | 2498 |
| 2481 frame()->OnNavigate(late_nav_params); | 2499 frame()->OnNavigate(late_nav_params); |
| 2482 ProcessPendingMessages(); | 2500 ProcessPendingMessages(); |
| 2483 base::Time after_navigation = | 2501 base::Time after_navigation = |
| 2484 base::Time::Now() + base::TimeDelta::FromDays(1); | 2502 base::Time::Now() + base::TimeDelta::FromDays(1); |
| 2485 | 2503 |
| 2486 base::Time late_nav_reported_start = | 2504 base::Time late_nav_reported_start = |
| 2487 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); | 2505 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); |
| 2488 EXPECT_LE(late_nav_reported_start, after_navigation); | 2506 EXPECT_LE(late_nav_reported_start, after_navigation); |
| 2489 } | 2507 } |
| 2490 | 2508 |
| 2491 } // namespace content | 2509 } // namespace content |
| OLD | NEW |