OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 } | 347 } |
348 | 348 |
349 TEST_F(NavigationControllerTest, LoadURL) { | 349 TEST_F(NavigationControllerTest, LoadURL) { |
350 NavigationControllerImpl& controller = controller_impl(); | 350 NavigationControllerImpl& controller = controller_impl(); |
351 TestNotificationTracker notifications; | 351 TestNotificationTracker notifications; |
352 RegisterForAllNavNotifications(¬ifications, &controller); | 352 RegisterForAllNavNotifications(¬ifications, &controller); |
353 | 353 |
354 const GURL url1("http://foo1"); | 354 const GURL url1("http://foo1"); |
355 const GURL url2("http://foo2"); | 355 const GURL url2("http://foo2"); |
356 | 356 |
357 controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 357 controller.LoadURL( |
| 358 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
358 // Creating a pending notification should not have issued any of the | 359 // Creating a pending notification should not have issued any of the |
359 // notifications we're listening for. | 360 // notifications we're listening for. |
360 EXPECT_EQ(0U, notifications.size()); | 361 EXPECT_EQ(0U, notifications.size()); |
361 | 362 |
362 // The load should now be pending. | 363 // The load should now be pending. |
363 EXPECT_EQ(controller.GetEntryCount(), 0); | 364 EXPECT_EQ(controller.GetEntryCount(), 0); |
364 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), -1); | 365 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), -1); |
365 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 366 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
366 EXPECT_FALSE(controller.GetLastCommittedEntry()); | 367 EXPECT_FALSE(controller.GetLastCommittedEntry()); |
367 ASSERT_TRUE(controller.GetPendingEntry()); | 368 ASSERT_TRUE(controller.GetPendingEntry()); |
(...skipping 23 matching lines...) Expand all Loading... |
391 EXPECT_FALSE(controller.CanGoBack()); | 392 EXPECT_FALSE(controller.CanGoBack()); |
392 EXPECT_FALSE(controller.CanGoForward()); | 393 EXPECT_FALSE(controller.CanGoForward()); |
393 EXPECT_EQ(contents()->GetMaxPageID(), 0); | 394 EXPECT_EQ(contents()->GetMaxPageID(), 0); |
394 EXPECT_EQ(0, NavigationEntryImpl::FromNavigationEntry( | 395 EXPECT_EQ(0, NavigationEntryImpl::FromNavigationEntry( |
395 controller.GetLastCommittedEntry())->bindings()); | 396 controller.GetLastCommittedEntry())->bindings()); |
396 | 397 |
397 // The timestamp should have been set. | 398 // The timestamp should have been set. |
398 EXPECT_FALSE(controller.GetVisibleEntry()->GetTimestamp().is_null()); | 399 EXPECT_FALSE(controller.GetVisibleEntry()->GetTimestamp().is_null()); |
399 | 400 |
400 // Load another... | 401 // Load another... |
401 controller.LoadURL(url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 402 controller.LoadURL( |
| 403 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
402 | 404 |
403 // The load should now be pending. | 405 // The load should now be pending. |
404 EXPECT_EQ(controller.GetEntryCount(), 1); | 406 EXPECT_EQ(controller.GetEntryCount(), 1); |
405 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 407 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
406 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 408 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
407 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 409 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
408 ASSERT_TRUE(controller.GetPendingEntry()); | 410 ASSERT_TRUE(controller.GetPendingEntry()); |
409 EXPECT_EQ(controller.GetPendingEntry(), controller.GetVisibleEntry()); | 411 EXPECT_EQ(controller.GetPendingEntry(), controller.GetVisibleEntry()); |
410 // TODO(darin): maybe this should really be true? | 412 // TODO(darin): maybe this should really be true? |
411 EXPECT_FALSE(controller.CanGoBack()); | 413 EXPECT_FALSE(controller.CanGoBack()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 TestNotificationTracker notifications; | 450 TestNotificationTracker notifications; |
449 RegisterForAllNavNotifications(¬ifications, &controller); | 451 RegisterForAllNavNotifications(¬ifications, &controller); |
450 | 452 |
451 // Set the clock to always return a timestamp of 1. | 453 // Set the clock to always return a timestamp of 1. |
452 controller.SetGetTimestampCallbackForTest( | 454 controller.SetGetTimestampCallbackForTest( |
453 base::Bind(&GetFixedTime, base::Time::FromInternalValue(1))); | 455 base::Bind(&GetFixedTime, base::Time::FromInternalValue(1))); |
454 | 456 |
455 const GURL url1("http://foo1"); | 457 const GURL url1("http://foo1"); |
456 const GURL url2("http://foo2"); | 458 const GURL url2("http://foo2"); |
457 | 459 |
458 controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 460 controller.LoadURL( |
| 461 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
459 | 462 |
460 main_test_rfh()->SendNavigate(0, url1); | 463 main_test_rfh()->SendNavigate(0, url1); |
461 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 464 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
462 navigation_entry_committed_counter_ = 0; | 465 navigation_entry_committed_counter_ = 0; |
463 | 466 |
464 // Load another... | 467 // Load another... |
465 controller.LoadURL(url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 468 controller.LoadURL( |
| 469 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
466 | 470 |
467 // Simulate the beforeunload ack for the cross-site transition, and then the | 471 // Simulate the beforeunload ack for the cross-site transition, and then the |
468 // commit. | 472 // commit. |
469 test_rvh()->SendBeforeUnloadACK(true); | 473 test_rvh()->SendBeforeUnloadACK(true); |
470 main_test_rfh()->SendNavigate(1, url2); | 474 main_test_rfh()->SendNavigate(1, url2); |
471 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 475 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
472 navigation_entry_committed_counter_ = 0; | 476 navigation_entry_committed_counter_ = 0; |
473 | 477 |
474 // The two loads should now be committed. | 478 // The two loads should now be committed. |
475 ASSERT_EQ(controller.GetEntryCount(), 2); | 479 ASSERT_EQ(controller.GetEntryCount(), 2); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 EXPECT_EQ(load_params.transferred_global_request_id, | 511 EXPECT_EQ(load_params.transferred_global_request_id, |
508 entry->transferred_global_request_id()); | 512 entry->transferred_global_request_id()); |
509 } | 513 } |
510 | 514 |
511 TEST_F(NavigationControllerTest, LoadURLWithParams) { | 515 TEST_F(NavigationControllerTest, LoadURLWithParams) { |
512 NavigationControllerImpl& controller = controller_impl(); | 516 NavigationControllerImpl& controller = controller_impl(); |
513 | 517 |
514 NavigationController::LoadURLParams load_params(GURL("http://foo")); | 518 NavigationController::LoadURLParams load_params(GURL("http://foo")); |
515 load_params.referrer = | 519 load_params.referrer = |
516 Referrer(GURL("http://referrer"), blink::WebReferrerPolicyDefault); | 520 Referrer(GURL("http://referrer"), blink::WebReferrerPolicyDefault); |
517 load_params.transition_type = PAGE_TRANSITION_GENERATED; | 521 load_params.transition_type = ui::PAGE_TRANSITION_GENERATED; |
518 load_params.extra_headers = "content-type: text/plain"; | 522 load_params.extra_headers = "content-type: text/plain"; |
519 load_params.load_type = NavigationController::LOAD_TYPE_DEFAULT; | 523 load_params.load_type = NavigationController::LOAD_TYPE_DEFAULT; |
520 load_params.is_renderer_initiated = true; | 524 load_params.is_renderer_initiated = true; |
521 load_params.override_user_agent = NavigationController::UA_OVERRIDE_TRUE; | 525 load_params.override_user_agent = NavigationController::UA_OVERRIDE_TRUE; |
522 load_params.transferred_global_request_id = GlobalRequestID(2, 3); | 526 load_params.transferred_global_request_id = GlobalRequestID(2, 3); |
523 | 527 |
524 controller.LoadURLWithParams(load_params); | 528 controller.LoadURLWithParams(load_params); |
525 NavigationEntryImpl* entry = | 529 NavigationEntryImpl* entry = |
526 NavigationEntryImpl::FromNavigationEntry( | 530 NavigationEntryImpl::FromNavigationEntry( |
527 controller.GetPendingEntry()); | 531 controller.GetPendingEntry()); |
(...skipping 20 matching lines...) Expand all Loading... |
548 NavigationEntryImpl::FromNavigationEntry( | 552 NavigationEntryImpl::FromNavigationEntry( |
549 controller.GetPendingEntry()); | 553 controller.GetPendingEntry()); |
550 | 554 |
551 CheckNavigationEntryMatchLoadParams(load_params, entry); | 555 CheckNavigationEntryMatchLoadParams(load_params, entry); |
552 } | 556 } |
553 | 557 |
554 TEST_F(NavigationControllerTest, LoadURLWithExtraParams_HttpPost) { | 558 TEST_F(NavigationControllerTest, LoadURLWithExtraParams_HttpPost) { |
555 NavigationControllerImpl& controller = controller_impl(); | 559 NavigationControllerImpl& controller = controller_impl(); |
556 | 560 |
557 NavigationController::LoadURLParams load_params(GURL("https://posturl")); | 561 NavigationController::LoadURLParams load_params(GURL("https://posturl")); |
558 load_params.transition_type = PAGE_TRANSITION_TYPED; | 562 load_params.transition_type = ui::PAGE_TRANSITION_TYPED; |
559 load_params.load_type = | 563 load_params.load_type = |
560 NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST; | 564 NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST; |
561 load_params.override_user_agent = NavigationController::UA_OVERRIDE_TRUE; | 565 load_params.override_user_agent = NavigationController::UA_OVERRIDE_TRUE; |
562 | 566 |
563 | 567 |
564 const unsigned char* raw_data = | 568 const unsigned char* raw_data = |
565 reinterpret_cast<const unsigned char*>("d\n\0a2"); | 569 reinterpret_cast<const unsigned char*>("d\n\0a2"); |
566 const int length = 5; | 570 const int length = 5; |
567 std::vector<unsigned char> post_data_vector(raw_data, raw_data+length); | 571 std::vector<unsigned char> post_data_vector(raw_data, raw_data+length); |
568 scoped_refptr<base::RefCountedBytes> data = | 572 scoped_refptr<base::RefCountedBytes> data = |
(...skipping 12 matching lines...) Expand all Loading... |
581 // new session history entry. This is what happens when you press enter in the | 585 // new session history entry. This is what happens when you press enter in the |
582 // URL bar to reload: a pending entry is created and then it is discarded when | 586 // URL bar to reload: a pending entry is created and then it is discarded when |
583 // the load commits (because WebCore didn't actually make a new entry). | 587 // the load commits (because WebCore didn't actually make a new entry). |
584 TEST_F(NavigationControllerTest, LoadURL_SamePage) { | 588 TEST_F(NavigationControllerTest, LoadURL_SamePage) { |
585 NavigationControllerImpl& controller = controller_impl(); | 589 NavigationControllerImpl& controller = controller_impl(); |
586 TestNotificationTracker notifications; | 590 TestNotificationTracker notifications; |
587 RegisterForAllNavNotifications(¬ifications, &controller); | 591 RegisterForAllNavNotifications(¬ifications, &controller); |
588 | 592 |
589 const GURL url1("http://foo1"); | 593 const GURL url1("http://foo1"); |
590 | 594 |
591 controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 595 controller.LoadURL( |
| 596 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
592 EXPECT_EQ(0U, notifications.size()); | 597 EXPECT_EQ(0U, notifications.size()); |
593 main_test_rfh()->SendNavigate(0, url1); | 598 main_test_rfh()->SendNavigate(0, url1); |
594 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 599 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
595 navigation_entry_committed_counter_ = 0; | 600 navigation_entry_committed_counter_ = 0; |
596 | 601 |
597 ASSERT_TRUE(controller.GetVisibleEntry()); | 602 ASSERT_TRUE(controller.GetVisibleEntry()); |
598 const base::Time timestamp = controller.GetVisibleEntry()->GetTimestamp(); | 603 const base::Time timestamp = controller.GetVisibleEntry()->GetTimestamp(); |
599 EXPECT_FALSE(timestamp.is_null()); | 604 EXPECT_FALSE(timestamp.is_null()); |
600 | 605 |
601 controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 606 controller.LoadURL( |
| 607 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
602 EXPECT_EQ(0U, notifications.size()); | 608 EXPECT_EQ(0U, notifications.size()); |
603 main_test_rfh()->SendNavigate(0, url1); | 609 main_test_rfh()->SendNavigate(0, url1); |
604 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 610 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
605 navigation_entry_committed_counter_ = 0; | 611 navigation_entry_committed_counter_ = 0; |
606 | 612 |
607 // We should not have produced a new session history entry. | 613 // We should not have produced a new session history entry. |
608 EXPECT_EQ(controller.GetEntryCount(), 1); | 614 EXPECT_EQ(controller.GetEntryCount(), 1); |
609 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 615 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
610 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 616 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
611 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 617 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
(...skipping 11 matching lines...) Expand all Loading... |
623 | 629 |
624 // Load the same page twice, once as a GET and once as a POST. | 630 // Load the same page twice, once as a GET and once as a POST. |
625 // We should update the post state on the NavigationEntry. | 631 // We should update the post state on the NavigationEntry. |
626 TEST_F(NavigationControllerTest, LoadURL_SamePage_DifferentMethod) { | 632 TEST_F(NavigationControllerTest, LoadURL_SamePage_DifferentMethod) { |
627 NavigationControllerImpl& controller = controller_impl(); | 633 NavigationControllerImpl& controller = controller_impl(); |
628 TestNotificationTracker notifications; | 634 TestNotificationTracker notifications; |
629 RegisterForAllNavNotifications(¬ifications, &controller); | 635 RegisterForAllNavNotifications(¬ifications, &controller); |
630 | 636 |
631 const GURL url1("http://foo1"); | 637 const GURL url1("http://foo1"); |
632 | 638 |
633 controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 639 controller.LoadURL( |
| 640 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
634 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 641 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
635 params.page_id = 0; | 642 params.page_id = 0; |
636 params.url = url1; | 643 params.url = url1; |
637 params.transition = PAGE_TRANSITION_TYPED; | 644 params.transition = ui::PAGE_TRANSITION_TYPED; |
638 params.is_post = true; | 645 params.is_post = true; |
639 params.post_id = 123; | 646 params.post_id = 123; |
640 params.page_state = PageState::CreateForTesting(url1, false, 0, 0); | 647 params.page_state = PageState::CreateForTesting(url1, false, 0, 0); |
641 main_test_rfh()->SendNavigateWithParams(¶ms); | 648 main_test_rfh()->SendNavigateWithParams(¶ms); |
642 | 649 |
643 // The post data should be visible. | 650 // The post data should be visible. |
644 NavigationEntry* entry = controller.GetVisibleEntry(); | 651 NavigationEntry* entry = controller.GetVisibleEntry(); |
645 ASSERT_TRUE(entry); | 652 ASSERT_TRUE(entry); |
646 EXPECT_TRUE(entry->GetHasPostData()); | 653 EXPECT_TRUE(entry->GetHasPostData()); |
647 EXPECT_EQ(entry->GetPostID(), 123); | 654 EXPECT_EQ(entry->GetPostID(), 123); |
648 | 655 |
649 controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 656 controller.LoadURL( |
| 657 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
650 main_test_rfh()->SendNavigate(0, url1); | 658 main_test_rfh()->SendNavigate(0, url1); |
651 | 659 |
652 // We should not have produced a new session history entry. | 660 // We should not have produced a new session history entry. |
653 ASSERT_EQ(controller.GetVisibleEntry(), entry); | 661 ASSERT_EQ(controller.GetVisibleEntry(), entry); |
654 | 662 |
655 // The post data should have been cleared due to the GET. | 663 // The post data should have been cleared due to the GET. |
656 EXPECT_FALSE(entry->GetHasPostData()); | 664 EXPECT_FALSE(entry->GetHasPostData()); |
657 EXPECT_EQ(entry->GetPostID(), 0); | 665 EXPECT_EQ(entry->GetPostID(), 0); |
658 } | 666 } |
659 | 667 |
660 // Tests loading a URL but discarding it before the load commits. | 668 // Tests loading a URL but discarding it before the load commits. |
661 TEST_F(NavigationControllerTest, LoadURL_Discarded) { | 669 TEST_F(NavigationControllerTest, LoadURL_Discarded) { |
662 NavigationControllerImpl& controller = controller_impl(); | 670 NavigationControllerImpl& controller = controller_impl(); |
663 TestNotificationTracker notifications; | 671 TestNotificationTracker notifications; |
664 RegisterForAllNavNotifications(¬ifications, &controller); | 672 RegisterForAllNavNotifications(¬ifications, &controller); |
665 | 673 |
666 const GURL url1("http://foo1"); | 674 const GURL url1("http://foo1"); |
667 const GURL url2("http://foo2"); | 675 const GURL url2("http://foo2"); |
668 | 676 |
669 controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 677 controller.LoadURL( |
| 678 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
670 EXPECT_EQ(0U, notifications.size()); | 679 EXPECT_EQ(0U, notifications.size()); |
671 main_test_rfh()->SendNavigate(0, url1); | 680 main_test_rfh()->SendNavigate(0, url1); |
672 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 681 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
673 navigation_entry_committed_counter_ = 0; | 682 navigation_entry_committed_counter_ = 0; |
674 | 683 |
675 ASSERT_TRUE(controller.GetVisibleEntry()); | 684 ASSERT_TRUE(controller.GetVisibleEntry()); |
676 const base::Time timestamp = controller.GetVisibleEntry()->GetTimestamp(); | 685 const base::Time timestamp = controller.GetVisibleEntry()->GetTimestamp(); |
677 EXPECT_FALSE(timestamp.is_null()); | 686 EXPECT_FALSE(timestamp.is_null()); |
678 | 687 |
679 controller.LoadURL(url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 688 controller.LoadURL( |
| 689 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
680 controller.DiscardNonCommittedEntries(); | 690 controller.DiscardNonCommittedEntries(); |
681 EXPECT_EQ(0U, notifications.size()); | 691 EXPECT_EQ(0U, notifications.size()); |
682 | 692 |
683 // Should not have produced a new session history entry. | 693 // Should not have produced a new session history entry. |
684 EXPECT_EQ(controller.GetEntryCount(), 1); | 694 EXPECT_EQ(controller.GetEntryCount(), 1); |
685 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 695 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
686 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 696 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
687 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 697 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
688 EXPECT_FALSE(controller.GetPendingEntry()); | 698 EXPECT_FALSE(controller.GetPendingEntry()); |
689 ASSERT_TRUE(controller.GetVisibleEntry()); | 699 ASSERT_TRUE(controller.GetVisibleEntry()); |
690 EXPECT_FALSE(controller.CanGoBack()); | 700 EXPECT_FALSE(controller.CanGoBack()); |
691 EXPECT_FALSE(controller.CanGoForward()); | 701 EXPECT_FALSE(controller.CanGoForward()); |
692 | 702 |
693 // Timestamp should not have changed. | 703 // Timestamp should not have changed. |
694 EXPECT_EQ(timestamp, controller.GetVisibleEntry()->GetTimestamp()); | 704 EXPECT_EQ(timestamp, controller.GetVisibleEntry()->GetTimestamp()); |
695 } | 705 } |
696 | 706 |
697 // Tests navigations that come in unrequested. This happens when the user | 707 // Tests navigations that come in unrequested. This happens when the user |
698 // navigates from the web page, and here we test that there is no pending entry. | 708 // navigates from the web page, and here we test that there is no pending entry. |
699 TEST_F(NavigationControllerTest, LoadURL_NoPending) { | 709 TEST_F(NavigationControllerTest, LoadURL_NoPending) { |
700 NavigationControllerImpl& controller = controller_impl(); | 710 NavigationControllerImpl& controller = controller_impl(); |
701 TestNotificationTracker notifications; | 711 TestNotificationTracker notifications; |
702 RegisterForAllNavNotifications(¬ifications, &controller); | 712 RegisterForAllNavNotifications(¬ifications, &controller); |
703 | 713 |
704 // First make an existing committed entry. | 714 // First make an existing committed entry. |
705 const GURL kExistingURL1("http://eh"); | 715 const GURL kExistingURL1("http://eh"); |
706 controller.LoadURL( | 716 controller.LoadURL( |
707 kExistingURL1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 717 kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
708 main_test_rfh()->SendNavigate(0, kExistingURL1); | 718 main_test_rfh()->SendNavigate(0, kExistingURL1); |
709 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 719 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
710 navigation_entry_committed_counter_ = 0; | 720 navigation_entry_committed_counter_ = 0; |
711 | 721 |
712 // Do a new navigation without making a pending one. | 722 // Do a new navigation without making a pending one. |
713 const GURL kNewURL("http://see"); | 723 const GURL kNewURL("http://see"); |
714 main_test_rfh()->SendNavigate(99, kNewURL); | 724 main_test_rfh()->SendNavigate(99, kNewURL); |
715 | 725 |
716 // There should no longer be any pending entry, and the third navigation we | 726 // There should no longer be any pending entry, and the third navigation we |
717 // just made should be committed. | 727 // just made should be committed. |
718 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 728 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
719 navigation_entry_committed_counter_ = 0; | 729 navigation_entry_committed_counter_ = 0; |
720 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 730 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
721 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 731 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
722 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); | 732 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); |
723 } | 733 } |
724 | 734 |
725 // Tests navigating to a new URL when there is a new pending navigation that is | 735 // Tests navigating to a new URL when there is a new pending navigation that is |
726 // not the one that just loaded. This will happen if the user types in a URL to | 736 // not the one that just loaded. This will happen if the user types in a URL to |
727 // somewhere slow, and then navigates the current page before the typed URL | 737 // somewhere slow, and then navigates the current page before the typed URL |
728 // commits. | 738 // commits. |
729 TEST_F(NavigationControllerTest, LoadURL_NewPending) { | 739 TEST_F(NavigationControllerTest, LoadURL_NewPending) { |
730 NavigationControllerImpl& controller = controller_impl(); | 740 NavigationControllerImpl& controller = controller_impl(); |
731 TestNotificationTracker notifications; | 741 TestNotificationTracker notifications; |
732 RegisterForAllNavNotifications(¬ifications, &controller); | 742 RegisterForAllNavNotifications(¬ifications, &controller); |
733 | 743 |
734 // First make an existing committed entry. | 744 // First make an existing committed entry. |
735 const GURL kExistingURL1("http://eh"); | 745 const GURL kExistingURL1("http://eh"); |
736 controller.LoadURL( | 746 controller.LoadURL( |
737 kExistingURL1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 747 kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
738 main_test_rfh()->SendNavigate(0, kExistingURL1); | 748 main_test_rfh()->SendNavigate(0, kExistingURL1); |
739 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 749 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
740 navigation_entry_committed_counter_ = 0; | 750 navigation_entry_committed_counter_ = 0; |
741 | 751 |
742 // Make a pending entry to somewhere new. | 752 // Make a pending entry to somewhere new. |
743 const GURL kExistingURL2("http://bee"); | 753 const GURL kExistingURL2("http://bee"); |
744 controller.LoadURL( | 754 controller.LoadURL( |
745 kExistingURL2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 755 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
746 EXPECT_EQ(0U, notifications.size()); | 756 EXPECT_EQ(0U, notifications.size()); |
747 | 757 |
748 // After the beforeunload but before it commits, do a new navigation. | 758 // After the beforeunload but before it commits, do a new navigation. |
749 test_rvh()->SendBeforeUnloadACK(true); | 759 test_rvh()->SendBeforeUnloadACK(true); |
750 const GURL kNewURL("http://see"); | 760 const GURL kNewURL("http://see"); |
751 contents()->GetPendingMainFrame()->SendNavigate(3, kNewURL); | 761 contents()->GetPendingMainFrame()->SendNavigate(3, kNewURL); |
752 | 762 |
753 // There should no longer be any pending entry, and the third navigation we | 763 // There should no longer be any pending entry, and the third navigation we |
754 // just made should be committed. | 764 // just made should be committed. |
755 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 765 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
756 navigation_entry_committed_counter_ = 0; | 766 navigation_entry_committed_counter_ = 0; |
757 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 767 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
758 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 768 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
759 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); | 769 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); |
760 } | 770 } |
761 | 771 |
762 // Tests navigating to a new URL when there is a pending back/forward | 772 // Tests navigating to a new URL when there is a pending back/forward |
763 // navigation. This will happen if the user hits back, but before that commits, | 773 // navigation. This will happen if the user hits back, but before that commits, |
764 // they navigate somewhere new. | 774 // they navigate somewhere new. |
765 TEST_F(NavigationControllerTest, LoadURL_ExistingPending) { | 775 TEST_F(NavigationControllerTest, LoadURL_ExistingPending) { |
766 NavigationControllerImpl& controller = controller_impl(); | 776 NavigationControllerImpl& controller = controller_impl(); |
767 TestNotificationTracker notifications; | 777 TestNotificationTracker notifications; |
768 RegisterForAllNavNotifications(¬ifications, &controller); | 778 RegisterForAllNavNotifications(¬ifications, &controller); |
769 | 779 |
770 // First make some history. | 780 // First make some history. |
771 const GURL kExistingURL1("http://foo/eh"); | 781 const GURL kExistingURL1("http://foo/eh"); |
772 controller.LoadURL( | 782 controller.LoadURL( |
773 kExistingURL1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 783 kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
774 main_test_rfh()->SendNavigate(0, kExistingURL1); | 784 main_test_rfh()->SendNavigate(0, kExistingURL1); |
775 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 785 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
776 navigation_entry_committed_counter_ = 0; | 786 navigation_entry_committed_counter_ = 0; |
777 | 787 |
778 const GURL kExistingURL2("http://foo/bee"); | 788 const GURL kExistingURL2("http://foo/bee"); |
779 controller.LoadURL( | 789 controller.LoadURL( |
780 kExistingURL2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 790 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
781 main_test_rfh()->SendNavigate(1, kExistingURL2); | 791 main_test_rfh()->SendNavigate(1, kExistingURL2); |
782 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 792 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
783 navigation_entry_committed_counter_ = 0; | 793 navigation_entry_committed_counter_ = 0; |
784 | 794 |
785 // Now make a pending back/forward navigation. The zeroth entry should be | 795 // Now make a pending back/forward navigation. The zeroth entry should be |
786 // pending. | 796 // pending. |
787 controller.GoBack(); | 797 controller.GoBack(); |
788 EXPECT_EQ(0U, notifications.size()); | 798 EXPECT_EQ(0U, notifications.size()); |
789 EXPECT_EQ(0, controller.GetPendingEntryIndex()); | 799 EXPECT_EQ(0, controller.GetPendingEntryIndex()); |
790 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 800 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
(...skipping 16 matching lines...) Expand all Loading... |
807 // navigation to a cross-process, privileged URL. This will happen if the user | 817 // navigation to a cross-process, privileged URL. This will happen if the user |
808 // hits back, but before that commits, they navigate somewhere new. | 818 // hits back, but before that commits, they navigate somewhere new. |
809 TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) { | 819 TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) { |
810 NavigationControllerImpl& controller = controller_impl(); | 820 NavigationControllerImpl& controller = controller_impl(); |
811 TestNotificationTracker notifications; | 821 TestNotificationTracker notifications; |
812 RegisterForAllNavNotifications(¬ifications, &controller); | 822 RegisterForAllNavNotifications(¬ifications, &controller); |
813 | 823 |
814 // First make some history, starting with a privileged URL. | 824 // First make some history, starting with a privileged URL. |
815 const GURL kExistingURL1("http://privileged"); | 825 const GURL kExistingURL1("http://privileged"); |
816 controller.LoadURL( | 826 controller.LoadURL( |
817 kExistingURL1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 827 kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
818 // Pretend it has bindings so we can tell if we incorrectly copy it. | 828 // Pretend it has bindings so we can tell if we incorrectly copy it. |
819 test_rvh()->AllowBindings(2); | 829 test_rvh()->AllowBindings(2); |
820 main_test_rfh()->SendNavigate(0, kExistingURL1); | 830 main_test_rfh()->SendNavigate(0, kExistingURL1); |
821 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 831 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
822 navigation_entry_committed_counter_ = 0; | 832 navigation_entry_committed_counter_ = 0; |
823 | 833 |
824 // Navigate cross-process to a second URL. | 834 // Navigate cross-process to a second URL. |
825 const GURL kExistingURL2("http://foo/eh"); | 835 const GURL kExistingURL2("http://foo/eh"); |
826 controller.LoadURL( | 836 controller.LoadURL( |
827 kExistingURL2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 837 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
828 test_rvh()->SendBeforeUnloadACK(true); | 838 test_rvh()->SendBeforeUnloadACK(true); |
829 TestRenderFrameHost* foo_rfh = contents()->GetPendingMainFrame(); | 839 TestRenderFrameHost* foo_rfh = contents()->GetPendingMainFrame(); |
830 foo_rfh->SendNavigate(1, kExistingURL2); | 840 foo_rfh->SendNavigate(1, kExistingURL2); |
831 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 841 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
832 navigation_entry_committed_counter_ = 0; | 842 navigation_entry_committed_counter_ = 0; |
833 | 843 |
834 // Now make a pending back/forward navigation to a privileged entry. | 844 // Now make a pending back/forward navigation to a privileged entry. |
835 // The zeroth entry should be pending. | 845 // The zeroth entry should be pending. |
836 controller.GoBack(); | 846 controller.GoBack(); |
837 foo_rfh->GetRenderViewHost()->SendBeforeUnloadACK(true); | 847 foo_rfh->GetRenderViewHost()->SendBeforeUnloadACK(true); |
(...skipping 23 matching lines...) Expand all Loading... |
861 // This will happen if the user enters a URL, but before that commits, the | 871 // This will happen if the user enters a URL, but before that commits, the |
862 // current page fires history.back(). | 872 // current page fires history.back(). |
863 TEST_F(NavigationControllerTest, LoadURL_BackPreemptsPending) { | 873 TEST_F(NavigationControllerTest, LoadURL_BackPreemptsPending) { |
864 NavigationControllerImpl& controller = controller_impl(); | 874 NavigationControllerImpl& controller = controller_impl(); |
865 TestNotificationTracker notifications; | 875 TestNotificationTracker notifications; |
866 RegisterForAllNavNotifications(¬ifications, &controller); | 876 RegisterForAllNavNotifications(¬ifications, &controller); |
867 | 877 |
868 // First make some history. | 878 // First make some history. |
869 const GURL kExistingURL1("http://foo/eh"); | 879 const GURL kExistingURL1("http://foo/eh"); |
870 controller.LoadURL( | 880 controller.LoadURL( |
871 kExistingURL1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 881 kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
872 main_test_rfh()->SendNavigate(0, kExistingURL1); | 882 main_test_rfh()->SendNavigate(0, kExistingURL1); |
873 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 883 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
874 navigation_entry_committed_counter_ = 0; | 884 navigation_entry_committed_counter_ = 0; |
875 | 885 |
876 const GURL kExistingURL2("http://foo/bee"); | 886 const GURL kExistingURL2("http://foo/bee"); |
877 controller.LoadURL( | 887 controller.LoadURL( |
878 kExistingURL2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 888 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
879 main_test_rfh()->SendNavigate(1, kExistingURL2); | 889 main_test_rfh()->SendNavigate(1, kExistingURL2); |
880 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 890 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
881 navigation_entry_committed_counter_ = 0; | 891 navigation_entry_committed_counter_ = 0; |
882 | 892 |
883 // Now make a pending new navigation. | 893 // Now make a pending new navigation. |
884 const GURL kNewURL("http://foo/see"); | 894 const GURL kNewURL("http://foo/see"); |
885 controller.LoadURL( | 895 controller.LoadURL( |
886 kNewURL, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 896 kNewURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
887 EXPECT_EQ(0U, notifications.size()); | 897 EXPECT_EQ(0U, notifications.size()); |
888 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 898 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
889 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 899 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
890 | 900 |
891 // Before that commits, a back navigation from the renderer commits. | 901 // Before that commits, a back navigation from the renderer commits. |
892 main_test_rfh()->SendNavigate(0, kExistingURL1); | 902 main_test_rfh()->SendNavigate(0, kExistingURL1); |
893 | 903 |
894 // There should no longer be any pending entry, and the back navigation we | 904 // There should no longer be any pending entry, and the back navigation we |
895 // just made should be committed. | 905 // just made should be committed. |
896 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 906 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
(...skipping 15 matching lines...) Expand all Loading... |
912 scoped_ptr<TestWebContentsDelegate> delegate(new TestWebContentsDelegate()); | 922 scoped_ptr<TestWebContentsDelegate> delegate(new TestWebContentsDelegate()); |
913 EXPECT_FALSE(contents()->GetDelegate()); | 923 EXPECT_FALSE(contents()->GetDelegate()); |
914 contents()->SetDelegate(delegate.get()); | 924 contents()->SetDelegate(delegate.get()); |
915 | 925 |
916 // Without any navigations, the renderer starts at about:blank. | 926 // Without any navigations, the renderer starts at about:blank. |
917 const GURL kExistingURL(url::kAboutBlankURL); | 927 const GURL kExistingURL(url::kAboutBlankURL); |
918 | 928 |
919 // Now make a pending new navigation. | 929 // Now make a pending new navigation. |
920 const GURL kNewURL("http://eh"); | 930 const GURL kNewURL("http://eh"); |
921 controller.LoadURL( | 931 controller.LoadURL( |
922 kNewURL, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 932 kNewURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
923 EXPECT_EQ(0U, notifications.size()); | 933 EXPECT_EQ(0U, notifications.size()); |
924 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 934 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
925 EXPECT_TRUE(controller.GetPendingEntry()); | 935 EXPECT_TRUE(controller.GetPendingEntry()); |
926 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); | 936 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); |
927 EXPECT_EQ(1, delegate->navigation_state_change_count()); | 937 EXPECT_EQ(1, delegate->navigation_state_change_count()); |
928 | 938 |
929 // Before that commits, a document.write and location.reload can cause the | 939 // Before that commits, a document.write and location.reload can cause the |
930 // renderer to send a FrameNavigate with page_id -1. | 940 // renderer to send a FrameNavigate with page_id -1. |
931 main_test_rfh()->SendNavigate(-1, kExistingURL); | 941 main_test_rfh()->SendNavigate(-1, kExistingURL); |
932 | 942 |
(...skipping 16 matching lines...) Expand all Loading... |
949 RegisterForAllNavNotifications(¬ifications, &controller); | 959 RegisterForAllNavNotifications(¬ifications, &controller); |
950 | 960 |
951 // Set a WebContentsDelegate to listen for state changes. | 961 // Set a WebContentsDelegate to listen for state changes. |
952 scoped_ptr<TestWebContentsDelegate> delegate(new TestWebContentsDelegate()); | 962 scoped_ptr<TestWebContentsDelegate> delegate(new TestWebContentsDelegate()); |
953 EXPECT_FALSE(contents()->GetDelegate()); | 963 EXPECT_FALSE(contents()->GetDelegate()); |
954 contents()->SetDelegate(delegate.get()); | 964 contents()->SetDelegate(delegate.get()); |
955 | 965 |
956 // Start with a pending new navigation. | 966 // Start with a pending new navigation. |
957 const GURL kNewURL("http://eh"); | 967 const GURL kNewURL("http://eh"); |
958 controller.LoadURL( | 968 controller.LoadURL( |
959 kNewURL, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 969 kNewURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
960 EXPECT_EQ(0U, notifications.size()); | 970 EXPECT_EQ(0U, notifications.size()); |
961 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 971 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
962 EXPECT_TRUE(controller.GetPendingEntry()); | 972 EXPECT_TRUE(controller.GetPendingEntry()); |
963 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); | 973 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); |
964 EXPECT_EQ(1, delegate->navigation_state_change_count()); | 974 EXPECT_EQ(1, delegate->navigation_state_change_count()); |
965 | 975 |
966 // It may abort before committing, if it's a download or due to a stop or | 976 // It may abort before committing, if it's a download or due to a stop or |
967 // a new navigation from the user. | 977 // a new navigation from the user. |
968 FrameHostMsg_DidFailProvisionalLoadWithError_Params params; | 978 FrameHostMsg_DidFailProvisionalLoadWithError_Params params; |
969 params.error_code = net::ERR_ABORTED; | 979 params.error_code = net::ERR_ABORTED; |
(...skipping 25 matching lines...) Expand all Loading... |
995 // Tests that the pending URL is not visible during a renderer-initiated | 1005 // Tests that the pending URL is not visible during a renderer-initiated |
996 // redirect and abort. See http://crbug.com/83031. | 1006 // redirect and abort. See http://crbug.com/83031. |
997 TEST_F(NavigationControllerTest, LoadURL_RedirectAbortDoesntShowPendingURL) { | 1007 TEST_F(NavigationControllerTest, LoadURL_RedirectAbortDoesntShowPendingURL) { |
998 NavigationControllerImpl& controller = controller_impl(); | 1008 NavigationControllerImpl& controller = controller_impl(); |
999 TestNotificationTracker notifications; | 1009 TestNotificationTracker notifications; |
1000 RegisterForAllNavNotifications(¬ifications, &controller); | 1010 RegisterForAllNavNotifications(¬ifications, &controller); |
1001 | 1011 |
1002 // First make an existing committed entry. | 1012 // First make an existing committed entry. |
1003 const GURL kExistingURL("http://foo/eh"); | 1013 const GURL kExistingURL("http://foo/eh"); |
1004 controller.LoadURL(kExistingURL, content::Referrer(), | 1014 controller.LoadURL(kExistingURL, content::Referrer(), |
1005 content::PAGE_TRANSITION_TYPED, std::string()); | 1015 ui::PAGE_TRANSITION_TYPED, std::string()); |
1006 main_test_rfh()->SendNavigate(1, kExistingURL); | 1016 main_test_rfh()->SendNavigate(1, kExistingURL); |
1007 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1017 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1008 navigation_entry_committed_counter_ = 0; | 1018 navigation_entry_committed_counter_ = 0; |
1009 | 1019 |
1010 // Set a WebContentsDelegate to listen for state changes. | 1020 // Set a WebContentsDelegate to listen for state changes. |
1011 scoped_ptr<TestWebContentsDelegate> delegate(new TestWebContentsDelegate()); | 1021 scoped_ptr<TestWebContentsDelegate> delegate(new TestWebContentsDelegate()); |
1012 EXPECT_FALSE(contents()->GetDelegate()); | 1022 EXPECT_FALSE(contents()->GetDelegate()); |
1013 contents()->SetDelegate(delegate.get()); | 1023 contents()->SetDelegate(delegate.get()); |
1014 | 1024 |
1015 // Now make a pending new navigation, initiated by the renderer. | 1025 // Now make a pending new navigation, initiated by the renderer. |
1016 const GURL kNewURL("http://foo/bee"); | 1026 const GURL kNewURL("http://foo/bee"); |
1017 NavigationController::LoadURLParams load_url_params(kNewURL); | 1027 NavigationController::LoadURLParams load_url_params(kNewURL); |
1018 load_url_params.transition_type = PAGE_TRANSITION_TYPED; | 1028 load_url_params.transition_type = ui::PAGE_TRANSITION_TYPED; |
1019 load_url_params.is_renderer_initiated = true; | 1029 load_url_params.is_renderer_initiated = true; |
1020 controller.LoadURLWithParams(load_url_params); | 1030 controller.LoadURLWithParams(load_url_params); |
1021 EXPECT_EQ(0U, notifications.size()); | 1031 EXPECT_EQ(0U, notifications.size()); |
1022 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 1032 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
1023 EXPECT_TRUE(controller.GetPendingEntry()); | 1033 EXPECT_TRUE(controller.GetPendingEntry()); |
1024 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 1034 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
1025 EXPECT_EQ(0, delegate->navigation_state_change_count()); | 1035 EXPECT_EQ(0, delegate->navigation_state_change_count()); |
1026 | 1036 |
1027 // The visible entry should be the last committed URL, not the pending one. | 1037 // The visible entry should be the last committed URL, not the pending one. |
1028 EXPECT_EQ(kExistingURL, controller.GetVisibleEntry()->GetURL()); | 1038 EXPECT_EQ(kExistingURL, controller.GetVisibleEntry()->GetURL()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 TEST_F(NavigationControllerTest, LoadURL_WithBindings) { | 1079 TEST_F(NavigationControllerTest, LoadURL_WithBindings) { |
1070 NavigationControllerImpl& controller = controller_impl(); | 1080 NavigationControllerImpl& controller = controller_impl(); |
1071 TestNotificationTracker notifications; | 1081 TestNotificationTracker notifications; |
1072 RegisterForAllNavNotifications(¬ifications, &controller); | 1082 RegisterForAllNavNotifications(¬ifications, &controller); |
1073 std::vector<GURL> url_chain; | 1083 std::vector<GURL> url_chain; |
1074 | 1084 |
1075 const GURL url1("http://foo1"); | 1085 const GURL url1("http://foo1"); |
1076 const GURL url2("http://foo2"); | 1086 const GURL url2("http://foo2"); |
1077 | 1087 |
1078 // Navigate to a first, unprivileged URL. | 1088 // Navigate to a first, unprivileged URL. |
1079 controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 1089 controller.LoadURL( |
| 1090 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1080 EXPECT_EQ(NavigationEntryImpl::kInvalidBindings, | 1091 EXPECT_EQ(NavigationEntryImpl::kInvalidBindings, |
1081 NavigationEntryImpl::FromNavigationEntry( | 1092 NavigationEntryImpl::FromNavigationEntry( |
1082 controller.GetPendingEntry())->bindings()); | 1093 controller.GetPendingEntry())->bindings()); |
1083 | 1094 |
1084 // Commit. | 1095 // Commit. |
1085 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); | 1096 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); |
1086 orig_rfh->SendNavigate(0, url1); | 1097 orig_rfh->SendNavigate(0, url1); |
1087 EXPECT_EQ(controller.GetEntryCount(), 1); | 1098 EXPECT_EQ(controller.GetEntryCount(), 1); |
1088 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 1099 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
1089 EXPECT_EQ(0, NavigationEntryImpl::FromNavigationEntry( | 1100 EXPECT_EQ(0, NavigationEntryImpl::FromNavigationEntry( |
1090 controller.GetLastCommittedEntry())->bindings()); | 1101 controller.GetLastCommittedEntry())->bindings()); |
1091 | 1102 |
1092 // Manually increase the number of active views in the SiteInstance | 1103 // Manually increase the number of active views in the SiteInstance |
1093 // that orig_rfh belongs to, to prevent it from being destroyed when | 1104 // that orig_rfh belongs to, to prevent it from being destroyed when |
1094 // it gets swapped out, so that we can reuse orig_rfh when the | 1105 // it gets swapped out, so that we can reuse orig_rfh when the |
1095 // controller goes back. | 1106 // controller goes back. |
1096 static_cast<SiteInstanceImpl*>(orig_rfh->GetSiteInstance())-> | 1107 static_cast<SiteInstanceImpl*>(orig_rfh->GetSiteInstance())-> |
1097 increment_active_view_count(); | 1108 increment_active_view_count(); |
1098 | 1109 |
1099 // Navigate to a second URL, simulate the beforeunload ack for the cross-site | 1110 // Navigate to a second URL, simulate the beforeunload ack for the cross-site |
1100 // transition, and set bindings on the pending RenderViewHost to simulate a | 1111 // transition, and set bindings on the pending RenderViewHost to simulate a |
1101 // privileged url. | 1112 // privileged url. |
1102 controller.LoadURL(url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 1113 controller.LoadURL( |
| 1114 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1103 orig_rfh->GetRenderViewHost()->SendBeforeUnloadACK(true); | 1115 orig_rfh->GetRenderViewHost()->SendBeforeUnloadACK(true); |
1104 TestRenderFrameHost* new_rfh = contents()->GetPendingMainFrame(); | 1116 TestRenderFrameHost* new_rfh = contents()->GetPendingMainFrame(); |
1105 new_rfh->GetRenderViewHost()->AllowBindings(1); | 1117 new_rfh->GetRenderViewHost()->AllowBindings(1); |
1106 new_rfh->SendNavigate(1, url2); | 1118 new_rfh->SendNavigate(1, url2); |
1107 | 1119 |
1108 // The second load should be committed, and bindings should be remembered. | 1120 // The second load should be committed, and bindings should be remembered. |
1109 EXPECT_EQ(controller.GetEntryCount(), 2); | 1121 EXPECT_EQ(controller.GetEntryCount(), 2); |
1110 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 1122 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
1111 EXPECT_TRUE(controller.CanGoBack()); | 1123 EXPECT_TRUE(controller.CanGoBack()); |
1112 EXPECT_EQ(1, NavigationEntryImpl::FromNavigationEntry( | 1124 EXPECT_EQ(1, NavigationEntryImpl::FromNavigationEntry( |
1113 controller.GetLastCommittedEntry())->bindings()); | 1125 controller.GetLastCommittedEntry())->bindings()); |
1114 | 1126 |
1115 // Going back, the first entry should still appear unprivileged. | 1127 // Going back, the first entry should still appear unprivileged. |
1116 controller.GoBack(); | 1128 controller.GoBack(); |
1117 new_rfh->GetRenderViewHost()->SendBeforeUnloadACK(true); | 1129 new_rfh->GetRenderViewHost()->SendBeforeUnloadACK(true); |
1118 orig_rfh->SendNavigate(0, url1); | 1130 orig_rfh->SendNavigate(0, url1); |
1119 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 1131 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
1120 EXPECT_EQ(0, NavigationEntryImpl::FromNavigationEntry( | 1132 EXPECT_EQ(0, NavigationEntryImpl::FromNavigationEntry( |
1121 controller.GetLastCommittedEntry())->bindings()); | 1133 controller.GetLastCommittedEntry())->bindings()); |
1122 } | 1134 } |
1123 | 1135 |
1124 TEST_F(NavigationControllerTest, Reload) { | 1136 TEST_F(NavigationControllerTest, Reload) { |
1125 NavigationControllerImpl& controller = controller_impl(); | 1137 NavigationControllerImpl& controller = controller_impl(); |
1126 TestNotificationTracker notifications; | 1138 TestNotificationTracker notifications; |
1127 RegisterForAllNavNotifications(¬ifications, &controller); | 1139 RegisterForAllNavNotifications(¬ifications, &controller); |
1128 | 1140 |
1129 const GURL url1("http://foo1"); | 1141 const GURL url1("http://foo1"); |
1130 | 1142 |
1131 controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 1143 controller.LoadURL( |
| 1144 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1132 EXPECT_EQ(0U, notifications.size()); | 1145 EXPECT_EQ(0U, notifications.size()); |
1133 main_test_rfh()->SendNavigate(0, url1); | 1146 main_test_rfh()->SendNavigate(0, url1); |
1134 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1147 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1135 navigation_entry_committed_counter_ = 0; | 1148 navigation_entry_committed_counter_ = 0; |
1136 ASSERT_TRUE(controller.GetVisibleEntry()); | 1149 ASSERT_TRUE(controller.GetVisibleEntry()); |
1137 controller.GetVisibleEntry()->SetTitle(base::ASCIIToUTF16("Title")); | 1150 controller.GetVisibleEntry()->SetTitle(base::ASCIIToUTF16("Title")); |
1138 controller.Reload(true); | 1151 controller.Reload(true); |
1139 EXPECT_EQ(0U, notifications.size()); | 1152 EXPECT_EQ(0U, notifications.size()); |
1140 | 1153 |
1141 const base::Time timestamp = controller.GetVisibleEntry()->GetTimestamp(); | 1154 const base::Time timestamp = controller.GetVisibleEntry()->GetTimestamp(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 | 1187 |
1175 // Tests what happens when a reload navigation produces a new page. | 1188 // Tests what happens when a reload navigation produces a new page. |
1176 TEST_F(NavigationControllerTest, Reload_GeneratesNewPage) { | 1189 TEST_F(NavigationControllerTest, Reload_GeneratesNewPage) { |
1177 NavigationControllerImpl& controller = controller_impl(); | 1190 NavigationControllerImpl& controller = controller_impl(); |
1178 TestNotificationTracker notifications; | 1191 TestNotificationTracker notifications; |
1179 RegisterForAllNavNotifications(¬ifications, &controller); | 1192 RegisterForAllNavNotifications(¬ifications, &controller); |
1180 | 1193 |
1181 const GURL url1("http://foo1"); | 1194 const GURL url1("http://foo1"); |
1182 const GURL url2("http://foo2"); | 1195 const GURL url2("http://foo2"); |
1183 | 1196 |
1184 controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 1197 controller.LoadURL( |
| 1198 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1185 main_test_rfh()->SendNavigate(0, url1); | 1199 main_test_rfh()->SendNavigate(0, url1); |
1186 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1200 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1187 navigation_entry_committed_counter_ = 0; | 1201 navigation_entry_committed_counter_ = 0; |
1188 | 1202 |
1189 controller.Reload(true); | 1203 controller.Reload(true); |
1190 EXPECT_EQ(0U, notifications.size()); | 1204 EXPECT_EQ(0U, notifications.size()); |
1191 | 1205 |
1192 main_test_rfh()->SendNavigate(1, url2); | 1206 main_test_rfh()->SendNavigate(1, url2); |
1193 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1207 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1194 navigation_entry_committed_counter_ = 0; | 1208 navigation_entry_committed_counter_ = 0; |
1195 | 1209 |
1196 // Now the reload is committed. | 1210 // Now the reload is committed. |
1197 EXPECT_EQ(controller.GetEntryCount(), 2); | 1211 EXPECT_EQ(controller.GetEntryCount(), 2); |
1198 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); | 1212 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); |
1199 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 1213 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
1200 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 1214 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
1201 EXPECT_FALSE(controller.GetPendingEntry()); | 1215 EXPECT_FALSE(controller.GetPendingEntry()); |
1202 EXPECT_TRUE(controller.CanGoBack()); | 1216 EXPECT_TRUE(controller.CanGoBack()); |
1203 EXPECT_FALSE(controller.CanGoForward()); | 1217 EXPECT_FALSE(controller.CanGoForward()); |
1204 } | 1218 } |
1205 | 1219 |
1206 // This test ensures that when a guest renderer reloads, the reload goes through | 1220 // This test ensures that when a guest renderer reloads, the reload goes through |
1207 // without ending up in the "we have a wrong process for the URL" branch in | 1221 // without ending up in the "we have a wrong process for the URL" branch in |
1208 // NavigationControllerImpl::ReloadInternal. | 1222 // NavigationControllerImpl::ReloadInternal. |
1209 TEST_F(NavigationControllerTest, ReloadWithGuest) { | 1223 TEST_F(NavigationControllerTest, ReloadWithGuest) { |
1210 NavigationControllerImpl& controller = controller_impl(); | 1224 NavigationControllerImpl& controller = controller_impl(); |
1211 | 1225 |
1212 const GURL url1("http://foo1"); | 1226 const GURL url1("http://foo1"); |
1213 controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 1227 controller.LoadURL( |
| 1228 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1214 main_test_rfh()->SendNavigate(0, url1); | 1229 main_test_rfh()->SendNavigate(0, url1); |
1215 ASSERT_TRUE(controller.GetVisibleEntry()); | 1230 ASSERT_TRUE(controller.GetVisibleEntry()); |
1216 | 1231 |
1217 // Make the entry believe its RenderProcessHost is a guest. | 1232 // Make the entry believe its RenderProcessHost is a guest. |
1218 NavigationEntryImpl* entry1 = | 1233 NavigationEntryImpl* entry1 = |
1219 NavigationEntryImpl::FromNavigationEntry(controller.GetVisibleEntry()); | 1234 NavigationEntryImpl::FromNavigationEntry(controller.GetVisibleEntry()); |
1220 reinterpret_cast<MockRenderProcessHost*>( | 1235 reinterpret_cast<MockRenderProcessHost*>( |
1221 entry1->site_instance()->GetProcess())->set_is_isolated_guest(true); | 1236 entry1->site_instance()->GetProcess())->set_is_isolated_guest(true); |
1222 | 1237 |
1223 // And reload. | 1238 // And reload. |
(...skipping 14 matching lines...) Expand all Loading... |
1238 TEST_F(NavigationControllerTest, ReloadOriginalRequestURL) { | 1253 TEST_F(NavigationControllerTest, ReloadOriginalRequestURL) { |
1239 NavigationControllerImpl& controller = controller_impl(); | 1254 NavigationControllerImpl& controller = controller_impl(); |
1240 TestNotificationTracker notifications; | 1255 TestNotificationTracker notifications; |
1241 RegisterForAllNavNotifications(¬ifications, &controller); | 1256 RegisterForAllNavNotifications(¬ifications, &controller); |
1242 | 1257 |
1243 const GURL original_url("http://foo1"); | 1258 const GURL original_url("http://foo1"); |
1244 const GURL final_url("http://foo2"); | 1259 const GURL final_url("http://foo2"); |
1245 | 1260 |
1246 // Load up the original URL, but get redirected. | 1261 // Load up the original URL, but get redirected. |
1247 controller.LoadURL( | 1262 controller.LoadURL( |
1248 original_url, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 1263 original_url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1249 EXPECT_EQ(0U, notifications.size()); | 1264 EXPECT_EQ(0U, notifications.size()); |
1250 main_test_rfh()->SendNavigateWithOriginalRequestURL( | 1265 main_test_rfh()->SendNavigateWithOriginalRequestURL( |
1251 0, final_url, original_url); | 1266 0, final_url, original_url); |
1252 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1267 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1253 navigation_entry_committed_counter_ = 0; | 1268 navigation_entry_committed_counter_ = 0; |
1254 | 1269 |
1255 // The NavigationEntry should save both the original URL and the final | 1270 // The NavigationEntry should save both the original URL and the final |
1256 // redirected URL. | 1271 // redirected URL. |
1257 EXPECT_EQ( | 1272 EXPECT_EQ( |
1258 original_url, controller.GetVisibleEntry()->GetOriginalRequestURL()); | 1273 original_url, controller.GetVisibleEntry()->GetOriginalRequestURL()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 EXPECT_FALSE(controller.CanGoForward()); | 1308 EXPECT_FALSE(controller.CanGoForward()); |
1294 } | 1309 } |
1295 | 1310 |
1296 #endif // !defined(OS_ANDROID) | 1311 #endif // !defined(OS_ANDROID) |
1297 | 1312 |
1298 // Test that certain non-persisted NavigationEntryImpl values get reset after | 1313 // Test that certain non-persisted NavigationEntryImpl values get reset after |
1299 // commit. | 1314 // commit. |
1300 TEST_F(NavigationControllerTest, ResetEntryValuesAfterCommit) { | 1315 TEST_F(NavigationControllerTest, ResetEntryValuesAfterCommit) { |
1301 NavigationControllerImpl& controller = controller_impl(); | 1316 NavigationControllerImpl& controller = controller_impl(); |
1302 const GURL url1("http://foo1"); | 1317 const GURL url1("http://foo1"); |
1303 controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 1318 controller.LoadURL( |
| 1319 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1304 | 1320 |
1305 // Set up some sample values. | 1321 // Set up some sample values. |
1306 const unsigned char* raw_data = | 1322 const unsigned char* raw_data = |
1307 reinterpret_cast<const unsigned char*>("post\n\n\0data"); | 1323 reinterpret_cast<const unsigned char*>("post\n\n\0data"); |
1308 const int length = 11; | 1324 const int length = 11; |
1309 std::vector<unsigned char> post_data_vector(raw_data, raw_data+length); | 1325 std::vector<unsigned char> post_data_vector(raw_data, raw_data+length); |
1310 scoped_refptr<base::RefCountedBytes> post_data = | 1326 scoped_refptr<base::RefCountedBytes> post_data = |
1311 base::RefCountedBytes::TakeVector(&post_data_vector); | 1327 base::RefCountedBytes::TakeVector(&post_data_vector); |
1312 GlobalRequestID transfer_id(3, 4); | 1328 GlobalRequestID transfer_id(3, 4); |
1313 std::vector<GURL> redirects; | 1329 std::vector<GURL> redirects; |
(...skipping 25 matching lines...) Expand all Loading... |
1339 EXPECT_EQ(GlobalRequestID(-1, -1), | 1355 EXPECT_EQ(GlobalRequestID(-1, -1), |
1340 committed_entry->transferred_global_request_id()); | 1356 committed_entry->transferred_global_request_id()); |
1341 EXPECT_FALSE(committed_entry->should_replace_entry()); | 1357 EXPECT_FALSE(committed_entry->should_replace_entry()); |
1342 EXPECT_FALSE(committed_entry->should_clear_history_list()); | 1358 EXPECT_FALSE(committed_entry->should_clear_history_list()); |
1343 } | 1359 } |
1344 | 1360 |
1345 // Test that Redirects are preserved after a commit. | 1361 // Test that Redirects are preserved after a commit. |
1346 TEST_F(NavigationControllerTest, RedirectsAreNotResetByCommit) { | 1362 TEST_F(NavigationControllerTest, RedirectsAreNotResetByCommit) { |
1347 NavigationControllerImpl& controller = controller_impl(); | 1363 NavigationControllerImpl& controller = controller_impl(); |
1348 const GURL url1("http://foo1"); | 1364 const GURL url1("http://foo1"); |
1349 controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 1365 controller.LoadURL( |
| 1366 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1350 | 1367 |
1351 // Set up some redirect values. | 1368 // Set up some redirect values. |
1352 std::vector<GURL> redirects; | 1369 std::vector<GURL> redirects; |
1353 redirects.push_back(GURL("http://foo2")); | 1370 redirects.push_back(GURL("http://foo2")); |
1354 | 1371 |
1355 // Set redirects on the pending entry. | 1372 // Set redirects on the pending entry. |
1356 NavigationEntryImpl* pending_entry = | 1373 NavigationEntryImpl* pending_entry = |
1357 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry()); | 1374 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry()); |
1358 pending_entry->SetRedirectChain(redirects); | 1375 pending_entry->SetRedirectChain(redirects); |
1359 EXPECT_EQ(1U, pending_entry->GetRedirectChain().size()); | 1376 EXPECT_EQ(1U, pending_entry->GetRedirectChain().size()); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1430 TEST_F(NavigationControllerTest, Back_GeneratesNewPage) { | 1447 TEST_F(NavigationControllerTest, Back_GeneratesNewPage) { |
1431 NavigationControllerImpl& controller = controller_impl(); | 1448 NavigationControllerImpl& controller = controller_impl(); |
1432 TestNotificationTracker notifications; | 1449 TestNotificationTracker notifications; |
1433 RegisterForAllNavNotifications(¬ifications, &controller); | 1450 RegisterForAllNavNotifications(¬ifications, &controller); |
1434 | 1451 |
1435 const GURL url1("http://foo/1"); | 1452 const GURL url1("http://foo/1"); |
1436 const GURL url2("http://foo/2"); | 1453 const GURL url2("http://foo/2"); |
1437 const GURL url3("http://foo/3"); | 1454 const GURL url3("http://foo/3"); |
1438 | 1455 |
1439 controller.LoadURL( | 1456 controller.LoadURL( |
1440 url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 1457 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1441 main_test_rfh()->SendNavigate(0, url1); | 1458 main_test_rfh()->SendNavigate(0, url1); |
1442 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1459 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1443 navigation_entry_committed_counter_ = 0; | 1460 navigation_entry_committed_counter_ = 0; |
1444 | 1461 |
1445 controller.LoadURL(url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 1462 controller.LoadURL( |
| 1463 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1446 main_test_rfh()->SendNavigate(1, url2); | 1464 main_test_rfh()->SendNavigate(1, url2); |
1447 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1465 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1448 navigation_entry_committed_counter_ = 0; | 1466 navigation_entry_committed_counter_ = 0; |
1449 | 1467 |
1450 controller.GoBack(); | 1468 controller.GoBack(); |
1451 EXPECT_EQ(0U, notifications.size()); | 1469 EXPECT_EQ(0U, notifications.size()); |
1452 | 1470 |
1453 // We should now have a pending navigation to go back. | 1471 // We should now have a pending navigation to go back. |
1454 EXPECT_EQ(controller.GetEntryCount(), 2); | 1472 EXPECT_EQ(controller.GetEntryCount(), 2); |
1455 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); | 1473 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); |
(...skipping 26 matching lines...) Expand all Loading... |
1482 | 1500 |
1483 const GURL kUrl1("http://foo1"); | 1501 const GURL kUrl1("http://foo1"); |
1484 const GURL kUrl2("http://foo2"); | 1502 const GURL kUrl2("http://foo2"); |
1485 const GURL kUrl3("http://foo3"); | 1503 const GURL kUrl3("http://foo3"); |
1486 | 1504 |
1487 // First navigate two places so we have some back history. | 1505 // First navigate two places so we have some back history. |
1488 main_test_rfh()->SendNavigate(0, kUrl1); | 1506 main_test_rfh()->SendNavigate(0, kUrl1); |
1489 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1507 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1490 navigation_entry_committed_counter_ = 0; | 1508 navigation_entry_committed_counter_ = 0; |
1491 | 1509 |
1492 // controller.LoadURL(kUrl2, PAGE_TRANSITION_TYPED); | 1510 // controller.LoadURL(kUrl2, ui::PAGE_TRANSITION_TYPED); |
1493 main_test_rfh()->SendNavigate(1, kUrl2); | 1511 main_test_rfh()->SendNavigate(1, kUrl2); |
1494 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1512 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1495 navigation_entry_committed_counter_ = 0; | 1513 navigation_entry_committed_counter_ = 0; |
1496 | 1514 |
1497 // Now start a new pending navigation and go back before it commits. | 1515 // Now start a new pending navigation and go back before it commits. |
1498 controller.LoadURL(kUrl3, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 1516 controller.LoadURL( |
| 1517 kUrl3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1499 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 1518 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
1500 EXPECT_EQ(kUrl3, controller.GetPendingEntry()->GetURL()); | 1519 EXPECT_EQ(kUrl3, controller.GetPendingEntry()->GetURL()); |
1501 controller.GoBack(); | 1520 controller.GoBack(); |
1502 | 1521 |
1503 // The pending navigation should now be the "back" item and the new one | 1522 // The pending navigation should now be the "back" item and the new one |
1504 // should be gone. | 1523 // should be gone. |
1505 EXPECT_EQ(0, controller.GetPendingEntryIndex()); | 1524 EXPECT_EQ(0, controller.GetPendingEntryIndex()); |
1506 EXPECT_EQ(kUrl1, controller.GetPendingEntry()->GetURL()); | 1525 EXPECT_EQ(kUrl1, controller.GetPendingEntry()->GetURL()); |
1507 } | 1526 } |
1508 | 1527 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1671 // as SAME_PAGE navigation even when we are redirected to some other page. | 1690 // as SAME_PAGE navigation even when we are redirected to some other page. |
1672 TEST_F(NavigationControllerTest, Redirect) { | 1691 TEST_F(NavigationControllerTest, Redirect) { |
1673 NavigationControllerImpl& controller = controller_impl(); | 1692 NavigationControllerImpl& controller = controller_impl(); |
1674 TestNotificationTracker notifications; | 1693 TestNotificationTracker notifications; |
1675 RegisterForAllNavNotifications(¬ifications, &controller); | 1694 RegisterForAllNavNotifications(¬ifications, &controller); |
1676 | 1695 |
1677 const GURL url1("http://foo1"); | 1696 const GURL url1("http://foo1"); |
1678 const GURL url2("http://foo2"); // Redirection target | 1697 const GURL url2("http://foo2"); // Redirection target |
1679 | 1698 |
1680 // First request | 1699 // First request |
1681 controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 1700 controller.LoadURL( |
| 1701 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1682 | 1702 |
1683 EXPECT_EQ(0U, notifications.size()); | 1703 EXPECT_EQ(0U, notifications.size()); |
1684 main_test_rfh()->SendNavigate(0, url2); | 1704 main_test_rfh()->SendNavigate(0, url2); |
1685 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1705 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1686 navigation_entry_committed_counter_ = 0; | 1706 navigation_entry_committed_counter_ = 0; |
1687 | 1707 |
1688 // Second request | 1708 // Second request |
1689 controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 1709 controller.LoadURL( |
| 1710 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1690 | 1711 |
1691 EXPECT_TRUE(controller.GetPendingEntry()); | 1712 EXPECT_TRUE(controller.GetPendingEntry()); |
1692 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 1713 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
1693 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); | 1714 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); |
1694 | 1715 |
1695 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 1716 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
1696 params.page_id = 0; | 1717 params.page_id = 0; |
1697 params.url = url2; | 1718 params.url = url2; |
1698 params.transition = PAGE_TRANSITION_SERVER_REDIRECT; | 1719 params.transition = ui::PAGE_TRANSITION_SERVER_REDIRECT; |
1699 params.redirects.push_back(GURL("http://foo1")); | 1720 params.redirects.push_back(GURL("http://foo1")); |
1700 params.redirects.push_back(GURL("http://foo2")); | 1721 params.redirects.push_back(GURL("http://foo2")); |
1701 params.should_update_history = false; | 1722 params.should_update_history = false; |
1702 params.gesture = NavigationGestureAuto; | 1723 params.gesture = NavigationGestureAuto; |
1703 params.is_post = false; | 1724 params.is_post = false; |
1704 params.page_state = PageState::CreateFromURL(url2); | 1725 params.page_state = PageState::CreateFromURL(url2); |
1705 | 1726 |
1706 LoadCommittedDetails details; | 1727 LoadCommittedDetails details; |
1707 | 1728 |
1708 EXPECT_EQ(0U, notifications.size()); | 1729 EXPECT_EQ(0U, notifications.size()); |
(...skipping 19 matching lines...) Expand all Loading... |
1728 // must be cleared. http://crbug.com/21245 | 1749 // must be cleared. http://crbug.com/21245 |
1729 TEST_F(NavigationControllerTest, PostThenRedirect) { | 1750 TEST_F(NavigationControllerTest, PostThenRedirect) { |
1730 NavigationControllerImpl& controller = controller_impl(); | 1751 NavigationControllerImpl& controller = controller_impl(); |
1731 TestNotificationTracker notifications; | 1752 TestNotificationTracker notifications; |
1732 RegisterForAllNavNotifications(¬ifications, &controller); | 1753 RegisterForAllNavNotifications(¬ifications, &controller); |
1733 | 1754 |
1734 const GURL url1("http://foo1"); | 1755 const GURL url1("http://foo1"); |
1735 const GURL url2("http://foo2"); // Redirection target | 1756 const GURL url2("http://foo2"); // Redirection target |
1736 | 1757 |
1737 // First request as POST | 1758 // First request as POST |
1738 controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 1759 controller.LoadURL( |
| 1760 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1739 controller.GetVisibleEntry()->SetHasPostData(true); | 1761 controller.GetVisibleEntry()->SetHasPostData(true); |
1740 | 1762 |
1741 EXPECT_EQ(0U, notifications.size()); | 1763 EXPECT_EQ(0U, notifications.size()); |
1742 main_test_rfh()->SendNavigate(0, url2); | 1764 main_test_rfh()->SendNavigate(0, url2); |
1743 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1765 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1744 navigation_entry_committed_counter_ = 0; | 1766 navigation_entry_committed_counter_ = 0; |
1745 | 1767 |
1746 // Second request | 1768 // Second request |
1747 controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 1769 controller.LoadURL( |
| 1770 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1748 | 1771 |
1749 EXPECT_TRUE(controller.GetPendingEntry()); | 1772 EXPECT_TRUE(controller.GetPendingEntry()); |
1750 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 1773 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
1751 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); | 1774 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); |
1752 | 1775 |
1753 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 1776 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
1754 params.page_id = 0; | 1777 params.page_id = 0; |
1755 params.url = url2; | 1778 params.url = url2; |
1756 params.transition = PAGE_TRANSITION_SERVER_REDIRECT; | 1779 params.transition = ui::PAGE_TRANSITION_SERVER_REDIRECT; |
1757 params.redirects.push_back(GURL("http://foo1")); | 1780 params.redirects.push_back(GURL("http://foo1")); |
1758 params.redirects.push_back(GURL("http://foo2")); | 1781 params.redirects.push_back(GURL("http://foo2")); |
1759 params.should_update_history = false; | 1782 params.should_update_history = false; |
1760 params.gesture = NavigationGestureAuto; | 1783 params.gesture = NavigationGestureAuto; |
1761 params.is_post = false; | 1784 params.is_post = false; |
1762 params.page_state = PageState::CreateFromURL(url2); | 1785 params.page_state = PageState::CreateFromURL(url2); |
1763 | 1786 |
1764 LoadCommittedDetails details; | 1787 LoadCommittedDetails details; |
1765 | 1788 |
1766 EXPECT_EQ(0U, notifications.size()); | 1789 EXPECT_EQ(0U, notifications.size()); |
(...skipping 18 matching lines...) Expand all Loading... |
1785 // A redirect right off the bat should be a NEW_PAGE. | 1808 // A redirect right off the bat should be a NEW_PAGE. |
1786 TEST_F(NavigationControllerTest, ImmediateRedirect) { | 1809 TEST_F(NavigationControllerTest, ImmediateRedirect) { |
1787 NavigationControllerImpl& controller = controller_impl(); | 1810 NavigationControllerImpl& controller = controller_impl(); |
1788 TestNotificationTracker notifications; | 1811 TestNotificationTracker notifications; |
1789 RegisterForAllNavNotifications(¬ifications, &controller); | 1812 RegisterForAllNavNotifications(¬ifications, &controller); |
1790 | 1813 |
1791 const GURL url1("http://foo1"); | 1814 const GURL url1("http://foo1"); |
1792 const GURL url2("http://foo2"); // Redirection target | 1815 const GURL url2("http://foo2"); // Redirection target |
1793 | 1816 |
1794 // First request | 1817 // First request |
1795 controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 1818 controller.LoadURL( |
| 1819 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1796 | 1820 |
1797 EXPECT_TRUE(controller.GetPendingEntry()); | 1821 EXPECT_TRUE(controller.GetPendingEntry()); |
1798 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 1822 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
1799 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); | 1823 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); |
1800 | 1824 |
1801 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 1825 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
1802 params.page_id = 0; | 1826 params.page_id = 0; |
1803 params.url = url2; | 1827 params.url = url2; |
1804 params.transition = PAGE_TRANSITION_SERVER_REDIRECT; | 1828 params.transition = ui::PAGE_TRANSITION_SERVER_REDIRECT; |
1805 params.redirects.push_back(GURL("http://foo1")); | 1829 params.redirects.push_back(GURL("http://foo1")); |
1806 params.redirects.push_back(GURL("http://foo2")); | 1830 params.redirects.push_back(GURL("http://foo2")); |
1807 params.should_update_history = false; | 1831 params.should_update_history = false; |
1808 params.gesture = NavigationGestureAuto; | 1832 params.gesture = NavigationGestureAuto; |
1809 params.is_post = false; | 1833 params.is_post = false; |
1810 params.page_state = PageState::CreateFromURL(url2); | 1834 params.page_state = PageState::CreateFromURL(url2); |
1811 | 1835 |
1812 LoadCommittedDetails details; | 1836 LoadCommittedDetails details; |
1813 | 1837 |
1814 EXPECT_EQ(0U, notifications.size()); | 1838 EXPECT_EQ(0U, notifications.size()); |
(...skipping 23 matching lines...) Expand all Loading... |
1838 | 1862 |
1839 const GURL url1("http://foo1"); | 1863 const GURL url1("http://foo1"); |
1840 main_test_rfh()->SendNavigate(0, url1); | 1864 main_test_rfh()->SendNavigate(0, url1); |
1841 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1865 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1842 navigation_entry_committed_counter_ = 0; | 1866 navigation_entry_committed_counter_ = 0; |
1843 | 1867 |
1844 const GURL url2("http://foo2"); | 1868 const GURL url2("http://foo2"); |
1845 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 1869 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
1846 params.page_id = 1; | 1870 params.page_id = 1; |
1847 params.url = url2; | 1871 params.url = url2; |
1848 params.transition = PAGE_TRANSITION_MANUAL_SUBFRAME; | 1872 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; |
1849 params.should_update_history = false; | 1873 params.should_update_history = false; |
1850 params.gesture = NavigationGestureUser; | 1874 params.gesture = NavigationGestureUser; |
1851 params.is_post = false; | 1875 params.is_post = false; |
1852 params.page_state = PageState::CreateFromURL(url2); | 1876 params.page_state = PageState::CreateFromURL(url2); |
1853 | 1877 |
1854 LoadCommittedDetails details; | 1878 LoadCommittedDetails details; |
1855 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, | 1879 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, |
1856 &details)); | 1880 &details)); |
1857 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1881 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1858 navigation_entry_committed_counter_ = 0; | 1882 navigation_entry_committed_counter_ = 0; |
(...skipping 16 matching lines...) Expand all Loading... |
1875 TEST_F(NavigationControllerTest, SubframeOnEmptyPage) { | 1899 TEST_F(NavigationControllerTest, SubframeOnEmptyPage) { |
1876 NavigationControllerImpl& controller = controller_impl(); | 1900 NavigationControllerImpl& controller = controller_impl(); |
1877 TestNotificationTracker notifications; | 1901 TestNotificationTracker notifications; |
1878 RegisterForAllNavNotifications(¬ifications, &controller); | 1902 RegisterForAllNavNotifications(¬ifications, &controller); |
1879 | 1903 |
1880 // Navigation controller currently has no entries. | 1904 // Navigation controller currently has no entries. |
1881 const GURL url("http://foo2"); | 1905 const GURL url("http://foo2"); |
1882 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 1906 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
1883 params.page_id = 1; | 1907 params.page_id = 1; |
1884 params.url = url; | 1908 params.url = url; |
1885 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; | 1909 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
1886 params.should_update_history = false; | 1910 params.should_update_history = false; |
1887 params.gesture = NavigationGestureAuto; | 1911 params.gesture = NavigationGestureAuto; |
1888 params.is_post = false; | 1912 params.is_post = false; |
1889 params.page_state = PageState::CreateFromURL(url); | 1913 params.page_state = PageState::CreateFromURL(url); |
1890 | 1914 |
1891 LoadCommittedDetails details; | 1915 LoadCommittedDetails details; |
1892 EXPECT_FALSE(controller.RendererDidNavigate(main_test_rfh(), params, | 1916 EXPECT_FALSE(controller.RendererDidNavigate(main_test_rfh(), params, |
1893 &details)); | 1917 &details)); |
1894 EXPECT_EQ(0U, notifications.size()); | 1918 EXPECT_EQ(0U, notifications.size()); |
1895 } | 1919 } |
1896 | 1920 |
1897 // Auto subframes are ones the page loads automatically like ads. They should | 1921 // Auto subframes are ones the page loads automatically like ads. They should |
1898 // not create new navigation entries. | 1922 // not create new navigation entries. |
1899 TEST_F(NavigationControllerTest, AutoSubframe) { | 1923 TEST_F(NavigationControllerTest, AutoSubframe) { |
1900 NavigationControllerImpl& controller = controller_impl(); | 1924 NavigationControllerImpl& controller = controller_impl(); |
1901 TestNotificationTracker notifications; | 1925 TestNotificationTracker notifications; |
1902 RegisterForAllNavNotifications(¬ifications, &controller); | 1926 RegisterForAllNavNotifications(¬ifications, &controller); |
1903 | 1927 |
1904 const GURL url1("http://foo1"); | 1928 const GURL url1("http://foo1"); |
1905 main_test_rfh()->SendNavigate(0, url1); | 1929 main_test_rfh()->SendNavigate(0, url1); |
1906 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1930 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1907 navigation_entry_committed_counter_ = 0; | 1931 navigation_entry_committed_counter_ = 0; |
1908 | 1932 |
1909 const GURL url2("http://foo2"); | 1933 const GURL url2("http://foo2"); |
1910 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 1934 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
1911 params.page_id = 0; | 1935 params.page_id = 0; |
1912 params.url = url2; | 1936 params.url = url2; |
1913 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; | 1937 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
1914 params.should_update_history = false; | 1938 params.should_update_history = false; |
1915 params.gesture = NavigationGestureUser; | 1939 params.gesture = NavigationGestureUser; |
1916 params.is_post = false; | 1940 params.is_post = false; |
1917 params.page_state = PageState::CreateFromURL(url2); | 1941 params.page_state = PageState::CreateFromURL(url2); |
1918 | 1942 |
1919 // Navigating should do nothing. | 1943 // Navigating should do nothing. |
1920 LoadCommittedDetails details; | 1944 LoadCommittedDetails details; |
1921 EXPECT_FALSE(controller.RendererDidNavigate(main_test_rfh(), params, | 1945 EXPECT_FALSE(controller.RendererDidNavigate(main_test_rfh(), params, |
1922 &details)); | 1946 &details)); |
1923 EXPECT_EQ(0U, notifications.size()); | 1947 EXPECT_EQ(0U, notifications.size()); |
(...skipping 12 matching lines...) Expand all Loading... |
1936 const GURL url1("http://foo1"); | 1960 const GURL url1("http://foo1"); |
1937 main_test_rfh()->SendNavigate(0, url1); | 1961 main_test_rfh()->SendNavigate(0, url1); |
1938 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1962 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1939 navigation_entry_committed_counter_ = 0; | 1963 navigation_entry_committed_counter_ = 0; |
1940 | 1964 |
1941 // First manual subframe navigation. | 1965 // First manual subframe navigation. |
1942 const GURL url2("http://foo2"); | 1966 const GURL url2("http://foo2"); |
1943 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 1967 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
1944 params.page_id = 1; | 1968 params.page_id = 1; |
1945 params.url = url2; | 1969 params.url = url2; |
1946 params.transition = PAGE_TRANSITION_MANUAL_SUBFRAME; | 1970 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; |
1947 params.should_update_history = false; | 1971 params.should_update_history = false; |
1948 params.gesture = NavigationGestureUser; | 1972 params.gesture = NavigationGestureUser; |
1949 params.is_post = false; | 1973 params.is_post = false; |
1950 params.page_state = PageState::CreateFromURL(url2); | 1974 params.page_state = PageState::CreateFromURL(url2); |
1951 | 1975 |
1952 // This should generate a new entry. | 1976 // This should generate a new entry. |
1953 LoadCommittedDetails details; | 1977 LoadCommittedDetails details; |
1954 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, | 1978 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, |
1955 &details)); | 1979 &details)); |
1956 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1980 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2030 const GURL url1("http://foo"); | 2054 const GURL url1("http://foo"); |
2031 main_test_rfh()->SendNavigate(0, url1); | 2055 main_test_rfh()->SendNavigate(0, url1); |
2032 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2056 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2033 navigation_entry_committed_counter_ = 0; | 2057 navigation_entry_committed_counter_ = 0; |
2034 | 2058 |
2035 // Ensure main page navigation to same url respects the was_within_same_page | 2059 // Ensure main page navigation to same url respects the was_within_same_page |
2036 // hint provided in the params. | 2060 // hint provided in the params. |
2037 FrameHostMsg_DidCommitProvisionalLoad_Params self_params; | 2061 FrameHostMsg_DidCommitProvisionalLoad_Params self_params; |
2038 self_params.page_id = 0; | 2062 self_params.page_id = 0; |
2039 self_params.url = url1; | 2063 self_params.url = url1; |
2040 self_params.transition = PAGE_TRANSITION_LINK; | 2064 self_params.transition = ui::PAGE_TRANSITION_LINK; |
2041 self_params.should_update_history = false; | 2065 self_params.should_update_history = false; |
2042 self_params.gesture = NavigationGestureUser; | 2066 self_params.gesture = NavigationGestureUser; |
2043 self_params.is_post = false; | 2067 self_params.is_post = false; |
2044 self_params.page_state = PageState::CreateFromURL(url1); | 2068 self_params.page_state = PageState::CreateFromURL(url1); |
2045 self_params.was_within_same_page = true; | 2069 self_params.was_within_same_page = true; |
2046 | 2070 |
2047 LoadCommittedDetails details; | 2071 LoadCommittedDetails details; |
2048 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), self_params, | 2072 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), self_params, |
2049 &details)); | 2073 &details)); |
2050 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2074 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2051 navigation_entry_committed_counter_ = 0; | 2075 navigation_entry_committed_counter_ = 0; |
2052 EXPECT_TRUE(details.is_in_page); | 2076 EXPECT_TRUE(details.is_in_page); |
2053 EXPECT_TRUE(details.did_replace_entry); | 2077 EXPECT_TRUE(details.did_replace_entry); |
2054 EXPECT_EQ(1, controller.GetEntryCount()); | 2078 EXPECT_EQ(1, controller.GetEntryCount()); |
2055 | 2079 |
2056 // Fragment navigation to a new page_id. | 2080 // Fragment navigation to a new page_id. |
2057 const GURL url2("http://foo#a"); | 2081 const GURL url2("http://foo#a"); |
2058 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2082 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2059 params.page_id = 1; | 2083 params.page_id = 1; |
2060 params.url = url2; | 2084 params.url = url2; |
2061 params.transition = PAGE_TRANSITION_LINK; | 2085 params.transition = ui::PAGE_TRANSITION_LINK; |
2062 params.should_update_history = false; | 2086 params.should_update_history = false; |
2063 params.gesture = NavigationGestureUser; | 2087 params.gesture = NavigationGestureUser; |
2064 params.is_post = false; | 2088 params.is_post = false; |
2065 params.page_state = PageState::CreateFromURL(url2); | 2089 params.page_state = PageState::CreateFromURL(url2); |
2066 params.was_within_same_page = true; | 2090 params.was_within_same_page = true; |
2067 | 2091 |
2068 // This should generate a new entry. | 2092 // This should generate a new entry. |
2069 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, | 2093 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, |
2070 &details)); | 2094 &details)); |
2071 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2095 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2139 const GURL url1("http://foo"); | 2163 const GURL url1("http://foo"); |
2140 main_test_rfh()->SendNavigate(0, url1); | 2164 main_test_rfh()->SendNavigate(0, url1); |
2141 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2165 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2142 navigation_entry_committed_counter_ = 0; | 2166 navigation_entry_committed_counter_ = 0; |
2143 | 2167 |
2144 // First navigation. | 2168 // First navigation. |
2145 const GURL url2("http://foo#a"); | 2169 const GURL url2("http://foo#a"); |
2146 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2170 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2147 params.page_id = 0; // Same page_id | 2171 params.page_id = 0; // Same page_id |
2148 params.url = url2; | 2172 params.url = url2; |
2149 params.transition = PAGE_TRANSITION_LINK; | 2173 params.transition = ui::PAGE_TRANSITION_LINK; |
2150 params.should_update_history = false; | 2174 params.should_update_history = false; |
2151 params.gesture = NavigationGestureUser; | 2175 params.gesture = NavigationGestureUser; |
2152 params.is_post = false; | 2176 params.is_post = false; |
2153 params.page_state = PageState::CreateFromURL(url2); | 2177 params.page_state = PageState::CreateFromURL(url2); |
2154 params.was_within_same_page = true; | 2178 params.was_within_same_page = true; |
2155 | 2179 |
2156 // This should NOT generate a new entry, nor prune the list. | 2180 // This should NOT generate a new entry, nor prune the list. |
2157 LoadCommittedDetails details; | 2181 LoadCommittedDetails details; |
2158 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, | 2182 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, |
2159 &details)); | 2183 &details)); |
(...skipping 30 matching lines...) Expand all Loading... |
2190 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2214 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2191 navigation_entry_committed_counter_ = 0; | 2215 navigation_entry_committed_counter_ = 0; |
2192 } | 2216 } |
2193 | 2217 |
2194 // Navigate within the page. | 2218 // Navigate within the page. |
2195 { | 2219 { |
2196 const GURL url("http://foo2/#a"); | 2220 const GURL url("http://foo2/#a"); |
2197 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2221 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2198 params.page_id = 1; // Same page_id | 2222 params.page_id = 1; // Same page_id |
2199 params.url = url; | 2223 params.url = url; |
2200 params.transition = PAGE_TRANSITION_LINK; | 2224 params.transition = ui::PAGE_TRANSITION_LINK; |
2201 params.redirects.push_back(url); | 2225 params.redirects.push_back(url); |
2202 params.should_update_history = true; | 2226 params.should_update_history = true; |
2203 params.gesture = NavigationGestureUnknown; | 2227 params.gesture = NavigationGestureUnknown; |
2204 params.is_post = false; | 2228 params.is_post = false; |
2205 params.page_state = PageState::CreateFromURL(url); | 2229 params.page_state = PageState::CreateFromURL(url); |
2206 params.was_within_same_page = true; | 2230 params.was_within_same_page = true; |
2207 | 2231 |
2208 // This should NOT generate a new entry, nor prune the list. | 2232 // This should NOT generate a new entry, nor prune the list. |
2209 LoadCommittedDetails details; | 2233 LoadCommittedDetails details; |
2210 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, | 2234 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, |
2211 &details)); | 2235 &details)); |
2212 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2236 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2213 navigation_entry_committed_counter_ = 0; | 2237 navigation_entry_committed_counter_ = 0; |
2214 EXPECT_TRUE(details.is_in_page); | 2238 EXPECT_TRUE(details.is_in_page); |
2215 EXPECT_TRUE(details.did_replace_entry); | 2239 EXPECT_TRUE(details.did_replace_entry); |
2216 EXPECT_EQ(2, controller.GetEntryCount()); | 2240 EXPECT_EQ(2, controller.GetEntryCount()); |
2217 } | 2241 } |
2218 | 2242 |
2219 // Perform a client redirect to a new page. | 2243 // Perform a client redirect to a new page. |
2220 { | 2244 { |
2221 const GURL url("http://foo3/"); | 2245 const GURL url("http://foo3/"); |
2222 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2246 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2223 params.page_id = 2; // New page_id | 2247 params.page_id = 2; // New page_id |
2224 params.url = url; | 2248 params.url = url; |
2225 params.transition = PAGE_TRANSITION_CLIENT_REDIRECT; | 2249 params.transition = ui::PAGE_TRANSITION_CLIENT_REDIRECT; |
2226 params.redirects.push_back(GURL("http://foo2/#a")); | 2250 params.redirects.push_back(GURL("http://foo2/#a")); |
2227 params.redirects.push_back(url); | 2251 params.redirects.push_back(url); |
2228 params.should_update_history = true; | 2252 params.should_update_history = true; |
2229 params.gesture = NavigationGestureUnknown; | 2253 params.gesture = NavigationGestureUnknown; |
2230 params.is_post = false; | 2254 params.is_post = false; |
2231 params.page_state = PageState::CreateFromURL(url); | 2255 params.page_state = PageState::CreateFromURL(url); |
2232 | 2256 |
2233 // This SHOULD generate a new entry. | 2257 // This SHOULD generate a new entry. |
2234 LoadCommittedDetails details; | 2258 LoadCommittedDetails details; |
2235 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, | 2259 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2301 size_t original_count = NavigationControllerImpl::max_entry_count(); | 2325 size_t original_count = NavigationControllerImpl::max_entry_count(); |
2302 const int kMaxEntryCount = 5; | 2326 const int kMaxEntryCount = 5; |
2303 | 2327 |
2304 NavigationControllerImpl::set_max_entry_count_for_testing(kMaxEntryCount); | 2328 NavigationControllerImpl::set_max_entry_count_for_testing(kMaxEntryCount); |
2305 | 2329 |
2306 int url_index; | 2330 int url_index; |
2307 // Load up to the max count, all entries should be there. | 2331 // Load up to the max count, all entries should be there. |
2308 for (url_index = 0; url_index < kMaxEntryCount; url_index++) { | 2332 for (url_index = 0; url_index < kMaxEntryCount; url_index++) { |
2309 GURL url(base::StringPrintf("http://www.a.com/%d", url_index)); | 2333 GURL url(base::StringPrintf("http://www.a.com/%d", url_index)); |
2310 controller.LoadURL( | 2334 controller.LoadURL( |
2311 url, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2335 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
2312 main_test_rfh()->SendNavigate(url_index, url); | 2336 main_test_rfh()->SendNavigate(url_index, url); |
2313 } | 2337 } |
2314 | 2338 |
2315 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); | 2339 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); |
2316 | 2340 |
2317 // Created a PrunedListener to observe prune notifications. | 2341 // Created a PrunedListener to observe prune notifications. |
2318 PrunedListener listener(&controller); | 2342 PrunedListener listener(&controller); |
2319 | 2343 |
2320 // Navigate some more. | 2344 // Navigate some more. |
2321 GURL url(base::StringPrintf("http://www.a.com/%d", url_index)); | 2345 GURL url(base::StringPrintf("http://www.a.com/%d", url_index)); |
2322 controller.LoadURL( | 2346 controller.LoadURL( |
2323 url, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2347 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
2324 main_test_rfh()->SendNavigate(url_index, url); | 2348 main_test_rfh()->SendNavigate(url_index, url); |
2325 url_index++; | 2349 url_index++; |
2326 | 2350 |
2327 // We should have got a pruned navigation. | 2351 // We should have got a pruned navigation. |
2328 EXPECT_EQ(1, listener.notification_count_); | 2352 EXPECT_EQ(1, listener.notification_count_); |
2329 EXPECT_TRUE(listener.details_.from_front); | 2353 EXPECT_TRUE(listener.details_.from_front); |
2330 EXPECT_EQ(1, listener.details_.count); | 2354 EXPECT_EQ(1, listener.details_.count); |
2331 | 2355 |
2332 // We expect http://www.a.com/0 to be gone. | 2356 // We expect http://www.a.com/0 to be gone. |
2333 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); | 2357 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); |
2334 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), | 2358 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), |
2335 GURL("http:////www.a.com/1")); | 2359 GURL("http:////www.a.com/1")); |
2336 | 2360 |
2337 // More navigations. | 2361 // More navigations. |
2338 for (int i = 0; i < 3; i++) { | 2362 for (int i = 0; i < 3; i++) { |
2339 url = GURL(base::StringPrintf("http:////www.a.com/%d", url_index)); | 2363 url = GURL(base::StringPrintf("http:////www.a.com/%d", url_index)); |
2340 controller.LoadURL( | 2364 controller.LoadURL( |
2341 url, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2365 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
2342 main_test_rfh()->SendNavigate(url_index, url); | 2366 main_test_rfh()->SendNavigate(url_index, url); |
2343 url_index++; | 2367 url_index++; |
2344 } | 2368 } |
2345 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); | 2369 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); |
2346 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), | 2370 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), |
2347 GURL("http:////www.a.com/4")); | 2371 GURL("http:////www.a.com/4")); |
2348 | 2372 |
2349 NavigationControllerImpl::set_max_entry_count_for_testing(original_count); | 2373 NavigationControllerImpl::set_max_entry_count_for_testing(original_count); |
2350 } | 2374 } |
2351 | 2375 |
2352 // Tests that we can do a restore and navigate to the restored entries and | 2376 // Tests that we can do a restore and navigate to the restored entries and |
2353 // everything is updated properly. This can be tricky since there is no | 2377 // everything is updated properly. This can be tricky since there is no |
2354 // SiteInstance for the entries created initially. | 2378 // SiteInstance for the entries created initially. |
2355 TEST_F(NavigationControllerTest, RestoreNavigate) { | 2379 TEST_F(NavigationControllerTest, RestoreNavigate) { |
2356 // Create a NavigationController with a restored set of tabs. | 2380 // Create a NavigationController with a restored set of tabs. |
2357 GURL url("http://foo"); | 2381 GURL url("http://foo"); |
2358 std::vector<NavigationEntry*> entries; | 2382 std::vector<NavigationEntry*> entries; |
2359 NavigationEntry* entry = NavigationControllerImpl::CreateNavigationEntry( | 2383 NavigationEntry* entry = NavigationControllerImpl::CreateNavigationEntry( |
2360 url, Referrer(), PAGE_TRANSITION_RELOAD, false, std::string(), | 2384 url, Referrer(), ui::PAGE_TRANSITION_RELOAD, false, std::string(), |
2361 browser_context()); | 2385 browser_context()); |
2362 entry->SetPageID(0); | 2386 entry->SetPageID(0); |
2363 entry->SetTitle(base::ASCIIToUTF16("Title")); | 2387 entry->SetTitle(base::ASCIIToUTF16("Title")); |
2364 entry->SetPageState(PageState::CreateFromEncodedData("state")); | 2388 entry->SetPageState(PageState::CreateFromEncodedData("state")); |
2365 const base::Time timestamp = base::Time::Now(); | 2389 const base::Time timestamp = base::Time::Now(); |
2366 entry->SetTimestamp(timestamp); | 2390 entry->SetTimestamp(timestamp); |
2367 entries.push_back(entry); | 2391 entries.push_back(entry); |
2368 scoped_ptr<WebContentsImpl> our_contents(static_cast<WebContentsImpl*>( | 2392 scoped_ptr<WebContentsImpl> our_contents(static_cast<WebContentsImpl*>( |
2369 WebContents::Create(WebContents::CreateParams(browser_context())))); | 2393 WebContents::Create(WebContents::CreateParams(browser_context())))); |
2370 NavigationControllerImpl& our_controller = our_contents->GetController(); | 2394 NavigationControllerImpl& our_controller = our_contents->GetController(); |
(...skipping 25 matching lines...) Expand all Loading... |
2396 EXPECT_TRUE(NavigationEntryImpl::FromNavigationEntry( | 2420 EXPECT_TRUE(NavigationEntryImpl::FromNavigationEntry( |
2397 our_controller.GetEntryAtIndex(0))->site_instance()); | 2421 our_controller.GetEntryAtIndex(0))->site_instance()); |
2398 | 2422 |
2399 // Timestamp should remain the same before the navigation finishes. | 2423 // Timestamp should remain the same before the navigation finishes. |
2400 EXPECT_EQ(timestamp, our_controller.GetEntryAtIndex(0)->GetTimestamp()); | 2424 EXPECT_EQ(timestamp, our_controller.GetEntryAtIndex(0)->GetTimestamp()); |
2401 | 2425 |
2402 // Say we navigated to that entry. | 2426 // Say we navigated to that entry. |
2403 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2427 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2404 params.page_id = 0; | 2428 params.page_id = 0; |
2405 params.url = url; | 2429 params.url = url; |
2406 params.transition = PAGE_TRANSITION_LINK; | 2430 params.transition = ui::PAGE_TRANSITION_LINK; |
2407 params.should_update_history = false; | 2431 params.should_update_history = false; |
2408 params.gesture = NavigationGestureUser; | 2432 params.gesture = NavigationGestureUser; |
2409 params.is_post = false; | 2433 params.is_post = false; |
2410 params.page_state = PageState::CreateFromURL(url); | 2434 params.page_state = PageState::CreateFromURL(url); |
2411 LoadCommittedDetails details; | 2435 LoadCommittedDetails details; |
2412 our_controller.RendererDidNavigate(our_contents->GetMainFrame(), params, | 2436 our_controller.RendererDidNavigate(our_contents->GetMainFrame(), params, |
2413 &details); | 2437 &details); |
2414 | 2438 |
2415 // There should be no longer any pending entry and one committed one. This | 2439 // There should be no longer any pending entry and one committed one. This |
2416 // means that we were able to locate the entry, assign its site instance, and | 2440 // means that we were able to locate the entry, assign its site instance, and |
(...skipping 13 matching lines...) Expand all Loading... |
2430 EXPECT_GE(our_controller.GetEntryAtIndex(0)->GetTimestamp(), timestamp); | 2454 EXPECT_GE(our_controller.GetEntryAtIndex(0)->GetTimestamp(), timestamp); |
2431 } | 2455 } |
2432 | 2456 |
2433 // Tests that we can still navigate to a restored entry after a different | 2457 // Tests that we can still navigate to a restored entry after a different |
2434 // navigation fails and clears the pending entry. http://crbug.com/90085 | 2458 // navigation fails and clears the pending entry. http://crbug.com/90085 |
2435 TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) { | 2459 TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) { |
2436 // Create a NavigationController with a restored set of tabs. | 2460 // Create a NavigationController with a restored set of tabs. |
2437 GURL url("http://foo"); | 2461 GURL url("http://foo"); |
2438 std::vector<NavigationEntry*> entries; | 2462 std::vector<NavigationEntry*> entries; |
2439 NavigationEntry* entry = NavigationControllerImpl::CreateNavigationEntry( | 2463 NavigationEntry* entry = NavigationControllerImpl::CreateNavigationEntry( |
2440 url, Referrer(), PAGE_TRANSITION_RELOAD, false, std::string(), | 2464 url, Referrer(), ui::PAGE_TRANSITION_RELOAD, false, std::string(), |
2441 browser_context()); | 2465 browser_context()); |
2442 entry->SetPageID(0); | 2466 entry->SetPageID(0); |
2443 entry->SetTitle(base::ASCIIToUTF16("Title")); | 2467 entry->SetTitle(base::ASCIIToUTF16("Title")); |
2444 entry->SetPageState(PageState::CreateFromEncodedData("state")); | 2468 entry->SetPageState(PageState::CreateFromEncodedData("state")); |
2445 entries.push_back(entry); | 2469 entries.push_back(entry); |
2446 scoped_ptr<WebContentsImpl> our_contents(static_cast<WebContentsImpl*>( | 2470 scoped_ptr<WebContentsImpl> our_contents(static_cast<WebContentsImpl*>( |
2447 WebContents::Create(WebContents::CreateParams(browser_context())))); | 2471 WebContents::Create(WebContents::CreateParams(browser_context())))); |
2448 NavigationControllerImpl& our_controller = our_contents->GetController(); | 2472 NavigationControllerImpl& our_controller = our_contents->GetController(); |
2449 our_controller.Restore( | 2473 our_controller.Restore( |
2450 0, NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, &entries); | 2474 0, NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, &entries); |
(...skipping 28 matching lines...) Expand all Loading... |
2479 fail_load_params.url = url; | 2503 fail_load_params.url = url; |
2480 fail_load_params.showing_repost_interstitial = false; | 2504 fail_load_params.showing_repost_interstitial = false; |
2481 main_test_rfh()->OnMessageReceived( | 2505 main_test_rfh()->OnMessageReceived( |
2482 FrameHostMsg_DidFailProvisionalLoadWithError(0, // routing_id | 2506 FrameHostMsg_DidFailProvisionalLoadWithError(0, // routing_id |
2483 fail_load_params)); | 2507 fail_load_params)); |
2484 | 2508 |
2485 // Now the pending restored entry commits. | 2509 // Now the pending restored entry commits. |
2486 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2510 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2487 params.page_id = 0; | 2511 params.page_id = 0; |
2488 params.url = url; | 2512 params.url = url; |
2489 params.transition = PAGE_TRANSITION_LINK; | 2513 params.transition = ui::PAGE_TRANSITION_LINK; |
2490 params.should_update_history = false; | 2514 params.should_update_history = false; |
2491 params.gesture = NavigationGestureUser; | 2515 params.gesture = NavigationGestureUser; |
2492 params.is_post = false; | 2516 params.is_post = false; |
2493 params.page_state = PageState::CreateFromURL(url); | 2517 params.page_state = PageState::CreateFromURL(url); |
2494 LoadCommittedDetails details; | 2518 LoadCommittedDetails details; |
2495 our_controller.RendererDidNavigate(our_contents->GetMainFrame(), params, | 2519 our_controller.RendererDidNavigate(our_contents->GetMainFrame(), params, |
2496 &details); | 2520 &details); |
2497 | 2521 |
2498 // There should be no pending entry and one committed one. | 2522 // There should be no pending entry and one committed one. |
2499 EXPECT_EQ(1, our_controller.GetEntryCount()); | 2523 EXPECT_EQ(1, our_controller.GetEntryCount()); |
2500 EXPECT_EQ(0, our_controller.GetLastCommittedEntryIndex()); | 2524 EXPECT_EQ(0, our_controller.GetLastCommittedEntryIndex()); |
2501 EXPECT_FALSE(our_controller.GetPendingEntry()); | 2525 EXPECT_FALSE(our_controller.GetPendingEntry()); |
2502 EXPECT_EQ(url, | 2526 EXPECT_EQ(url, |
2503 NavigationEntryImpl::FromNavigationEntry( | 2527 NavigationEntryImpl::FromNavigationEntry( |
2504 our_controller.GetLastCommittedEntry())->site_instance()-> | 2528 our_controller.GetLastCommittedEntry())->site_instance()-> |
2505 GetSiteURL()); | 2529 GetSiteURL()); |
2506 EXPECT_EQ(NavigationEntryImpl::RESTORE_NONE, | 2530 EXPECT_EQ(NavigationEntryImpl::RESTORE_NONE, |
2507 NavigationEntryImpl::FromNavigationEntry( | 2531 NavigationEntryImpl::FromNavigationEntry( |
2508 our_controller.GetEntryAtIndex(0))->restore_type()); | 2532 our_controller.GetEntryAtIndex(0))->restore_type()); |
2509 } | 2533 } |
2510 | 2534 |
2511 // Make sure that the page type and stuff is correct after an interstitial. | 2535 // Make sure that the page type and stuff is correct after an interstitial. |
2512 TEST_F(NavigationControllerTest, Interstitial) { | 2536 TEST_F(NavigationControllerTest, Interstitial) { |
2513 NavigationControllerImpl& controller = controller_impl(); | 2537 NavigationControllerImpl& controller = controller_impl(); |
2514 // First navigate somewhere normal. | 2538 // First navigate somewhere normal. |
2515 const GURL url1("http://foo"); | 2539 const GURL url1("http://foo"); |
2516 controller.LoadURL( | 2540 controller.LoadURL( |
2517 url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2541 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
2518 main_test_rfh()->SendNavigate(0, url1); | 2542 main_test_rfh()->SendNavigate(0, url1); |
2519 | 2543 |
2520 // Now navigate somewhere with an interstitial. | 2544 // Now navigate somewhere with an interstitial. |
2521 const GURL url2("http://bar"); | 2545 const GURL url2("http://bar"); |
2522 controller.LoadURL( | 2546 controller.LoadURL( |
2523 url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2547 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
2524 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())-> | 2548 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())-> |
2525 set_page_type(PAGE_TYPE_INTERSTITIAL); | 2549 set_page_type(PAGE_TYPE_INTERSTITIAL); |
2526 | 2550 |
2527 // At this point the interstitial will be displayed and the load will still | 2551 // At this point the interstitial will be displayed and the load will still |
2528 // be pending. If the user continues, the load will commit. | 2552 // be pending. If the user continues, the load will commit. |
2529 main_test_rfh()->SendNavigate(1, url2); | 2553 main_test_rfh()->SendNavigate(1, url2); |
2530 | 2554 |
2531 // The page should be a normal page again. | 2555 // The page should be a normal page again. |
2532 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL()); | 2556 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL()); |
2533 EXPECT_EQ(PAGE_TYPE_NORMAL, | 2557 EXPECT_EQ(PAGE_TYPE_NORMAL, |
2534 controller.GetLastCommittedEntry()->GetPageType()); | 2558 controller.GetLastCommittedEntry()->GetPageType()); |
2535 } | 2559 } |
2536 | 2560 |
2537 TEST_F(NavigationControllerTest, RemoveEntry) { | 2561 TEST_F(NavigationControllerTest, RemoveEntry) { |
2538 NavigationControllerImpl& controller = controller_impl(); | 2562 NavigationControllerImpl& controller = controller_impl(); |
2539 const GURL url1("http://foo/1"); | 2563 const GURL url1("http://foo/1"); |
2540 const GURL url2("http://foo/2"); | 2564 const GURL url2("http://foo/2"); |
2541 const GURL url3("http://foo/3"); | 2565 const GURL url3("http://foo/3"); |
2542 const GURL url4("http://foo/4"); | 2566 const GURL url4("http://foo/4"); |
2543 const GURL url5("http://foo/5"); | 2567 const GURL url5("http://foo/5"); |
2544 const GURL pending_url("http://foo/pending"); | 2568 const GURL pending_url("http://foo/pending"); |
2545 const GURL default_url("http://foo/default"); | 2569 const GURL default_url("http://foo/default"); |
2546 | 2570 |
2547 controller.LoadURL( | 2571 controller.LoadURL( |
2548 url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2572 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
2549 main_test_rfh()->SendNavigate(0, url1); | 2573 main_test_rfh()->SendNavigate(0, url1); |
2550 controller.LoadURL( | 2574 controller.LoadURL( |
2551 url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2575 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
2552 main_test_rfh()->SendNavigate(1, url2); | 2576 main_test_rfh()->SendNavigate(1, url2); |
2553 controller.LoadURL( | 2577 controller.LoadURL( |
2554 url3, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2578 url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
2555 main_test_rfh()->SendNavigate(2, url3); | 2579 main_test_rfh()->SendNavigate(2, url3); |
2556 controller.LoadURL( | 2580 controller.LoadURL( |
2557 url4, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2581 url4, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
2558 main_test_rfh()->SendNavigate(3, url4); | 2582 main_test_rfh()->SendNavigate(3, url4); |
2559 controller.LoadURL( | 2583 controller.LoadURL( |
2560 url5, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2584 url5, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
2561 main_test_rfh()->SendNavigate(4, url5); | 2585 main_test_rfh()->SendNavigate(4, url5); |
2562 | 2586 |
2563 // Try to remove the last entry. Will fail because it is the current entry. | 2587 // Try to remove the last entry. Will fail because it is the current entry. |
2564 EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1)); | 2588 EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1)); |
2565 EXPECT_EQ(5, controller.GetEntryCount()); | 2589 EXPECT_EQ(5, controller.GetEntryCount()); |
2566 EXPECT_EQ(4, controller.GetLastCommittedEntryIndex()); | 2590 EXPECT_EQ(4, controller.GetLastCommittedEntryIndex()); |
2567 | 2591 |
2568 // Go back, but don't commit yet. Check that we can't delete the current | 2592 // Go back, but don't commit yet. Check that we can't delete the current |
2569 // and pending entries. | 2593 // and pending entries. |
2570 controller.GoBack(); | 2594 controller.GoBack(); |
(...skipping 30 matching lines...) Expand all Loading... |
2601 | 2625 |
2602 const GURL url0("http://foo/0"); | 2626 const GURL url0("http://foo/0"); |
2603 const GURL url1("http://foo/1"); | 2627 const GURL url1("http://foo/1"); |
2604 const GURL url2("http://foo/2"); | 2628 const GURL url2("http://foo/2"); |
2605 const GURL url3("http://foo/3"); | 2629 const GURL url3("http://foo/3"); |
2606 const GURL url3_ref("http://foo/3#bar"); | 2630 const GURL url3_ref("http://foo/3#bar"); |
2607 const GURL url4("http://foo/4"); | 2631 const GURL url4("http://foo/4"); |
2608 const GURL transient_url("http://foo/transient"); | 2632 const GURL transient_url("http://foo/transient"); |
2609 | 2633 |
2610 controller.LoadURL( | 2634 controller.LoadURL( |
2611 url0, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2635 url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
2612 main_test_rfh()->SendNavigate(0, url0); | 2636 main_test_rfh()->SendNavigate(0, url0); |
2613 controller.LoadURL( | 2637 controller.LoadURL( |
2614 url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2638 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
2615 main_test_rfh()->SendNavigate(1, url1); | 2639 main_test_rfh()->SendNavigate(1, url1); |
2616 | 2640 |
2617 notifications.Reset(); | 2641 notifications.Reset(); |
2618 | 2642 |
2619 // Adding a transient with no pending entry. | 2643 // Adding a transient with no pending entry. |
2620 NavigationEntryImpl* transient_entry = new NavigationEntryImpl; | 2644 NavigationEntryImpl* transient_entry = new NavigationEntryImpl; |
2621 transient_entry->SetURL(transient_url); | 2645 transient_entry->SetURL(transient_url); |
2622 controller.SetTransientEntry(transient_entry); | 2646 controller.SetTransientEntry(transient_entry); |
2623 | 2647 |
2624 // We should not have received any notifications. | 2648 // We should not have received any notifications. |
2625 EXPECT_EQ(0U, notifications.size()); | 2649 EXPECT_EQ(0U, notifications.size()); |
2626 | 2650 |
2627 // Check our state. | 2651 // Check our state. |
2628 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 2652 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
2629 EXPECT_EQ(controller.GetEntryCount(), 3); | 2653 EXPECT_EQ(controller.GetEntryCount(), 3); |
2630 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); | 2654 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); |
2631 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 2655 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
2632 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 2656 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
2633 EXPECT_FALSE(controller.GetPendingEntry()); | 2657 EXPECT_FALSE(controller.GetPendingEntry()); |
2634 EXPECT_TRUE(controller.CanGoBack()); | 2658 EXPECT_TRUE(controller.CanGoBack()); |
2635 EXPECT_FALSE(controller.CanGoForward()); | 2659 EXPECT_FALSE(controller.CanGoForward()); |
2636 EXPECT_EQ(contents()->GetMaxPageID(), 1); | 2660 EXPECT_EQ(contents()->GetMaxPageID(), 1); |
2637 | 2661 |
2638 // Navigate. | 2662 // Navigate. |
2639 controller.LoadURL( | 2663 controller.LoadURL( |
2640 url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2664 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
2641 main_test_rfh()->SendNavigate(2, url2); | 2665 main_test_rfh()->SendNavigate(2, url2); |
2642 | 2666 |
2643 // We should have navigated, transient entry should be gone. | 2667 // We should have navigated, transient entry should be gone. |
2644 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); | 2668 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); |
2645 EXPECT_EQ(controller.GetEntryCount(), 3); | 2669 EXPECT_EQ(controller.GetEntryCount(), 3); |
2646 | 2670 |
2647 // Add a transient again, then navigate with no pending entry this time. | 2671 // Add a transient again, then navigate with no pending entry this time. |
2648 transient_entry = new NavigationEntryImpl; | 2672 transient_entry = new NavigationEntryImpl; |
2649 transient_entry->SetURL(transient_url); | 2673 transient_entry->SetURL(transient_url); |
2650 controller.SetTransientEntry(transient_entry); | 2674 controller.SetTransientEntry(transient_entry); |
2651 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 2675 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
2652 main_test_rfh()->SendNavigate(3, url3); | 2676 main_test_rfh()->SendNavigate(3, url3); |
2653 // Transient entry should be gone. | 2677 // Transient entry should be gone. |
2654 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); | 2678 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); |
2655 EXPECT_EQ(controller.GetEntryCount(), 4); | 2679 EXPECT_EQ(controller.GetEntryCount(), 4); |
2656 | 2680 |
2657 // Initiate a navigation, add a transient then commit navigation. | 2681 // Initiate a navigation, add a transient then commit navigation. |
2658 controller.LoadURL( | 2682 controller.LoadURL( |
2659 url4, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2683 url4, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
2660 transient_entry = new NavigationEntryImpl; | 2684 transient_entry = new NavigationEntryImpl; |
2661 transient_entry->SetURL(transient_url); | 2685 transient_entry->SetURL(transient_url); |
2662 controller.SetTransientEntry(transient_entry); | 2686 controller.SetTransientEntry(transient_entry); |
2663 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 2687 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
2664 main_test_rfh()->SendNavigate(4, url4); | 2688 main_test_rfh()->SendNavigate(4, url4); |
2665 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL()); | 2689 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL()); |
2666 EXPECT_EQ(controller.GetEntryCount(), 5); | 2690 EXPECT_EQ(controller.GetEntryCount(), 5); |
2667 | 2691 |
2668 // Add a transient and go back. This should simply remove the transient. | 2692 // Add a transient and go back. This should simply remove the transient. |
2669 transient_entry = new NavigationEntryImpl; | 2693 transient_entry = new NavigationEntryImpl; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2741 | 2765 |
2742 // Test that Reload initiates a new navigation to a transient entry's URL. | 2766 // Test that Reload initiates a new navigation to a transient entry's URL. |
2743 TEST_F(NavigationControllerTest, ReloadTransient) { | 2767 TEST_F(NavigationControllerTest, ReloadTransient) { |
2744 NavigationControllerImpl& controller = controller_impl(); | 2768 NavigationControllerImpl& controller = controller_impl(); |
2745 const GURL url0("http://foo/0"); | 2769 const GURL url0("http://foo/0"); |
2746 const GURL url1("http://foo/1"); | 2770 const GURL url1("http://foo/1"); |
2747 const GURL transient_url("http://foo/transient"); | 2771 const GURL transient_url("http://foo/transient"); |
2748 | 2772 |
2749 // Load |url0|, and start a pending navigation to |url1|. | 2773 // Load |url0|, and start a pending navigation to |url1|. |
2750 controller.LoadURL( | 2774 controller.LoadURL( |
2751 url0, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2775 url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
2752 main_test_rfh()->SendNavigate(0, url0); | 2776 main_test_rfh()->SendNavigate(0, url0); |
2753 controller.LoadURL( | 2777 controller.LoadURL( |
2754 url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2778 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
2755 | 2779 |
2756 // A transient entry is added, interrupting the navigation. | 2780 // A transient entry is added, interrupting the navigation. |
2757 NavigationEntryImpl* transient_entry = new NavigationEntryImpl; | 2781 NavigationEntryImpl* transient_entry = new NavigationEntryImpl; |
2758 transient_entry->SetURL(transient_url); | 2782 transient_entry->SetURL(transient_url); |
2759 controller.SetTransientEntry(transient_entry); | 2783 controller.SetTransientEntry(transient_entry); |
2760 EXPECT_TRUE(controller.GetTransientEntry()); | 2784 EXPECT_TRUE(controller.GetTransientEntry()); |
2761 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 2785 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
2762 | 2786 |
2763 // The page is reloaded, which should remove the pending entry for |url1| and | 2787 // The page is reloaded, which should remove the pending entry for |url1| and |
2764 // the transient entry for |transient_url|, and start a navigation to | 2788 // the transient entry for |transient_url|, and start a navigation to |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2843 TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) { | 2867 TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) { |
2844 NavigationControllerImpl& controller = controller_impl(); | 2868 NavigationControllerImpl& controller = controller_impl(); |
2845 TestNotificationTracker notifications; | 2869 TestNotificationTracker notifications; |
2846 RegisterForAllNavNotifications(¬ifications, &controller); | 2870 RegisterForAllNavNotifications(¬ifications, &controller); |
2847 | 2871 |
2848 const GURL url0("http://foo/0"); | 2872 const GURL url0("http://foo/0"); |
2849 const GURL url1("http://foo/1"); | 2873 const GURL url1("http://foo/1"); |
2850 | 2874 |
2851 // For typed navigations (browser-initiated), both pending and visible entries | 2875 // For typed navigations (browser-initiated), both pending and visible entries |
2852 // should update before commit. | 2876 // should update before commit. |
2853 controller.LoadURL(url0, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2877 controller.LoadURL( |
| 2878 url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
2854 EXPECT_EQ(url0, controller.GetPendingEntry()->GetURL()); | 2879 EXPECT_EQ(url0, controller.GetPendingEntry()->GetURL()); |
2855 EXPECT_EQ(url0, controller.GetVisibleEntry()->GetURL()); | 2880 EXPECT_EQ(url0, controller.GetVisibleEntry()->GetURL()); |
2856 main_test_rfh()->SendNavigate(0, url0); | 2881 main_test_rfh()->SendNavigate(0, url0); |
2857 | 2882 |
2858 // For link clicks (renderer-initiated navigations), the pending entry should | 2883 // For link clicks (renderer-initiated navigations), the pending entry should |
2859 // update before commit but the visible should not. | 2884 // update before commit but the visible should not. |
2860 NavigationController::LoadURLParams load_url_params(url1); | 2885 NavigationController::LoadURLParams load_url_params(url1); |
2861 load_url_params.is_renderer_initiated = true; | 2886 load_url_params.is_renderer_initiated = true; |
2862 controller.LoadURLWithParams(load_url_params); | 2887 controller.LoadURLWithParams(load_url_params); |
2863 EXPECT_EQ(url0, controller.GetVisibleEntry()->GetURL()); | 2888 EXPECT_EQ(url0, controller.GetVisibleEntry()->GetURL()); |
(...skipping 22 matching lines...) Expand all Loading... |
2886 NavigationControllerImpl& controller = controller_impl(); | 2911 NavigationControllerImpl& controller = controller_impl(); |
2887 TestNotificationTracker notifications; | 2912 TestNotificationTracker notifications; |
2888 RegisterForAllNavNotifications(¬ifications, &controller); | 2913 RegisterForAllNavNotifications(¬ifications, &controller); |
2889 | 2914 |
2890 const GURL url("http://foo"); | 2915 const GURL url("http://foo"); |
2891 | 2916 |
2892 // For renderer-initiated navigations in new tabs (with no committed entries), | 2917 // For renderer-initiated navigations in new tabs (with no committed entries), |
2893 // we show the pending entry's URL as long as the about:blank page is not | 2918 // we show the pending entry's URL as long as the about:blank page is not |
2894 // modified. | 2919 // modified. |
2895 NavigationController::LoadURLParams load_url_params(url); | 2920 NavigationController::LoadURLParams load_url_params(url); |
2896 load_url_params.transition_type = PAGE_TRANSITION_LINK; | 2921 load_url_params.transition_type = ui::PAGE_TRANSITION_LINK; |
2897 load_url_params.is_renderer_initiated = true; | 2922 load_url_params.is_renderer_initiated = true; |
2898 controller.LoadURLWithParams(load_url_params); | 2923 controller.LoadURLWithParams(load_url_params); |
2899 EXPECT_EQ(url, controller.GetVisibleEntry()->GetURL()); | 2924 EXPECT_EQ(url, controller.GetVisibleEntry()->GetURL()); |
2900 EXPECT_EQ(url, controller.GetPendingEntry()->GetURL()); | 2925 EXPECT_EQ(url, controller.GetPendingEntry()->GetURL()); |
2901 EXPECT_TRUE( | 2926 EXPECT_TRUE( |
2902 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())-> | 2927 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())-> |
2903 is_renderer_initiated()); | 2928 is_renderer_initiated()); |
2904 EXPECT_TRUE(controller.IsInitialNavigation()); | 2929 EXPECT_TRUE(controller.IsInitialNavigation()); |
2905 EXPECT_FALSE(contents()->HasAccessedInitialDocument()); | 2930 EXPECT_FALSE(contents()->HasAccessedInitialDocument()); |
2906 | 2931 |
(...skipping 19 matching lines...) Expand all Loading... |
2926 TestNotificationTracker notifications; | 2951 TestNotificationTracker notifications; |
2927 RegisterForAllNavNotifications(¬ifications, &controller); | 2952 RegisterForAllNavNotifications(¬ifications, &controller); |
2928 | 2953 |
2929 const GURL url("http://foo"); | 2954 const GURL url("http://foo"); |
2930 | 2955 |
2931 // For browser-initiated navigations in new tabs (with no committed entries), | 2956 // For browser-initiated navigations in new tabs (with no committed entries), |
2932 // we show the pending entry's URL as long as the about:blank page is not | 2957 // we show the pending entry's URL as long as the about:blank page is not |
2933 // modified. This is possible in cases that the user types a URL into a popup | 2958 // modified. This is possible in cases that the user types a URL into a popup |
2934 // tab created with a slow URL. | 2959 // tab created with a slow URL. |
2935 NavigationController::LoadURLParams load_url_params(url); | 2960 NavigationController::LoadURLParams load_url_params(url); |
2936 load_url_params.transition_type = PAGE_TRANSITION_TYPED; | 2961 load_url_params.transition_type = ui::PAGE_TRANSITION_TYPED; |
2937 load_url_params.is_renderer_initiated = false; | 2962 load_url_params.is_renderer_initiated = false; |
2938 controller.LoadURLWithParams(load_url_params); | 2963 controller.LoadURLWithParams(load_url_params); |
2939 EXPECT_EQ(url, controller.GetVisibleEntry()->GetURL()); | 2964 EXPECT_EQ(url, controller.GetVisibleEntry()->GetURL()); |
2940 EXPECT_EQ(url, controller.GetPendingEntry()->GetURL()); | 2965 EXPECT_EQ(url, controller.GetPendingEntry()->GetURL()); |
2941 EXPECT_FALSE( | 2966 EXPECT_FALSE( |
2942 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())-> | 2967 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())-> |
2943 is_renderer_initiated()); | 2968 is_renderer_initiated()); |
2944 EXPECT_TRUE(controller.IsInitialNavigation()); | 2969 EXPECT_TRUE(controller.IsInitialNavigation()); |
2945 EXPECT_FALSE(contents()->HasAccessedInitialDocument()); | 2970 EXPECT_FALSE(contents()->HasAccessedInitialDocument()); |
2946 | 2971 |
(...skipping 30 matching lines...) Expand all Loading... |
2977 NavigationControllerImpl& controller = controller_impl(); | 3002 NavigationControllerImpl& controller = controller_impl(); |
2978 TestNotificationTracker notifications; | 3003 TestNotificationTracker notifications; |
2979 RegisterForAllNavNotifications(¬ifications, &controller); | 3004 RegisterForAllNavNotifications(¬ifications, &controller); |
2980 | 3005 |
2981 const GURL url("http://foo"); | 3006 const GURL url("http://foo"); |
2982 | 3007 |
2983 // For renderer-initiated navigations in new tabs (with no committed entries), | 3008 // For renderer-initiated navigations in new tabs (with no committed entries), |
2984 // we show the pending entry's URL as long as the about:blank page is not | 3009 // we show the pending entry's URL as long as the about:blank page is not |
2985 // modified. | 3010 // modified. |
2986 NavigationController::LoadURLParams load_url_params(url); | 3011 NavigationController::LoadURLParams load_url_params(url); |
2987 load_url_params.transition_type = PAGE_TRANSITION_LINK; | 3012 load_url_params.transition_type = ui::PAGE_TRANSITION_LINK; |
2988 load_url_params.is_renderer_initiated = true; | 3013 load_url_params.is_renderer_initiated = true; |
2989 controller.LoadURLWithParams(load_url_params); | 3014 controller.LoadURLWithParams(load_url_params); |
2990 EXPECT_EQ(url, controller.GetVisibleEntry()->GetURL()); | 3015 EXPECT_EQ(url, controller.GetVisibleEntry()->GetURL()); |
2991 EXPECT_EQ(url, controller.GetPendingEntry()->GetURL()); | 3016 EXPECT_EQ(url, controller.GetPendingEntry()->GetURL()); |
2992 EXPECT_TRUE( | 3017 EXPECT_TRUE( |
2993 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())-> | 3018 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())-> |
2994 is_renderer_initiated()); | 3019 is_renderer_initiated()); |
2995 EXPECT_TRUE(controller.IsInitialNavigation()); | 3020 EXPECT_TRUE(controller.IsInitialNavigation()); |
2996 EXPECT_FALSE(contents()->HasAccessedInitialDocument()); | 3021 EXPECT_FALSE(contents()->HasAccessedInitialDocument()); |
2997 | 3022 |
(...skipping 26 matching lines...) Expand all Loading... |
3024 TestNotificationTracker notifications; | 3049 TestNotificationTracker notifications; |
3025 RegisterForAllNavNotifications(¬ifications, &controller); | 3050 RegisterForAllNavNotifications(¬ifications, &controller); |
3026 | 3051 |
3027 const GURL url1("http://foo/eh"); | 3052 const GURL url1("http://foo/eh"); |
3028 const GURL url2("http://foo/bee"); | 3053 const GURL url2("http://foo/bee"); |
3029 | 3054 |
3030 // For renderer-initiated navigations in new tabs (with no committed entries), | 3055 // For renderer-initiated navigations in new tabs (with no committed entries), |
3031 // we show the pending entry's URL as long as the about:blank page is not | 3056 // we show the pending entry's URL as long as the about:blank page is not |
3032 // modified. | 3057 // modified. |
3033 NavigationController::LoadURLParams load_url_params(url1); | 3058 NavigationController::LoadURLParams load_url_params(url1); |
3034 load_url_params.transition_type = PAGE_TRANSITION_LINK; | 3059 load_url_params.transition_type = ui::PAGE_TRANSITION_LINK; |
3035 load_url_params.is_renderer_initiated = true; | 3060 load_url_params.is_renderer_initiated = true; |
3036 controller.LoadURLWithParams(load_url_params); | 3061 controller.LoadURLWithParams(load_url_params); |
3037 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); | 3062 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); |
3038 EXPECT_TRUE( | 3063 EXPECT_TRUE( |
3039 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())-> | 3064 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())-> |
3040 is_renderer_initiated()); | 3065 is_renderer_initiated()); |
3041 EXPECT_TRUE(controller.IsInitialNavigation()); | 3066 EXPECT_TRUE(controller.IsInitialNavigation()); |
3042 EXPECT_FALSE(contents()->HasAccessedInitialDocument()); | 3067 EXPECT_FALSE(contents()->HasAccessedInitialDocument()); |
3043 | 3068 |
3044 // Simulate a commit and then starting a new pending navigation. | 3069 // Simulate a commit and then starting a new pending navigation. |
3045 main_test_rfh()->SendNavigate(0, url1); | 3070 main_test_rfh()->SendNavigate(0, url1); |
3046 NavigationController::LoadURLParams load_url2_params(url2); | 3071 NavigationController::LoadURLParams load_url2_params(url2); |
3047 load_url2_params.transition_type = PAGE_TRANSITION_LINK; | 3072 load_url2_params.transition_type = ui::PAGE_TRANSITION_LINK; |
3048 load_url2_params.is_renderer_initiated = true; | 3073 load_url2_params.is_renderer_initiated = true; |
3049 controller.LoadURLWithParams(load_url2_params); | 3074 controller.LoadURLWithParams(load_url2_params); |
3050 | 3075 |
3051 // We should not consider this an initial navigation, and thus should | 3076 // We should not consider this an initial navigation, and thus should |
3052 // not show the pending URL. | 3077 // not show the pending URL. |
3053 EXPECT_FALSE(contents()->HasAccessedInitialDocument()); | 3078 EXPECT_FALSE(contents()->HasAccessedInitialDocument()); |
3054 EXPECT_FALSE(controller.IsInitialNavigation()); | 3079 EXPECT_FALSE(controller.IsInitialNavigation()); |
3055 EXPECT_TRUE(controller.GetVisibleEntry()); | 3080 EXPECT_TRUE(controller.GetVisibleEntry()); |
3056 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); | 3081 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); |
3057 | 3082 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3141 | 3166 |
3142 // We should be at the first navigation entry. | 3167 // We should be at the first navigation entry. |
3143 EXPECT_EQ(controller.GetEntryCount(), 1); | 3168 EXPECT_EQ(controller.GetEntryCount(), 1); |
3144 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 3169 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
3145 | 3170 |
3146 // Navigate a subframe that would normally count as in-page. | 3171 // Navigate a subframe that would normally count as in-page. |
3147 const GURL subframe("http://www.google.com/#"); | 3172 const GURL subframe("http://www.google.com/#"); |
3148 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 3173 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
3149 params.page_id = 0; | 3174 params.page_id = 0; |
3150 params.url = subframe; | 3175 params.url = subframe; |
3151 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; | 3176 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
3152 params.should_update_history = false; | 3177 params.should_update_history = false; |
3153 params.gesture = NavigationGestureAuto; | 3178 params.gesture = NavigationGestureAuto; |
3154 params.is_post = false; | 3179 params.is_post = false; |
3155 params.page_state = PageState::CreateFromURL(subframe); | 3180 params.page_state = PageState::CreateFromURL(subframe); |
3156 LoadCommittedDetails details; | 3181 LoadCommittedDetails details; |
3157 EXPECT_FALSE(controller.RendererDidNavigate(main_test_rfh(), params, | 3182 EXPECT_FALSE(controller.RendererDidNavigate(main_test_rfh(), params, |
3158 &details)); | 3183 &details)); |
3159 | 3184 |
3160 // Nothing should have changed. | 3185 // Nothing should have changed. |
3161 EXPECT_EQ(controller.GetEntryCount(), 1); | 3186 EXPECT_EQ(controller.GetEntryCount(), 1); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3249 // http://crbug.com/43967 | 3274 // http://crbug.com/43967 |
3250 TEST_F(NavigationControllerTest, SubframeWhilePending) { | 3275 TEST_F(NavigationControllerTest, SubframeWhilePending) { |
3251 NavigationControllerImpl& controller = controller_impl(); | 3276 NavigationControllerImpl& controller = controller_impl(); |
3252 // Load the first page. | 3277 // Load the first page. |
3253 const GURL url1("http://foo/"); | 3278 const GURL url1("http://foo/"); |
3254 NavigateAndCommit(url1); | 3279 NavigateAndCommit(url1); |
3255 | 3280 |
3256 // Now start a pending load to a totally different page, but don't commit it. | 3281 // Now start a pending load to a totally different page, but don't commit it. |
3257 const GURL url2("http://bar/"); | 3282 const GURL url2("http://bar/"); |
3258 controller.LoadURL( | 3283 controller.LoadURL( |
3259 url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 3284 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
3260 | 3285 |
3261 // Send a subframe update from the first page, as if one had just | 3286 // Send a subframe update from the first page, as if one had just |
3262 // automatically loaded. Auto subframes don't increment the page ID. | 3287 // automatically loaded. Auto subframes don't increment the page ID. |
3263 const GURL url1_sub("http://foo/subframe"); | 3288 const GURL url1_sub("http://foo/subframe"); |
3264 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 3289 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
3265 params.page_id = controller.GetLastCommittedEntry()->GetPageID(); | 3290 params.page_id = controller.GetLastCommittedEntry()->GetPageID(); |
3266 params.url = url1_sub; | 3291 params.url = url1_sub; |
3267 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; | 3292 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
3268 params.should_update_history = false; | 3293 params.should_update_history = false; |
3269 params.gesture = NavigationGestureAuto; | 3294 params.gesture = NavigationGestureAuto; |
3270 params.is_post = false; | 3295 params.is_post = false; |
3271 params.page_state = PageState::CreateFromURL(url1_sub); | 3296 params.page_state = PageState::CreateFromURL(url1_sub); |
3272 LoadCommittedDetails details; | 3297 LoadCommittedDetails details; |
3273 | 3298 |
3274 // This should return false meaning that nothing was actually updated. | 3299 // This should return false meaning that nothing was actually updated. |
3275 EXPECT_FALSE(controller.RendererDidNavigate(main_test_rfh(), params, | 3300 EXPECT_FALSE(controller.RendererDidNavigate(main_test_rfh(), params, |
3276 &details)); | 3301 &details)); |
3277 | 3302 |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3520 NavigateAndCommit(url1); | 3545 NavigateAndCommit(url1); |
3521 NavigateAndCommit(url2); | 3546 NavigateAndCommit(url2); |
3522 controller.GoBack(); | 3547 controller.GoBack(); |
3523 contents()->CommitPendingNavigation(); | 3548 contents()->CommitPendingNavigation(); |
3524 | 3549 |
3525 scoped_ptr<TestWebContents> other_contents( | 3550 scoped_ptr<TestWebContents> other_contents( |
3526 static_cast<TestWebContents*>(CreateTestWebContents())); | 3551 static_cast<TestWebContents*>(CreateTestWebContents())); |
3527 NavigationControllerImpl& other_controller = other_contents->GetController(); | 3552 NavigationControllerImpl& other_controller = other_contents->GetController(); |
3528 other_contents->NavigateAndCommit(url3); | 3553 other_contents->NavigateAndCommit(url3); |
3529 other_controller.LoadURL( | 3554 other_controller.LoadURL( |
3530 url4, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 3555 url4, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
3531 other_contents->ExpectSetHistoryLengthAndPrune( | 3556 other_contents->ExpectSetHistoryLengthAndPrune( |
3532 GetSiteInstanceFromEntry(other_controller.GetEntryAtIndex(0)), 1, | 3557 GetSiteInstanceFromEntry(other_controller.GetEntryAtIndex(0)), 1, |
3533 other_controller.GetEntryAtIndex(0)->GetPageID()); | 3558 other_controller.GetEntryAtIndex(0)->GetPageID()); |
3534 other_controller.CopyStateFromAndPrune(&controller, false); | 3559 other_controller.CopyStateFromAndPrune(&controller, false); |
3535 | 3560 |
3536 // other_controller should now contain url1, url3, and a pending entry | 3561 // other_controller should now contain url1, url3, and a pending entry |
3537 // for url4. | 3562 // for url4. |
3538 | 3563 |
3539 ASSERT_EQ(2, other_controller.GetEntryCount()); | 3564 ASSERT_EQ(2, other_controller.GetEntryCount()); |
3540 EXPECT_EQ(1, other_controller.GetCurrentEntryIndex()); | 3565 EXPECT_EQ(1, other_controller.GetCurrentEntryIndex()); |
(...skipping 23 matching lines...) Expand all Loading... |
3564 const GURL url2b("http://foo2/b"); | 3589 const GURL url2b("http://foo2/b"); |
3565 | 3590 |
3566 NavigateAndCommit(url1); | 3591 NavigateAndCommit(url1); |
3567 | 3592 |
3568 scoped_ptr<TestWebContents> other_contents( | 3593 scoped_ptr<TestWebContents> other_contents( |
3569 static_cast<TestWebContents*>(CreateTestWebContents())); | 3594 static_cast<TestWebContents*>(CreateTestWebContents())); |
3570 NavigationControllerImpl& other_controller = other_contents->GetController(); | 3595 NavigationControllerImpl& other_controller = other_contents->GetController(); |
3571 other_contents->NavigateAndCommit(url2a); | 3596 other_contents->NavigateAndCommit(url2a); |
3572 // Simulate a client redirect, which has the same page ID as entry 2a. | 3597 // Simulate a client redirect, which has the same page ID as entry 2a. |
3573 other_controller.LoadURL( | 3598 other_controller.LoadURL( |
3574 url2b, Referrer(), PAGE_TRANSITION_LINK, std::string()); | 3599 url2b, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); |
3575 other_controller.GetPendingEntry()->SetPageID( | 3600 other_controller.GetPendingEntry()->SetPageID( |
3576 other_controller.GetLastCommittedEntry()->GetPageID()); | 3601 other_controller.GetLastCommittedEntry()->GetPageID()); |
3577 | 3602 |
3578 other_contents->ExpectSetHistoryLengthAndPrune( | 3603 other_contents->ExpectSetHistoryLengthAndPrune( |
3579 GetSiteInstanceFromEntry(other_controller.GetEntryAtIndex(0)), 1, | 3604 GetSiteInstanceFromEntry(other_controller.GetEntryAtIndex(0)), 1, |
3580 other_controller.GetEntryAtIndex(0)->GetPageID()); | 3605 other_controller.GetEntryAtIndex(0)->GetPageID()); |
3581 other_controller.CopyStateFromAndPrune(&controller, false); | 3606 other_controller.CopyStateFromAndPrune(&controller, false); |
3582 | 3607 |
3583 // other_controller should now contain url1, url2a, and a pending entry | 3608 // other_controller should now contain url1, url2a, and a pending entry |
3584 // for url2b. | 3609 // for url2b. |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3800 TEST_F(NavigationControllerTest, CopyRestoredStateAndNavigate) { | 3825 TEST_F(NavigationControllerTest, CopyRestoredStateAndNavigate) { |
3801 const GURL kRestoredUrls[] = { | 3826 const GURL kRestoredUrls[] = { |
3802 GURL("http://site1.com"), | 3827 GURL("http://site1.com"), |
3803 GURL("http://site2.com"), | 3828 GURL("http://site2.com"), |
3804 }; | 3829 }; |
3805 const GURL kInitialUrl("http://site3.com"); | 3830 const GURL kInitialUrl("http://site3.com"); |
3806 | 3831 |
3807 std::vector<NavigationEntry*> entries; | 3832 std::vector<NavigationEntry*> entries; |
3808 for (size_t i = 0; i < arraysize(kRestoredUrls); ++i) { | 3833 for (size_t i = 0; i < arraysize(kRestoredUrls); ++i) { |
3809 NavigationEntry* entry = NavigationControllerImpl::CreateNavigationEntry( | 3834 NavigationEntry* entry = NavigationControllerImpl::CreateNavigationEntry( |
3810 kRestoredUrls[i], Referrer(), PAGE_TRANSITION_RELOAD, false, | 3835 kRestoredUrls[i], Referrer(), ui::PAGE_TRANSITION_RELOAD, false, |
3811 std::string(), browser_context()); | 3836 std::string(), browser_context()); |
3812 entry->SetPageID(static_cast<int>(i)); | 3837 entry->SetPageID(static_cast<int>(i)); |
3813 entries.push_back(entry); | 3838 entries.push_back(entry); |
3814 } | 3839 } |
3815 | 3840 |
3816 // Create a WebContents with restored entries. | 3841 // Create a WebContents with restored entries. |
3817 scoped_ptr<TestWebContents> source_contents( | 3842 scoped_ptr<TestWebContents> source_contents( |
3818 static_cast<TestWebContents*>(CreateTestWebContents())); | 3843 static_cast<TestWebContents*>(CreateTestWebContents())); |
3819 NavigationControllerImpl& source_controller = | 3844 NavigationControllerImpl& source_controller = |
3820 source_contents->GetController(); | 3845 source_contents->GetController(); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3969 NavigationControllerImpl& controller = controller_impl(); | 3994 NavigationControllerImpl& controller = controller_impl(); |
3970 const GURL url1("http://foo/1"); | 3995 const GURL url1("http://foo/1"); |
3971 const GURL url2("http://foo/2"); | 3996 const GURL url2("http://foo/2"); |
3972 const GURL url3("http://foo/3"); | 3997 const GURL url3("http://foo/3"); |
3973 | 3998 |
3974 NavigateAndCommit(url1); | 3999 NavigateAndCommit(url1); |
3975 NavigateAndCommit(url2); | 4000 NavigateAndCommit(url2); |
3976 | 4001 |
3977 // Create a pending entry that is not in the entry list. | 4002 // Create a pending entry that is not in the entry list. |
3978 controller.LoadURL( | 4003 controller.LoadURL( |
3979 url3, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 4004 url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
3980 EXPECT_TRUE(controller.GetPendingEntry()); | 4005 EXPECT_TRUE(controller.GetPendingEntry()); |
3981 EXPECT_EQ(2, controller.GetEntryCount()); | 4006 EXPECT_EQ(2, controller.GetEntryCount()); |
3982 | 4007 |
3983 contents()->ExpectSetHistoryLengthAndPrune( | 4008 contents()->ExpectSetHistoryLengthAndPrune( |
3984 NULL, 0, controller.GetPendingEntry()->GetPageID()); | 4009 NULL, 0, controller.GetPendingEntry()->GetPageID()); |
3985 controller.PruneAllButLastCommitted(); | 4010 controller.PruneAllButLastCommitted(); |
3986 | 4011 |
3987 // We should only have the last committed and pending entries at this point, | 4012 // We should only have the last committed and pending entries at this point, |
3988 // and the pending entry should still not be in the entry list. | 4013 // and the pending entry should still not be in the entry list. |
3989 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 4014 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4036 // After commit, it stays false. | 4061 // After commit, it stays false. |
4037 const GURL url1("http://foo1"); | 4062 const GURL url1("http://foo1"); |
4038 main_test_rfh()->SendNavigate(0, url1); | 4063 main_test_rfh()->SendNavigate(0, url1); |
4039 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 4064 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
4040 navigation_entry_committed_counter_ = 0; | 4065 navigation_entry_committed_counter_ = 0; |
4041 EXPECT_FALSE(controller.IsInitialNavigation()); | 4066 EXPECT_FALSE(controller.IsInitialNavigation()); |
4042 | 4067 |
4043 // After starting a new navigation, it stays false. | 4068 // After starting a new navigation, it stays false. |
4044 const GURL url2("http://foo2"); | 4069 const GURL url2("http://foo2"); |
4045 controller.LoadURL( | 4070 controller.LoadURL( |
4046 url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 4071 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
4047 } | 4072 } |
4048 | 4073 |
4049 // Check that the favicon is not reused across a client redirect. | 4074 // Check that the favicon is not reused across a client redirect. |
4050 // (crbug.com/28515) | 4075 // (crbug.com/28515) |
4051 TEST_F(NavigationControllerTest, ClearFaviconOnRedirect) { | 4076 TEST_F(NavigationControllerTest, ClearFaviconOnRedirect) { |
4052 const GURL kPageWithFavicon("http://withfavicon.html"); | 4077 const GURL kPageWithFavicon("http://withfavicon.html"); |
4053 const GURL kPageWithoutFavicon("http://withoutfavicon.html"); | 4078 const GURL kPageWithoutFavicon("http://withoutfavicon.html"); |
4054 const GURL kIconURL("http://withfavicon.ico"); | 4079 const GURL kIconURL("http://withfavicon.ico"); |
4055 const gfx::Image kDefaultFavicon = FaviconStatus().image; | 4080 const gfx::Image kDefaultFavicon = FaviconStatus().image; |
4056 | 4081 |
(...skipping 12 matching lines...) Expand all Loading... |
4069 // Simulate Chromium having set the favicon for |kPageWithFavicon|. | 4094 // Simulate Chromium having set the favicon for |kPageWithFavicon|. |
4070 content::FaviconStatus& favicon_status = entry->GetFavicon(); | 4095 content::FaviconStatus& favicon_status = entry->GetFavicon(); |
4071 favicon_status.image = CreateImage(SK_ColorWHITE); | 4096 favicon_status.image = CreateImage(SK_ColorWHITE); |
4072 favicon_status.url = kIconURL; | 4097 favicon_status.url = kIconURL; |
4073 favicon_status.valid = true; | 4098 favicon_status.valid = true; |
4074 EXPECT_FALSE(DoImagesMatch(kDefaultFavicon, entry->GetFavicon().image)); | 4099 EXPECT_FALSE(DoImagesMatch(kDefaultFavicon, entry->GetFavicon().image)); |
4075 | 4100 |
4076 main_test_rfh()->SendNavigateWithTransition( | 4101 main_test_rfh()->SendNavigateWithTransition( |
4077 0, // same page ID. | 4102 0, // same page ID. |
4078 kPageWithoutFavicon, | 4103 kPageWithoutFavicon, |
4079 PAGE_TRANSITION_CLIENT_REDIRECT); | 4104 ui::PAGE_TRANSITION_CLIENT_REDIRECT); |
4080 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 4105 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
4081 navigation_entry_committed_counter_ = 0; | 4106 navigation_entry_committed_counter_ = 0; |
4082 | 4107 |
4083 entry = controller.GetLastCommittedEntry(); | 4108 entry = controller.GetLastCommittedEntry(); |
4084 EXPECT_TRUE(entry); | 4109 EXPECT_TRUE(entry); |
4085 EXPECT_EQ(kPageWithoutFavicon, entry->GetURL()); | 4110 EXPECT_EQ(kPageWithoutFavicon, entry->GetURL()); |
4086 | 4111 |
4087 EXPECT_TRUE(DoImagesMatch(kDefaultFavicon, entry->GetFavicon().image)); | 4112 EXPECT_TRUE(DoImagesMatch(kDefaultFavicon, entry->GetFavicon().image)); |
4088 } | 4113 } |
4089 | 4114 |
(...skipping 21 matching lines...) Expand all Loading... |
4111 favicon_status.url = kIconURL; | 4136 favicon_status.url = kIconURL; |
4112 favicon_status.valid = true; | 4137 favicon_status.valid = true; |
4113 | 4138 |
4114 // Navigate to another page and go back to the original page. | 4139 // Navigate to another page and go back to the original page. |
4115 main_test_rfh()->SendNavigate(1, kUrl2); | 4140 main_test_rfh()->SendNavigate(1, kUrl2); |
4116 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 4141 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
4117 navigation_entry_committed_counter_ = 0; | 4142 navigation_entry_committed_counter_ = 0; |
4118 main_test_rfh()->SendNavigateWithTransition( | 4143 main_test_rfh()->SendNavigateWithTransition( |
4119 0, | 4144 0, |
4120 kUrl1, | 4145 kUrl1, |
4121 PAGE_TRANSITION_FORWARD_BACK); | 4146 ui::PAGE_TRANSITION_FORWARD_BACK); |
4122 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 4147 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
4123 navigation_entry_committed_counter_ = 0; | 4148 navigation_entry_committed_counter_ = 0; |
4124 | 4149 |
4125 // Verify that the favicon for the page at |kUrl1| was not cleared. | 4150 // Verify that the favicon for the page at |kUrl1| was not cleared. |
4126 entry = controller.GetEntryAtIndex(0); | 4151 entry = controller.GetEntryAtIndex(0); |
4127 EXPECT_TRUE(entry); | 4152 EXPECT_TRUE(entry); |
4128 EXPECT_EQ(kUrl1, entry->GetURL()); | 4153 EXPECT_EQ(kUrl1, entry->GetURL()); |
4129 EXPECT_TRUE(DoImagesMatch(favicon_image, entry->GetFavicon().image)); | 4154 EXPECT_TRUE(DoImagesMatch(favicon_image, entry->GetFavicon().image)); |
4130 } | 4155 } |
4131 | 4156 |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4308 TEST_F(NavigationControllerTest, PostThenReplaceStateThenReload) { | 4333 TEST_F(NavigationControllerTest, PostThenReplaceStateThenReload) { |
4309 scoped_ptr<TestWebContentsDelegate> delegate(new TestWebContentsDelegate()); | 4334 scoped_ptr<TestWebContentsDelegate> delegate(new TestWebContentsDelegate()); |
4310 EXPECT_FALSE(contents()->GetDelegate()); | 4335 EXPECT_FALSE(contents()->GetDelegate()); |
4311 contents()->SetDelegate(delegate.get()); | 4336 contents()->SetDelegate(delegate.get()); |
4312 | 4337 |
4313 // Submit a form. | 4338 // Submit a form. |
4314 GURL url("http://foo"); | 4339 GURL url("http://foo"); |
4315 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 4340 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
4316 params.page_id = 1; | 4341 params.page_id = 1; |
4317 params.url = url; | 4342 params.url = url; |
4318 params.transition = PAGE_TRANSITION_FORM_SUBMIT; | 4343 params.transition = ui::PAGE_TRANSITION_FORM_SUBMIT; |
4319 params.gesture = NavigationGestureUser; | 4344 params.gesture = NavigationGestureUser; |
4320 params.page_state = PageState::CreateFromURL(url); | 4345 params.page_state = PageState::CreateFromURL(url); |
4321 params.was_within_same_page = false; | 4346 params.was_within_same_page = false; |
4322 params.is_post = true; | 4347 params.is_post = true; |
4323 params.post_id = 2; | 4348 params.post_id = 2; |
4324 test_rvh()->SendNavigateWithParams(¶ms); | 4349 test_rvh()->SendNavigateWithParams(¶ms); |
4325 | 4350 |
4326 // history.replaceState() is called. | 4351 // history.replaceState() is called. |
4327 GURL replace_url("http://foo#foo"); | 4352 GURL replace_url("http://foo#foo"); |
4328 params.page_id = 1; | 4353 params.page_id = 1; |
4329 params.url = replace_url; | 4354 params.url = replace_url; |
4330 params.transition = PAGE_TRANSITION_LINK; | 4355 params.transition = ui::PAGE_TRANSITION_LINK; |
4331 params.gesture = NavigationGestureUser; | 4356 params.gesture = NavigationGestureUser; |
4332 params.page_state = PageState::CreateFromURL(replace_url); | 4357 params.page_state = PageState::CreateFromURL(replace_url); |
4333 params.was_within_same_page = true; | 4358 params.was_within_same_page = true; |
4334 params.is_post = false; | 4359 params.is_post = false; |
4335 params.post_id = -1; | 4360 params.post_id = -1; |
4336 test_rvh()->SendNavigateWithParams(¶ms); | 4361 test_rvh()->SendNavigateWithParams(¶ms); |
4337 | 4362 |
4338 // Now reload. replaceState overrides the POST, so we should not show a | 4363 // Now reload. replaceState overrides the POST, so we should not show a |
4339 // repost warning dialog. | 4364 // repost warning dialog. |
4340 controller_impl().Reload(true); | 4365 controller_impl().Reload(true); |
4341 EXPECT_EQ(0, delegate->repost_form_warning_count()); | 4366 EXPECT_EQ(0, delegate->repost_form_warning_count()); |
4342 } | 4367 } |
4343 | 4368 |
4344 } // namespace content | 4369 } // namespace content |
OLD | NEW |