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

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

Issue 339573003: NavigationTiming: set navigationStart for navigations in new tabs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update browsertests. Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/time/time.h"
11 #include "base/win/windows_version.h" 12 #include "base/win/windows_version.h"
12 #include "content/child/request_extra_data.h" 13 #include "content/child/request_extra_data.h"
13 #include "content/child/service_worker/service_worker_network_provider.h" 14 #include "content/child/service_worker/service_worker_network_provider.h"
14 #include "content/common/frame_messages.h" 15 #include "content/common/frame_messages.h"
15 #include "content/common/ssl_status_serialization.h" 16 #include "content/common/ssl_status_serialization.h"
16 #include "content/common/view_messages.h" 17 #include "content/common/view_messages.h"
17 #include "content/public/browser/browser_context.h" 18 #include "content/public/browser/browser_context.h"
18 #include "content/public/browser/native_web_keyboard_event.h" 19 #include "content/public/browser/native_web_keyboard_event.h"
19 #include "content/public/browser/web_ui_controller_factory.h" 20 #include "content/public/browser/web_ui_controller_factory.h"
20 #include "content/public/common/bindings_policy.h" 21 #include "content/public/common/bindings_policy.h"
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 312
312 TEST_F(RenderViewImplTest, OnNavigationHttpPost) { 313 TEST_F(RenderViewImplTest, OnNavigationHttpPost) {
313 FrameMsg_Navigate_Params nav_params; 314 FrameMsg_Navigate_Params nav_params;
314 315
315 // An http url will trigger a resource load so cannot be used here. 316 // An http url will trigger a resource load so cannot be used here.
316 nav_params.url = GURL("data:text/html,<div>Page</div>"); 317 nav_params.url = GURL("data:text/html,<div>Page</div>");
317 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 318 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
318 nav_params.transition = PAGE_TRANSITION_TYPED; 319 nav_params.transition = PAGE_TRANSITION_TYPED;
319 nav_params.page_id = -1; 320 nav_params.page_id = -1;
320 nav_params.is_post = true; 321 nav_params.is_post = true;
322 nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
321 323
322 // Set up post data. 324 // Set up post data.
323 const unsigned char* raw_data = reinterpret_cast<const unsigned char*>( 325 const unsigned char* raw_data = reinterpret_cast<const unsigned char*>(
324 "post \0\ndata"); 326 "post \0\ndata");
325 const unsigned int length = 11; 327 const unsigned int length = 11;
326 const std::vector<unsigned char> post_data(raw_data, raw_data + length); 328 const std::vector<unsigned char> post_data(raw_data, raw_data + length);
327 nav_params.browser_initiated_post_data = post_data; 329 nav_params.browser_initiated_post_data = post_data;
328 330
329 frame()->OnNavigate(nav_params); 331 frame()->OnNavigate(nav_params);
330 ProcessPendingMessages(); 332 ProcessPendingMessages();
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 // If we navigate back to this RenderView, ensure we don't send a state 518 // If we navigate back to this RenderView, ensure we don't send a state
517 // update for the swapped out URL. (http://crbug.com/72235) 519 // update for the swapped out URL. (http://crbug.com/72235)
518 FrameMsg_Navigate_Params nav_params; 520 FrameMsg_Navigate_Params nav_params;
519 nav_params.url = GURL("data:text/html,<div>Page B</div>"); 521 nav_params.url = GURL("data:text/html,<div>Page B</div>");
520 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 522 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
521 nav_params.transition = PAGE_TRANSITION_TYPED; 523 nav_params.transition = PAGE_TRANSITION_TYPED;
522 nav_params.current_history_list_length = 1; 524 nav_params.current_history_list_length = 1;
523 nav_params.current_history_list_offset = 0; 525 nav_params.current_history_list_offset = 0;
524 nav_params.pending_history_list_offset = 1; 526 nav_params.pending_history_list_offset = 1;
525 nav_params.page_id = -1; 527 nav_params.page_id = -1;
528 nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
526 frame()->OnNavigate(nav_params); 529 frame()->OnNavigate(nav_params);
527 ProcessPendingMessages(); 530 ProcessPendingMessages();
528 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching( 531 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching(
529 ViewHostMsg_UpdateState::ID); 532 ViewHostMsg_UpdateState::ID);
530 EXPECT_FALSE(msg3); 533 EXPECT_FALSE(msg3);
531 } 534 }
532 535
533 // Ensure the RenderViewImpl reloads the previous page if a reload request 536 // Ensure the RenderViewImpl reloads the previous page if a reload request
534 // arrives while it is showing swappedout://. http://crbug.com/143155. 537 // arrives while it is showing swappedout://. http://crbug.com/143155.
535 TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) { 538 TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) {
(...skipping 17 matching lines...) Expand all
553 556
554 // Back to page A (page_id 1) and commit. 557 // Back to page A (page_id 1) and commit.
555 FrameMsg_Navigate_Params params_A; 558 FrameMsg_Navigate_Params params_A;
556 params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; 559 params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL;
557 params_A.transition = PAGE_TRANSITION_FORWARD_BACK; 560 params_A.transition = PAGE_TRANSITION_FORWARD_BACK;
558 params_A.current_history_list_length = 2; 561 params_A.current_history_list_length = 2;
559 params_A.current_history_list_offset = 1; 562 params_A.current_history_list_offset = 1;
560 params_A.pending_history_list_offset = 0; 563 params_A.pending_history_list_offset = 0;
561 params_A.page_id = 1; 564 params_A.page_id = 1;
562 params_A.page_state = state_A; 565 params_A.page_state = state_A;
566 params_A.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
563 frame()->OnNavigate(params_A); 567 frame()->OnNavigate(params_A);
564 ProcessPendingMessages(); 568 ProcessPendingMessages();
565 569
566 // Respond to a swap out request. 570 // Respond to a swap out request.
567 view()->main_render_frame()->OnSwapOut(kProxyRoutingId); 571 view()->main_render_frame()->OnSwapOut(kProxyRoutingId);
568 572
569 // Check for a OnSwapOutACK. 573 // Check for a OnSwapOutACK.
570 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( 574 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching(
571 FrameHostMsg_SwapOut_ACK::ID); 575 FrameHostMsg_SwapOut_ACK::ID);
572 ASSERT_TRUE(msg); 576 ASSERT_TRUE(msg);
573 render_thread_->sink().ClearMessages(); 577 render_thread_->sink().ClearMessages();
574 578
575 // It is possible to get a reload request at this point, containing the 579 // It is possible to get a reload request at this point, containing the
576 // params.page_state of the initial page (e.g., if the new page fails the 580 // params.page_state of the initial page (e.g., if the new page fails the
577 // provisional load in the renderer process, after we unload the old page). 581 // provisional load in the renderer process, after we unload the old page).
578 // Ensure the old page gets reloaded, not swappedout://. 582 // Ensure the old page gets reloaded, not swappedout://.
579 FrameMsg_Navigate_Params nav_params; 583 FrameMsg_Navigate_Params nav_params;
580 nav_params.url = GURL("data:text/html,<div>Page A</div>"); 584 nav_params.url = GURL("data:text/html,<div>Page A</div>");
581 nav_params.navigation_type = FrameMsg_Navigate_Type::RELOAD; 585 nav_params.navigation_type = FrameMsg_Navigate_Type::RELOAD;
582 nav_params.transition = PAGE_TRANSITION_RELOAD; 586 nav_params.transition = PAGE_TRANSITION_RELOAD;
583 nav_params.current_history_list_length = 2; 587 nav_params.current_history_list_length = 2;
584 nav_params.current_history_list_offset = 0; 588 nav_params.current_history_list_offset = 0;
585 nav_params.pending_history_list_offset = 0; 589 nav_params.pending_history_list_offset = 0;
586 nav_params.page_id = 1; 590 nav_params.page_id = 1;
587 nav_params.page_state = state_A; 591 nav_params.page_state = state_A;
592 nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
588 frame()->OnNavigate(nav_params); 593 frame()->OnNavigate(nav_params);
589 ProcessPendingMessages(); 594 ProcessPendingMessages();
590 595
591 // Verify page A committed, not swappedout://. 596 // Verify page A committed, not swappedout://.
592 const IPC::Message* frame_navigate_msg = 597 const IPC::Message* frame_navigate_msg =
593 render_thread_->sink().GetUniqueMessageMatching( 598 render_thread_->sink().GetUniqueMessageMatching(
594 FrameHostMsg_DidCommitProvisionalLoad::ID); 599 FrameHostMsg_DidCommitProvisionalLoad::ID);
595 EXPECT_TRUE(frame_navigate_msg); 600 EXPECT_TRUE(frame_navigate_msg);
596 601
597 // Read URL out of the parent trait of the params object. 602 // Read URL out of the parent trait of the params object.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 661
657 // Go back to C and commit, preparing for our real test. 662 // Go back to C and commit, preparing for our real test.
658 FrameMsg_Navigate_Params params_C; 663 FrameMsg_Navigate_Params params_C;
659 params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL; 664 params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL;
660 params_C.transition = PAGE_TRANSITION_FORWARD_BACK; 665 params_C.transition = PAGE_TRANSITION_FORWARD_BACK;
661 params_C.current_history_list_length = 4; 666 params_C.current_history_list_length = 4;
662 params_C.current_history_list_offset = 3; 667 params_C.current_history_list_offset = 3;
663 params_C.pending_history_list_offset = 2; 668 params_C.pending_history_list_offset = 2;
664 params_C.page_id = 3; 669 params_C.page_id = 3;
665 params_C.page_state = state_C; 670 params_C.page_state = state_C;
671 params_C.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
666 frame()->OnNavigate(params_C); 672 frame()->OnNavigate(params_C);
667 ProcessPendingMessages(); 673 ProcessPendingMessages();
668 render_thread_->sink().ClearMessages(); 674 render_thread_->sink().ClearMessages();
669 675
670 // Go back twice quickly, such that page B does not have a chance to commit. 676 // Go back twice quickly, such that page B does not have a chance to commit.
671 // This leads to two changes to the back/forward list but only one change to 677 // This leads to two changes to the back/forward list but only one change to
672 // the RenderView's page ID. 678 // the RenderView's page ID.
673 679
674 // Back to page B (page_id 2), without committing. 680 // Back to page B (page_id 2), without committing.
675 FrameMsg_Navigate_Params params_B; 681 FrameMsg_Navigate_Params params_B;
676 params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; 682 params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL;
677 params_B.transition = PAGE_TRANSITION_FORWARD_BACK; 683 params_B.transition = PAGE_TRANSITION_FORWARD_BACK;
678 params_B.current_history_list_length = 4; 684 params_B.current_history_list_length = 4;
679 params_B.current_history_list_offset = 2; 685 params_B.current_history_list_offset = 2;
680 params_B.pending_history_list_offset = 1; 686 params_B.pending_history_list_offset = 1;
681 params_B.page_id = 2; 687 params_B.page_id = 2;
682 params_B.page_state = state_B; 688 params_B.page_state = state_B;
689 params_B.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
683 frame()->OnNavigate(params_B); 690 frame()->OnNavigate(params_B);
684 691
685 // Back to page A (page_id 1) and commit. 692 // Back to page A (page_id 1) and commit.
686 FrameMsg_Navigate_Params params; 693 FrameMsg_Navigate_Params params;
687 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 694 params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
688 params.transition = PAGE_TRANSITION_FORWARD_BACK; 695 params.transition = PAGE_TRANSITION_FORWARD_BACK;
689 params_B.current_history_list_length = 4; 696 params_B.current_history_list_length = 4;
690 params_B.current_history_list_offset = 2; 697 params_B.current_history_list_offset = 2;
691 params_B.pending_history_list_offset = 0; 698 params_B.pending_history_list_offset = 0;
692 params.page_id = 1; 699 params.page_id = 1;
693 params.page_state = state_A; 700 params.page_state = state_A;
701 params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
694 frame()->OnNavigate(params); 702 frame()->OnNavigate(params);
695 ProcessPendingMessages(); 703 ProcessPendingMessages();
696 704
697 // Now ensure that the UpdateState message we receive is consistent 705 // Now ensure that the UpdateState message we receive is consistent
698 // and represents page C in both page_id and state. 706 // and represents page C in both page_id and state.
699 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( 707 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching(
700 ViewHostMsg_UpdateState::ID); 708 ViewHostMsg_UpdateState::ID);
701 ASSERT_TRUE(msg); 709 ASSERT_TRUE(msg);
702 ViewHostMsg_UpdateState::Read(msg, &param); 710 ViewHostMsg_UpdateState::Read(msg, &param);
703 int page_id = param.a; 711 int page_id = param.a;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 746
739 // Back to page A (page_id 1) and commit. 747 // Back to page A (page_id 1) and commit.
740 FrameMsg_Navigate_Params params_A; 748 FrameMsg_Navigate_Params params_A;
741 params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; 749 params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL;
742 params_A.transition = PAGE_TRANSITION_FORWARD_BACK; 750 params_A.transition = PAGE_TRANSITION_FORWARD_BACK;
743 params_A.current_history_list_length = 2; 751 params_A.current_history_list_length = 2;
744 params_A.current_history_list_offset = 1; 752 params_A.current_history_list_offset = 1;
745 params_A.pending_history_list_offset = 0; 753 params_A.pending_history_list_offset = 0;
746 params_A.page_id = 1; 754 params_A.page_id = 1;
747 params_A.page_state = state_A; 755 params_A.page_state = state_A;
756 params_A.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
748 frame()->OnNavigate(params_A); 757 frame()->OnNavigate(params_A);
749 ProcessPendingMessages(); 758 ProcessPendingMessages();
750 759
751 // A new navigation commits, clearing the forward history. 760 // A new navigation commits, clearing the forward history.
752 LoadHTML("<div>Page C</div>"); 761 LoadHTML("<div>Page C</div>");
753 EXPECT_EQ(2, view()->history_list_length_); 762 EXPECT_EQ(2, view()->history_list_length_);
754 EXPECT_EQ(1, view()->history_list_offset_); 763 EXPECT_EQ(1, view()->history_list_offset_);
755 EXPECT_EQ(3, view()->history_page_ids_[1]); 764 EXPECT_EQ(3, view()->history_page_ids_[1]);
756 765
757 // The browser then sends a stale navigation to B, which should be ignored. 766 // The browser then sends a stale navigation to B, which should be ignored.
758 FrameMsg_Navigate_Params params_B; 767 FrameMsg_Navigate_Params params_B;
759 params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; 768 params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL;
760 params_B.transition = PAGE_TRANSITION_FORWARD_BACK; 769 params_B.transition = PAGE_TRANSITION_FORWARD_BACK;
761 params_B.current_history_list_length = 2; 770 params_B.current_history_list_length = 2;
762 params_B.current_history_list_offset = 0; 771 params_B.current_history_list_offset = 0;
763 params_B.pending_history_list_offset = 1; 772 params_B.pending_history_list_offset = 1;
764 params_B.page_id = 2; 773 params_B.page_id = 2;
765 params_B.page_state = state_A; // Doesn't matter, just has to be present. 774 params_B.page_state = state_A; // Doesn't matter, just has to be present.
775 params_B.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
766 frame()->OnNavigate(params_B); 776 frame()->OnNavigate(params_B);
767 777
768 // State should be unchanged. 778 // State should be unchanged.
769 EXPECT_EQ(2, view()->history_list_length_); 779 EXPECT_EQ(2, view()->history_list_length_);
770 EXPECT_EQ(1, view()->history_list_offset_); 780 EXPECT_EQ(1, view()->history_list_offset_);
771 EXPECT_EQ(3, view()->history_page_ids_[1]); 781 EXPECT_EQ(3, view()->history_page_ids_[1]);
772 } 782 }
773 783
774 // Test that we do not ignore navigations after the entry limit is reached, 784 // Test that we do not ignore navigations after the entry limit is reached,
775 // in which case the browser starts dropping entries from the front. In this 785 // in which case the browser starts dropping entries from the front. In this
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 // It has now dropped the first entry, but the renderer isn't notified. 833 // It has now dropped the first entry, but the renderer isn't notified.
824 // Ensure that going back to page B (page_id 2) at offset 0 is successful. 834 // Ensure that going back to page B (page_id 2) at offset 0 is successful.
825 FrameMsg_Navigate_Params params_B; 835 FrameMsg_Navigate_Params params_B;
826 params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; 836 params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL;
827 params_B.transition = PAGE_TRANSITION_FORWARD_BACK; 837 params_B.transition = PAGE_TRANSITION_FORWARD_BACK;
828 params_B.current_history_list_length = 2; 838 params_B.current_history_list_length = 2;
829 params_B.current_history_list_offset = 1; 839 params_B.current_history_list_offset = 1;
830 params_B.pending_history_list_offset = 0; 840 params_B.pending_history_list_offset = 0;
831 params_B.page_id = 2; 841 params_B.page_id = 2;
832 params_B.page_state = state_B; 842 params_B.page_state = state_B;
843 params_B.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
833 frame()->OnNavigate(params_B); 844 frame()->OnNavigate(params_B);
834 ProcessPendingMessages(); 845 ProcessPendingMessages();
835 846
836 EXPECT_EQ(2, view()->history_list_length_); 847 EXPECT_EQ(2, view()->history_list_length_);
837 EXPECT_EQ(0, view()->history_list_offset_); 848 EXPECT_EQ(0, view()->history_list_offset_);
838 EXPECT_EQ(2, view()->history_page_ids_[0]); 849 EXPECT_EQ(2, view()->history_page_ids_[0]);
839 } 850 }
840 851
841 // Test that our IME backend sends a notification message when the input focus 852 // Test that our IME backend sends a notification message when the input focus
842 // changes. 853 // changes.
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 error.reason = net::ERR_FILE_NOT_FOUND; 1541 error.reason = net::ERR_FILE_NOT_FOUND;
1531 error.unreachableURL = GURL("http://foo"); 1542 error.unreachableURL = GURL("http://foo");
1532 WebLocalFrame* web_frame = GetMainFrame(); 1543 WebLocalFrame* web_frame = GetMainFrame();
1533 1544
1534 // Start a load that will reach provisional state synchronously, 1545 // Start a load that will reach provisional state synchronously,
1535 // but won't complete synchronously. 1546 // but won't complete synchronously.
1536 FrameMsg_Navigate_Params params; 1547 FrameMsg_Navigate_Params params;
1537 params.page_id = -1; 1548 params.page_id = -1;
1538 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 1549 params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
1539 params.url = GURL("data:text/html,test data"); 1550 params.url = GURL("data:text/html,test data");
1551 params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
1540 frame()->OnNavigate(params); 1552 frame()->OnNavigate(params);
1541 1553
1542 // An error occurred. 1554 // An error occurred.
1543 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error); 1555 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error);
1544 // Frame should exit view-source mode. 1556 // Frame should exit view-source mode.
1545 EXPECT_FALSE(web_frame->isViewSourceModeEnabled()); 1557 EXPECT_FALSE(web_frame->isViewSourceModeEnabled());
1546 } 1558 }
1547 1559
1548 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) { 1560 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) {
1549 GetMainFrame()->enableViewSourceMode(true); 1561 GetMainFrame()->enableViewSourceMode(true);
1550 WebURLError error; 1562 WebURLError error;
1551 error.domain = WebString::fromUTF8(net::kErrorDomain); 1563 error.domain = WebString::fromUTF8(net::kErrorDomain);
1552 error.reason = net::ERR_ABORTED; 1564 error.reason = net::ERR_ABORTED;
1553 error.unreachableURL = GURL("http://foo"); 1565 error.unreachableURL = GURL("http://foo");
1554 WebLocalFrame* web_frame = GetMainFrame(); 1566 WebLocalFrame* web_frame = GetMainFrame();
1555 1567
1556 // Start a load that will reach provisional state synchronously, 1568 // Start a load that will reach provisional state synchronously,
1557 // but won't complete synchronously. 1569 // but won't complete synchronously.
1558 FrameMsg_Navigate_Params params; 1570 FrameMsg_Navigate_Params params;
1559 params.page_id = -1; 1571 params.page_id = -1;
1560 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 1572 params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
1561 params.url = GURL("data:text/html,test data"); 1573 params.url = GURL("data:text/html,test data");
1574 params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
1562 frame()->OnNavigate(params); 1575 frame()->OnNavigate(params);
1563 1576
1564 // A cancellation occurred. 1577 // A cancellation occurred.
1565 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error); 1578 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error);
1566 // Frame should stay in view-source mode. 1579 // Frame should stay in view-source mode.
1567 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); 1580 EXPECT_TRUE(web_frame->isViewSourceModeEnabled());
1568 } 1581 }
1569 1582
1570 // Regression test for http://crbug.com/41562 1583 // Regression test for http://crbug.com/41562
1571 TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) { 1584 TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) {
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 } 1945 }
1933 #endif 1946 #endif
1934 1947
1935 TEST_F(RenderViewImplTest, ZoomLimit) { 1948 TEST_F(RenderViewImplTest, ZoomLimit) {
1936 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor); 1949 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor);
1937 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor); 1950 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor);
1938 1951
1939 FrameMsg_Navigate_Params params; 1952 FrameMsg_Navigate_Params params;
1940 params.page_id = -1; 1953 params.page_id = -1;
1941 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 1954 params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
1955 params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
1942 1956
1943 // Verifies navigation to a URL with preset zoom level indeed sets the level. 1957 // Verifies navigation to a URL with preset zoom level indeed sets the level.
1944 // Regression test for http://crbug.com/139559, where the level was not 1958 // Regression test for http://crbug.com/139559, where the level was not
1945 // properly set when it is out of the default zoom limits of WebView. 1959 // properly set when it is out of the default zoom limits of WebView.
1946 params.url = GURL("data:text/html,min_zoomlimit_test"); 1960 params.url = GURL("data:text/html,min_zoomlimit_test");
1947 view()->OnSetZoomLevelForLoadingURL(params.url, kMinZoomLevel); 1961 view()->OnSetZoomLevelForLoadingURL(params.url, kMinZoomLevel);
1948 frame()->OnNavigate(params); 1962 frame()->OnNavigate(params);
1949 ProcessPendingMessages(); 1963 ProcessPendingMessages();
1950 EXPECT_DOUBLE_EQ(kMinZoomLevel, view()->GetWebView()->zoomLevel()); 1964 EXPECT_DOUBLE_EQ(kMinZoomLevel, view()->GetWebView()->zoomLevel());
1951 1965
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2016 // Navigate the frame only. 2030 // Navigate the frame only.
2017 FrameMsg_Navigate_Params nav_params; 2031 FrameMsg_Navigate_Params nav_params;
2018 nav_params.url = GURL("data:text/html,world"); 2032 nav_params.url = GURL("data:text/html,world");
2019 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 2033 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2020 nav_params.transition = PAGE_TRANSITION_TYPED; 2034 nav_params.transition = PAGE_TRANSITION_TYPED;
2021 nav_params.current_history_list_length = 1; 2035 nav_params.current_history_list_length = 1;
2022 nav_params.current_history_list_offset = 0; 2036 nav_params.current_history_list_offset = 0;
2023 nav_params.pending_history_list_offset = 1; 2037 nav_params.pending_history_list_offset = 1;
2024 nav_params.page_id = -1; 2038 nav_params.page_id = -1;
2025 nav_params.frame_to_navigate = "frame"; 2039 nav_params.frame_to_navigate = "frame";
2040 nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
2026 frame()->OnNavigate(nav_params); 2041 frame()->OnNavigate(nav_params);
2027 FrameLoadWaiter( 2042 FrameLoadWaiter(
2028 RenderFrame::FromWebFrame(frame()->GetWebFrame()->firstChild())).Wait(); 2043 RenderFrame::FromWebFrame(frame()->GetWebFrame()->firstChild())).Wait();
2029 2044
2030 // Copy the document content to std::wstring and compare with the 2045 // Copy the document content to std::wstring and compare with the
2031 // expected result. 2046 // expected result.
2032 const int kMaxOutputCharacters = 256; 2047 const int kMaxOutputCharacters = 256;
2033 std::string output = base::UTF16ToUTF8( 2048 std::string output = base::UTF16ToUTF8(
2034 GetMainFrame()->contentAsText(kMaxOutputCharacters)); 2049 GetMainFrame()->contentAsText(kMaxOutputCharacters));
2035 EXPECT_EQ(output, "hello \n\nworld"); 2050 EXPECT_EQ(output, "hello \n\nworld");
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
2135 error.reason = net::ERR_FILE_NOT_FOUND; 2150 error.reason = net::ERR_FILE_NOT_FOUND;
2136 error.unreachableURL = GURL("http://example.com/suppress"); 2151 error.unreachableURL = GURL("http://example.com/suppress");
2137 WebLocalFrame* web_frame = GetMainFrame(); 2152 WebLocalFrame* web_frame = GetMainFrame();
2138 2153
2139 // Start a load that will reach provisional state synchronously, 2154 // Start a load that will reach provisional state synchronously,
2140 // but won't complete synchronously. 2155 // but won't complete synchronously.
2141 FrameMsg_Navigate_Params params; 2156 FrameMsg_Navigate_Params params;
2142 params.page_id = -1; 2157 params.page_id = -1;
2143 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 2158 params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2144 params.url = GURL("data:text/html,test data"); 2159 params.url = GURL("data:text/html,test data");
2160 params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
2145 frame()->OnNavigate(params); 2161 frame()->OnNavigate(params);
2146 2162
2147 // An error occurred. 2163 // An error occurred.
2148 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error); 2164 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error);
2149 const int kMaxOutputCharacters = 22; 2165 const int kMaxOutputCharacters = 22;
2150 EXPECT_EQ("", 2166 EXPECT_EQ("",
2151 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); 2167 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
2152 } 2168 }
2153 2169
2154 #if defined(OS_ANDROID) 2170 #if defined(OS_ANDROID)
2155 // Crashing on Android: http://crbug.com/311341 2171 // Crashing on Android: http://crbug.com/311341
2156 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress 2172 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress
2157 #else 2173 #else
2158 #define MAYBE_DoesNotSuppress DoesNotSuppress 2174 #define MAYBE_DoesNotSuppress DoesNotSuppress
2159 #endif 2175 #endif
2160 2176
2161 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) { 2177 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) {
2162 WebURLError error; 2178 WebURLError error;
2163 error.domain = WebString::fromUTF8(net::kErrorDomain); 2179 error.domain = WebString::fromUTF8(net::kErrorDomain);
2164 error.reason = net::ERR_FILE_NOT_FOUND; 2180 error.reason = net::ERR_FILE_NOT_FOUND;
2165 error.unreachableURL = GURL("http://example.com/dont-suppress"); 2181 error.unreachableURL = GURL("http://example.com/dont-suppress");
2166 WebLocalFrame* web_frame = GetMainFrame(); 2182 WebLocalFrame* web_frame = GetMainFrame();
2167 2183
2168 // Start a load that will reach provisional state synchronously, 2184 // Start a load that will reach provisional state synchronously,
2169 // but won't complete synchronously. 2185 // but won't complete synchronously.
2170 FrameMsg_Navigate_Params params; 2186 FrameMsg_Navigate_Params params;
2171 params.page_id = -1; 2187 params.page_id = -1;
2172 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 2188 params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2173 params.url = GURL("data:text/html,test data"); 2189 params.url = GURL("data:text/html,test data");
2190 params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
2174 frame()->OnNavigate(params); 2191 frame()->OnNavigate(params);
2175 2192
2176 // An error occurred. 2193 // An error occurred.
2177 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error); 2194 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error);
2178 // The error page itself is loaded asynchronously. 2195 // The error page itself is loaded asynchronously.
2179 FrameLoadWaiter(frame()).Wait(); 2196 FrameLoadWaiter(frame()).Wait();
2180 const int kMaxOutputCharacters = 22; 2197 const int kMaxOutputCharacters = 22;
2181 EXPECT_EQ("A suffusion of yellow.", 2198 EXPECT_EQ("A suffusion of yellow.",
2182 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); 2199 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
2183 } 2200 }
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
2366 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(get_height, &height)); 2383 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(get_height, &height));
2367 EXPECT_EQ(params.viewSize.height, height); 2384 EXPECT_EQ(params.viewSize.height, height);
2368 2385
2369 view()->DisableScreenMetricsEmulation(); 2386 view()->DisableScreenMetricsEmulation();
2370 2387
2371 view()->EnableScreenMetricsEmulation(params); 2388 view()->EnableScreenMetricsEmulation(params);
2372 // Don't disable here to test that emulation is being shutdown properly. 2389 // Don't disable here to test that emulation is being shutdown properly.
2373 } 2390 }
2374 2391
2375 } // namespace content 2392 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698