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

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

Issue 971653004: Remove the FrameMsg_Navigate_Params (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@history-params
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 350
351 // Change the value of the input. We should have gotten an update state 351 // Change the value of the input. We should have gotten an update state
352 // notification. We need to spin the message loop to catch this update. 352 // notification. We need to spin the message loop to catch this update.
353 ExecuteJavaScript("document.getElementById('elt_text').value = 'foo';"); 353 ExecuteJavaScript("document.getElementById('elt_text').value = 'foo';");
354 ProcessPendingMessages(); 354 ProcessPendingMessages();
355 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( 355 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching(
356 ViewHostMsg_UpdateState::ID)); 356 ViewHostMsg_UpdateState::ID));
357 } 357 }
358 358
359 TEST_F(RenderViewImplTest, OnNavigationHttpPost) { 359 TEST_F(RenderViewImplTest, OnNavigationHttpPost) {
360 FrameMsg_Navigate_Params nav_params;
361
362 // An http url will trigger a resource load so cannot be used here. 360 // An http url will trigger a resource load so cannot be used here.
363 nav_params.common_params.url = GURL("data:text/html,<div>Page</div>"); 361 CommonNavigationParams common_params;
364 nav_params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 362 StartNavigationParams start_params;
365 nav_params.common_params.transition = ui::PAGE_TRANSITION_TYPED; 363 CommitNavigationParams commit_params;
366 nav_params.history_params.page_id = -1; 364 HistoryNavigationParams history_params;
367 nav_params.is_post = true; 365 common_params.url = GURL("data:text/html,<div>Page</div>");
368 nav_params.commit_params.browser_navigation_start = 366 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
367 common_params.transition = ui::PAGE_TRANSITION_TYPED;
368 history_params.page_id = -1;
369 commit_params.browser_navigation_start =
369 base::TimeTicks::FromInternalValue(1); 370 base::TimeTicks::FromInternalValue(1);
370 371
371 // Set up post data. 372 // Set up post data.
372 const unsigned char* raw_data = reinterpret_cast<const unsigned char*>( 373 const unsigned char* raw_data = reinterpret_cast<const unsigned char*>(
373 "post \0\ndata"); 374 "post \0\ndata");
374 const unsigned int length = 11; 375 const unsigned int length = 11;
375 const std::vector<unsigned char> post_data(raw_data, raw_data + length); 376 const std::vector<unsigned char> post_data(raw_data, raw_data + length);
376 nav_params.browser_initiated_post_data = post_data; 377 start_params.is_post = true;
378 start_params.browser_initiated_post_data = post_data;
377 379
378 frame()->OnNavigate(nav_params); 380 frame()->OnNavigate(common_params, start_params, commit_params,
381 history_params);
379 ProcessPendingMessages(); 382 ProcessPendingMessages();
380 383
381 const IPC::Message* frame_navigate_msg = 384 const IPC::Message* frame_navigate_msg =
382 render_thread_->sink().GetUniqueMessageMatching( 385 render_thread_->sink().GetUniqueMessageMatching(
383 FrameHostMsg_DidCommitProvisionalLoad::ID); 386 FrameHostMsg_DidCommitProvisionalLoad::ID);
384 EXPECT_TRUE(frame_navigate_msg); 387 EXPECT_TRUE(frame_navigate_msg);
385 388
386 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params; 389 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params;
387 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg, 390 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg,
388 &host_nav_params); 391 &host_nav_params);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 // an ACK, even if we don't have to do anything else. 563 // an ACK, even if we don't have to do anything else.
561 render_thread_->sink().ClearMessages(); 564 render_thread_->sink().ClearMessages();
562 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId, false, 565 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId, false,
563 content::FrameReplicationState()); 566 content::FrameReplicationState());
564 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching( 567 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching(
565 FrameHostMsg_SwapOut_ACK::ID); 568 FrameHostMsg_SwapOut_ACK::ID);
566 ASSERT_TRUE(msg2); 569 ASSERT_TRUE(msg2);
567 570
568 // 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
569 // update for the swapped out URL. (http://crbug.com/72235) 572 // update for the swapped out URL. (http://crbug.com/72235)
570 FrameMsg_Navigate_Params nav_params; 573 CommonNavigationParams common_params;
571 nav_params.common_params.url = GURL("data:text/html,<div>Page B</div>"); 574 CommitNavigationParams commit_params;
572 nav_params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 575 HistoryNavigationParams history_params;
573 nav_params.common_params.transition = ui::PAGE_TRANSITION_TYPED; 576 common_params.url = GURL("data:text/html,<div>Page B</div>");
574 nav_params.history_params.current_history_list_length = 1; 577 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
575 nav_params.history_params.current_history_list_offset = 0; 578 common_params.transition = ui::PAGE_TRANSITION_TYPED;
576 nav_params.history_params.pending_history_list_offset = 1; 579 history_params.current_history_list_length = 1;
577 nav_params.history_params.page_id = -1; 580 history_params.current_history_list_offset = 0;
578 nav_params.commit_params.browser_navigation_start = 581 history_params.pending_history_list_offset = 1;
582 history_params.page_id = -1;
583 commit_params.browser_navigation_start =
579 base::TimeTicks::FromInternalValue(1); 584 base::TimeTicks::FromInternalValue(1);
580 frame()->OnNavigate(nav_params); 585 frame()->OnNavigate(common_params, StartNavigationParams(), commit_params,
586 history_params);
581 ProcessPendingMessages(); 587 ProcessPendingMessages();
582 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching( 588 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching(
583 ViewHostMsg_UpdateState::ID); 589 ViewHostMsg_UpdateState::ID);
584 EXPECT_FALSE(msg3); 590 EXPECT_FALSE(msg3);
585 } 591 }
586 592
587 // Ensure the RenderViewImpl reloads the previous page if a reload request 593 // Ensure the RenderViewImpl reloads the previous page if a reload request
588 // arrives while it is showing swappedout://. http://crbug.com/143155. 594 // arrives while it is showing swappedout://. http://crbug.com/143155.
589 TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) { 595 TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) {
590 // Load page A. 596 // Load page A.
591 LoadHTML("<div>Page A</div>"); 597 LoadHTML("<div>Page A</div>");
592 598
593 // Load page B, which will trigger an UpdateState message for page A. 599 // Load page B, which will trigger an UpdateState message for page A.
594 LoadHTML("<div>Page B</div>"); 600 LoadHTML("<div>Page B</div>");
595 601
596 // Check for a valid UpdateState message for page A. 602 // Check for a valid UpdateState message for page A.
597 ProcessPendingMessages(); 603 ProcessPendingMessages();
598 const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching( 604 const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching(
599 ViewHostMsg_UpdateState::ID); 605 ViewHostMsg_UpdateState::ID);
600 ASSERT_TRUE(msg_A); 606 ASSERT_TRUE(msg_A);
601 ViewHostMsg_UpdateState::Param params; 607 ViewHostMsg_UpdateState::Param params;
602 ViewHostMsg_UpdateState::Read(msg_A, &params); 608 ViewHostMsg_UpdateState::Read(msg_A, &params);
603 int page_id_A = get<0>(params); 609 int page_id_A = get<0>(params);
604 PageState state_A = get<1>(params); 610 PageState state_A = get<1>(params);
605 EXPECT_EQ(1, page_id_A); 611 EXPECT_EQ(1, page_id_A);
606 render_thread_->sink().ClearMessages(); 612 render_thread_->sink().ClearMessages();
607 613
608 // Back to page A (page_id 1) and commit. 614 // Back to page A (page_id 1) and commit.
609 FrameMsg_Navigate_Params params_A; 615 CommonNavigationParams common_params_A;
610 params_A.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 616 CommitNavigationParams commit_params_A;
611 params_A.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; 617 HistoryNavigationParams history_params_A;
612 params_A.history_params.current_history_list_length = 2; 618 common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL;
613 params_A.history_params.current_history_list_offset = 1; 619 common_params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
614 params_A.history_params.pending_history_list_offset = 0; 620 history_params_A.current_history_list_length = 2;
615 params_A.history_params.page_id = 1; 621 history_params_A.current_history_list_offset = 1;
616 params_A.history_params.page_state = state_A; 622 history_params_A.pending_history_list_offset = 0;
617 params_A.commit_params.browser_navigation_start = 623 history_params_A.page_id = 1;
624 history_params_A.page_state = state_A;
625 commit_params_A.browser_navigation_start =
618 base::TimeTicks::FromInternalValue(1); 626 base::TimeTicks::FromInternalValue(1);
619 frame()->OnNavigate(params_A); 627 frame()->OnNavigate(common_params_A, StartNavigationParams(), commit_params_A,
628 history_params_A);
620 EXPECT_EQ(1, view()->historyBackListCount()); 629 EXPECT_EQ(1, view()->historyBackListCount());
621 EXPECT_EQ(2, view()->historyBackListCount() + 630 EXPECT_EQ(2, view()->historyBackListCount() +
622 view()->historyForwardListCount() + 1); 631 view()->historyForwardListCount() + 1);
623 ProcessPendingMessages(); 632 ProcessPendingMessages();
624 633
625 // Respond to a swap out request. 634 // Respond to a swap out request.
626 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId, true, 635 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId, true,
627 content::FrameReplicationState()); 636 content::FrameReplicationState());
628 637
629 // Check for a OnSwapOutACK. 638 // Check for a OnSwapOutACK.
630 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( 639 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching(
631 FrameHostMsg_SwapOut_ACK::ID); 640 FrameHostMsg_SwapOut_ACK::ID);
632 ASSERT_TRUE(msg); 641 ASSERT_TRUE(msg);
633 render_thread_->sink().ClearMessages(); 642 render_thread_->sink().ClearMessages();
634 643
635 // It is possible to get a reload request at this point, containing the 644 // It is possible to get a reload request at this point, containing the
636 // params.page_state of the initial page (e.g., if the new page fails the 645 // params.page_state of the initial page (e.g., if the new page fails the
637 // provisional load in the renderer process, after we unload the old page). 646 // provisional load in the renderer process, after we unload the old page).
638 // Ensure the old page gets reloaded, not swappedout://. 647 // Ensure the old page gets reloaded, not swappedout://.
639 FrameMsg_Navigate_Params nav_params; 648 CommonNavigationParams common_params;
640 nav_params.common_params.url = GURL("data:text/html,<div>Page A</div>"); 649 CommitNavigationParams commit_params;
641 nav_params.common_params.navigation_type = FrameMsg_Navigate_Type::RELOAD; 650 HistoryNavigationParams history_params;
642 nav_params.common_params.transition = ui::PAGE_TRANSITION_RELOAD; 651 common_params.url = GURL("data:text/html,<div>Page A</div>");
643 nav_params.history_params.current_history_list_length = 2; 652 common_params.navigation_type = FrameMsg_Navigate_Type::RELOAD;
644 nav_params.history_params.current_history_list_offset = 0; 653 common_params.transition = ui::PAGE_TRANSITION_RELOAD;
645 nav_params.history_params.pending_history_list_offset = 0; 654 history_params.current_history_list_length = 2;
646 nav_params.history_params.page_id = 1; 655 history_params.current_history_list_offset = 0;
647 nav_params.history_params.page_state = state_A; 656 history_params.pending_history_list_offset = 0;
648 nav_params.commit_params.browser_navigation_start = 657 history_params.page_id = 1;
658 history_params.page_state = state_A;
659 commit_params.browser_navigation_start =
649 base::TimeTicks::FromInternalValue(1); 660 base::TimeTicks::FromInternalValue(1);
650 frame()->OnNavigate(nav_params); 661 frame()->OnNavigate(common_params, StartNavigationParams(), commit_params,
662 history_params);
651 ProcessPendingMessages(); 663 ProcessPendingMessages();
652 664
653 // Verify page A committed, not swappedout://. 665 // Verify page A committed, not swappedout://.
654 const IPC::Message* frame_navigate_msg = 666 const IPC::Message* frame_navigate_msg =
655 render_thread_->sink().GetUniqueMessageMatching( 667 render_thread_->sink().GetUniqueMessageMatching(
656 FrameHostMsg_DidCommitProvisionalLoad::ID); 668 FrameHostMsg_DidCommitProvisionalLoad::ID);
657 EXPECT_TRUE(frame_navigate_msg); 669 EXPECT_TRUE(frame_navigate_msg);
658 670
659 // Read URL out of the parent trait of the params object. 671 // Read URL out of the parent trait of the params object.
660 FrameHostMsg_DidCommitProvisionalLoad::Param commit_params; 672 FrameHostMsg_DidCommitProvisionalLoad::Param commit_load_params;
661 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg, 673 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg,
662 &commit_params); 674 &commit_load_params);
663 EXPECT_NE(GURL("swappedout://"), get<0>(commit_params).url); 675 EXPECT_NE(GURL("swappedout://"), get<0>(commit_load_params).url);
664 } 676 }
665 677
666 // Verify that security origins are replicated properly to RenderFrameProxies 678 // Verify that security origins are replicated properly to RenderFrameProxies
667 // when swapping out. 679 // when swapping out.
668 TEST_F(RenderViewImplTest, OriginReplicationForSwapOut) { 680 TEST_F(RenderViewImplTest, OriginReplicationForSwapOut) {
669 // This test should only run with --site-per-process, since origin 681 // This test should only run with --site-per-process, since origin
670 // replication only happens in that mode. 682 // replication only happens in that mode.
671 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 683 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
672 switches::kSitePerProcess)) 684 switches::kSitePerProcess))
673 return; 685 return;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 ViewHostMsg_UpdateState::ID); 761 ViewHostMsg_UpdateState::ID);
750 ASSERT_TRUE(msg_C); 762 ASSERT_TRUE(msg_C);
751 ViewHostMsg_UpdateState::Read(msg_C, &param); 763 ViewHostMsg_UpdateState::Read(msg_C, &param);
752 int page_id_C = get<0>(param); 764 int page_id_C = get<0>(param);
753 PageState state_C = get<1>(param); 765 PageState state_C = get<1>(param);
754 EXPECT_EQ(3, page_id_C); 766 EXPECT_EQ(3, page_id_C);
755 EXPECT_NE(state_B, state_C); 767 EXPECT_NE(state_B, state_C);
756 render_thread_->sink().ClearMessages(); 768 render_thread_->sink().ClearMessages();
757 769
758 // Go back to C and commit, preparing for our real test. 770 // Go back to C and commit, preparing for our real test.
759 FrameMsg_Navigate_Params params_C; 771 CommonNavigationParams common_params_C;
760 params_C.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 772 CommitNavigationParams commit_params_C;
761 params_C.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; 773 HistoryNavigationParams history_params_C;
762 params_C.history_params.current_history_list_length = 4; 774 common_params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL;
763 params_C.history_params.current_history_list_offset = 3; 775 common_params_C.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
764 params_C.history_params.pending_history_list_offset = 2; 776 history_params_C.current_history_list_length = 4;
765 params_C.history_params.page_id = 3; 777 history_params_C.current_history_list_offset = 3;
766 params_C.history_params.page_state = state_C; 778 history_params_C.pending_history_list_offset = 2;
767 params_C.commit_params.browser_navigation_start = 779 history_params_C.page_id = 3;
780 history_params_C.page_state = state_C;
781 commit_params_C.browser_navigation_start =
768 base::TimeTicks::FromInternalValue(1); 782 base::TimeTicks::FromInternalValue(1);
769 frame()->OnNavigate(params_C); 783 frame()->OnNavigate(common_params_C, StartNavigationParams(), commit_params_C,
784 history_params_C);
770 ProcessPendingMessages(); 785 ProcessPendingMessages();
771 render_thread_->sink().ClearMessages(); 786 render_thread_->sink().ClearMessages();
772 787
773 // Go back twice quickly, such that page B does not have a chance to commit. 788 // Go back twice quickly, such that page B does not have a chance to commit.
774 // This leads to two changes to the back/forward list but only one change to 789 // This leads to two changes to the back/forward list but only one change to
775 // the RenderView's page ID. 790 // the RenderView's page ID.
776 791
777 // Back to page B (page_id 2), without committing. 792 // Back to page B (page_id 2), without committing.
778 FrameMsg_Navigate_Params params_B; 793 CommonNavigationParams common_params_B;
779 params_B.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 794 CommitNavigationParams commit_params_B;
780 params_B.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; 795 HistoryNavigationParams history_params_B;
781 params_B.history_params.current_history_list_length = 4; 796 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL;
782 params_B.history_params.current_history_list_offset = 2; 797 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
783 params_B.history_params.pending_history_list_offset = 1; 798 history_params_B.current_history_list_length = 4;
784 params_B.history_params.page_id = 2; 799 history_params_B.current_history_list_offset = 2;
785 params_B.history_params.page_state = state_B; 800 history_params_B.pending_history_list_offset = 1;
786 params_B.commit_params.browser_navigation_start = 801 history_params_B.page_id = 2;
802 history_params_B.page_state = state_B;
803 commit_params_B.browser_navigation_start =
787 base::TimeTicks::FromInternalValue(1); 804 base::TimeTicks::FromInternalValue(1);
788 frame()->OnNavigate(params_B); 805 frame()->OnNavigate(common_params_B, StartNavigationParams(), commit_params_B,
806 history_params_B);
789 807
790 // Back to page A (page_id 1) and commit. 808 // Back to page A (page_id 1) and commit.
791 FrameMsg_Navigate_Params params; 809 CommonNavigationParams common_params;
792 params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 810 CommitNavigationParams commit_params;
793 params.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; 811 HistoryNavigationParams history_params;
794 params.history_params.current_history_list_length = 4; 812 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
795 params.history_params.current_history_list_offset = 2; 813 common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
796 params.history_params.pending_history_list_offset = 0; 814 history_params.current_history_list_length = 4;
797 params.history_params.page_id = 1; 815 history_params.current_history_list_offset = 2;
798 params.history_params.page_state = state_A; 816 history_params.pending_history_list_offset = 0;
799 params.commit_params.browser_navigation_start = 817 history_params.page_id = 1;
818 history_params.page_state = state_A;
819 commit_params.browser_navigation_start =
800 base::TimeTicks::FromInternalValue(1); 820 base::TimeTicks::FromInternalValue(1);
801 frame()->OnNavigate(params); 821 frame()->OnNavigate(common_params, StartNavigationParams(), commit_params,
822 history_params);
802 ProcessPendingMessages(); 823 ProcessPendingMessages();
803 824
804 // Now ensure that the UpdateState message we receive is consistent 825 // Now ensure that the UpdateState message we receive is consistent
805 // and represents page C in both page_id and state. 826 // and represents page C in both page_id and state.
806 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( 827 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching(
807 ViewHostMsg_UpdateState::ID); 828 ViewHostMsg_UpdateState::ID);
808 ASSERT_TRUE(msg); 829 ASSERT_TRUE(msg);
809 ViewHostMsg_UpdateState::Read(msg, &param); 830 ViewHostMsg_UpdateState::Read(msg, &param);
810 int page_id = get<0>(param); 831 int page_id = get<0>(param);
811 PageState state = get<1>(param); 832 PageState state = get<1>(param);
(...skipping 22 matching lines...) Expand all
834 ViewHostMsg_UpdateState::ID); 855 ViewHostMsg_UpdateState::ID);
835 ASSERT_TRUE(msg_A); 856 ASSERT_TRUE(msg_A);
836 ViewHostMsg_UpdateState::Param param; 857 ViewHostMsg_UpdateState::Param param;
837 ViewHostMsg_UpdateState::Read(msg_A, &param); 858 ViewHostMsg_UpdateState::Read(msg_A, &param);
838 int page_id_A = get<0>(param); 859 int page_id_A = get<0>(param);
839 PageState state_A = get<1>(param); 860 PageState state_A = get<1>(param);
840 EXPECT_EQ(1, page_id_A); 861 EXPECT_EQ(1, page_id_A);
841 render_thread_->sink().ClearMessages(); 862 render_thread_->sink().ClearMessages();
842 863
843 // Back to page A (page_id 1) and commit. 864 // Back to page A (page_id 1) and commit.
844 FrameMsg_Navigate_Params params_A; 865 CommonNavigationParams common_params_A;
845 params_A.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 866 CommitNavigationParams commit_params_A;
846 params_A.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; 867 HistoryNavigationParams history_params_A;
847 params_A.history_params.current_history_list_length = 2; 868 common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL;
848 params_A.history_params.current_history_list_offset = 1; 869 common_params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
849 params_A.history_params.pending_history_list_offset = 0; 870 history_params_A.current_history_list_length = 2;
850 params_A.history_params.page_id = 1; 871 history_params_A.current_history_list_offset = 1;
851 params_A.history_params.page_state = state_A; 872 history_params_A.pending_history_list_offset = 0;
852 params_A.commit_params.browser_navigation_start = 873 history_params_A.page_id = 1;
874 history_params_A.page_state = state_A;
875 commit_params_A.browser_navigation_start =
853 base::TimeTicks::FromInternalValue(1); 876 base::TimeTicks::FromInternalValue(1);
854 frame()->OnNavigate(params_A); 877 frame()->OnNavigate(common_params_A, StartNavigationParams(), commit_params_A,
878 history_params_A);
855 ProcessPendingMessages(); 879 ProcessPendingMessages();
856 880
857 // A new navigation commits, clearing the forward history. 881 // A new navigation commits, clearing the forward history.
858 LoadHTML("<div>Page C</div>"); 882 LoadHTML("<div>Page C</div>");
859 EXPECT_EQ(2, view()->history_list_length_); 883 EXPECT_EQ(2, view()->history_list_length_);
860 EXPECT_EQ(1, view()->history_list_offset_); 884 EXPECT_EQ(1, view()->history_list_offset_);
861 EXPECT_EQ(3, view()->page_id_); // page C is now page id 3 885 EXPECT_EQ(3, view()->page_id_); // page C is now page id 3
862 886
863 // The browser then sends a stale navigation to B, which should be ignored. 887 // The browser then sends a stale navigation to B, which should be ignored.
864 FrameMsg_Navigate_Params params_B; 888 CommonNavigationParams common_params_B;
865 params_B.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 889 CommitNavigationParams commit_params_B;
866 params_B.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; 890 HistoryNavigationParams history_params_B;
867 params_B.history_params.current_history_list_length = 2; 891 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL;
868 params_B.history_params.current_history_list_offset = 0; 892 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
869 params_B.history_params.pending_history_list_offset = 1; 893 history_params_B.current_history_list_length = 2;
870 params_B.history_params.page_id = 2; 894 history_params_B.current_history_list_offset = 0;
871 params_B.history_params.page_state = 895 history_params_B.pending_history_list_offset = 1;
896 history_params_B.page_id = 2;
897 history_params_B.page_state =
872 state_A; // Doesn't matter, just has to be present. 898 state_A; // Doesn't matter, just has to be present.
873 params_B.commit_params.browser_navigation_start = 899 commit_params_B.browser_navigation_start =
874 base::TimeTicks::FromInternalValue(1); 900 base::TimeTicks::FromInternalValue(1);
875 frame()->OnNavigate(params_B); 901 frame()->OnNavigate(common_params_B, StartNavigationParams(), commit_params_B,
902 history_params_B);
876 903
877 // State should be unchanged. 904 // State should be unchanged.
878 EXPECT_EQ(2, view()->history_list_length_); 905 EXPECT_EQ(2, view()->history_list_length_);
879 EXPECT_EQ(1, view()->history_list_offset_); 906 EXPECT_EQ(1, view()->history_list_offset_);
880 EXPECT_EQ(3, view()->page_id_); // page C, not page B 907 EXPECT_EQ(3, view()->page_id_); // page C, not page B
881 908
882 // Check for a valid DidDropNavigation message. 909 // Check for a valid DidDropNavigation message.
883 ProcessPendingMessages(); 910 ProcessPendingMessages();
884 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( 911 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching(
885 FrameHostMsg_DidDropNavigation::ID); 912 FrameHostMsg_DidDropNavigation::ID);
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
1577 TEST_F(RenderViewImplTest, DISABLED_DidFailProvisionalLoadWithErrorForError) { 1604 TEST_F(RenderViewImplTest, DISABLED_DidFailProvisionalLoadWithErrorForError) {
1578 GetMainFrame()->enableViewSourceMode(true); 1605 GetMainFrame()->enableViewSourceMode(true);
1579 WebURLError error; 1606 WebURLError error;
1580 error.domain = WebString::fromUTF8(net::kErrorDomain); 1607 error.domain = WebString::fromUTF8(net::kErrorDomain);
1581 error.reason = net::ERR_FILE_NOT_FOUND; 1608 error.reason = net::ERR_FILE_NOT_FOUND;
1582 error.unreachableURL = GURL("http://foo"); 1609 error.unreachableURL = GURL("http://foo");
1583 WebLocalFrame* web_frame = GetMainFrame(); 1610 WebLocalFrame* web_frame = GetMainFrame();
1584 1611
1585 // Start a load that will reach provisional state synchronously, 1612 // Start a load that will reach provisional state synchronously,
1586 // but won't complete synchronously. 1613 // but won't complete synchronously.
1587 FrameMsg_Navigate_Params params; 1614 CommonNavigationParams common_params;
1588 params.history_params.page_id = -1; 1615 CommitNavigationParams commit_params;
1589 params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 1616 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
1590 params.common_params.url = GURL("data:text/html,test data"); 1617 common_params.url = GURL("data:text/html,test data");
1591 params.commit_params.browser_navigation_start = 1618 commit_params.browser_navigation_start =
1592 base::TimeTicks::FromInternalValue(1); 1619 base::TimeTicks::FromInternalValue(1);
1593 frame()->OnNavigate(params); 1620 frame()->OnNavigate(common_params, StartNavigationParams(), commit_params,
1621 HistoryNavigationParams());
1594 1622
1595 // An error occurred. 1623 // An error occurred.
1596 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); 1624 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error);
1597 // Frame should exit view-source mode. 1625 // Frame should exit view-source mode.
1598 EXPECT_FALSE(web_frame->isViewSourceModeEnabled()); 1626 EXPECT_FALSE(web_frame->isViewSourceModeEnabled());
1599 } 1627 }
1600 1628
1601 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) { 1629 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) {
1602 GetMainFrame()->enableViewSourceMode(true); 1630 GetMainFrame()->enableViewSourceMode(true);
1603 WebURLError error; 1631 WebURLError error;
1604 error.domain = WebString::fromUTF8(net::kErrorDomain); 1632 error.domain = WebString::fromUTF8(net::kErrorDomain);
1605 error.reason = net::ERR_ABORTED; 1633 error.reason = net::ERR_ABORTED;
1606 error.unreachableURL = GURL("http://foo"); 1634 error.unreachableURL = GURL("http://foo");
1607 WebLocalFrame* web_frame = GetMainFrame(); 1635 WebLocalFrame* web_frame = GetMainFrame();
1608 1636
1609 // Start a load that will reach provisional state synchronously, 1637 // Start a load that will reach provisional state synchronously,
1610 // but won't complete synchronously. 1638 // but won't complete synchronously.
1611 FrameMsg_Navigate_Params params; 1639 CommonNavigationParams common_params;
1612 params.history_params.page_id = -1; 1640 CommitNavigationParams commit_params;
1613 params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 1641 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
1614 params.common_params.url = GURL("data:text/html,test data"); 1642 common_params.url = GURL("data:text/html,test data");
1615 params.commit_params.browser_navigation_start = 1643 commit_params.browser_navigation_start =
1616 base::TimeTicks::FromInternalValue(1); 1644 base::TimeTicks::FromInternalValue(1);
1617 frame()->OnNavigate(params); 1645 frame()->OnNavigate(common_params, StartNavigationParams(), commit_params,
1646 HistoryNavigationParams());
1618 1647
1619 // A cancellation occurred. 1648 // A cancellation occurred.
1620 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); 1649 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error);
1621 // Frame should stay in view-source mode. 1650 // Frame should stay in view-source mode.
1622 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); 1651 EXPECT_TRUE(web_frame->isViewSourceModeEnabled());
1623 } 1652 }
1624 1653
1625 // Regression test for http://crbug.com/41562 1654 // Regression test for http://crbug.com/41562
1626 TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) { 1655 TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) {
1627 const GURL invalid_gurl("http://"); 1656 const GURL invalid_gurl("http://");
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1797 } 1826 }
1798 view()->OnImeConfirmComposition( 1827 view()->OnImeConfirmComposition(
1799 empty_string, gfx::Range::InvalidRange(), false); 1828 empty_string, gfx::Range::InvalidRange(), false);
1800 } 1829 }
1801 #endif 1830 #endif
1802 1831
1803 TEST_F(RenderViewImplTest, ZoomLimit) { 1832 TEST_F(RenderViewImplTest, ZoomLimit) {
1804 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor); 1833 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor);
1805 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor); 1834 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor);
1806 1835
1807 FrameMsg_Navigate_Params params; 1836 CommonNavigationParams common_params;
1808 params.history_params.page_id = -1; 1837 CommitNavigationParams commit_params;
1809 params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 1838 commit_params.browser_navigation_start =
1810 params.commit_params.browser_navigation_start =
1811 base::TimeTicks::FromInternalValue(1); 1839 base::TimeTicks::FromInternalValue(1);
1812 1840
1813 // Verifies navigation to a URL with preset zoom level indeed sets the level. 1841 // Verifies navigation to a URL with preset zoom level indeed sets the level.
1814 // Regression test for http://crbug.com/139559, where the level was not 1842 // Regression test for http://crbug.com/139559, where the level was not
1815 // properly set when it is out of the default zoom limits of WebView. 1843 // properly set when it is out of the default zoom limits of WebView.
1816 params.common_params.url = GURL("data:text/html,min_zoomlimit_test"); 1844 common_params.url = GURL("data:text/html,min_zoomlimit_test");
1817 view()->OnSetZoomLevelForLoadingURL(params.common_params.url, kMinZoomLevel); 1845 view()->OnSetZoomLevelForLoadingURL(common_params.url, kMinZoomLevel);
1818 frame()->OnNavigate(params); 1846 frame()->OnNavigate(common_params, StartNavigationParams(), commit_params,
1847 HistoryNavigationParams());
1819 ProcessPendingMessages(); 1848 ProcessPendingMessages();
1820 EXPECT_DOUBLE_EQ(kMinZoomLevel, view()->GetWebView()->zoomLevel()); 1849 EXPECT_DOUBLE_EQ(kMinZoomLevel, view()->GetWebView()->zoomLevel());
1821 1850
1822 // It should work even when the zoom limit is temporarily changed in the page. 1851 // It should work even when the zoom limit is temporarily changed in the page.
1823 view()->GetWebView()->zoomLimitsChanged(ZoomFactorToZoomLevel(1.0), 1852 view()->GetWebView()->zoomLimitsChanged(ZoomFactorToZoomLevel(1.0),
1824 ZoomFactorToZoomLevel(1.0)); 1853 ZoomFactorToZoomLevel(1.0));
1825 params.common_params.url = GURL("data:text/html,max_zoomlimit_test"); 1854 common_params.url = GURL("data:text/html,max_zoomlimit_test");
1826 view()->OnSetZoomLevelForLoadingURL(params.common_params.url, kMaxZoomLevel); 1855 view()->OnSetZoomLevelForLoadingURL(common_params.url, kMaxZoomLevel);
1827 frame()->OnNavigate(params); 1856 frame()->OnNavigate(common_params, StartNavigationParams(), commit_params,
1857 HistoryNavigationParams());
1828 ProcessPendingMessages(); 1858 ProcessPendingMessages();
1829 EXPECT_DOUBLE_EQ(kMaxZoomLevel, view()->GetWebView()->zoomLevel()); 1859 EXPECT_DOUBLE_EQ(kMaxZoomLevel, view()->GetWebView()->zoomLevel());
1830 } 1860 }
1831 1861
1832 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) { 1862 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) {
1833 // Load an HTML page consisting of an input field. 1863 // Load an HTML page consisting of an input field.
1834 LoadHTML("<html>" 1864 LoadHTML("<html>"
1835 "<head>" 1865 "<head>"
1836 "</head>" 1866 "</head>"
1837 "<body>" 1867 "<body>"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 EXPECT_EQ(2, info.selectionStart); 1907 EXPECT_EQ(2, info.selectionStart);
1878 EXPECT_EQ(2, info.selectionEnd); 1908 EXPECT_EQ(2, info.selectionEnd);
1879 } 1909 }
1880 1910
1881 // Test that the navigating specific frames works correctly. 1911 // Test that the navigating specific frames works correctly.
1882 TEST_F(RenderViewImplTest, NavigateFrame) { 1912 TEST_F(RenderViewImplTest, NavigateFrame) {
1883 // Load page A. 1913 // Load page A.
1884 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); 1914 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>");
1885 1915
1886 // Navigate the frame only. 1916 // Navigate the frame only.
1887 FrameMsg_Navigate_Params nav_params; 1917 CommonNavigationParams common_params;
1888 nav_params.common_params.url = GURL("data:text/html,world"); 1918 CommitNavigationParams commit_params;
1889 nav_params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 1919 HistoryNavigationParams history_params;
1890 nav_params.common_params.transition = ui::PAGE_TRANSITION_TYPED; 1920 common_params.url = GURL("data:text/html,world");
1891 nav_params.history_params.current_history_list_length = 1; 1921 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
1892 nav_params.history_params.current_history_list_offset = 0; 1922 common_params.transition = ui::PAGE_TRANSITION_TYPED;
1893 nav_params.history_params.pending_history_list_offset = 1; 1923 history_params.current_history_list_length = 1;
1894 nav_params.history_params.page_id = -1; 1924 history_params.current_history_list_offset = 0;
1895 nav_params.frame_to_navigate = "frame"; 1925 history_params.pending_history_list_offset = 1;
1896 nav_params.commit_params.browser_navigation_start = 1926 history_params.page_id = -1;
1927 commit_params.frame_to_navigate = "frame";
1928 commit_params.browser_navigation_start =
1897 base::TimeTicks::FromInternalValue(1); 1929 base::TimeTicks::FromInternalValue(1);
1898 frame()->OnNavigate(nav_params); 1930 frame()->OnNavigate(common_params, StartNavigationParams(), commit_params,
1931 history_params);
1899 FrameLoadWaiter( 1932 FrameLoadWaiter(
1900 RenderFrame::FromWebFrame(frame()->GetWebFrame()->firstChild())).Wait(); 1933 RenderFrame::FromWebFrame(frame()->GetWebFrame()->firstChild())).Wait();
1901 1934
1902 // Copy the document content to std::wstring and compare with the 1935 // Copy the document content to std::wstring and compare with the
1903 // expected result. 1936 // expected result.
1904 const int kMaxOutputCharacters = 256; 1937 const int kMaxOutputCharacters = 256;
1905 std::string output = base::UTF16ToUTF8( 1938 std::string output = base::UTF16ToUTF8(
1906 GetMainFrame()->contentAsText(kMaxOutputCharacters)); 1939 GetMainFrame()->contentAsText(kMaxOutputCharacters));
1907 EXPECT_EQ(output, "hello \n\nworld"); 1940 EXPECT_EQ(output, "hello \n\nworld");
1908 } 1941 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 2035
2003 TEST_F(SuppressErrorPageTest, MAYBE_Suppresses) { 2036 TEST_F(SuppressErrorPageTest, MAYBE_Suppresses) {
2004 WebURLError error; 2037 WebURLError error;
2005 error.domain = WebString::fromUTF8(net::kErrorDomain); 2038 error.domain = WebString::fromUTF8(net::kErrorDomain);
2006 error.reason = net::ERR_FILE_NOT_FOUND; 2039 error.reason = net::ERR_FILE_NOT_FOUND;
2007 error.unreachableURL = GURL("http://example.com/suppress"); 2040 error.unreachableURL = GURL("http://example.com/suppress");
2008 WebLocalFrame* web_frame = GetMainFrame(); 2041 WebLocalFrame* web_frame = GetMainFrame();
2009 2042
2010 // Start a load that will reach provisional state synchronously, 2043 // Start a load that will reach provisional state synchronously,
2011 // but won't complete synchronously. 2044 // but won't complete synchronously.
2012 FrameMsg_Navigate_Params params; 2045 CommonNavigationParams common_params;
2013 params.history_params.page_id = -1; 2046 CommitNavigationParams commit_params;
2014 params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 2047 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2015 params.common_params.url = GURL("data:text/html,test data"); 2048 common_params.url = GURL("data:text/html,test data");
2016 params.commit_params.browser_navigation_start = 2049 commit_params.browser_navigation_start =
2017 base::TimeTicks::FromInternalValue(1); 2050 base::TimeTicks::FromInternalValue(1);
2018 frame()->OnNavigate(params); 2051 frame()->OnNavigate(common_params, StartNavigationParams(), commit_params,
2052 HistoryNavigationParams());
2019 2053
2020 // An error occurred. 2054 // An error occurred.
2021 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); 2055 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error);
2022 const int kMaxOutputCharacters = 22; 2056 const int kMaxOutputCharacters = 22;
2023 EXPECT_EQ("", 2057 EXPECT_EQ("",
2024 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); 2058 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
2025 } 2059 }
2026 2060
2027 #if defined(OS_ANDROID) 2061 #if defined(OS_ANDROID)
2028 // Crashing on Android: http://crbug.com/311341 2062 // Crashing on Android: http://crbug.com/311341
2029 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress 2063 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress
2030 #else 2064 #else
2031 #define MAYBE_DoesNotSuppress DoesNotSuppress 2065 #define MAYBE_DoesNotSuppress DoesNotSuppress
2032 #endif 2066 #endif
2033 2067
2034 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) { 2068 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) {
2035 WebURLError error; 2069 WebURLError error;
2036 error.domain = WebString::fromUTF8(net::kErrorDomain); 2070 error.domain = WebString::fromUTF8(net::kErrorDomain);
2037 error.reason = net::ERR_FILE_NOT_FOUND; 2071 error.reason = net::ERR_FILE_NOT_FOUND;
2038 error.unreachableURL = GURL("http://example.com/dont-suppress"); 2072 error.unreachableURL = GURL("http://example.com/dont-suppress");
2039 WebLocalFrame* web_frame = GetMainFrame(); 2073 WebLocalFrame* web_frame = GetMainFrame();
2040 2074
2041 // Start a load that will reach provisional state synchronously, 2075 // Start a load that will reach provisional state synchronously,
2042 // but won't complete synchronously. 2076 // but won't complete synchronously.
2043 FrameMsg_Navigate_Params params; 2077 CommonNavigationParams common_params;
2044 params.history_params.page_id = -1; 2078 CommitNavigationParams commit_params;
2045 params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 2079 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2046 params.common_params.url = GURL("data:text/html,test data"); 2080 common_params.url = GURL("data:text/html,test data");
2047 params.commit_params.browser_navigation_start = 2081 commit_params.browser_navigation_start =
2048 base::TimeTicks::FromInternalValue(1); 2082 base::TimeTicks::FromInternalValue(1);
2049 frame()->OnNavigate(params); 2083 frame()->OnNavigate(common_params, StartNavigationParams(), commit_params,
2084 HistoryNavigationParams());
2050 2085
2051 // An error occurred. 2086 // An error occurred.
2052 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); 2087 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error);
2053 // The error page itself is loaded asynchronously. 2088 // The error page itself is loaded asynchronously.
2054 FrameLoadWaiter(frame()).Wait(); 2089 FrameLoadWaiter(frame()).Wait();
2055 const int kMaxOutputCharacters = 22; 2090 const int kMaxOutputCharacters = 22;
2056 EXPECT_EQ("A suffusion of yellow.", 2091 EXPECT_EQ("A suffusion of yellow.",
2057 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); 2092 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
2058 } 2093 }
2059 2094
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
2238 } 2273 }
2239 2274
2240 // Sanity checks for the Navigation Timing API |navigationStart| override. We 2275 // Sanity checks for the Navigation Timing API |navigationStart| override. We
2241 // are asserting only most basic constraints, as TimeTicks (passed as the 2276 // are asserting only most basic constraints, as TimeTicks (passed as the
2242 // override) are not comparable with the wall time (returned by the Blink API). 2277 // override) are not comparable with the wall time (returned by the Blink API).
2243 TEST_F(RenderViewImplTest, NavigationStartOverride) { 2278 TEST_F(RenderViewImplTest, NavigationStartOverride) {
2244 // Verify that a navigation that claims to have started at the earliest 2279 // Verify that a navigation that claims to have started at the earliest
2245 // possible TimeTicks is indeed reported as one that started before 2280 // possible TimeTicks is indeed reported as one that started before
2246 // OnNavigate() is called. 2281 // OnNavigate() is called.
2247 base::Time before_navigation = base::Time::Now(); 2282 base::Time before_navigation = base::Time::Now();
2248 FrameMsg_Navigate_Params early_nav_params; 2283 CommonNavigationParams early_common_params;
2249 early_nav_params.common_params.url = GURL("data:text/html,<div>Page</div>"); 2284 CommitNavigationParams early_commit_params;
2250 early_nav_params.common_params.navigation_type = 2285 StartNavigationParams early_start_params;
2251 FrameMsg_Navigate_Type::NORMAL; 2286 early_common_params.url = GURL("data:text/html,<div>Page</div>");
2252 early_nav_params.common_params.transition = ui::PAGE_TRANSITION_TYPED; 2287 early_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2253 early_nav_params.history_params.page_id = -1; 2288 early_common_params.transition = ui::PAGE_TRANSITION_TYPED;
2254 early_nav_params.is_post = true; 2289 early_start_params.is_post = true;
2255 early_nav_params.commit_params.browser_navigation_start = 2290 early_commit_params.browser_navigation_start =
2256 base::TimeTicks::FromInternalValue(1); 2291 base::TimeTicks::FromInternalValue(1);
2257 2292
2258 frame()->OnNavigate(early_nav_params); 2293 frame()->OnNavigate(early_common_params, early_start_params,
2294 early_commit_params, HistoryNavigationParams());
2259 ProcessPendingMessages(); 2295 ProcessPendingMessages();
2260 2296
2261 base::Time early_nav_reported_start = 2297 base::Time early_nav_reported_start =
2262 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); 2298 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart());
2263 EXPECT_LT(early_nav_reported_start, before_navigation); 2299 EXPECT_LT(early_nav_reported_start, before_navigation);
2264 2300
2265 // Verify that a navigation that claims to have started in the future - 42 2301 // Verify that a navigation that claims to have started in the future - 42
2266 // days from now is *not* reported as one that starts in the future; as we 2302 // days from now is *not* reported as one that starts in the future; as we
2267 // sanitize the override allowing a maximum of ::Now(). 2303 // sanitize the override allowing a maximum of ::Now().
2268 FrameMsg_Navigate_Params late_nav_params; 2304 CommonNavigationParams late_common_params;
2269 late_nav_params.common_params.url = 2305 CommitNavigationParams late_commit_params;
2270 GURL("data:text/html,<div>Another page</div>"); 2306 StartNavigationParams late_start_params;
2271 late_nav_params.common_params.navigation_type = 2307 late_common_params.url = GURL("data:text/html,<div>Another page</div>");
2272 FrameMsg_Navigate_Type::NORMAL; 2308 late_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2273 late_nav_params.common_params.transition = ui::PAGE_TRANSITION_TYPED; 2309 late_common_params.transition = ui::PAGE_TRANSITION_TYPED;
2274 late_nav_params.history_params.page_id = -1; 2310 late_start_params.is_post = true;
2275 late_nav_params.is_post = true; 2311 late_commit_params.browser_navigation_start =
2276 late_nav_params.commit_params.browser_navigation_start =
2277 base::TimeTicks::Now() + base::TimeDelta::FromDays(42); 2312 base::TimeTicks::Now() + base::TimeDelta::FromDays(42);
2278 2313
2279 frame()->OnNavigate(late_nav_params); 2314 frame()->OnNavigate(late_common_params, late_start_params, late_commit_params,
2315 HistoryNavigationParams());
2280 ProcessPendingMessages(); 2316 ProcessPendingMessages();
2281 base::Time after_navigation = 2317 base::Time after_navigation =
2282 base::Time::Now() + base::TimeDelta::FromDays(1); 2318 base::Time::Now() + base::TimeDelta::FromDays(1);
2283 2319
2284 base::Time late_nav_reported_start = 2320 base::Time late_nav_reported_start =
2285 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); 2321 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart());
2286 EXPECT_LE(late_nav_reported_start, after_navigation); 2322 EXPECT_LE(late_nav_reported_start, after_navigation);
2287 } 2323 }
2288 2324
2289 TEST_F(RenderViewImplTest, PreferredSizeZoomed) { 2325 TEST_F(RenderViewImplTest, PreferredSizeZoomed) {
(...skipping 11 matching lines...) Expand all
2301 } 2337 }
2302 2338
2303 // Ensure the RenderViewImpl history list is properly updated when starting a 2339 // Ensure the RenderViewImpl history list is properly updated when starting a
2304 // new browser-initiated navigation. 2340 // new browser-initiated navigation.
2305 TEST_F(RenderViewImplTest, HistoryIsProperlyUpdatedOnNavigation) { 2341 TEST_F(RenderViewImplTest, HistoryIsProperlyUpdatedOnNavigation) {
2306 EXPECT_EQ(0, view()->historyBackListCount()); 2342 EXPECT_EQ(0, view()->historyBackListCount());
2307 EXPECT_EQ(0, view()->historyBackListCount() + 2343 EXPECT_EQ(0, view()->historyBackListCount() +
2308 view()->historyForwardListCount() + 1); 2344 view()->historyForwardListCount() + 1);
2309 2345
2310 // Receive a Navigate message with history parameters. 2346 // Receive a Navigate message with history parameters.
2311 FrameMsg_Navigate_Params params; 2347 CommitNavigationParams commit_params;
2312 params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 2348 HistoryNavigationParams history_params;
2313 params.common_params.transition = ui::PAGE_TRANSITION_LINK; 2349 history_params.current_history_list_length = 2;
2314 params.history_params.current_history_list_length = 2; 2350 history_params.current_history_list_offset = 1;
2315 params.history_params.current_history_list_offset = 1; 2351 history_params.pending_history_list_offset = 2;
2316 params.history_params.pending_history_list_offset = 2; 2352 history_params.page_id = -1;
2317 params.history_params.page_id = -1; 2353 commit_params.browser_navigation_start =
2318 params.commit_params.browser_navigation_start =
2319 base::TimeTicks::FromInternalValue(1); 2354 base::TimeTicks::FromInternalValue(1);
2320 frame()->OnNavigate(params); 2355 frame()->OnNavigate(CommonNavigationParams(), StartNavigationParams(),
2356 commit_params, history_params);
2321 2357
2322 // The history list in RenderView should have been updated. 2358 // The history list in RenderView should have been updated.
2323 EXPECT_EQ(1, view()->historyBackListCount()); 2359 EXPECT_EQ(1, view()->historyBackListCount());
2324 EXPECT_EQ(2, view()->historyBackListCount() + 2360 EXPECT_EQ(2, view()->historyBackListCount() +
2325 view()->historyForwardListCount() + 1); 2361 view()->historyForwardListCount() + 1);
2326 } 2362 }
2327 2363
2328 } // namespace content 2364 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698