| 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 HistoryNavigationParams history_params; |
| 366 nav_params.history_params.page_id = -1; | 364 common_params.url = GURL("data:text/html,<div>Page</div>"); |
| 367 nav_params.is_post = true; | 365 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 368 nav_params.commit_params.browser_navigation_start = | 366 common_params.transition = ui::PAGE_TRANSITION_TYPED; |
| 369 base::TimeTicks::FromInternalValue(1); | 367 history_params.page_id = -1; |
| 370 | 368 |
| 371 // Set up post data. | 369 // Set up post data. |
| 372 const unsigned char* raw_data = reinterpret_cast<const unsigned char*>( | 370 const unsigned char* raw_data = reinterpret_cast<const unsigned char*>( |
| 373 "post \0\ndata"); | 371 "post \0\ndata"); |
| 374 const unsigned int length = 11; | 372 const unsigned int length = 11; |
| 375 const std::vector<unsigned char> post_data(raw_data, raw_data + length); | 373 const std::vector<unsigned char> post_data(raw_data, raw_data + length); |
| 376 nav_params.browser_initiated_post_data = post_data; | 374 start_params.is_post = true; |
| 375 start_params.browser_initiated_post_data = post_data; |
| 377 | 376 |
| 378 frame()->OnNavigate(nav_params); | 377 frame()->OnNavigate(common_params, start_params, CommitNavigationParams(), |
| 378 history_params); |
| 379 ProcessPendingMessages(); | 379 ProcessPendingMessages(); |
| 380 | 380 |
| 381 const IPC::Message* frame_navigate_msg = | 381 const IPC::Message* frame_navigate_msg = |
| 382 render_thread_->sink().GetUniqueMessageMatching( | 382 render_thread_->sink().GetUniqueMessageMatching( |
| 383 FrameHostMsg_DidCommitProvisionalLoad::ID); | 383 FrameHostMsg_DidCommitProvisionalLoad::ID); |
| 384 EXPECT_TRUE(frame_navigate_msg); | 384 EXPECT_TRUE(frame_navigate_msg); |
| 385 | 385 |
| 386 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params; | 386 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params; |
| 387 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg, | 387 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg, |
| 388 &host_nav_params); | 388 &host_nav_params); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 // an ACK, even if we don't have to do anything else. | 560 // an ACK, even if we don't have to do anything else. |
| 561 render_thread_->sink().ClearMessages(); | 561 render_thread_->sink().ClearMessages(); |
| 562 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId, false, | 562 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId, false, |
| 563 content::FrameReplicationState()); | 563 content::FrameReplicationState()); |
| 564 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching( | 564 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching( |
| 565 FrameHostMsg_SwapOut_ACK::ID); | 565 FrameHostMsg_SwapOut_ACK::ID); |
| 566 ASSERT_TRUE(msg2); | 566 ASSERT_TRUE(msg2); |
| 567 | 567 |
| 568 // If we navigate back to this RenderView, ensure we don't send a state | 568 // 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) | 569 // update for the swapped out URL. (http://crbug.com/72235) |
| 570 FrameMsg_Navigate_Params nav_params; | 570 CommonNavigationParams common_params; |
| 571 nav_params.common_params.url = GURL("data:text/html,<div>Page B</div>"); | 571 HistoryNavigationParams history_params; |
| 572 nav_params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 572 common_params.url = GURL("data:text/html,<div>Page B</div>"); |
| 573 nav_params.common_params.transition = ui::PAGE_TRANSITION_TYPED; | 573 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 574 nav_params.history_params.current_history_list_length = 1; | 574 common_params.transition = ui::PAGE_TRANSITION_TYPED; |
| 575 nav_params.history_params.current_history_list_offset = 0; | 575 history_params.current_history_list_length = 1; |
| 576 nav_params.history_params.pending_history_list_offset = 1; | 576 history_params.current_history_list_offset = 0; |
| 577 nav_params.history_params.page_id = -1; | 577 history_params.pending_history_list_offset = 1; |
| 578 nav_params.commit_params.browser_navigation_start = | 578 history_params.page_id = -1; |
| 579 base::TimeTicks::FromInternalValue(1); | 579 frame()->OnNavigate(common_params, StartNavigationParams(), |
| 580 frame()->OnNavigate(nav_params); | 580 CommitNavigationParams(), history_params); |
| 581 ProcessPendingMessages(); | 581 ProcessPendingMessages(); |
| 582 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching( | 582 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching( |
| 583 ViewHostMsg_UpdateState::ID); | 583 ViewHostMsg_UpdateState::ID); |
| 584 EXPECT_FALSE(msg3); | 584 EXPECT_FALSE(msg3); |
| 585 } | 585 } |
| 586 | 586 |
| 587 // Ensure the RenderViewImpl reloads the previous page if a reload request | 587 // Ensure the RenderViewImpl reloads the previous page if a reload request |
| 588 // arrives while it is showing swappedout://. http://crbug.com/143155. | 588 // arrives while it is showing swappedout://. http://crbug.com/143155. |
| 589 TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) { | 589 TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) { |
| 590 // Load page A. | 590 // Load page A. |
| 591 LoadHTML("<div>Page A</div>"); | 591 LoadHTML("<div>Page A</div>"); |
| 592 | 592 |
| 593 // Load page B, which will trigger an UpdateState message for page A. | 593 // Load page B, which will trigger an UpdateState message for page A. |
| 594 LoadHTML("<div>Page B</div>"); | 594 LoadHTML("<div>Page B</div>"); |
| 595 | 595 |
| 596 // Check for a valid UpdateState message for page A. | 596 // Check for a valid UpdateState message for page A. |
| 597 ProcessPendingMessages(); | 597 ProcessPendingMessages(); |
| 598 const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching( | 598 const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching( |
| 599 ViewHostMsg_UpdateState::ID); | 599 ViewHostMsg_UpdateState::ID); |
| 600 ASSERT_TRUE(msg_A); | 600 ASSERT_TRUE(msg_A); |
| 601 ViewHostMsg_UpdateState::Param params; | 601 ViewHostMsg_UpdateState::Param params; |
| 602 ViewHostMsg_UpdateState::Read(msg_A, ¶ms); | 602 ViewHostMsg_UpdateState::Read(msg_A, ¶ms); |
| 603 int page_id_A = get<0>(params); | 603 int page_id_A = get<0>(params); |
| 604 PageState state_A = get<1>(params); | 604 PageState state_A = get<1>(params); |
| 605 EXPECT_EQ(1, page_id_A); | 605 EXPECT_EQ(1, page_id_A); |
| 606 render_thread_->sink().ClearMessages(); | 606 render_thread_->sink().ClearMessages(); |
| 607 | 607 |
| 608 // Back to page A (page_id 1) and commit. | 608 // Back to page A (page_id 1) and commit. |
| 609 FrameMsg_Navigate_Params params_A; | 609 CommonNavigationParams common_params_A; |
| 610 params_A.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 610 HistoryNavigationParams history_params_A; |
| 611 params_A.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 611 common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 612 params_A.history_params.current_history_list_length = 2; | 612 common_params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 613 params_A.history_params.current_history_list_offset = 1; | 613 history_params_A.current_history_list_length = 2; |
| 614 params_A.history_params.pending_history_list_offset = 0; | 614 history_params_A.current_history_list_offset = 1; |
| 615 params_A.history_params.page_id = 1; | 615 history_params_A.pending_history_list_offset = 0; |
| 616 params_A.history_params.page_state = state_A; | 616 history_params_A.page_id = 1; |
| 617 params_A.commit_params.browser_navigation_start = | 617 history_params_A.page_state = state_A; |
| 618 base::TimeTicks::FromInternalValue(1); | 618 frame()->OnNavigate(common_params_A, StartNavigationParams(), |
| 619 frame()->OnNavigate(params_A); | 619 CommitNavigationParams(), history_params_A); |
| 620 EXPECT_EQ(1, view()->historyBackListCount()); | 620 EXPECT_EQ(1, view()->historyBackListCount()); |
| 621 EXPECT_EQ(2, view()->historyBackListCount() + | 621 EXPECT_EQ(2, view()->historyBackListCount() + |
| 622 view()->historyForwardListCount() + 1); | 622 view()->historyForwardListCount() + 1); |
| 623 ProcessPendingMessages(); | 623 ProcessPendingMessages(); |
| 624 | 624 |
| 625 // Respond to a swap out request. | 625 // Respond to a swap out request. |
| 626 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId, true, | 626 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId, true, |
| 627 content::FrameReplicationState()); | 627 content::FrameReplicationState()); |
| 628 | 628 |
| 629 // Check for a OnSwapOutACK. | 629 // Check for a OnSwapOutACK. |
| 630 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | 630 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
| 631 FrameHostMsg_SwapOut_ACK::ID); | 631 FrameHostMsg_SwapOut_ACK::ID); |
| 632 ASSERT_TRUE(msg); | 632 ASSERT_TRUE(msg); |
| 633 render_thread_->sink().ClearMessages(); | 633 render_thread_->sink().ClearMessages(); |
| 634 | 634 |
| 635 // 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 |
| 636 // 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 |
| 637 // 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). |
| 638 // Ensure the old page gets reloaded, not swappedout://. | 638 // Ensure the old page gets reloaded, not swappedout://. |
| 639 FrameMsg_Navigate_Params nav_params; | 639 CommonNavigationParams common_params; |
| 640 nav_params.common_params.url = GURL("data:text/html,<div>Page A</div>"); | 640 HistoryNavigationParams history_params; |
| 641 nav_params.common_params.navigation_type = FrameMsg_Navigate_Type::RELOAD; | 641 common_params.url = GURL("data:text/html,<div>Page A</div>"); |
| 642 nav_params.common_params.transition = ui::PAGE_TRANSITION_RELOAD; | 642 common_params.navigation_type = FrameMsg_Navigate_Type::RELOAD; |
| 643 nav_params.history_params.current_history_list_length = 2; | 643 common_params.transition = ui::PAGE_TRANSITION_RELOAD; |
| 644 nav_params.history_params.current_history_list_offset = 0; | 644 history_params.current_history_list_length = 2; |
| 645 nav_params.history_params.pending_history_list_offset = 0; | 645 history_params.current_history_list_offset = 0; |
| 646 nav_params.history_params.page_id = 1; | 646 history_params.pending_history_list_offset = 0; |
| 647 nav_params.history_params.page_state = state_A; | 647 history_params.page_id = 1; |
| 648 nav_params.commit_params.browser_navigation_start = | 648 history_params.page_state = state_A; |
| 649 base::TimeTicks::FromInternalValue(1); | 649 frame()->OnNavigate(common_params, StartNavigationParams(), |
| 650 frame()->OnNavigate(nav_params); | 650 CommitNavigationParams(), history_params); |
| 651 ProcessPendingMessages(); | 651 ProcessPendingMessages(); |
| 652 | 652 |
| 653 // Verify page A committed, not swappedout://. | 653 // Verify page A committed, not swappedout://. |
| 654 const IPC::Message* frame_navigate_msg = | 654 const IPC::Message* frame_navigate_msg = |
| 655 render_thread_->sink().GetUniqueMessageMatching( | 655 render_thread_->sink().GetUniqueMessageMatching( |
| 656 FrameHostMsg_DidCommitProvisionalLoad::ID); | 656 FrameHostMsg_DidCommitProvisionalLoad::ID); |
| 657 EXPECT_TRUE(frame_navigate_msg); | 657 EXPECT_TRUE(frame_navigate_msg); |
| 658 | 658 |
| 659 // Read URL out of the parent trait of the params object. | 659 // Read URL out of the parent trait of the params object. |
| 660 FrameHostMsg_DidCommitProvisionalLoad::Param commit_params; | 660 FrameHostMsg_DidCommitProvisionalLoad::Param commit_load_params; |
| 661 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg, | 661 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg, |
| 662 &commit_params); | 662 &commit_load_params); |
| 663 EXPECT_NE(GURL("swappedout://"), get<0>(commit_params).url); | 663 EXPECT_NE(GURL("swappedout://"), get<0>(commit_load_params).url); |
| 664 } | 664 } |
| 665 | 665 |
| 666 // Verify that security origins are replicated properly to RenderFrameProxies | 666 // Verify that security origins are replicated properly to RenderFrameProxies |
| 667 // when swapping out. | 667 // when swapping out. |
| 668 TEST_F(RenderViewImplTest, OriginReplicationForSwapOut) { | 668 TEST_F(RenderViewImplTest, OriginReplicationForSwapOut) { |
| 669 // This test should only run with --site-per-process, since origin | 669 // This test should only run with --site-per-process, since origin |
| 670 // replication only happens in that mode. | 670 // replication only happens in that mode. |
| 671 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 671 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 672 switches::kSitePerProcess)) | 672 switches::kSitePerProcess)) |
| 673 return; | 673 return; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 ViewHostMsg_UpdateState::ID); | 749 ViewHostMsg_UpdateState::ID); |
| 750 ASSERT_TRUE(msg_C); | 750 ASSERT_TRUE(msg_C); |
| 751 ViewHostMsg_UpdateState::Read(msg_C, ¶m); | 751 ViewHostMsg_UpdateState::Read(msg_C, ¶m); |
| 752 int page_id_C = get<0>(param); | 752 int page_id_C = get<0>(param); |
| 753 PageState state_C = get<1>(param); | 753 PageState state_C = get<1>(param); |
| 754 EXPECT_EQ(3, page_id_C); | 754 EXPECT_EQ(3, page_id_C); |
| 755 EXPECT_NE(state_B, state_C); | 755 EXPECT_NE(state_B, state_C); |
| 756 render_thread_->sink().ClearMessages(); | 756 render_thread_->sink().ClearMessages(); |
| 757 | 757 |
| 758 // Go back to C and commit, preparing for our real test. | 758 // Go back to C and commit, preparing for our real test. |
| 759 FrameMsg_Navigate_Params params_C; | 759 CommonNavigationParams common_params_C; |
| 760 params_C.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 760 HistoryNavigationParams history_params_C; |
| 761 params_C.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 761 common_params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 762 params_C.history_params.current_history_list_length = 4; | 762 common_params_C.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 763 params_C.history_params.current_history_list_offset = 3; | 763 history_params_C.current_history_list_length = 4; |
| 764 params_C.history_params.pending_history_list_offset = 2; | 764 history_params_C.current_history_list_offset = 3; |
| 765 params_C.history_params.page_id = 3; | 765 history_params_C.pending_history_list_offset = 2; |
| 766 params_C.history_params.page_state = state_C; | 766 history_params_C.page_id = 3; |
| 767 params_C.commit_params.browser_navigation_start = | 767 history_params_C.page_state = state_C; |
| 768 base::TimeTicks::FromInternalValue(1); | 768 frame()->OnNavigate(common_params_C, StartNavigationParams(), |
| 769 frame()->OnNavigate(params_C); | 769 CommitNavigationParams(), history_params_C); |
| 770 ProcessPendingMessages(); | 770 ProcessPendingMessages(); |
| 771 render_thread_->sink().ClearMessages(); | 771 render_thread_->sink().ClearMessages(); |
| 772 | 772 |
| 773 // Go back twice quickly, such that page B does not have a chance to commit. | 773 // 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 | 774 // This leads to two changes to the back/forward list but only one change to |
| 775 // the RenderView's page ID. | 775 // the RenderView's page ID. |
| 776 | 776 |
| 777 // Back to page B (page_id 2), without committing. | 777 // Back to page B (page_id 2), without committing. |
| 778 FrameMsg_Navigate_Params params_B; | 778 CommonNavigationParams common_params_B; |
| 779 params_B.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 779 HistoryNavigationParams history_params_B; |
| 780 params_B.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 780 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 781 params_B.history_params.current_history_list_length = 4; | 781 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 782 params_B.history_params.current_history_list_offset = 2; | 782 history_params_B.current_history_list_length = 4; |
| 783 params_B.history_params.pending_history_list_offset = 1; | 783 history_params_B.current_history_list_offset = 2; |
| 784 params_B.history_params.page_id = 2; | 784 history_params_B.pending_history_list_offset = 1; |
| 785 params_B.history_params.page_state = state_B; | 785 history_params_B.page_id = 2; |
| 786 params_B.commit_params.browser_navigation_start = | 786 history_params_B.page_state = state_B; |
| 787 base::TimeTicks::FromInternalValue(1); | 787 frame()->OnNavigate(common_params_B, StartNavigationParams(), |
| 788 frame()->OnNavigate(params_B); | 788 CommitNavigationParams(), history_params_B); |
| 789 | 789 |
| 790 // Back to page A (page_id 1) and commit. | 790 // Back to page A (page_id 1) and commit. |
| 791 FrameMsg_Navigate_Params params; | 791 CommonNavigationParams common_params; |
| 792 params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 792 HistoryNavigationParams history_params; |
| 793 params.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 793 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 794 params.history_params.current_history_list_length = 4; | 794 common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 795 params.history_params.current_history_list_offset = 2; | 795 history_params.current_history_list_length = 4; |
| 796 params.history_params.pending_history_list_offset = 0; | 796 history_params.current_history_list_offset = 2; |
| 797 params.history_params.page_id = 1; | 797 history_params.pending_history_list_offset = 0; |
| 798 params.history_params.page_state = state_A; | 798 history_params.page_id = 1; |
| 799 params.commit_params.browser_navigation_start = | 799 history_params.page_state = state_A; |
| 800 base::TimeTicks::FromInternalValue(1); | 800 frame()->OnNavigate(common_params, StartNavigationParams(), |
| 801 frame()->OnNavigate(params); | 801 CommitNavigationParams(), history_params); |
| 802 ProcessPendingMessages(); | 802 ProcessPendingMessages(); |
| 803 | 803 |
| 804 // Now ensure that the UpdateState message we receive is consistent | 804 // Now ensure that the UpdateState message we receive is consistent |
| 805 // and represents page C in both page_id and state. | 805 // and represents page C in both page_id and state. |
| 806 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | 806 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
| 807 ViewHostMsg_UpdateState::ID); | 807 ViewHostMsg_UpdateState::ID); |
| 808 ASSERT_TRUE(msg); | 808 ASSERT_TRUE(msg); |
| 809 ViewHostMsg_UpdateState::Read(msg, ¶m); | 809 ViewHostMsg_UpdateState::Read(msg, ¶m); |
| 810 int page_id = get<0>(param); | 810 int page_id = get<0>(param); |
| 811 PageState state = get<1>(param); | 811 PageState state = get<1>(param); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 834 ViewHostMsg_UpdateState::ID); | 834 ViewHostMsg_UpdateState::ID); |
| 835 ASSERT_TRUE(msg_A); | 835 ASSERT_TRUE(msg_A); |
| 836 ViewHostMsg_UpdateState::Param param; | 836 ViewHostMsg_UpdateState::Param param; |
| 837 ViewHostMsg_UpdateState::Read(msg_A, ¶m); | 837 ViewHostMsg_UpdateState::Read(msg_A, ¶m); |
| 838 int page_id_A = get<0>(param); | 838 int page_id_A = get<0>(param); |
| 839 PageState state_A = get<1>(param); | 839 PageState state_A = get<1>(param); |
| 840 EXPECT_EQ(1, page_id_A); | 840 EXPECT_EQ(1, page_id_A); |
| 841 render_thread_->sink().ClearMessages(); | 841 render_thread_->sink().ClearMessages(); |
| 842 | 842 |
| 843 // Back to page A (page_id 1) and commit. | 843 // Back to page A (page_id 1) and commit. |
| 844 FrameMsg_Navigate_Params params_A; | 844 CommonNavigationParams common_params_A; |
| 845 params_A.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 845 HistoryNavigationParams history_params_A; |
| 846 params_A.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 846 common_params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 847 params_A.history_params.current_history_list_length = 2; | 847 common_params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 848 params_A.history_params.current_history_list_offset = 1; | 848 history_params_A.current_history_list_length = 2; |
| 849 params_A.history_params.pending_history_list_offset = 0; | 849 history_params_A.current_history_list_offset = 1; |
| 850 params_A.history_params.page_id = 1; | 850 history_params_A.pending_history_list_offset = 0; |
| 851 params_A.history_params.page_state = state_A; | 851 history_params_A.page_id = 1; |
| 852 params_A.commit_params.browser_navigation_start = | 852 history_params_A.page_state = state_A; |
| 853 base::TimeTicks::FromInternalValue(1); | 853 frame()->OnNavigate(common_params_A, StartNavigationParams(), |
| 854 frame()->OnNavigate(params_A); | 854 CommitNavigationParams(), history_params_A); |
| 855 ProcessPendingMessages(); | 855 ProcessPendingMessages(); |
| 856 | 856 |
| 857 // A new navigation commits, clearing the forward history. | 857 // A new navigation commits, clearing the forward history. |
| 858 LoadHTML("<div>Page C</div>"); | 858 LoadHTML("<div>Page C</div>"); |
| 859 EXPECT_EQ(2, view()->history_list_length_); | 859 EXPECT_EQ(2, view()->history_list_length_); |
| 860 EXPECT_EQ(1, view()->history_list_offset_); | 860 EXPECT_EQ(1, view()->history_list_offset_); |
| 861 EXPECT_EQ(3, view()->page_id_); // page C is now page id 3 | 861 EXPECT_EQ(3, view()->page_id_); // page C is now page id 3 |
| 862 | 862 |
| 863 // The browser then sends a stale navigation to B, which should be ignored. | 863 // The browser then sends a stale navigation to B, which should be ignored. |
| 864 FrameMsg_Navigate_Params params_B; | 864 CommonNavigationParams common_params_B; |
| 865 params_B.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 865 HistoryNavigationParams history_params_B; |
| 866 params_B.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 866 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 867 params_B.history_params.current_history_list_length = 2; | 867 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 868 params_B.history_params.current_history_list_offset = 0; | 868 history_params_B.current_history_list_length = 2; |
| 869 params_B.history_params.pending_history_list_offset = 1; | 869 history_params_B.current_history_list_offset = 0; |
| 870 params_B.history_params.page_id = 2; | 870 history_params_B.pending_history_list_offset = 1; |
| 871 params_B.history_params.page_state = | 871 history_params_B.page_id = 2; |
| 872 history_params_B.page_state = |
| 872 state_A; // Doesn't matter, just has to be present. | 873 state_A; // Doesn't matter, just has to be present. |
| 873 params_B.commit_params.browser_navigation_start = | 874 frame()->OnNavigate(common_params_B, StartNavigationParams(), |
| 874 base::TimeTicks::FromInternalValue(1); | 875 CommitNavigationParams(), history_params_B); |
| 875 frame()->OnNavigate(params_B); | |
| 876 | 876 |
| 877 // State should be unchanged. | 877 // State should be unchanged. |
| 878 EXPECT_EQ(2, view()->history_list_length_); | 878 EXPECT_EQ(2, view()->history_list_length_); |
| 879 EXPECT_EQ(1, view()->history_list_offset_); | 879 EXPECT_EQ(1, view()->history_list_offset_); |
| 880 EXPECT_EQ(3, view()->page_id_); // page C, not page B | 880 EXPECT_EQ(3, view()->page_id_); // page C, not page B |
| 881 | 881 |
| 882 // Check for a valid DidDropNavigation message. | 882 // Check for a valid DidDropNavigation message. |
| 883 ProcessPendingMessages(); | 883 ProcessPendingMessages(); |
| 884 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | 884 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
| 885 FrameHostMsg_DidDropNavigation::ID); | 885 FrameHostMsg_DidDropNavigation::ID); |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1577 TEST_F(RenderViewImplTest, DISABLED_DidFailProvisionalLoadWithErrorForError) { | 1577 TEST_F(RenderViewImplTest, DISABLED_DidFailProvisionalLoadWithErrorForError) { |
| 1578 GetMainFrame()->enableViewSourceMode(true); | 1578 GetMainFrame()->enableViewSourceMode(true); |
| 1579 WebURLError error; | 1579 WebURLError error; |
| 1580 error.domain = WebString::fromUTF8(net::kErrorDomain); | 1580 error.domain = WebString::fromUTF8(net::kErrorDomain); |
| 1581 error.reason = net::ERR_FILE_NOT_FOUND; | 1581 error.reason = net::ERR_FILE_NOT_FOUND; |
| 1582 error.unreachableURL = GURL("http://foo"); | 1582 error.unreachableURL = GURL("http://foo"); |
| 1583 WebLocalFrame* web_frame = GetMainFrame(); | 1583 WebLocalFrame* web_frame = GetMainFrame(); |
| 1584 | 1584 |
| 1585 // Start a load that will reach provisional state synchronously, | 1585 // Start a load that will reach provisional state synchronously, |
| 1586 // but won't complete synchronously. | 1586 // but won't complete synchronously. |
| 1587 FrameMsg_Navigate_Params params; | 1587 CommonNavigationParams common_params; |
| 1588 params.history_params.page_id = -1; | 1588 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 1589 params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1589 common_params.url = GURL("data:text/html,test data"); |
| 1590 params.common_params.url = GURL("data:text/html,test data"); | 1590 frame()->OnNavigate(common_params, StartNavigationParams(), |
| 1591 params.commit_params.browser_navigation_start = | 1591 CommitNavigationParams(), HistoryNavigationParams()); |
| 1592 base::TimeTicks::FromInternalValue(1); | |
| 1593 frame()->OnNavigate(params); | |
| 1594 | 1592 |
| 1595 // An error occurred. | 1593 // An error occurred. |
| 1596 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); | 1594 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); |
| 1597 // Frame should exit view-source mode. | 1595 // Frame should exit view-source mode. |
| 1598 EXPECT_FALSE(web_frame->isViewSourceModeEnabled()); | 1596 EXPECT_FALSE(web_frame->isViewSourceModeEnabled()); |
| 1599 } | 1597 } |
| 1600 | 1598 |
| 1601 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) { | 1599 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) { |
| 1602 GetMainFrame()->enableViewSourceMode(true); | 1600 GetMainFrame()->enableViewSourceMode(true); |
| 1603 WebURLError error; | 1601 WebURLError error; |
| 1604 error.domain = WebString::fromUTF8(net::kErrorDomain); | 1602 error.domain = WebString::fromUTF8(net::kErrorDomain); |
| 1605 error.reason = net::ERR_ABORTED; | 1603 error.reason = net::ERR_ABORTED; |
| 1606 error.unreachableURL = GURL("http://foo"); | 1604 error.unreachableURL = GURL("http://foo"); |
| 1607 WebLocalFrame* web_frame = GetMainFrame(); | 1605 WebLocalFrame* web_frame = GetMainFrame(); |
| 1608 | 1606 |
| 1609 // Start a load that will reach provisional state synchronously, | 1607 // Start a load that will reach provisional state synchronously, |
| 1610 // but won't complete synchronously. | 1608 // but won't complete synchronously. |
| 1611 FrameMsg_Navigate_Params params; | 1609 CommonNavigationParams common_params; |
| 1612 params.history_params.page_id = -1; | 1610 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 1613 params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1611 common_params.url = GURL("data:text/html,test data"); |
| 1614 params.common_params.url = GURL("data:text/html,test data"); | 1612 frame()->OnNavigate(common_params, StartNavigationParams(), |
| 1615 params.commit_params.browser_navigation_start = | 1613 CommitNavigationParams(), HistoryNavigationParams()); |
| 1616 base::TimeTicks::FromInternalValue(1); | |
| 1617 frame()->OnNavigate(params); | |
| 1618 | 1614 |
| 1619 // A cancellation occurred. | 1615 // A cancellation occurred. |
| 1620 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); | 1616 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); |
| 1621 // Frame should stay in view-source mode. | 1617 // Frame should stay in view-source mode. |
| 1622 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); | 1618 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); |
| 1623 } | 1619 } |
| 1624 | 1620 |
| 1625 // Regression test for http://crbug.com/41562 | 1621 // Regression test for http://crbug.com/41562 |
| 1626 TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) { | 1622 TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) { |
| 1627 const GURL invalid_gurl("http://"); | 1623 const GURL invalid_gurl("http://"); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1797 } | 1793 } |
| 1798 view()->OnImeConfirmComposition( | 1794 view()->OnImeConfirmComposition( |
| 1799 empty_string, gfx::Range::InvalidRange(), false); | 1795 empty_string, gfx::Range::InvalidRange(), false); |
| 1800 } | 1796 } |
| 1801 #endif | 1797 #endif |
| 1802 | 1798 |
| 1803 TEST_F(RenderViewImplTest, ZoomLimit) { | 1799 TEST_F(RenderViewImplTest, ZoomLimit) { |
| 1804 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor); | 1800 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor); |
| 1805 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor); | 1801 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor); |
| 1806 | 1802 |
| 1807 FrameMsg_Navigate_Params params; | |
| 1808 params.history_params.page_id = -1; | |
| 1809 params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | |
| 1810 params.commit_params.browser_navigation_start = | |
| 1811 base::TimeTicks::FromInternalValue(1); | |
| 1812 | |
| 1813 // Verifies navigation to a URL with preset zoom level indeed sets the level. | 1803 // 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 | 1804 // 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. | 1805 // 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"); | 1806 CommonNavigationParams common_params; |
| 1817 view()->OnSetZoomLevelForLoadingURL(params.common_params.url, kMinZoomLevel); | 1807 common_params.url = GURL("data:text/html,min_zoomlimit_test"); |
| 1818 frame()->OnNavigate(params); | 1808 view()->OnSetZoomLevelForLoadingURL(common_params.url, kMinZoomLevel); |
| 1809 frame()->OnNavigate(common_params, StartNavigationParams(), |
| 1810 CommitNavigationParams(), HistoryNavigationParams()); |
| 1819 ProcessPendingMessages(); | 1811 ProcessPendingMessages(); |
| 1820 EXPECT_DOUBLE_EQ(kMinZoomLevel, view()->GetWebView()->zoomLevel()); | 1812 EXPECT_DOUBLE_EQ(kMinZoomLevel, view()->GetWebView()->zoomLevel()); |
| 1821 | 1813 |
| 1822 // It should work even when the zoom limit is temporarily changed in the page. | 1814 // It should work even when the zoom limit is temporarily changed in the page. |
| 1823 view()->GetWebView()->zoomLimitsChanged(ZoomFactorToZoomLevel(1.0), | 1815 view()->GetWebView()->zoomLimitsChanged(ZoomFactorToZoomLevel(1.0), |
| 1824 ZoomFactorToZoomLevel(1.0)); | 1816 ZoomFactorToZoomLevel(1.0)); |
| 1825 params.common_params.url = GURL("data:text/html,max_zoomlimit_test"); | 1817 common_params.url = GURL("data:text/html,max_zoomlimit_test"); |
| 1826 view()->OnSetZoomLevelForLoadingURL(params.common_params.url, kMaxZoomLevel); | 1818 view()->OnSetZoomLevelForLoadingURL(common_params.url, kMaxZoomLevel); |
| 1827 frame()->OnNavigate(params); | 1819 frame()->OnNavigate(common_params, StartNavigationParams(), |
| 1820 CommitNavigationParams(), HistoryNavigationParams()); |
| 1828 ProcessPendingMessages(); | 1821 ProcessPendingMessages(); |
| 1829 EXPECT_DOUBLE_EQ(kMaxZoomLevel, view()->GetWebView()->zoomLevel()); | 1822 EXPECT_DOUBLE_EQ(kMaxZoomLevel, view()->GetWebView()->zoomLevel()); |
| 1830 } | 1823 } |
| 1831 | 1824 |
| 1832 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) { | 1825 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) { |
| 1833 // Load an HTML page consisting of an input field. | 1826 // Load an HTML page consisting of an input field. |
| 1834 LoadHTML("<html>" | 1827 LoadHTML("<html>" |
| 1835 "<head>" | 1828 "<head>" |
| 1836 "</head>" | 1829 "</head>" |
| 1837 "<body>" | 1830 "<body>" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1877 EXPECT_EQ(2, info.selectionStart); | 1870 EXPECT_EQ(2, info.selectionStart); |
| 1878 EXPECT_EQ(2, info.selectionEnd); | 1871 EXPECT_EQ(2, info.selectionEnd); |
| 1879 } | 1872 } |
| 1880 | 1873 |
| 1881 // Test that the navigating specific frames works correctly. | 1874 // Test that the navigating specific frames works correctly. |
| 1882 TEST_F(RenderViewImplTest, NavigateFrame) { | 1875 TEST_F(RenderViewImplTest, NavigateFrame) { |
| 1883 // Load page A. | 1876 // Load page A. |
| 1884 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); | 1877 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); |
| 1885 | 1878 |
| 1886 // Navigate the frame only. | 1879 // Navigate the frame only. |
| 1887 FrameMsg_Navigate_Params nav_params; | 1880 CommonNavigationParams common_params; |
| 1888 nav_params.common_params.url = GURL("data:text/html,world"); | 1881 CommitNavigationParams commit_params; |
| 1889 nav_params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1882 HistoryNavigationParams history_params; |
| 1890 nav_params.common_params.transition = ui::PAGE_TRANSITION_TYPED; | 1883 common_params.url = GURL("data:text/html,world"); |
| 1891 nav_params.history_params.current_history_list_length = 1; | 1884 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 1892 nav_params.history_params.current_history_list_offset = 0; | 1885 common_params.transition = ui::PAGE_TRANSITION_TYPED; |
| 1893 nav_params.history_params.pending_history_list_offset = 1; | 1886 history_params.current_history_list_length = 1; |
| 1894 nav_params.history_params.page_id = -1; | 1887 history_params.current_history_list_offset = 0; |
| 1895 nav_params.frame_to_navigate = "frame"; | 1888 history_params.pending_history_list_offset = 1; |
| 1896 nav_params.commit_params.browser_navigation_start = | 1889 history_params.page_id = -1; |
| 1890 commit_params.frame_to_navigate = "frame"; |
| 1891 commit_params.browser_navigation_start = |
| 1897 base::TimeTicks::FromInternalValue(1); | 1892 base::TimeTicks::FromInternalValue(1); |
| 1898 frame()->OnNavigate(nav_params); | 1893 frame()->OnNavigate(common_params, StartNavigationParams(), commit_params, |
| 1894 history_params); |
| 1899 FrameLoadWaiter( | 1895 FrameLoadWaiter( |
| 1900 RenderFrame::FromWebFrame(frame()->GetWebFrame()->firstChild())).Wait(); | 1896 RenderFrame::FromWebFrame(frame()->GetWebFrame()->firstChild())).Wait(); |
| 1901 | 1897 |
| 1902 // Copy the document content to std::wstring and compare with the | 1898 // Copy the document content to std::wstring and compare with the |
| 1903 // expected result. | 1899 // expected result. |
| 1904 const int kMaxOutputCharacters = 256; | 1900 const int kMaxOutputCharacters = 256; |
| 1905 std::string output = base::UTF16ToUTF8( | 1901 std::string output = base::UTF16ToUTF8( |
| 1906 GetMainFrame()->contentAsText(kMaxOutputCharacters)); | 1902 GetMainFrame()->contentAsText(kMaxOutputCharacters)); |
| 1907 EXPECT_EQ(output, "hello \n\nworld"); | 1903 EXPECT_EQ(output, "hello \n\nworld"); |
| 1908 } | 1904 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2002 | 1998 |
| 2003 TEST_F(SuppressErrorPageTest, MAYBE_Suppresses) { | 1999 TEST_F(SuppressErrorPageTest, MAYBE_Suppresses) { |
| 2004 WebURLError error; | 2000 WebURLError error; |
| 2005 error.domain = WebString::fromUTF8(net::kErrorDomain); | 2001 error.domain = WebString::fromUTF8(net::kErrorDomain); |
| 2006 error.reason = net::ERR_FILE_NOT_FOUND; | 2002 error.reason = net::ERR_FILE_NOT_FOUND; |
| 2007 error.unreachableURL = GURL("http://example.com/suppress"); | 2003 error.unreachableURL = GURL("http://example.com/suppress"); |
| 2008 WebLocalFrame* web_frame = GetMainFrame(); | 2004 WebLocalFrame* web_frame = GetMainFrame(); |
| 2009 | 2005 |
| 2010 // Start a load that will reach provisional state synchronously, | 2006 // Start a load that will reach provisional state synchronously, |
| 2011 // but won't complete synchronously. | 2007 // but won't complete synchronously. |
| 2012 FrameMsg_Navigate_Params params; | 2008 CommonNavigationParams common_params; |
| 2013 params.history_params.page_id = -1; | 2009 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2014 params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2010 common_params.url = GURL("data:text/html,test data"); |
| 2015 params.common_params.url = GURL("data:text/html,test data"); | 2011 frame()->OnNavigate(common_params, StartNavigationParams(), |
| 2016 params.commit_params.browser_navigation_start = | 2012 CommitNavigationParams(), HistoryNavigationParams()); |
| 2017 base::TimeTicks::FromInternalValue(1); | |
| 2018 frame()->OnNavigate(params); | |
| 2019 | 2013 |
| 2020 // An error occurred. | 2014 // An error occurred. |
| 2021 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); | 2015 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); |
| 2022 const int kMaxOutputCharacters = 22; | 2016 const int kMaxOutputCharacters = 22; |
| 2023 EXPECT_EQ("", | 2017 EXPECT_EQ("", |
| 2024 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); | 2018 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); |
| 2025 } | 2019 } |
| 2026 | 2020 |
| 2027 #if defined(OS_ANDROID) | 2021 #if defined(OS_ANDROID) |
| 2028 // Crashing on Android: http://crbug.com/311341 | 2022 // Crashing on Android: http://crbug.com/311341 |
| 2029 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress | 2023 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress |
| 2030 #else | 2024 #else |
| 2031 #define MAYBE_DoesNotSuppress DoesNotSuppress | 2025 #define MAYBE_DoesNotSuppress DoesNotSuppress |
| 2032 #endif | 2026 #endif |
| 2033 | 2027 |
| 2034 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) { | 2028 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) { |
| 2035 WebURLError error; | 2029 WebURLError error; |
| 2036 error.domain = WebString::fromUTF8(net::kErrorDomain); | 2030 error.domain = WebString::fromUTF8(net::kErrorDomain); |
| 2037 error.reason = net::ERR_FILE_NOT_FOUND; | 2031 error.reason = net::ERR_FILE_NOT_FOUND; |
| 2038 error.unreachableURL = GURL("http://example.com/dont-suppress"); | 2032 error.unreachableURL = GURL("http://example.com/dont-suppress"); |
| 2039 WebLocalFrame* web_frame = GetMainFrame(); | 2033 WebLocalFrame* web_frame = GetMainFrame(); |
| 2040 | 2034 |
| 2041 // Start a load that will reach provisional state synchronously, | 2035 // Start a load that will reach provisional state synchronously, |
| 2042 // but won't complete synchronously. | 2036 // but won't complete synchronously. |
| 2043 FrameMsg_Navigate_Params params; | 2037 CommonNavigationParams common_params; |
| 2044 params.history_params.page_id = -1; | 2038 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2045 params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2039 common_params.url = GURL("data:text/html,test data"); |
| 2046 params.common_params.url = GURL("data:text/html,test data"); | 2040 frame()->OnNavigate(common_params, StartNavigationParams(), |
| 2047 params.commit_params.browser_navigation_start = | 2041 CommitNavigationParams(), HistoryNavigationParams()); |
| 2048 base::TimeTicks::FromInternalValue(1); | |
| 2049 frame()->OnNavigate(params); | |
| 2050 | 2042 |
| 2051 // An error occurred. | 2043 // An error occurred. |
| 2052 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); | 2044 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); |
| 2053 // The error page itself is loaded asynchronously. | 2045 // The error page itself is loaded asynchronously. |
| 2054 FrameLoadWaiter(frame()).Wait(); | 2046 FrameLoadWaiter(frame()).Wait(); |
| 2055 const int kMaxOutputCharacters = 22; | 2047 const int kMaxOutputCharacters = 22; |
| 2056 EXPECT_EQ("A suffusion of yellow.", | 2048 EXPECT_EQ("A suffusion of yellow.", |
| 2057 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); | 2049 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); |
| 2058 } | 2050 } |
| 2059 | 2051 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2238 } | 2230 } |
| 2239 | 2231 |
| 2240 // Sanity checks for the Navigation Timing API |navigationStart| override. We | 2232 // Sanity checks for the Navigation Timing API |navigationStart| override. We |
| 2241 // are asserting only most basic constraints, as TimeTicks (passed as the | 2233 // 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). | 2234 // override) are not comparable with the wall time (returned by the Blink API). |
| 2243 TEST_F(RenderViewImplTest, NavigationStartOverride) { | 2235 TEST_F(RenderViewImplTest, NavigationStartOverride) { |
| 2244 // Verify that a navigation that claims to have started at the earliest | 2236 // Verify that a navigation that claims to have started at the earliest |
| 2245 // possible TimeTicks is indeed reported as one that started before | 2237 // possible TimeTicks is indeed reported as one that started before |
| 2246 // OnNavigate() is called. | 2238 // OnNavigate() is called. |
| 2247 base::Time before_navigation = base::Time::Now(); | 2239 base::Time before_navigation = base::Time::Now(); |
| 2248 FrameMsg_Navigate_Params early_nav_params; | 2240 CommonNavigationParams early_common_params; |
| 2249 early_nav_params.common_params.url = GURL("data:text/html,<div>Page</div>"); | 2241 StartNavigationParams early_start_params; |
| 2250 early_nav_params.common_params.navigation_type = | 2242 CommitNavigationParams early_commit_params; |
| 2251 FrameMsg_Navigate_Type::NORMAL; | 2243 early_common_params.url = GURL("data:text/html,<div>Page</div>"); |
| 2252 early_nav_params.common_params.transition = ui::PAGE_TRANSITION_TYPED; | 2244 early_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2253 early_nav_params.history_params.page_id = -1; | 2245 early_common_params.transition = ui::PAGE_TRANSITION_TYPED; |
| 2254 early_nav_params.is_post = true; | 2246 early_start_params.is_post = true; |
| 2255 early_nav_params.commit_params.browser_navigation_start = | 2247 early_commit_params.browser_navigation_start = |
| 2256 base::TimeTicks::FromInternalValue(1); | 2248 base::TimeTicks::FromInternalValue(1); |
| 2257 | 2249 |
| 2258 frame()->OnNavigate(early_nav_params); | 2250 frame()->OnNavigate(early_common_params, early_start_params, |
| 2251 early_commit_params, HistoryNavigationParams()); |
| 2259 ProcessPendingMessages(); | 2252 ProcessPendingMessages(); |
| 2260 | 2253 |
| 2261 base::Time early_nav_reported_start = | 2254 base::Time early_nav_reported_start = |
| 2262 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); | 2255 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); |
| 2263 EXPECT_LT(early_nav_reported_start, before_navigation); | 2256 EXPECT_LT(early_nav_reported_start, before_navigation); |
| 2264 | 2257 |
| 2265 // Verify that a navigation that claims to have started in the future - 42 | 2258 // 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 | 2259 // days from now is *not* reported as one that starts in the future; as we |
| 2267 // sanitize the override allowing a maximum of ::Now(). | 2260 // sanitize the override allowing a maximum of ::Now(). |
| 2268 FrameMsg_Navigate_Params late_nav_params; | 2261 CommonNavigationParams late_common_params; |
| 2269 late_nav_params.common_params.url = | 2262 CommitNavigationParams late_commit_params; |
| 2270 GURL("data:text/html,<div>Another page</div>"); | 2263 StartNavigationParams late_start_params; |
| 2271 late_nav_params.common_params.navigation_type = | 2264 late_common_params.url = GURL("data:text/html,<div>Another page</div>"); |
| 2272 FrameMsg_Navigate_Type::NORMAL; | 2265 late_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2273 late_nav_params.common_params.transition = ui::PAGE_TRANSITION_TYPED; | 2266 late_common_params.transition = ui::PAGE_TRANSITION_TYPED; |
| 2274 late_nav_params.history_params.page_id = -1; | 2267 late_start_params.is_post = true; |
| 2275 late_nav_params.is_post = true; | 2268 late_commit_params.browser_navigation_start = |
| 2276 late_nav_params.commit_params.browser_navigation_start = | |
| 2277 base::TimeTicks::Now() + base::TimeDelta::FromDays(42); | 2269 base::TimeTicks::Now() + base::TimeDelta::FromDays(42); |
| 2278 | 2270 |
| 2279 frame()->OnNavigate(late_nav_params); | 2271 frame()->OnNavigate(late_common_params, late_start_params, late_commit_params, |
| 2272 HistoryNavigationParams()); |
| 2280 ProcessPendingMessages(); | 2273 ProcessPendingMessages(); |
| 2281 base::Time after_navigation = | 2274 base::Time after_navigation = |
| 2282 base::Time::Now() + base::TimeDelta::FromDays(1); | 2275 base::Time::Now() + base::TimeDelta::FromDays(1); |
| 2283 | 2276 |
| 2284 base::Time late_nav_reported_start = | 2277 base::Time late_nav_reported_start = |
| 2285 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); | 2278 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); |
| 2286 EXPECT_LE(late_nav_reported_start, after_navigation); | 2279 EXPECT_LE(late_nav_reported_start, after_navigation); |
| 2287 } | 2280 } |
| 2288 | 2281 |
| 2289 TEST_F(RenderViewImplTest, PreferredSizeZoomed) { | 2282 TEST_F(RenderViewImplTest, PreferredSizeZoomed) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2301 } | 2294 } |
| 2302 | 2295 |
| 2303 // Ensure the RenderViewImpl history list is properly updated when starting a | 2296 // Ensure the RenderViewImpl history list is properly updated when starting a |
| 2304 // new browser-initiated navigation. | 2297 // new browser-initiated navigation. |
| 2305 TEST_F(RenderViewImplTest, HistoryIsProperlyUpdatedOnNavigation) { | 2298 TEST_F(RenderViewImplTest, HistoryIsProperlyUpdatedOnNavigation) { |
| 2306 EXPECT_EQ(0, view()->historyBackListCount()); | 2299 EXPECT_EQ(0, view()->historyBackListCount()); |
| 2307 EXPECT_EQ(0, view()->historyBackListCount() + | 2300 EXPECT_EQ(0, view()->historyBackListCount() + |
| 2308 view()->historyForwardListCount() + 1); | 2301 view()->historyForwardListCount() + 1); |
| 2309 | 2302 |
| 2310 // Receive a Navigate message with history parameters. | 2303 // Receive a Navigate message with history parameters. |
| 2311 FrameMsg_Navigate_Params params; | 2304 HistoryNavigationParams history_params; |
| 2312 params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2305 history_params.current_history_list_length = 2; |
| 2313 params.common_params.transition = ui::PAGE_TRANSITION_LINK; | 2306 history_params.current_history_list_offset = 1; |
| 2314 params.history_params.current_history_list_length = 2; | 2307 history_params.pending_history_list_offset = 2; |
| 2315 params.history_params.current_history_list_offset = 1; | 2308 history_params.page_id = -1; |
| 2316 params.history_params.pending_history_list_offset = 2; | 2309 frame()->OnNavigate(CommonNavigationParams(), StartNavigationParams(), |
| 2317 params.history_params.page_id = -1; | 2310 CommitNavigationParams(), history_params); |
| 2318 params.commit_params.browser_navigation_start = | |
| 2319 base::TimeTicks::FromInternalValue(1); | |
| 2320 frame()->OnNavigate(params); | |
| 2321 | 2311 |
| 2322 // The history list in RenderView should have been updated. | 2312 // The history list in RenderView should have been updated. |
| 2323 EXPECT_EQ(1, view()->historyBackListCount()); | 2313 EXPECT_EQ(1, view()->historyBackListCount()); |
| 2324 EXPECT_EQ(2, view()->historyBackListCount() + | 2314 EXPECT_EQ(2, view()->historyBackListCount() + |
| 2325 view()->historyForwardListCount() + 1); | 2315 view()->historyForwardListCount() + 1); |
| 2326 } | 2316 } |
| 2327 | 2317 |
| 2328 } // namespace content | 2318 } // namespace content |
| OLD | NEW |