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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
780 main_test_rfh()->SendNavigate(0, kExistingURL1); | 780 main_test_rfh()->SendNavigate(0, kExistingURL1); |
781 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 781 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
782 navigation_entry_committed_counter_ = 0; | 782 navigation_entry_committed_counter_ = 0; |
783 | 783 |
784 // Make a pending entry to somewhere new. | 784 // Make a pending entry to somewhere new. |
785 const GURL kExistingURL2("http://bee"); | 785 const GURL kExistingURL2("http://bee"); |
786 controller.LoadURL( | 786 controller.LoadURL( |
787 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 787 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
788 EXPECT_EQ(0U, notifications.size()); | 788 EXPECT_EQ(0U, notifications.size()); |
789 | 789 |
790 // After the beforeunload but before it commits, do a new navigation. | 790 // After the beforeunload but before it commits... |
nasko
2015/03/16 17:38:26
nit: Add a space after "commits".
carlosk
2015/03/16 18:11:12
Leaving as is at it seems more English-like to fol
| |
791 main_test_rfh()->PrepareForCommit(); | 791 main_test_rfh()->PrepareForCommit(); |
792 | |
793 // ... Do a new navigation. | |
792 const GURL kNewURL("http://see"); | 794 const GURL kNewURL("http://see"); |
795 main_test_rfh()->SendRendererInitiatedNavigationRequest(kNewURL, true); | |
793 main_test_rfh()->PrepareForCommit(); | 796 main_test_rfh()->PrepareForCommit(); |
794 contents()->GetMainFrame()->SendNavigate(3, kNewURL); | 797 contents()->GetMainFrame()->SendNavigate(3, kNewURL); |
795 | 798 |
796 // There should no longer be any pending entry, and the third navigation we | 799 // There should no longer be any pending entry, and the third navigation we |
797 // just made should be committed. | 800 // just made should be committed. |
798 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 801 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
799 navigation_entry_committed_counter_ = 0; | 802 navigation_entry_committed_counter_ = 0; |
800 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 803 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
801 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 804 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
802 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); | 805 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1002 | 1005 |
1003 // Set a WebContentsDelegate to listen for state changes. | 1006 // Set a WebContentsDelegate to listen for state changes. |
1004 scoped_ptr<TestWebContentsDelegate> delegate(new TestWebContentsDelegate()); | 1007 scoped_ptr<TestWebContentsDelegate> delegate(new TestWebContentsDelegate()); |
1005 EXPECT_FALSE(contents()->GetDelegate()); | 1008 EXPECT_FALSE(contents()->GetDelegate()); |
1006 contents()->SetDelegate(delegate.get()); | 1009 contents()->SetDelegate(delegate.get()); |
1007 | 1010 |
1008 // Start with a pending new navigation. | 1011 // Start with a pending new navigation. |
1009 const GURL kNewURL("http://eh"); | 1012 const GURL kNewURL("http://eh"); |
1010 controller.LoadURL( | 1013 controller.LoadURL( |
1011 kNewURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1014 kNewURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1015 main_test_rfh()->PrepareForCommit(); | |
1012 EXPECT_EQ(0U, notifications.size()); | 1016 EXPECT_EQ(0U, notifications.size()); |
1013 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 1017 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
1014 EXPECT_TRUE(controller.GetPendingEntry()); | 1018 EXPECT_TRUE(controller.GetPendingEntry()); |
1015 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); | 1019 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); |
1016 EXPECT_EQ(1, delegate->navigation_state_change_count()); | 1020 EXPECT_EQ(1, delegate->navigation_state_change_count()); |
1017 | 1021 |
1018 // It may abort before committing, if it's a download or due to a stop or | 1022 // It may abort before committing, if it's a download or due to a stop or |
1019 // a new navigation from the user. | 1023 // a new navigation from the user. |
1020 FrameHostMsg_DidFailProvisionalLoadWithError_Params params; | 1024 FrameHostMsg_DidFailProvisionalLoadWithError_Params params; |
1021 params.error_code = net::ERR_ABORTED; | 1025 params.error_code = net::ERR_ABORTED; |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1628 | 1632 |
1629 // Tests what happens when we navigate forward successfully. | 1633 // Tests what happens when we navigate forward successfully. |
1630 TEST_F(NavigationControllerTest, Forward) { | 1634 TEST_F(NavigationControllerTest, Forward) { |
1631 NavigationControllerImpl& controller = controller_impl(); | 1635 NavigationControllerImpl& controller = controller_impl(); |
1632 TestNotificationTracker notifications; | 1636 TestNotificationTracker notifications; |
1633 RegisterForAllNavNotifications(¬ifications, &controller); | 1637 RegisterForAllNavNotifications(¬ifications, &controller); |
1634 | 1638 |
1635 const GURL url1("http://foo1"); | 1639 const GURL url1("http://foo1"); |
1636 const GURL url2("http://foo2"); | 1640 const GURL url2("http://foo2"); |
1637 | 1641 |
1642 main_test_rfh()->SendRendererInitiatedNavigationRequest(url1, true); | |
1638 main_test_rfh()->PrepareForCommit(); | 1643 main_test_rfh()->PrepareForCommit(); |
1639 main_test_rfh()->SendNavigate(0, url1); | 1644 main_test_rfh()->SendNavigate(0, url1); |
1640 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1645 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1641 navigation_entry_committed_counter_ = 0; | 1646 navigation_entry_committed_counter_ = 0; |
1642 | 1647 |
1648 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, true); | |
1643 main_test_rfh()->PrepareForCommit(); | 1649 main_test_rfh()->PrepareForCommit(); |
1644 main_test_rfh()->SendNavigate(1, url2); | 1650 main_test_rfh()->SendNavigate(1, url2); |
1645 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1651 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1646 navigation_entry_committed_counter_ = 0; | 1652 navigation_entry_committed_counter_ = 0; |
1647 | 1653 |
1648 controller.GoBack(); | 1654 controller.GoBack(); |
1649 main_test_rfh()->PrepareForCommit(); | 1655 main_test_rfh()->PrepareForCommit(); |
1650 main_test_rfh()->SendNavigate(0, url1); | 1656 main_test_rfh()->SendNavigate(0, url1); |
1651 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1657 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1652 navigation_entry_committed_counter_ = 0; | 1658 navigation_entry_committed_counter_ = 0; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1697 // Tests what happens when a forward navigation produces a new page. | 1703 // Tests what happens when a forward navigation produces a new page. |
1698 TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) { | 1704 TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) { |
1699 NavigationControllerImpl& controller = controller_impl(); | 1705 NavigationControllerImpl& controller = controller_impl(); |
1700 TestNotificationTracker notifications; | 1706 TestNotificationTracker notifications; |
1701 RegisterForAllNavNotifications(¬ifications, &controller); | 1707 RegisterForAllNavNotifications(¬ifications, &controller); |
1702 | 1708 |
1703 const GURL url1("http://foo1"); | 1709 const GURL url1("http://foo1"); |
1704 const GURL url2("http://foo2"); | 1710 const GURL url2("http://foo2"); |
1705 const GURL url3("http://foo3"); | 1711 const GURL url3("http://foo3"); |
1706 | 1712 |
1713 main_test_rfh()->SendRendererInitiatedNavigationRequest(url1, true); | |
1707 main_test_rfh()->PrepareForCommit(); | 1714 main_test_rfh()->PrepareForCommit(); |
1708 main_test_rfh()->SendNavigate(0, url1); | 1715 main_test_rfh()->SendNavigate(0, url1); |
1709 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1716 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1710 navigation_entry_committed_counter_ = 0; | 1717 navigation_entry_committed_counter_ = 0; |
1718 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, true); | |
1711 main_test_rfh()->PrepareForCommit(); | 1719 main_test_rfh()->PrepareForCommit(); |
1712 main_test_rfh()->SendNavigate(1, url2); | 1720 main_test_rfh()->SendNavigate(1, url2); |
1713 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1721 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1714 navigation_entry_committed_counter_ = 0; | 1722 navigation_entry_committed_counter_ = 0; |
1715 | 1723 |
1716 controller.GoBack(); | 1724 controller.GoBack(); |
1717 main_test_rfh()->PrepareForCommit(); | 1725 main_test_rfh()->PrepareForCommit(); |
1718 main_test_rfh()->SendNavigate(0, url1); | 1726 main_test_rfh()->SendNavigate(0, url1); |
1719 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1727 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1720 navigation_entry_committed_counter_ = 0; | 1728 navigation_entry_committed_counter_ = 0; |
(...skipping 2815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4536 { | 4544 { |
4537 LoadCommittedDetails details; | 4545 LoadCommittedDetails details; |
4538 controller_impl().RendererDidNavigate(main_test_rfh(), params, &details); | 4546 controller_impl().RendererDidNavigate(main_test_rfh(), params, &details); |
4539 EXPECT_EQ(PAGE_TYPE_ERROR, | 4547 EXPECT_EQ(PAGE_TYPE_ERROR, |
4540 controller_impl().GetLastCommittedEntry()->GetPageType()); | 4548 controller_impl().GetLastCommittedEntry()->GetPageType()); |
4541 EXPECT_EQ(NAVIGATION_TYPE_IN_PAGE, details.type); | 4549 EXPECT_EQ(NAVIGATION_TYPE_IN_PAGE, details.type); |
4542 } | 4550 } |
4543 } | 4551 } |
4544 | 4552 |
4545 } // namespace content | 4553 } // namespace content |
OLD | NEW |