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

Side by Side Diff: content/browser/frame_host/navigation_controller_impl_unittest.cc

Issue 182713005: Remove frame ID from DidCommitProvisionalLoad. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix John's comments and signin test Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/file_util.h" 7 #include "base/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 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after
1667 params.redirects.push_back(GURL("http://foo1")); 1667 params.redirects.push_back(GURL("http://foo1"));
1668 params.redirects.push_back(GURL("http://foo2")); 1668 params.redirects.push_back(GURL("http://foo2"));
1669 params.should_update_history = false; 1669 params.should_update_history = false;
1670 params.gesture = NavigationGestureAuto; 1670 params.gesture = NavigationGestureAuto;
1671 params.is_post = false; 1671 params.is_post = false;
1672 params.page_state = PageState::CreateFromURL(url2); 1672 params.page_state = PageState::CreateFromURL(url2);
1673 1673
1674 LoadCommittedDetails details; 1674 LoadCommittedDetails details;
1675 1675
1676 EXPECT_EQ(0U, notifications.size()); 1676 EXPECT_EQ(0U, notifications.size());
1677 EXPECT_TRUE(controller.RendererDidNavigate(test_rvh(), params, &details)); 1677 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
1678 &details));
1678 EXPECT_EQ(1U, navigation_entry_committed_counter_); 1679 EXPECT_EQ(1U, navigation_entry_committed_counter_);
1679 navigation_entry_committed_counter_ = 0; 1680 navigation_entry_committed_counter_ = 0;
1680 1681
1681 EXPECT_TRUE(details.type == NAVIGATION_TYPE_SAME_PAGE); 1682 EXPECT_TRUE(details.type == NAVIGATION_TYPE_SAME_PAGE);
1682 EXPECT_EQ(controller.GetEntryCount(), 1); 1683 EXPECT_EQ(controller.GetEntryCount(), 1);
1683 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); 1684 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0);
1684 EXPECT_TRUE(controller.GetLastCommittedEntry()); 1685 EXPECT_TRUE(controller.GetLastCommittedEntry());
1685 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); 1686 EXPECT_EQ(controller.GetPendingEntryIndex(), -1);
1686 EXPECT_FALSE(controller.GetPendingEntry()); 1687 EXPECT_FALSE(controller.GetPendingEntry());
1687 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); 1688 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 params.redirects.push_back(GURL("http://foo1")); 1725 params.redirects.push_back(GURL("http://foo1"));
1725 params.redirects.push_back(GURL("http://foo2")); 1726 params.redirects.push_back(GURL("http://foo2"));
1726 params.should_update_history = false; 1727 params.should_update_history = false;
1727 params.gesture = NavigationGestureAuto; 1728 params.gesture = NavigationGestureAuto;
1728 params.is_post = false; 1729 params.is_post = false;
1729 params.page_state = PageState::CreateFromURL(url2); 1730 params.page_state = PageState::CreateFromURL(url2);
1730 1731
1731 LoadCommittedDetails details; 1732 LoadCommittedDetails details;
1732 1733
1733 EXPECT_EQ(0U, notifications.size()); 1734 EXPECT_EQ(0U, notifications.size());
1734 EXPECT_TRUE(controller.RendererDidNavigate(test_rvh(), params, &details)); 1735 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
1736 &details));
1735 EXPECT_EQ(1U, navigation_entry_committed_counter_); 1737 EXPECT_EQ(1U, navigation_entry_committed_counter_);
1736 navigation_entry_committed_counter_ = 0; 1738 navigation_entry_committed_counter_ = 0;
1737 1739
1738 EXPECT_TRUE(details.type == NAVIGATION_TYPE_SAME_PAGE); 1740 EXPECT_TRUE(details.type == NAVIGATION_TYPE_SAME_PAGE);
1739 EXPECT_EQ(controller.GetEntryCount(), 1); 1741 EXPECT_EQ(controller.GetEntryCount(), 1);
1740 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); 1742 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0);
1741 EXPECT_TRUE(controller.GetLastCommittedEntry()); 1743 EXPECT_TRUE(controller.GetLastCommittedEntry());
1742 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); 1744 EXPECT_EQ(controller.GetPendingEntryIndex(), -1);
1743 EXPECT_FALSE(controller.GetPendingEntry()); 1745 EXPECT_FALSE(controller.GetPendingEntry());
1744 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); 1746 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL());
(...skipping 26 matching lines...) Expand all
1771 params.redirects.push_back(GURL("http://foo1")); 1773 params.redirects.push_back(GURL("http://foo1"));
1772 params.redirects.push_back(GURL("http://foo2")); 1774 params.redirects.push_back(GURL("http://foo2"));
1773 params.should_update_history = false; 1775 params.should_update_history = false;
1774 params.gesture = NavigationGestureAuto; 1776 params.gesture = NavigationGestureAuto;
1775 params.is_post = false; 1777 params.is_post = false;
1776 params.page_state = PageState::CreateFromURL(url2); 1778 params.page_state = PageState::CreateFromURL(url2);
1777 1779
1778 LoadCommittedDetails details; 1780 LoadCommittedDetails details;
1779 1781
1780 EXPECT_EQ(0U, notifications.size()); 1782 EXPECT_EQ(0U, notifications.size());
1781 EXPECT_TRUE(controller.RendererDidNavigate(test_rvh(), params, &details)); 1783 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
1784 &details));
1782 EXPECT_EQ(1U, navigation_entry_committed_counter_); 1785 EXPECT_EQ(1U, navigation_entry_committed_counter_);
1783 navigation_entry_committed_counter_ = 0; 1786 navigation_entry_committed_counter_ = 0;
1784 1787
1785 EXPECT_TRUE(details.type == NAVIGATION_TYPE_NEW_PAGE); 1788 EXPECT_TRUE(details.type == NAVIGATION_TYPE_NEW_PAGE);
1786 EXPECT_EQ(controller.GetEntryCount(), 1); 1789 EXPECT_EQ(controller.GetEntryCount(), 1);
1787 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); 1790 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0);
1788 EXPECT_TRUE(controller.GetLastCommittedEntry()); 1791 EXPECT_TRUE(controller.GetLastCommittedEntry());
1789 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); 1792 EXPECT_EQ(controller.GetPendingEntryIndex(), -1);
1790 EXPECT_FALSE(controller.GetPendingEntry()); 1793 EXPECT_FALSE(controller.GetPendingEntry());
1791 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); 1794 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL());
(...skipping 18 matching lines...) Expand all
1810 FrameHostMsg_DidCommitProvisionalLoad_Params params; 1813 FrameHostMsg_DidCommitProvisionalLoad_Params params;
1811 params.page_id = 1; 1814 params.page_id = 1;
1812 params.url = url2; 1815 params.url = url2;
1813 params.transition = PAGE_TRANSITION_MANUAL_SUBFRAME; 1816 params.transition = PAGE_TRANSITION_MANUAL_SUBFRAME;
1814 params.should_update_history = false; 1817 params.should_update_history = false;
1815 params.gesture = NavigationGestureUser; 1818 params.gesture = NavigationGestureUser;
1816 params.is_post = false; 1819 params.is_post = false;
1817 params.page_state = PageState::CreateFromURL(url2); 1820 params.page_state = PageState::CreateFromURL(url2);
1818 1821
1819 LoadCommittedDetails details; 1822 LoadCommittedDetails details;
1820 EXPECT_TRUE(controller.RendererDidNavigate(test_rvh(), params, &details)); 1823 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
1824 &details));
1821 EXPECT_EQ(1U, navigation_entry_committed_counter_); 1825 EXPECT_EQ(1U, navigation_entry_committed_counter_);
1822 navigation_entry_committed_counter_ = 0; 1826 navigation_entry_committed_counter_ = 0;
1823 EXPECT_EQ(url1, details.previous_url); 1827 EXPECT_EQ(url1, details.previous_url);
1824 EXPECT_FALSE(details.is_in_page); 1828 EXPECT_FALSE(details.is_in_page);
1825 EXPECT_FALSE(details.is_main_frame); 1829 EXPECT_FALSE(details.is_main_frame);
1826 1830
1827 // The new entry should be appended. 1831 // The new entry should be appended.
1828 EXPECT_EQ(2, controller.GetEntryCount()); 1832 EXPECT_EQ(2, controller.GetEntryCount());
1829 1833
1830 // New entry should refer to the new page, but the old URL (entries only 1834 // New entry should refer to the new page, but the old URL (entries only
(...skipping 15 matching lines...) Expand all
1846 FrameHostMsg_DidCommitProvisionalLoad_Params params; 1850 FrameHostMsg_DidCommitProvisionalLoad_Params params;
1847 params.page_id = 1; 1851 params.page_id = 1;
1848 params.url = url; 1852 params.url = url;
1849 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; 1853 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME;
1850 params.should_update_history = false; 1854 params.should_update_history = false;
1851 params.gesture = NavigationGestureAuto; 1855 params.gesture = NavigationGestureAuto;
1852 params.is_post = false; 1856 params.is_post = false;
1853 params.page_state = PageState::CreateFromURL(url); 1857 params.page_state = PageState::CreateFromURL(url);
1854 1858
1855 LoadCommittedDetails details; 1859 LoadCommittedDetails details;
1856 EXPECT_FALSE(controller.RendererDidNavigate(test_rvh(), params, &details)); 1860 EXPECT_FALSE(controller.RendererDidNavigate(main_test_rfh(), params,
1861 &details));
1857 EXPECT_EQ(0U, notifications.size()); 1862 EXPECT_EQ(0U, notifications.size());
1858 } 1863 }
1859 1864
1860 // Auto subframes are ones the page loads automatically like ads. They should 1865 // Auto subframes are ones the page loads automatically like ads. They should
1861 // not create new navigation entries. 1866 // not create new navigation entries.
1862 TEST_F(NavigationControllerTest, AutoSubframe) { 1867 TEST_F(NavigationControllerTest, AutoSubframe) {
1863 NavigationControllerImpl& controller = controller_impl(); 1868 NavigationControllerImpl& controller = controller_impl();
1864 TestNotificationTracker notifications; 1869 TestNotificationTracker notifications;
1865 RegisterForAllNavNotifications(&notifications, &controller); 1870 RegisterForAllNavNotifications(&notifications, &controller);
1866 1871
1867 const GURL url1("http://foo1"); 1872 const GURL url1("http://foo1");
1868 main_test_rfh()->SendNavigate(0, url1); 1873 main_test_rfh()->SendNavigate(0, url1);
1869 EXPECT_EQ(1U, navigation_entry_committed_counter_); 1874 EXPECT_EQ(1U, navigation_entry_committed_counter_);
1870 navigation_entry_committed_counter_ = 0; 1875 navigation_entry_committed_counter_ = 0;
1871 1876
1872 const GURL url2("http://foo2"); 1877 const GURL url2("http://foo2");
1873 FrameHostMsg_DidCommitProvisionalLoad_Params params; 1878 FrameHostMsg_DidCommitProvisionalLoad_Params params;
1874 params.page_id = 0; 1879 params.page_id = 0;
1875 params.url = url2; 1880 params.url = url2;
1876 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; 1881 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME;
1877 params.should_update_history = false; 1882 params.should_update_history = false;
1878 params.gesture = NavigationGestureUser; 1883 params.gesture = NavigationGestureUser;
1879 params.is_post = false; 1884 params.is_post = false;
1880 params.page_state = PageState::CreateFromURL(url2); 1885 params.page_state = PageState::CreateFromURL(url2);
1881 1886
1882 // Navigating should do nothing. 1887 // Navigating should do nothing.
1883 LoadCommittedDetails details; 1888 LoadCommittedDetails details;
1884 EXPECT_FALSE(controller.RendererDidNavigate(test_rvh(), params, &details)); 1889 EXPECT_FALSE(controller.RendererDidNavigate(main_test_rfh(), params,
1890 &details));
1885 EXPECT_EQ(0U, notifications.size()); 1891 EXPECT_EQ(0U, notifications.size());
1886 1892
1887 // There should still be only one entry. 1893 // There should still be only one entry.
1888 EXPECT_EQ(1, controller.GetEntryCount()); 1894 EXPECT_EQ(1, controller.GetEntryCount());
1889 } 1895 }
1890 1896
1891 // Tests navigation and then going back to a subframe navigation. 1897 // Tests navigation and then going back to a subframe navigation.
1892 TEST_F(NavigationControllerTest, BackSubframe) { 1898 TEST_F(NavigationControllerTest, BackSubframe) {
1893 NavigationControllerImpl& controller = controller_impl(); 1899 NavigationControllerImpl& controller = controller_impl();
1894 TestNotificationTracker notifications; 1900 TestNotificationTracker notifications;
(...skipping 11 matching lines...) Expand all
1906 params.page_id = 1; 1912 params.page_id = 1;
1907 params.url = url2; 1913 params.url = url2;
1908 params.transition = PAGE_TRANSITION_MANUAL_SUBFRAME; 1914 params.transition = PAGE_TRANSITION_MANUAL_SUBFRAME;
1909 params.should_update_history = false; 1915 params.should_update_history = false;
1910 params.gesture = NavigationGestureUser; 1916 params.gesture = NavigationGestureUser;
1911 params.is_post = false; 1917 params.is_post = false;
1912 params.page_state = PageState::CreateFromURL(url2); 1918 params.page_state = PageState::CreateFromURL(url2);
1913 1919
1914 // This should generate a new entry. 1920 // This should generate a new entry.
1915 LoadCommittedDetails details; 1921 LoadCommittedDetails details;
1916 EXPECT_TRUE(controller.RendererDidNavigate(test_rvh(), params, &details)); 1922 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
1923 &details));
1917 EXPECT_EQ(1U, navigation_entry_committed_counter_); 1924 EXPECT_EQ(1U, navigation_entry_committed_counter_);
1918 navigation_entry_committed_counter_ = 0; 1925 navigation_entry_committed_counter_ = 0;
1919 EXPECT_EQ(2, controller.GetEntryCount()); 1926 EXPECT_EQ(2, controller.GetEntryCount());
1920 1927
1921 // Second manual subframe navigation should also make a new entry. 1928 // Second manual subframe navigation should also make a new entry.
1922 const GURL url3("http://foo3"); 1929 const GURL url3("http://foo3");
1923 params.page_id = 2; 1930 params.page_id = 2;
1924 params.url = url3; 1931 params.url = url3;
1925 EXPECT_TRUE(controller.RendererDidNavigate(test_rvh(), params, &details)); 1932 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
1933 &details));
1926 EXPECT_EQ(1U, navigation_entry_committed_counter_); 1934 EXPECT_EQ(1U, navigation_entry_committed_counter_);
1927 navigation_entry_committed_counter_ = 0; 1935 navigation_entry_committed_counter_ = 0;
1928 EXPECT_EQ(3, controller.GetEntryCount()); 1936 EXPECT_EQ(3, controller.GetEntryCount());
1929 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); 1937 EXPECT_EQ(2, controller.GetCurrentEntryIndex());
1930 1938
1931 // Go back one. 1939 // Go back one.
1932 controller.GoBack(); 1940 controller.GoBack();
1933 params.url = url2; 1941 params.url = url2;
1934 params.page_id = 1; 1942 params.page_id = 1;
1935 EXPECT_TRUE(controller.RendererDidNavigate(test_rvh(), params, &details)); 1943 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
1944 &details));
1936 EXPECT_EQ(1U, navigation_entry_committed_counter_); 1945 EXPECT_EQ(1U, navigation_entry_committed_counter_);
1937 navigation_entry_committed_counter_ = 0; 1946 navigation_entry_committed_counter_ = 0;
1938 EXPECT_EQ(3, controller.GetEntryCount()); 1947 EXPECT_EQ(3, controller.GetEntryCount());
1939 EXPECT_EQ(1, controller.GetCurrentEntryIndex()); 1948 EXPECT_EQ(1, controller.GetCurrentEntryIndex());
1940 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 1949 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
1941 EXPECT_FALSE(controller.GetPendingEntry()); 1950 EXPECT_FALSE(controller.GetPendingEntry());
1942 1951
1943 // Go back one more. 1952 // Go back one more.
1944 controller.GoBack(); 1953 controller.GoBack();
1945 params.url = url1; 1954 params.url = url1;
1946 params.page_id = 0; 1955 params.page_id = 0;
1947 EXPECT_TRUE(controller.RendererDidNavigate(test_rvh(), params, &details)); 1956 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
1957 &details));
1948 EXPECT_EQ(1U, navigation_entry_committed_counter_); 1958 EXPECT_EQ(1U, navigation_entry_committed_counter_);
1949 navigation_entry_committed_counter_ = 0; 1959 navigation_entry_committed_counter_ = 0;
1950 EXPECT_EQ(3, controller.GetEntryCount()); 1960 EXPECT_EQ(3, controller.GetEntryCount());
1951 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); 1961 EXPECT_EQ(0, controller.GetCurrentEntryIndex());
1952 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 1962 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
1953 EXPECT_FALSE(controller.GetPendingEntry()); 1963 EXPECT_FALSE(controller.GetPendingEntry());
1954 } 1964 }
1955 1965
1956 TEST_F(NavigationControllerTest, LinkClick) { 1966 TEST_F(NavigationControllerTest, LinkClick) {
1957 NavigationControllerImpl& controller = controller_impl(); 1967 NavigationControllerImpl& controller = controller_impl();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 self_params.page_id = 0; 2006 self_params.page_id = 0;
1997 self_params.url = url1; 2007 self_params.url = url1;
1998 self_params.transition = PAGE_TRANSITION_LINK; 2008 self_params.transition = PAGE_TRANSITION_LINK;
1999 self_params.should_update_history = false; 2009 self_params.should_update_history = false;
2000 self_params.gesture = NavigationGestureUser; 2010 self_params.gesture = NavigationGestureUser;
2001 self_params.is_post = false; 2011 self_params.is_post = false;
2002 self_params.page_state = PageState::CreateFromURL(url1); 2012 self_params.page_state = PageState::CreateFromURL(url1);
2003 self_params.was_within_same_page = true; 2013 self_params.was_within_same_page = true;
2004 2014
2005 LoadCommittedDetails details; 2015 LoadCommittedDetails details;
2006 EXPECT_TRUE(controller.RendererDidNavigate(test_rvh(), self_params, 2016 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), self_params,
2007 &details)); 2017 &details));
2008 EXPECT_EQ(1U, navigation_entry_committed_counter_); 2018 EXPECT_EQ(1U, navigation_entry_committed_counter_);
2009 navigation_entry_committed_counter_ = 0; 2019 navigation_entry_committed_counter_ = 0;
2010 EXPECT_TRUE(details.is_in_page); 2020 EXPECT_TRUE(details.is_in_page);
2011 EXPECT_TRUE(details.did_replace_entry); 2021 EXPECT_TRUE(details.did_replace_entry);
2012 EXPECT_EQ(1, controller.GetEntryCount()); 2022 EXPECT_EQ(1, controller.GetEntryCount());
2013 2023
2014 // Fragment navigation to a new page_id. 2024 // Fragment navigation to a new page_id.
2015 const GURL url2("http://foo#a"); 2025 const GURL url2("http://foo#a");
2016 FrameHostMsg_DidCommitProvisionalLoad_Params params; 2026 FrameHostMsg_DidCommitProvisionalLoad_Params params;
2017 params.page_id = 1; 2027 params.page_id = 1;
2018 params.url = url2; 2028 params.url = url2;
2019 params.transition = PAGE_TRANSITION_LINK; 2029 params.transition = PAGE_TRANSITION_LINK;
2020 params.should_update_history = false; 2030 params.should_update_history = false;
2021 params.gesture = NavigationGestureUser; 2031 params.gesture = NavigationGestureUser;
2022 params.is_post = false; 2032 params.is_post = false;
2023 params.page_state = PageState::CreateFromURL(url2); 2033 params.page_state = PageState::CreateFromURL(url2);
2024 params.was_within_same_page = true; 2034 params.was_within_same_page = true;
2025 2035
2026 // This should generate a new entry. 2036 // This should generate a new entry.
2027 EXPECT_TRUE(controller.RendererDidNavigate(test_rvh(), params, &details)); 2037 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
2038 &details));
2028 EXPECT_EQ(1U, navigation_entry_committed_counter_); 2039 EXPECT_EQ(1U, navigation_entry_committed_counter_);
2029 navigation_entry_committed_counter_ = 0; 2040 navigation_entry_committed_counter_ = 0;
2030 EXPECT_TRUE(details.is_in_page); 2041 EXPECT_TRUE(details.is_in_page);
2031 EXPECT_FALSE(details.did_replace_entry); 2042 EXPECT_FALSE(details.did_replace_entry);
2032 EXPECT_EQ(2, controller.GetEntryCount()); 2043 EXPECT_EQ(2, controller.GetEntryCount());
2033 2044
2034 // Go back one. 2045 // Go back one.
2035 FrameHostMsg_DidCommitProvisionalLoad_Params back_params(params); 2046 FrameHostMsg_DidCommitProvisionalLoad_Params back_params(params);
2036 controller.GoBack(); 2047 controller.GoBack();
2037 back_params.url = url1; 2048 back_params.url = url1;
2038 back_params.page_id = 0; 2049 back_params.page_id = 0;
2039 EXPECT_TRUE(controller.RendererDidNavigate(test_rvh(), back_params, 2050 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), back_params,
2040 &details)); 2051 &details));
2041 EXPECT_EQ(1U, navigation_entry_committed_counter_); 2052 EXPECT_EQ(1U, navigation_entry_committed_counter_);
2042 navigation_entry_committed_counter_ = 0; 2053 navigation_entry_committed_counter_ = 0;
2043 EXPECT_TRUE(details.is_in_page); 2054 EXPECT_TRUE(details.is_in_page);
2044 EXPECT_EQ(2, controller.GetEntryCount()); 2055 EXPECT_EQ(2, controller.GetEntryCount());
2045 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); 2056 EXPECT_EQ(0, controller.GetCurrentEntryIndex());
2046 EXPECT_EQ(back_params.url, controller.GetVisibleEntry()->GetURL()); 2057 EXPECT_EQ(back_params.url, controller.GetVisibleEntry()->GetURL());
2047 2058
2048 // Go forward 2059 // Go forward
2049 FrameHostMsg_DidCommitProvisionalLoad_Params forward_params(params); 2060 FrameHostMsg_DidCommitProvisionalLoad_Params forward_params(params);
2050 controller.GoForward(); 2061 controller.GoForward();
2051 forward_params.url = url2; 2062 forward_params.url = url2;
2052 forward_params.page_id = 1; 2063 forward_params.page_id = 1;
2053 EXPECT_TRUE(controller.RendererDidNavigate(test_rvh(), forward_params, 2064 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), forward_params,
2054 &details)); 2065 &details));
2055 EXPECT_EQ(1U, navigation_entry_committed_counter_); 2066 EXPECT_EQ(1U, navigation_entry_committed_counter_);
2056 navigation_entry_committed_counter_ = 0; 2067 navigation_entry_committed_counter_ = 0;
2057 EXPECT_TRUE(details.is_in_page); 2068 EXPECT_TRUE(details.is_in_page);
2058 EXPECT_EQ(2, controller.GetEntryCount()); 2069 EXPECT_EQ(2, controller.GetEntryCount());
2059 EXPECT_EQ(1, controller.GetCurrentEntryIndex()); 2070 EXPECT_EQ(1, controller.GetCurrentEntryIndex());
2060 EXPECT_EQ(forward_params.url, 2071 EXPECT_EQ(forward_params.url,
2061 controller.GetVisibleEntry()->GetURL()); 2072 controller.GetVisibleEntry()->GetURL());
2062 2073
2063 // Now go back and forward again. This is to work around a bug where we would 2074 // Now go back and forward again. This is to work around a bug where we would
2064 // compare the incoming URL with the last committed entry rather than the 2075 // compare the incoming URL with the last committed entry rather than the
2065 // one identified by an existing page ID. This would result in the second URL 2076 // one identified by an existing page ID. This would result in the second URL
2066 // losing the reference fragment when you navigate away from it and then back. 2077 // losing the reference fragment when you navigate away from it and then back.
2067 controller.GoBack(); 2078 controller.GoBack();
2068 EXPECT_TRUE(controller.RendererDidNavigate(test_rvh(), back_params, 2079 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), back_params,
2069 &details)); 2080 &details));
2070 controller.GoForward(); 2081 controller.GoForward();
2071 EXPECT_TRUE(controller.RendererDidNavigate(test_rvh(), forward_params, 2082 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), forward_params,
2072 &details)); 2083 &details));
2073 EXPECT_EQ(forward_params.url, 2084 EXPECT_EQ(forward_params.url,
2074 controller.GetVisibleEntry()->GetURL()); 2085 controller.GetVisibleEntry()->GetURL());
2075 2086
2076 // Finally, navigate to an unrelated URL to make sure in_page is not sticky. 2087 // Finally, navigate to an unrelated URL to make sure in_page is not sticky.
2077 const GURL url3("http://bar"); 2088 const GURL url3("http://bar");
2078 params.page_id = 2; 2089 params.page_id = 2;
2079 params.url = url3; 2090 params.url = url3;
2080 navigation_entry_committed_counter_ = 0; 2091 navigation_entry_committed_counter_ = 0;
2081 EXPECT_TRUE(controller.RendererDidNavigate(test_rvh(), params, &details)); 2092 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
2093 &details));
2082 EXPECT_EQ(1U, navigation_entry_committed_counter_); 2094 EXPECT_EQ(1U, navigation_entry_committed_counter_);
2083 navigation_entry_committed_counter_ = 0; 2095 navigation_entry_committed_counter_ = 0;
2084 EXPECT_FALSE(details.is_in_page); 2096 EXPECT_FALSE(details.is_in_page);
2085 EXPECT_EQ(3, controller.GetEntryCount()); 2097 EXPECT_EQ(3, controller.GetEntryCount());
2086 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); 2098 EXPECT_EQ(2, controller.GetCurrentEntryIndex());
2087 } 2099 }
2088 2100
2089 TEST_F(NavigationControllerTest, InPage_Replace) { 2101 TEST_F(NavigationControllerTest, InPage_Replace) {
2090 NavigationControllerImpl& controller = controller_impl(); 2102 NavigationControllerImpl& controller = controller_impl();
2091 TestNotificationTracker notifications; 2103 TestNotificationTracker notifications;
(...skipping 11 matching lines...) Expand all
2103 params.page_id = 0; // Same page_id 2115 params.page_id = 0; // Same page_id
2104 params.url = url2; 2116 params.url = url2;
2105 params.transition = PAGE_TRANSITION_LINK; 2117 params.transition = PAGE_TRANSITION_LINK;
2106 params.should_update_history = false; 2118 params.should_update_history = false;
2107 params.gesture = NavigationGestureUser; 2119 params.gesture = NavigationGestureUser;
2108 params.is_post = false; 2120 params.is_post = false;
2109 params.page_state = PageState::CreateFromURL(url2); 2121 params.page_state = PageState::CreateFromURL(url2);
2110 2122
2111 // This should NOT generate a new entry, nor prune the list. 2123 // This should NOT generate a new entry, nor prune the list.
2112 LoadCommittedDetails details; 2124 LoadCommittedDetails details;
2113 EXPECT_TRUE(controller.RendererDidNavigate(test_rvh(), params, &details)); 2125 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
2126 &details));
2114 EXPECT_EQ(1U, navigation_entry_committed_counter_); 2127 EXPECT_EQ(1U, navigation_entry_committed_counter_);
2115 navigation_entry_committed_counter_ = 0; 2128 navigation_entry_committed_counter_ = 0;
2116 EXPECT_TRUE(details.is_in_page); 2129 EXPECT_TRUE(details.is_in_page);
2117 EXPECT_TRUE(details.did_replace_entry); 2130 EXPECT_TRUE(details.did_replace_entry);
2118 EXPECT_EQ(1, controller.GetEntryCount()); 2131 EXPECT_EQ(1, controller.GetEntryCount());
2119 } 2132 }
2120 2133
2121 // Tests for http://crbug.com/40395 2134 // Tests for http://crbug.com/40395
2122 // Simulates this: 2135 // Simulates this:
2123 // <script> 2136 // <script>
(...skipping 29 matching lines...) Expand all
2153 params.url = url; 2166 params.url = url;
2154 params.transition = PAGE_TRANSITION_LINK; 2167 params.transition = PAGE_TRANSITION_LINK;
2155 params.redirects.push_back(url); 2168 params.redirects.push_back(url);
2156 params.should_update_history = true; 2169 params.should_update_history = true;
2157 params.gesture = NavigationGestureUnknown; 2170 params.gesture = NavigationGestureUnknown;
2158 params.is_post = false; 2171 params.is_post = false;
2159 params.page_state = PageState::CreateFromURL(url); 2172 params.page_state = PageState::CreateFromURL(url);
2160 2173
2161 // This should NOT generate a new entry, nor prune the list. 2174 // This should NOT generate a new entry, nor prune the list.
2162 LoadCommittedDetails details; 2175 LoadCommittedDetails details;
2163 EXPECT_TRUE(controller.RendererDidNavigate(test_rvh(), params, &details)); 2176 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
2177 &details));
2164 EXPECT_EQ(1U, navigation_entry_committed_counter_); 2178 EXPECT_EQ(1U, navigation_entry_committed_counter_);
2165 navigation_entry_committed_counter_ = 0; 2179 navigation_entry_committed_counter_ = 0;
2166 EXPECT_TRUE(details.is_in_page); 2180 EXPECT_TRUE(details.is_in_page);
2167 EXPECT_TRUE(details.did_replace_entry); 2181 EXPECT_TRUE(details.did_replace_entry);
2168 EXPECT_EQ(2, controller.GetEntryCount()); 2182 EXPECT_EQ(2, controller.GetEntryCount());
2169 } 2183 }
2170 2184
2171 // Perform a client redirect to a new page. 2185 // Perform a client redirect to a new page.
2172 { 2186 {
2173 const GURL url("http://foo3/"); 2187 const GURL url("http://foo3/");
2174 FrameHostMsg_DidCommitProvisionalLoad_Params params; 2188 FrameHostMsg_DidCommitProvisionalLoad_Params params;
2175 params.page_id = 2; // New page_id 2189 params.page_id = 2; // New page_id
2176 params.url = url; 2190 params.url = url;
2177 params.transition = PAGE_TRANSITION_CLIENT_REDIRECT; 2191 params.transition = PAGE_TRANSITION_CLIENT_REDIRECT;
2178 params.redirects.push_back(GURL("http://foo2/#a")); 2192 params.redirects.push_back(GURL("http://foo2/#a"));
2179 params.redirects.push_back(url); 2193 params.redirects.push_back(url);
2180 params.should_update_history = true; 2194 params.should_update_history = true;
2181 params.gesture = NavigationGestureUnknown; 2195 params.gesture = NavigationGestureUnknown;
2182 params.is_post = false; 2196 params.is_post = false;
2183 params.page_state = PageState::CreateFromURL(url); 2197 params.page_state = PageState::CreateFromURL(url);
2184 2198
2185 // This SHOULD generate a new entry. 2199 // This SHOULD generate a new entry.
2186 LoadCommittedDetails details; 2200 LoadCommittedDetails details;
2187 EXPECT_TRUE(controller.RendererDidNavigate(test_rvh(), params, &details)); 2201 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
2202 &details));
2188 EXPECT_EQ(1U, navigation_entry_committed_counter_); 2203 EXPECT_EQ(1U, navigation_entry_committed_counter_);
2189 navigation_entry_committed_counter_ = 0; 2204 navigation_entry_committed_counter_ = 0;
2190 EXPECT_FALSE(details.is_in_page); 2205 EXPECT_FALSE(details.is_in_page);
2191 EXPECT_EQ(3, controller.GetEntryCount()); 2206 EXPECT_EQ(3, controller.GetEntryCount());
2192 } 2207 }
2193 2208
2194 // Verify that BACK brings us back to http://foo2/. 2209 // Verify that BACK brings us back to http://foo2/.
2195 { 2210 {
2196 const GURL url("http://foo2/"); 2211 const GURL url("http://foo2/");
2197 controller.GoBack(); 2212 controller.GoBack();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
2340 // Say we navigated to that entry. 2355 // Say we navigated to that entry.
2341 FrameHostMsg_DidCommitProvisionalLoad_Params params; 2356 FrameHostMsg_DidCommitProvisionalLoad_Params params;
2342 params.page_id = 0; 2357 params.page_id = 0;
2343 params.url = url; 2358 params.url = url;
2344 params.transition = PAGE_TRANSITION_LINK; 2359 params.transition = PAGE_TRANSITION_LINK;
2345 params.should_update_history = false; 2360 params.should_update_history = false;
2346 params.gesture = NavigationGestureUser; 2361 params.gesture = NavigationGestureUser;
2347 params.is_post = false; 2362 params.is_post = false;
2348 params.page_state = PageState::CreateFromURL(url); 2363 params.page_state = PageState::CreateFromURL(url);
2349 LoadCommittedDetails details; 2364 LoadCommittedDetails details;
2350 our_controller.RendererDidNavigate(our_contents->GetRenderViewHost(), params, 2365 our_controller.RendererDidNavigate(our_contents->GetMainFrame(), params,
2351 &details); 2366 &details);
2352 2367
2353 // There should be no longer any pending entry and one committed one. This 2368 // There should be no longer any pending entry and one committed one. This
2354 // means that we were able to locate the entry, assign its site instance, and 2369 // means that we were able to locate the entry, assign its site instance, and
2355 // commit it properly. 2370 // commit it properly.
2356 EXPECT_EQ(1, our_controller.GetEntryCount()); 2371 EXPECT_EQ(1, our_controller.GetEntryCount());
2357 EXPECT_EQ(0, our_controller.GetLastCommittedEntryIndex()); 2372 EXPECT_EQ(0, our_controller.GetLastCommittedEntryIndex());
2358 EXPECT_FALSE(our_controller.GetPendingEntry()); 2373 EXPECT_FALSE(our_controller.GetPendingEntry());
2359 EXPECT_EQ(url, 2374 EXPECT_EQ(url,
2360 NavigationEntryImpl::FromNavigationEntry( 2375 NavigationEntryImpl::FromNavigationEntry(
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2404 our_controller.GetPendingEntry()); 2419 our_controller.GetPendingEntry());
2405 EXPECT_EQ(0, our_controller.GetEntryAtIndex(0)->GetPageID()); 2420 EXPECT_EQ(0, our_controller.GetEntryAtIndex(0)->GetPageID());
2406 EXPECT_EQ(NavigationEntryImpl::RESTORE_NONE, 2421 EXPECT_EQ(NavigationEntryImpl::RESTORE_NONE,
2407 NavigationEntryImpl::FromNavigationEntry( 2422 NavigationEntryImpl::FromNavigationEntry(
2408 our_controller.GetEntryAtIndex(0))->restore_type()); 2423 our_controller.GetEntryAtIndex(0))->restore_type());
2409 EXPECT_TRUE(NavigationEntryImpl::FromNavigationEntry( 2424 EXPECT_TRUE(NavigationEntryImpl::FromNavigationEntry(
2410 our_controller.GetEntryAtIndex(0))->site_instance()); 2425 our_controller.GetEntryAtIndex(0))->site_instance());
2411 2426
2412 // This pending navigation may have caused a different navigation to fail, 2427 // This pending navigation may have caused a different navigation to fail,
2413 // which causes the pending entry to be cleared. 2428 // which causes the pending entry to be cleared.
2414 TestRenderViewHost* rvh =
2415 static_cast<TestRenderViewHost*>(our_contents->GetRenderViewHost());
2416 FrameHostMsg_DidFailProvisionalLoadWithError_Params fail_load_params; 2429 FrameHostMsg_DidFailProvisionalLoadWithError_Params fail_load_params;
2417 fail_load_params.is_main_frame = true; 2430 fail_load_params.is_main_frame = true;
2418 fail_load_params.error_code = net::ERR_ABORTED; 2431 fail_load_params.error_code = net::ERR_ABORTED;
2419 fail_load_params.error_description = base::string16(); 2432 fail_load_params.error_description = base::string16();
2420 fail_load_params.url = url; 2433 fail_load_params.url = url;
2421 fail_load_params.showing_repost_interstitial = false; 2434 fail_load_params.showing_repost_interstitial = false;
2422 main_test_rfh()->OnMessageReceived( 2435 main_test_rfh()->OnMessageReceived(
2423 FrameHostMsg_DidFailProvisionalLoadWithError(0, // routing_id 2436 FrameHostMsg_DidFailProvisionalLoadWithError(0, // routing_id
2424 fail_load_params)); 2437 fail_load_params));
2425 2438
2426 // Now the pending restored entry commits. 2439 // Now the pending restored entry commits.
2427 FrameHostMsg_DidCommitProvisionalLoad_Params params; 2440 FrameHostMsg_DidCommitProvisionalLoad_Params params;
2428 params.page_id = 0; 2441 params.page_id = 0;
2429 params.url = url; 2442 params.url = url;
2430 params.transition = PAGE_TRANSITION_LINK; 2443 params.transition = PAGE_TRANSITION_LINK;
2431 params.should_update_history = false; 2444 params.should_update_history = false;
2432 params.gesture = NavigationGestureUser; 2445 params.gesture = NavigationGestureUser;
2433 params.is_post = false; 2446 params.is_post = false;
2434 params.page_state = PageState::CreateFromURL(url); 2447 params.page_state = PageState::CreateFromURL(url);
2435 LoadCommittedDetails details; 2448 LoadCommittedDetails details;
2436 our_controller.RendererDidNavigate(rvh, params, &details); 2449 our_controller.RendererDidNavigate(our_contents->GetMainFrame(), params,
2450 &details);
2437 2451
2438 // There should be no pending entry and one committed one. 2452 // There should be no pending entry and one committed one.
2439 EXPECT_EQ(1, our_controller.GetEntryCount()); 2453 EXPECT_EQ(1, our_controller.GetEntryCount());
2440 EXPECT_EQ(0, our_controller.GetLastCommittedEntryIndex()); 2454 EXPECT_EQ(0, our_controller.GetLastCommittedEntryIndex());
2441 EXPECT_FALSE(our_controller.GetPendingEntry()); 2455 EXPECT_FALSE(our_controller.GetPendingEntry());
2442 EXPECT_EQ(url, 2456 EXPECT_EQ(url,
2443 NavigationEntryImpl::FromNavigationEntry( 2457 NavigationEntryImpl::FromNavigationEntry(
2444 our_controller.GetLastCommittedEntry())->site_instance()-> 2458 our_controller.GetLastCommittedEntry())->site_instance()->
2445 GetSiteURL()); 2459 GetSiteURL());
2446 EXPECT_EQ(NavigationEntryImpl::RESTORE_NONE, 2460 EXPECT_EQ(NavigationEntryImpl::RESTORE_NONE,
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
2951 const GURL subframe("http://www.google.com/#"); 2965 const GURL subframe("http://www.google.com/#");
2952 FrameHostMsg_DidCommitProvisionalLoad_Params params; 2966 FrameHostMsg_DidCommitProvisionalLoad_Params params;
2953 params.page_id = 0; 2967 params.page_id = 0;
2954 params.url = subframe; 2968 params.url = subframe;
2955 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; 2969 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME;
2956 params.should_update_history = false; 2970 params.should_update_history = false;
2957 params.gesture = NavigationGestureAuto; 2971 params.gesture = NavigationGestureAuto;
2958 params.is_post = false; 2972 params.is_post = false;
2959 params.page_state = PageState::CreateFromURL(subframe); 2973 params.page_state = PageState::CreateFromURL(subframe);
2960 LoadCommittedDetails details; 2974 LoadCommittedDetails details;
2961 EXPECT_FALSE(controller.RendererDidNavigate(test_rvh(), params, &details)); 2975 EXPECT_FALSE(controller.RendererDidNavigate(main_test_rfh(), params,
2976 &details));
2962 2977
2963 // Nothing should have changed. 2978 // Nothing should have changed.
2964 EXPECT_EQ(controller.GetEntryCount(), 1); 2979 EXPECT_EQ(controller.GetEntryCount(), 1);
2965 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); 2980 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0);
2966 } 2981 }
2967 2982
2968 // Make sure that on cloning a WebContentsImpl and going back needs_reload is 2983 // Make sure that on cloning a WebContentsImpl and going back needs_reload is
2969 // false. 2984 // false.
2970 TEST_F(NavigationControllerTest, CloneAndGoBack) { 2985 TEST_F(NavigationControllerTest, CloneAndGoBack) {
2971 NavigationControllerImpl& controller = controller_impl(); 2986 NavigationControllerImpl& controller = controller_impl();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
3068 params.page_id = controller.GetLastCommittedEntry()->GetPageID(); 3083 params.page_id = controller.GetLastCommittedEntry()->GetPageID();
3069 params.url = url1_sub; 3084 params.url = url1_sub;
3070 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; 3085 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME;
3071 params.should_update_history = false; 3086 params.should_update_history = false;
3072 params.gesture = NavigationGestureAuto; 3087 params.gesture = NavigationGestureAuto;
3073 params.is_post = false; 3088 params.is_post = false;
3074 params.page_state = PageState::CreateFromURL(url1_sub); 3089 params.page_state = PageState::CreateFromURL(url1_sub);
3075 LoadCommittedDetails details; 3090 LoadCommittedDetails details;
3076 3091
3077 // This should return false meaning that nothing was actually updated. 3092 // This should return false meaning that nothing was actually updated.
3078 EXPECT_FALSE(controller.RendererDidNavigate(test_rvh(), params, &details)); 3093 EXPECT_FALSE(controller.RendererDidNavigate(main_test_rfh(), params,
3094 &details));
3079 3095
3080 // The notification should have updated the last committed one, and not 3096 // The notification should have updated the last committed one, and not
3081 // the pending load. 3097 // the pending load.
3082 EXPECT_EQ(url1, controller.GetLastCommittedEntry()->GetURL()); 3098 EXPECT_EQ(url1, controller.GetLastCommittedEntry()->GetURL());
3083 3099
3084 // The active entry should be unchanged by the subframe load. 3100 // The active entry should be unchanged by the subframe load.
3085 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); 3101 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL());
3086 } 3102 }
3087 3103
3088 // Test CopyStateFrom with 2 urls, the first selected and nothing in the target. 3104 // Test CopyStateFrom with 2 urls, the first selected and nothing in the target.
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
4015 EXPECT_EQ(1, controller.GetEntryCount()); 4031 EXPECT_EQ(1, controller.GetEntryCount());
4016 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); 4032 EXPECT_EQ(0, controller.GetCurrentEntryIndex());
4017 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); 4033 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
4018 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 4034 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
4019 EXPECT_FALSE(controller.CanGoBack()); 4035 EXPECT_FALSE(controller.CanGoBack());
4020 EXPECT_FALSE(controller.CanGoForward()); 4036 EXPECT_FALSE(controller.CanGoForward());
4021 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL()); 4037 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL());
4022 } 4038 }
4023 4039
4024 } // namespace content 4040 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698