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 "content/browser/frame_host/navigation_controller_impl.h" | 5 #include "content/browser/frame_host/navigation_controller_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
20 #include "content/browser/frame_host/cross_site_transferring_request.h" | 20 #include "content/browser/frame_host/cross_site_transferring_request.h" |
21 #include "content/browser/frame_host/frame_navigation_entry.h" | 21 #include "content/browser/frame_host/frame_navigation_entry.h" |
22 #include "content/browser/frame_host/navigation_entry_impl.h" | 22 #include "content/browser/frame_host/navigation_entry_impl.h" |
23 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" | 23 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" |
24 #include "content/browser/frame_host/navigation_handle_impl.h" | |
24 #include "content/browser/frame_host/navigation_request.h" | 25 #include "content/browser/frame_host/navigation_request.h" |
25 #include "content/browser/frame_host/navigator.h" | 26 #include "content/browser/frame_host/navigator.h" |
26 #include "content/browser/frame_host/navigator_impl.h" | 27 #include "content/browser/frame_host/navigator_impl.h" |
27 #include "content/browser/site_instance_impl.h" | 28 #include "content/browser/site_instance_impl.h" |
28 #include "content/browser/web_contents/web_contents_impl.h" | 29 #include "content/browser/web_contents/web_contents_impl.h" |
29 #include "content/common/frame_messages.h" | 30 #include "content/common/frame_messages.h" |
30 #include "content/common/site_isolation_policy.h" | 31 #include "content/common/site_isolation_policy.h" |
31 #include "content/common/ssl_status_serialization.h" | 32 #include "content/common/ssl_status_serialization.h" |
32 #include "content/common/view_messages.h" | 33 #include "content/common/view_messages.h" |
33 #include "content/public/browser/navigation_details.h" | 34 #include "content/public/browser/navigation_details.h" |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 } | 289 } |
289 | 290 |
290 private: | 291 private: |
291 // The number of times NavigationStateChanged has been called. | 292 // The number of times NavigationStateChanged has been called. |
292 int navigation_state_change_count_; | 293 int navigation_state_change_count_; |
293 | 294 |
294 // The number of times ShowRepostFormWarningDialog() was called. | 295 // The number of times ShowRepostFormWarningDialog() was called. |
295 int repost_form_warning_count_; | 296 int repost_form_warning_count_; |
296 }; | 297 }; |
297 | 298 |
299 // Observer that records the LoadCommittedDetails from the most recent commit. | |
300 class LoadCommittedDetailsObserver : public WebContentsObserver { | |
nasko
2016/03/11 17:10:06
Can't we use FrameNavigateParamsCapturer which is
Charlie Reis
2016/03/11 20:12:48
That one is defined for a browsertest and spins a
nasko
2016/03/11 20:21:56
Acknowledged.
| |
301 public: | |
302 // Observes navigation for the specified |web_contents|. | |
303 explicit LoadCommittedDetailsObserver(WebContents* web_contents) | |
304 : WebContentsObserver(web_contents) {} | |
305 | |
306 const LoadCommittedDetails& details() { return details_; } | |
307 | |
308 private: | |
309 void DidNavigateAnyFrame(RenderFrameHost* render_frame_host, | |
310 const LoadCommittedDetails& details, | |
311 const FrameNavigateParams& params) override { | |
312 details_ = details; | |
313 } | |
314 | |
315 LoadCommittedDetails details_; | |
316 }; | |
317 | |
298 // ----------------------------------------------------------------------------- | 318 // ----------------------------------------------------------------------------- |
299 | 319 |
300 TEST_F(NavigationControllerTest, Defaults) { | 320 TEST_F(NavigationControllerTest, Defaults) { |
301 NavigationControllerImpl& controller = controller_impl(); | 321 NavigationControllerImpl& controller = controller_impl(); |
302 | 322 |
303 EXPECT_FALSE(controller.GetPendingEntry()); | 323 EXPECT_FALSE(controller.GetPendingEntry()); |
304 EXPECT_FALSE(controller.GetVisibleEntry()); | 324 EXPECT_FALSE(controller.GetVisibleEntry()); |
305 EXPECT_FALSE(controller.GetLastCommittedEntry()); | 325 EXPECT_FALSE(controller.GetLastCommittedEntry()); |
306 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 326 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
307 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), -1); | 327 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), -1); |
(...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1857 params.did_create_new_entry = true; | 1877 params.did_create_new_entry = true; |
1858 params.url = url2; | 1878 params.url = url2; |
1859 params.transition = ui::PAGE_TRANSITION_SERVER_REDIRECT; | 1879 params.transition = ui::PAGE_TRANSITION_SERVER_REDIRECT; |
1860 params.redirects.push_back(GURL("http://foo1")); | 1880 params.redirects.push_back(GURL("http://foo1")); |
1861 params.redirects.push_back(GURL("http://foo2")); | 1881 params.redirects.push_back(GURL("http://foo2")); |
1862 params.should_update_history = false; | 1882 params.should_update_history = false; |
1863 params.gesture = NavigationGestureAuto; | 1883 params.gesture = NavigationGestureAuto; |
1864 params.is_post = false; | 1884 params.is_post = false; |
1865 params.page_state = PageState::CreateFromURL(url2); | 1885 params.page_state = PageState::CreateFromURL(url2); |
1866 | 1886 |
1867 LoadCommittedDetails details; | 1887 LoadCommittedDetailsObserver observer(contents()); |
nasko
2016/03/11 17:10:06
nit: I'd move this closer to the commit it is obse
Charlie Reis
2016/03/11 20:12:48
Done.
| |
1868 | 1888 |
1869 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, | 1889 main_test_rfh()->PrepareForCommit(); |
1870 &details)); | 1890 main_test_rfh()->SendNavigateWithParams(¶ms); |
1871 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1891 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1872 navigation_entry_committed_counter_ = 0; | 1892 navigation_entry_committed_counter_ = 0; |
1873 | 1893 |
1874 // Second request. | 1894 // Second request. |
1875 controller.LoadURL( | 1895 controller.LoadURL( |
1876 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1896 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1877 entry_id = controller.GetPendingEntry()->GetUniqueID(); | 1897 entry_id = controller.GetPendingEntry()->GetUniqueID(); |
1878 | 1898 |
1879 EXPECT_TRUE(controller.GetPendingEntry()); | 1899 EXPECT_TRUE(controller.GetPendingEntry()); |
1880 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 1900 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
1881 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); | 1901 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); |
1882 | 1902 |
1883 params.nav_entry_id = entry_id; | 1903 params.nav_entry_id = entry_id; |
1884 params.did_create_new_entry = false; | 1904 params.did_create_new_entry = false; |
1885 | 1905 |
1886 EXPECT_EQ(0U, notifications.size()); | 1906 EXPECT_EQ(0U, notifications.size()); |
1887 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, | 1907 main_test_rfh()->PrepareForCommit(); |
1888 &details)); | 1908 main_test_rfh()->SendNavigateWithParams(¶ms); |
1889 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1909 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1890 navigation_entry_committed_counter_ = 0; | 1910 navigation_entry_committed_counter_ = 0; |
1891 | 1911 |
1892 EXPECT_TRUE(details.type == NAVIGATION_TYPE_SAME_PAGE); | 1912 EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, observer.details().type); |
1893 EXPECT_EQ(controller.GetEntryCount(), 1); | 1913 EXPECT_EQ(controller.GetEntryCount(), 1); |
1894 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 1914 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
1895 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 1915 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
1896 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 1916 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
1897 EXPECT_FALSE(controller.GetPendingEntry()); | 1917 EXPECT_FALSE(controller.GetPendingEntry()); |
1898 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); | 1918 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); |
1899 | 1919 |
1900 EXPECT_FALSE(controller.CanGoBack()); | 1920 EXPECT_FALSE(controller.CanGoBack()); |
1901 EXPECT_FALSE(controller.CanGoForward()); | 1921 EXPECT_FALSE(controller.CanGoForward()); |
1902 } | 1922 } |
(...skipping 23 matching lines...) Expand all Loading... | |
1926 params.did_create_new_entry = true; | 1946 params.did_create_new_entry = true; |
1927 params.url = url2; | 1947 params.url = url2; |
1928 params.transition = ui::PAGE_TRANSITION_SERVER_REDIRECT; | 1948 params.transition = ui::PAGE_TRANSITION_SERVER_REDIRECT; |
1929 params.redirects.push_back(GURL("http://foo1")); | 1949 params.redirects.push_back(GURL("http://foo1")); |
1930 params.redirects.push_back(GURL("http://foo2")); | 1950 params.redirects.push_back(GURL("http://foo2")); |
1931 params.should_update_history = false; | 1951 params.should_update_history = false; |
1932 params.gesture = NavigationGestureAuto; | 1952 params.gesture = NavigationGestureAuto; |
1933 params.is_post = true; | 1953 params.is_post = true; |
1934 params.page_state = PageState::CreateFromURL(url2); | 1954 params.page_state = PageState::CreateFromURL(url2); |
1935 | 1955 |
1936 LoadCommittedDetails details; | 1956 LoadCommittedDetailsObserver observer(contents()); |
nasko
2016/03/11 17:10:06
nit: Same nit as above, closer to the commit it ob
Charlie Reis
2016/03/11 20:12:48
Done.
| |
1937 | 1957 |
1938 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, | 1958 main_test_rfh()->PrepareForCommit(); |
1939 &details)); | 1959 main_test_rfh()->SendNavigateWithParams(¶ms); |
1940 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1960 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1941 navigation_entry_committed_counter_ = 0; | 1961 navigation_entry_committed_counter_ = 0; |
1942 | 1962 |
1943 // Second request. | 1963 // Second request. |
1944 controller.LoadURL( | 1964 controller.LoadURL( |
1945 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1965 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1946 entry_id = controller.GetPendingEntry()->GetUniqueID(); | 1966 entry_id = controller.GetPendingEntry()->GetUniqueID(); |
1947 | 1967 |
1948 EXPECT_TRUE(controller.GetPendingEntry()); | 1968 EXPECT_TRUE(controller.GetPendingEntry()); |
1949 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 1969 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
1950 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); | 1970 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); |
1951 | 1971 |
1952 params.nav_entry_id = entry_id; | 1972 params.nav_entry_id = entry_id; |
1953 params.did_create_new_entry = false; | 1973 params.did_create_new_entry = false; |
1954 params.is_post = false; | 1974 params.is_post = false; |
1955 | 1975 |
1956 EXPECT_EQ(0U, notifications.size()); | 1976 EXPECT_EQ(0U, notifications.size()); |
1957 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, | 1977 main_test_rfh()->PrepareForCommit(); |
1958 &details)); | 1978 main_test_rfh()->SendNavigateWithParams(¶ms); |
1959 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1979 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1960 navigation_entry_committed_counter_ = 0; | 1980 navigation_entry_committed_counter_ = 0; |
1961 | 1981 |
1962 EXPECT_TRUE(details.type == NAVIGATION_TYPE_SAME_PAGE); | 1982 EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, observer.details().type); |
1963 EXPECT_EQ(controller.GetEntryCount(), 1); | 1983 EXPECT_EQ(controller.GetEntryCount(), 1); |
1964 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 1984 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
1965 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 1985 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
1966 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 1986 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
1967 EXPECT_FALSE(controller.GetPendingEntry()); | 1987 EXPECT_FALSE(controller.GetPendingEntry()); |
1968 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); | 1988 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); |
1969 EXPECT_FALSE(controller.GetVisibleEntry()->GetHasPostData()); | 1989 EXPECT_FALSE(controller.GetVisibleEntry()->GetHasPostData()); |
1970 | 1990 |
1971 EXPECT_FALSE(controller.CanGoBack()); | 1991 EXPECT_FALSE(controller.CanGoBack()); |
1972 EXPECT_FALSE(controller.CanGoForward()); | 1992 EXPECT_FALSE(controller.CanGoForward()); |
(...skipping 23 matching lines...) Expand all Loading... | |
1996 params.did_create_new_entry = true; | 2016 params.did_create_new_entry = true; |
1997 params.url = url2; | 2017 params.url = url2; |
1998 params.transition = ui::PAGE_TRANSITION_SERVER_REDIRECT; | 2018 params.transition = ui::PAGE_TRANSITION_SERVER_REDIRECT; |
1999 params.redirects.push_back(GURL("http://foo1")); | 2019 params.redirects.push_back(GURL("http://foo1")); |
2000 params.redirects.push_back(GURL("http://foo2")); | 2020 params.redirects.push_back(GURL("http://foo2")); |
2001 params.should_update_history = false; | 2021 params.should_update_history = false; |
2002 params.gesture = NavigationGestureAuto; | 2022 params.gesture = NavigationGestureAuto; |
2003 params.is_post = false; | 2023 params.is_post = false; |
2004 params.page_state = PageState::CreateFromURL(url2); | 2024 params.page_state = PageState::CreateFromURL(url2); |
2005 | 2025 |
2006 LoadCommittedDetails details; | 2026 LoadCommittedDetailsObserver observer(contents()); |
2007 | 2027 |
2008 EXPECT_EQ(0U, notifications.size()); | 2028 EXPECT_EQ(0U, notifications.size()); |
2009 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, | 2029 main_test_rfh()->PrepareForCommit(); |
2010 &details)); | 2030 main_test_rfh()->SendNavigateWithParams(¶ms); |
2011 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2031 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2012 navigation_entry_committed_counter_ = 0; | 2032 navigation_entry_committed_counter_ = 0; |
2013 | 2033 |
2014 EXPECT_TRUE(details.type == NAVIGATION_TYPE_NEW_PAGE); | 2034 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, observer.details().type); |
2015 EXPECT_EQ(controller.GetEntryCount(), 1); | 2035 EXPECT_EQ(controller.GetEntryCount(), 1); |
2016 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 2036 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
2017 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 2037 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
2018 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 2038 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
2019 EXPECT_FALSE(controller.GetPendingEntry()); | 2039 EXPECT_FALSE(controller.GetPendingEntry()); |
2020 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); | 2040 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); |
2021 | 2041 |
2022 EXPECT_FALSE(controller.CanGoBack()); | 2042 EXPECT_FALSE(controller.CanGoBack()); |
2023 EXPECT_FALSE(controller.CanGoForward()); | 2043 EXPECT_FALSE(controller.CanGoForward()); |
2024 } | 2044 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2061 // ... and now the renderer sends a commit for the first navigation. | 2081 // ... and now the renderer sends a commit for the first navigation. |
2062 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2082 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2063 params.page_id = 0; | 2083 params.page_id = 0; |
2064 params.nav_entry_id = entry_id1; | 2084 params.nav_entry_id = entry_id1; |
2065 params.intended_as_new_entry = true; | 2085 params.intended_as_new_entry = true; |
2066 params.did_create_new_entry = false; | 2086 params.did_create_new_entry = false; |
2067 params.url = url1; | 2087 params.url = url1; |
2068 params.transition = ui::PAGE_TRANSITION_TYPED; | 2088 params.transition = ui::PAGE_TRANSITION_TYPED; |
2069 params.page_state = PageState::CreateFromURL(url1); | 2089 params.page_state = PageState::CreateFromURL(url1); |
2070 | 2090 |
2071 LoadCommittedDetails details; | 2091 LoadCommittedDetailsObserver observer(contents()); |
2072 | 2092 |
2073 main_test_rfh()->PrepareForCommit(); | 2093 main_test_rfh()->PrepareForCommit(); |
2074 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, | 2094 main_test_rfh()->SendNavigateWithParams(¶ms); |
2075 &details)); | 2095 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, observer.details().type); |
2076 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, details.type); | |
2077 } | 2096 } |
2078 | 2097 |
2079 // Tests navigation via link click within a subframe. A new navigation entry | 2098 // Tests navigation via link click within a subframe. A new navigation entry |
2080 // should be created. | 2099 // should be created. |
2081 TEST_F(NavigationControllerTest, NewSubframe) { | 2100 TEST_F(NavigationControllerTest, NewSubframe) { |
2082 NavigationControllerImpl& controller = controller_impl(); | 2101 NavigationControllerImpl& controller = controller_impl(); |
2083 TestNotificationTracker notifications; | 2102 TestNotificationTracker notifications; |
2084 RegisterForAllNavNotifications(¬ifications, &controller); | 2103 RegisterForAllNavNotifications(¬ifications, &controller); |
2085 | 2104 |
2086 const GURL url1("http://foo1"); | 2105 const GURL url1("http://foo1"); |
2087 main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); | 2106 main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); |
2088 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2107 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2089 navigation_entry_committed_counter_ = 0; | 2108 navigation_entry_committed_counter_ = 0; |
2090 | 2109 |
2091 // Prereq: add a subframe with an initial auto-subframe navigation. | 2110 // Prereq: add a subframe with an initial auto-subframe navigation. |
2092 main_test_rfh()->OnCreateChildFrame( | 2111 main_test_rfh()->OnCreateChildFrame( |
2093 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, | 2112 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, |
2094 std::string(), "uniqueName0", blink::WebSandboxFlags::None, | 2113 std::string(), "uniqueName0", blink::WebSandboxFlags::None, |
2095 blink::WebFrameOwnerProperties()); | 2114 blink::WebFrameOwnerProperties()); |
2096 RenderFrameHostImpl* subframe = | 2115 TestRenderFrameHost* subframe = static_cast<TestRenderFrameHost*>( |
2097 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host(); | 2116 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host()); |
2098 const GURL subframe_url("http://foo1/subframe"); | 2117 const GURL subframe_url("http://foo1/subframe"); |
2099 { | 2118 { |
2100 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2119 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2101 params.page_id = 1; | 2120 params.page_id = 1; |
2102 params.nav_entry_id = 0; | 2121 params.nav_entry_id = 0; |
2103 params.did_create_new_entry = false; | 2122 params.did_create_new_entry = false; |
2104 params.url = subframe_url; | 2123 params.url = subframe_url; |
2105 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 2124 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
2106 params.should_update_history = false; | 2125 params.should_update_history = false; |
2107 params.gesture = NavigationGestureUser; | 2126 params.gesture = NavigationGestureUser; |
2108 params.is_post = false; | 2127 params.is_post = false; |
2109 params.page_state = PageState::CreateFromURL(subframe_url); | 2128 params.page_state = PageState::CreateFromURL(subframe_url); |
2110 | 2129 |
2111 // Navigating should do nothing. | 2130 // Navigating should do nothing. |
2112 LoadCommittedDetails details; | 2131 subframe->PrepareForCommit(); |
2113 EXPECT_FALSE(controller.RendererDidNavigate(subframe, params, &details)); | 2132 subframe->SendNavigateWithParams(¶ms); |
2114 EXPECT_EQ(0U, notifications.size()); | 2133 EXPECT_EQ(0U, notifications.size()); |
2115 } | 2134 } |
2116 | 2135 |
2117 // Now do a new navigation in the frame. | 2136 // Now do a new navigation in the frame. |
2118 const GURL url2("http://foo2"); | 2137 const GURL url2("http://foo2"); |
2119 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2138 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2120 params.page_id = 2; | 2139 params.page_id = 2; |
2121 params.nav_entry_id = 0; | 2140 params.nav_entry_id = 0; |
2122 params.did_create_new_entry = true; | 2141 params.did_create_new_entry = true; |
2123 params.url = url2; | 2142 params.url = url2; |
2124 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; | 2143 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; |
2125 params.should_update_history = false; | 2144 params.should_update_history = false; |
2126 params.gesture = NavigationGestureUser; | 2145 params.gesture = NavigationGestureUser; |
2127 params.is_post = false; | 2146 params.is_post = false; |
2128 params.page_state = PageState::CreateFromURL(url2); | 2147 params.page_state = PageState::CreateFromURL(url2); |
2129 | 2148 |
2130 LoadCommittedDetails details; | 2149 LoadCommittedDetailsObserver observer(contents()); |
2131 EXPECT_TRUE(controller.RendererDidNavigate(subframe, params, &details)); | 2150 subframe->PrepareForCommit(); |
2151 subframe->SendNavigateWithParams(¶ms); | |
2132 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2152 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2133 navigation_entry_committed_counter_ = 0; | 2153 navigation_entry_committed_counter_ = 0; |
2134 EXPECT_EQ(url1, details.previous_url); | 2154 EXPECT_EQ(url1, observer.details().previous_url); |
2135 EXPECT_FALSE(details.is_in_page); | 2155 EXPECT_FALSE(observer.details().is_in_page); |
2136 EXPECT_FALSE(details.is_main_frame); | 2156 EXPECT_FALSE(observer.details().is_main_frame); |
2137 | 2157 |
2138 // The new entry should be appended. | 2158 // The new entry should be appended. |
2139 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 2159 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
2140 EXPECT_EQ(2, controller.GetEntryCount()); | 2160 EXPECT_EQ(2, controller.GetEntryCount()); |
2141 EXPECT_EQ(entry, details.entry); | 2161 EXPECT_EQ(entry, observer.details().entry); |
2142 | 2162 |
2143 // New entry should refer to the new page, but the old URL (entries only | 2163 // New entry should refer to the new page, but the old URL (entries only |
2144 // reflect the toplevel URL). | 2164 // reflect the toplevel URL). |
2145 EXPECT_EQ(url1, entry->GetURL()); | 2165 EXPECT_EQ(url1, entry->GetURL()); |
2146 EXPECT_EQ(params.page_id, entry->GetPageID()); | 2166 EXPECT_EQ(params.page_id, entry->GetPageID()); |
2147 | 2167 |
2148 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2168 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
2149 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2169 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
2150 // The entry should have a subframe FrameNavigationEntry. | 2170 // The entry should have a subframe FrameNavigationEntry. |
2151 ASSERT_EQ(1U, entry->root_node()->children.size()); | 2171 ASSERT_EQ(1U, entry->root_node()->children.size()); |
(...skipping 15 matching lines...) Expand all Loading... | |
2167 const GURL url1("http://foo/1"); | 2187 const GURL url1("http://foo/1"); |
2168 main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); | 2188 main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); |
2169 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2189 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2170 navigation_entry_committed_counter_ = 0; | 2190 navigation_entry_committed_counter_ = 0; |
2171 | 2191 |
2172 // Add a subframe and navigate it. | 2192 // Add a subframe and navigate it. |
2173 main_test_rfh()->OnCreateChildFrame( | 2193 main_test_rfh()->OnCreateChildFrame( |
2174 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, | 2194 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, |
2175 std::string(), "uniqueName0", blink::WebSandboxFlags::None, | 2195 std::string(), "uniqueName0", blink::WebSandboxFlags::None, |
2176 blink::WebFrameOwnerProperties()); | 2196 blink::WebFrameOwnerProperties()); |
2177 RenderFrameHostImpl* subframe = | 2197 TestRenderFrameHost* subframe = static_cast<TestRenderFrameHost*>( |
2178 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host(); | 2198 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host()); |
2179 const GURL url2("http://foo/2"); | 2199 const GURL url2("http://foo/2"); |
2180 { | 2200 { |
2181 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2201 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2182 params.page_id = 1; | 2202 params.page_id = 1; |
2183 params.nav_entry_id = 0; | 2203 params.nav_entry_id = 0; |
2184 params.did_create_new_entry = false; | 2204 params.did_create_new_entry = false; |
2185 params.url = url2; | 2205 params.url = url2; |
2186 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 2206 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
2187 params.should_update_history = false; | 2207 params.should_update_history = false; |
2188 params.gesture = NavigationGestureUser; | 2208 params.gesture = NavigationGestureUser; |
2189 params.is_post = false; | 2209 params.is_post = false; |
2190 params.page_state = PageState::CreateFromURL(url2); | 2210 params.page_state = PageState::CreateFromURL(url2); |
2191 | 2211 |
2192 // Navigating should do nothing. | 2212 // Navigating should do nothing. |
2193 LoadCommittedDetails details; | 2213 subframe->PrepareForCommit(); |
2194 EXPECT_FALSE(controller.RendererDidNavigate(subframe, params, &details)); | 2214 subframe->SendNavigateWithParams(¶ms); |
2195 EXPECT_EQ(0U, notifications.size()); | 2215 EXPECT_EQ(0U, notifications.size()); |
2196 } | 2216 } |
2197 | 2217 |
2198 // There should still be only one entry. | 2218 // There should still be only one entry. |
2199 EXPECT_EQ(1, controller.GetEntryCount()); | 2219 EXPECT_EQ(1, controller.GetEntryCount()); |
2200 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 2220 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
2201 EXPECT_EQ(url1, entry->GetURL()); | 2221 EXPECT_EQ(url1, entry->GetURL()); |
2202 EXPECT_EQ(1, entry->GetPageID()); | 2222 EXPECT_EQ(1, entry->GetPageID()); |
2203 FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get(); | 2223 FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get(); |
2204 EXPECT_EQ(url1, root_entry->url()); | 2224 EXPECT_EQ(url1, root_entry->url()); |
2205 | 2225 |
2206 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2226 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
2207 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2227 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
2208 // The entry should now have a subframe FrameNavigationEntry. | 2228 // The entry should now have a subframe FrameNavigationEntry. |
2209 ASSERT_EQ(1U, entry->root_node()->children.size()); | 2229 ASSERT_EQ(1U, entry->root_node()->children.size()); |
2210 FrameNavigationEntry* frame_entry = | 2230 FrameNavigationEntry* frame_entry = |
2211 entry->root_node()->children[0]->frame_entry.get(); | 2231 entry->root_node()->children[0]->frame_entry.get(); |
2212 EXPECT_EQ(url2, frame_entry->url()); | 2232 EXPECT_EQ(url2, frame_entry->url()); |
2213 } else { | 2233 } else { |
2214 // There are no subframe FrameNavigationEntries by default. | 2234 // There are no subframe FrameNavigationEntries by default. |
2215 EXPECT_EQ(0U, entry->root_node()->children.size()); | 2235 EXPECT_EQ(0U, entry->root_node()->children.size()); |
2216 } | 2236 } |
2217 | 2237 |
2218 // Add a second subframe and navigate. | 2238 // Add a second subframe and navigate. |
2219 main_test_rfh()->OnCreateChildFrame( | 2239 main_test_rfh()->OnCreateChildFrame( |
2220 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, | 2240 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, |
2221 std::string(), "uniqueName1", blink::WebSandboxFlags::None, | 2241 std::string(), "uniqueName1", blink::WebSandboxFlags::None, |
2222 blink::WebFrameOwnerProperties()); | 2242 blink::WebFrameOwnerProperties()); |
2223 RenderFrameHostImpl* subframe2 = | 2243 TestRenderFrameHost* subframe2 = static_cast<TestRenderFrameHost*>( |
2224 contents()->GetFrameTree()->root()->child_at(1)->current_frame_host(); | 2244 contents()->GetFrameTree()->root()->child_at(1)->current_frame_host()); |
2225 const GURL url3("http://foo/3"); | 2245 const GURL url3("http://foo/3"); |
2226 { | 2246 { |
2227 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2247 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2228 params.page_id = 1; | 2248 params.page_id = 1; |
2229 params.nav_entry_id = 0; | 2249 params.nav_entry_id = 0; |
2230 params.did_create_new_entry = false; | 2250 params.did_create_new_entry = false; |
2231 params.url = url3; | 2251 params.url = url3; |
2232 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 2252 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
2233 params.should_update_history = false; | 2253 params.should_update_history = false; |
2234 params.gesture = NavigationGestureUser; | 2254 params.gesture = NavigationGestureUser; |
2235 params.is_post = false; | 2255 params.is_post = false; |
2236 params.page_state = PageState::CreateFromURL(url3); | 2256 params.page_state = PageState::CreateFromURL(url3); |
2237 | 2257 |
2238 // Navigating should do nothing. | 2258 // Navigating should do nothing. |
2239 LoadCommittedDetails details; | 2259 subframe2->PrepareForCommit(); |
2240 EXPECT_FALSE(controller.RendererDidNavigate(subframe2, params, &details)); | 2260 subframe2->SendNavigateWithParams(¶ms); |
2241 EXPECT_EQ(0U, notifications.size()); | 2261 EXPECT_EQ(0U, notifications.size()); |
2242 } | 2262 } |
2243 | 2263 |
2244 // There should still be only one entry, mostly unchanged. | 2264 // There should still be only one entry, mostly unchanged. |
2245 EXPECT_EQ(1, controller.GetEntryCount()); | 2265 EXPECT_EQ(1, controller.GetEntryCount()); |
2246 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); | 2266 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); |
2247 EXPECT_EQ(url1, entry->GetURL()); | 2267 EXPECT_EQ(url1, entry->GetURL()); |
2248 EXPECT_EQ(1, entry->GetPageID()); | 2268 EXPECT_EQ(1, entry->GetPageID()); |
2249 EXPECT_EQ(root_entry, entry->root_node()->frame_entry.get()); | 2269 EXPECT_EQ(root_entry, entry->root_node()->frame_entry.get()); |
2250 EXPECT_EQ(url1, root_entry->url()); | 2270 EXPECT_EQ(url1, root_entry->url()); |
2251 | 2271 |
2252 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2272 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
2253 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2273 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
2254 // The entry should now have 2 subframe FrameNavigationEntries. | 2274 // The entry should now have 2 subframe FrameNavigationEntries. |
2255 ASSERT_EQ(2U, entry->root_node()->children.size()); | 2275 ASSERT_EQ(2U, entry->root_node()->children.size()); |
2256 FrameNavigationEntry* new_frame_entry = | 2276 FrameNavigationEntry* new_frame_entry = |
2257 entry->root_node()->children[1]->frame_entry.get(); | 2277 entry->root_node()->children[1]->frame_entry.get(); |
2258 EXPECT_EQ(url3, new_frame_entry->url()); | 2278 EXPECT_EQ(url3, new_frame_entry->url()); |
2259 } else { | 2279 } else { |
2260 // There are no subframe FrameNavigationEntries by default. | 2280 // There are no subframe FrameNavigationEntries by default. |
2261 EXPECT_EQ(0U, entry->root_node()->children.size()); | 2281 EXPECT_EQ(0U, entry->root_node()->children.size()); |
2262 } | 2282 } |
2263 | 2283 |
2264 // Add a nested subframe and navigate. | 2284 // Add a nested subframe and navigate. |
2265 subframe->OnCreateChildFrame(process()->GetNextRoutingID(), | 2285 subframe->OnCreateChildFrame(process()->GetNextRoutingID(), |
2266 blink::WebTreeScopeType::Document, std::string(), | 2286 blink::WebTreeScopeType::Document, std::string(), |
2267 "uniqueName2", blink::WebSandboxFlags::None, | 2287 "uniqueName2", blink::WebSandboxFlags::None, |
2268 blink::WebFrameOwnerProperties()); | 2288 blink::WebFrameOwnerProperties()); |
2269 RenderFrameHostImpl* subframe3 = contents() | 2289 TestRenderFrameHost* subframe3 = |
2270 ->GetFrameTree() | 2290 static_cast<TestRenderFrameHost*>(contents() |
2271 ->root() | 2291 ->GetFrameTree() |
2272 ->child_at(0) | 2292 ->root() |
2273 ->child_at(0) | 2293 ->child_at(0) |
2274 ->current_frame_host(); | 2294 ->child_at(0) |
2295 ->current_frame_host()); | |
2275 const GURL url4("http://foo/4"); | 2296 const GURL url4("http://foo/4"); |
2276 { | 2297 { |
2277 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2298 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2278 params.page_id = 1; | 2299 params.page_id = 1; |
2279 params.nav_entry_id = 0; | 2300 params.nav_entry_id = 0; |
2280 params.did_create_new_entry = false; | 2301 params.did_create_new_entry = false; |
2281 params.url = url4; | 2302 params.url = url4; |
2282 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 2303 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
2283 params.should_update_history = false; | 2304 params.should_update_history = false; |
2284 params.gesture = NavigationGestureUser; | 2305 params.gesture = NavigationGestureUser; |
2285 params.is_post = false; | 2306 params.is_post = false; |
2286 params.page_state = PageState::CreateFromURL(url4); | 2307 params.page_state = PageState::CreateFromURL(url4); |
2287 | 2308 |
2288 // Navigating should do nothing. | 2309 // Navigating should do nothing. |
2289 LoadCommittedDetails details; | 2310 subframe3->PrepareForCommit(); |
2290 EXPECT_FALSE(controller.RendererDidNavigate(subframe3, params, &details)); | 2311 subframe3->SendNavigateWithParams(¶ms); |
2291 EXPECT_EQ(0U, notifications.size()); | 2312 EXPECT_EQ(0U, notifications.size()); |
2292 } | 2313 } |
2293 | 2314 |
2294 // There should still be only one entry, mostly unchanged. | 2315 // There should still be only one entry, mostly unchanged. |
2295 EXPECT_EQ(1, controller.GetEntryCount()); | 2316 EXPECT_EQ(1, controller.GetEntryCount()); |
2296 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); | 2317 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); |
2297 EXPECT_EQ(url1, entry->GetURL()); | 2318 EXPECT_EQ(url1, entry->GetURL()); |
2298 EXPECT_EQ(1, entry->GetPageID()); | 2319 EXPECT_EQ(1, entry->GetPageID()); |
2299 EXPECT_EQ(root_entry, entry->root_node()->frame_entry.get()); | 2320 EXPECT_EQ(root_entry, entry->root_node()->frame_entry.get()); |
2300 EXPECT_EQ(url1, root_entry->url()); | 2321 EXPECT_EQ(url1, root_entry->url()); |
(...skipping 23 matching lines...) Expand all Loading... | |
2324 main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); | 2345 main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); |
2325 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2346 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2326 NavigationEntry* entry1 = controller.GetLastCommittedEntry(); | 2347 NavigationEntry* entry1 = controller.GetLastCommittedEntry(); |
2327 navigation_entry_committed_counter_ = 0; | 2348 navigation_entry_committed_counter_ = 0; |
2328 | 2349 |
2329 // Prereq: add a subframe with an initial auto-subframe navigation. | 2350 // Prereq: add a subframe with an initial auto-subframe navigation. |
2330 main_test_rfh()->OnCreateChildFrame( | 2351 main_test_rfh()->OnCreateChildFrame( |
2331 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, | 2352 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, |
2332 std::string(), "uniqueName0", blink::WebSandboxFlags::None, | 2353 std::string(), "uniqueName0", blink::WebSandboxFlags::None, |
2333 blink::WebFrameOwnerProperties()); | 2354 blink::WebFrameOwnerProperties()); |
2334 RenderFrameHostImpl* subframe = | 2355 TestRenderFrameHost* subframe = static_cast<TestRenderFrameHost*>( |
2335 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host(); | 2356 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host()); |
2336 const GURL subframe_url("http://foo1/subframe"); | 2357 const GURL subframe_url("http://foo1/subframe"); |
2337 { | 2358 { |
2338 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2359 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2339 params.page_id = 1; | 2360 params.page_id = 1; |
2340 params.nav_entry_id = 0; | 2361 params.nav_entry_id = 0; |
2341 params.did_create_new_entry = false; | 2362 params.did_create_new_entry = false; |
2342 params.url = subframe_url; | 2363 params.url = subframe_url; |
2343 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 2364 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
2344 params.should_update_history = false; | 2365 params.should_update_history = false; |
2345 params.gesture = NavigationGestureUser; | 2366 params.gesture = NavigationGestureUser; |
2346 params.is_post = false; | 2367 params.is_post = false; |
2347 params.page_state = PageState::CreateFromURL(subframe_url); | 2368 params.page_state = PageState::CreateFromURL(subframe_url); |
2348 | 2369 |
2349 // Navigating should do nothing. | 2370 // Navigating should do nothing. |
2350 LoadCommittedDetails details; | 2371 subframe->PrepareForCommit(); |
2351 EXPECT_FALSE(controller.RendererDidNavigate(subframe, params, &details)); | 2372 subframe->SendNavigateWithParams(¶ms); |
2352 EXPECT_EQ(0U, notifications.size()); | 2373 EXPECT_EQ(0U, notifications.size()); |
2353 } | 2374 } |
2354 | 2375 |
2355 // First manual subframe navigation. | 2376 // First manual subframe navigation. |
2356 const GURL url2("http://foo2"); | 2377 const GURL url2("http://foo2"); |
2357 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2378 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2358 params.page_id = 2; | 2379 params.page_id = 2; |
2359 params.nav_entry_id = 0; | 2380 params.nav_entry_id = 0; |
2360 params.did_create_new_entry = true; | 2381 params.did_create_new_entry = true; |
2361 params.url = url2; | 2382 params.url = url2; |
2362 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; | 2383 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; |
2363 params.should_update_history = false; | 2384 params.should_update_history = false; |
2364 params.gesture = NavigationGestureUser; | 2385 params.gesture = NavigationGestureUser; |
2365 params.is_post = false; | 2386 params.is_post = false; |
2366 params.page_state = PageState::CreateFromURL(url2); | 2387 params.page_state = PageState::CreateFromURL(url2); |
2367 | 2388 |
2368 // This should generate a new entry. | 2389 // This should generate a new entry. |
2369 LoadCommittedDetails details; | 2390 subframe->PrepareForCommit(); |
2370 EXPECT_TRUE(controller.RendererDidNavigate(subframe, params, &details)); | 2391 subframe->SendNavigateWithParams(¶ms); |
2371 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); | 2392 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); |
2372 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2393 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2373 navigation_entry_committed_counter_ = 0; | 2394 navigation_entry_committed_counter_ = 0; |
2374 EXPECT_EQ(2, controller.GetEntryCount()); | 2395 EXPECT_EQ(2, controller.GetEntryCount()); |
2375 | 2396 |
2376 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2397 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
2377 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2398 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
2378 // The entry should have a subframe FrameNavigationEntry. | 2399 // The entry should have a subframe FrameNavigationEntry. |
2379 ASSERT_EQ(1U, entry2->root_node()->children.size()); | 2400 ASSERT_EQ(1U, entry2->root_node()->children.size()); |
2380 EXPECT_EQ(url2, entry2->root_node()->children[0]->frame_entry->url()); | 2401 EXPECT_EQ(url2, entry2->root_node()->children[0]->frame_entry->url()); |
2381 } else { | 2402 } else { |
2382 // There are no subframe FrameNavigationEntries by default. | 2403 // There are no subframe FrameNavigationEntries by default. |
2383 EXPECT_EQ(0U, entry2->root_node()->children.size()); | 2404 EXPECT_EQ(0U, entry2->root_node()->children.size()); |
2384 } | 2405 } |
2385 | 2406 |
2386 // Second manual subframe navigation should also make a new entry. | 2407 // Second manual subframe navigation should also make a new entry. |
2387 const GURL url3("http://foo3"); | 2408 const GURL url3("http://foo3"); |
2388 params.page_id = 3; | 2409 params.page_id = 3; |
2389 params.nav_entry_id = 0; | 2410 params.nav_entry_id = 0; |
2390 params.did_create_new_entry = true; | 2411 params.did_create_new_entry = true; |
2391 params.url = url3; | 2412 params.url = url3; |
2392 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; | 2413 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; |
2393 params.page_state = PageState::CreateFromURL(url3); | 2414 params.page_state = PageState::CreateFromURL(url3); |
2394 EXPECT_TRUE(controller.RendererDidNavigate(subframe, params, &details)); | 2415 subframe->PrepareForCommit(); |
2416 subframe->SendNavigateWithParams(¶ms); | |
2395 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2417 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2396 navigation_entry_committed_counter_ = 0; | 2418 navigation_entry_committed_counter_ = 0; |
2397 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry(); | 2419 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry(); |
2398 EXPECT_EQ(3, controller.GetEntryCount()); | 2420 EXPECT_EQ(3, controller.GetEntryCount()); |
2399 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); | 2421 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); |
2400 | 2422 |
2401 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2423 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
2402 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2424 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
2403 // The entry should have a subframe FrameNavigationEntry. | 2425 // The entry should have a subframe FrameNavigationEntry. |
2404 ASSERT_EQ(1U, entry3->root_node()->children.size()); | 2426 ASSERT_EQ(1U, entry3->root_node()->children.size()); |
2405 EXPECT_EQ(url3, entry3->root_node()->children[0]->frame_entry->url()); | 2427 EXPECT_EQ(url3, entry3->root_node()->children[0]->frame_entry->url()); |
2406 } else { | 2428 } else { |
2407 // There are no subframe FrameNavigationEntries by default. | 2429 // There are no subframe FrameNavigationEntries by default. |
2408 EXPECT_EQ(0U, entry3->root_node()->children.size()); | 2430 EXPECT_EQ(0U, entry3->root_node()->children.size()); |
2409 } | 2431 } |
2410 | 2432 |
2411 // Go back one. | 2433 // Go back one. |
2412 controller.GoBack(); | 2434 controller.GoBack(); |
2413 params.page_id = 2; | 2435 params.page_id = 2; |
2414 params.nav_entry_id = entry2->GetUniqueID(); | 2436 params.nav_entry_id = entry2->GetUniqueID(); |
2415 params.did_create_new_entry = false; | 2437 params.did_create_new_entry = false; |
2416 params.url = url2; | 2438 params.url = url2; |
2417 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 2439 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
2418 params.page_state = PageState::CreateFromURL(url2); | 2440 params.page_state = PageState::CreateFromURL(url2); |
2419 EXPECT_TRUE(controller.RendererDidNavigate(subframe, params, &details)); | 2441 subframe->PrepareForCommit(); |
2442 subframe->SendNavigateWithParams(¶ms); | |
2420 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2443 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2421 navigation_entry_committed_counter_ = 0; | 2444 navigation_entry_committed_counter_ = 0; |
2422 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); | 2445 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); |
2423 EXPECT_EQ(3, controller.GetEntryCount()); | 2446 EXPECT_EQ(3, controller.GetEntryCount()); |
2424 EXPECT_EQ(1, controller.GetCurrentEntryIndex()); | 2447 EXPECT_EQ(1, controller.GetCurrentEntryIndex()); |
2425 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 2448 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
2426 EXPECT_FALSE(controller.GetPendingEntry()); | 2449 EXPECT_FALSE(controller.GetPendingEntry()); |
2427 | 2450 |
2428 // Go back one more. | 2451 // Go back one more. |
2429 controller.GoBack(); | 2452 controller.GoBack(); |
2430 params.page_id = 1; | 2453 params.page_id = 1; |
2431 params.nav_entry_id = entry1->GetUniqueID(); | 2454 params.nav_entry_id = entry1->GetUniqueID(); |
2432 params.did_create_new_entry = false; | 2455 params.did_create_new_entry = false; |
2433 params.url = subframe_url; | 2456 params.url = subframe_url; |
2434 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 2457 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
2435 params.page_state = PageState::CreateFromURL(subframe_url); | 2458 params.page_state = PageState::CreateFromURL(subframe_url); |
2436 EXPECT_TRUE(controller.RendererDidNavigate(subframe, params, &details)); | 2459 subframe->PrepareForCommit(); |
2460 subframe->SendNavigateWithParams(¶ms); | |
2437 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2461 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2438 navigation_entry_committed_counter_ = 0; | 2462 navigation_entry_committed_counter_ = 0; |
2439 EXPECT_EQ(entry1, controller.GetLastCommittedEntry()); | 2463 EXPECT_EQ(entry1, controller.GetLastCommittedEntry()); |
2440 EXPECT_EQ(3, controller.GetEntryCount()); | 2464 EXPECT_EQ(3, controller.GetEntryCount()); |
2441 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); | 2465 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); |
2442 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 2466 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
2443 EXPECT_FALSE(controller.GetPendingEntry()); | 2467 EXPECT_FALSE(controller.GetPendingEntry()); |
2444 } | 2468 } |
2445 | 2469 |
2446 TEST_F(NavigationControllerTest, LinkClick) { | 2470 TEST_F(NavigationControllerTest, LinkClick) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2487 self_params.nav_entry_id = 0; | 2511 self_params.nav_entry_id = 0; |
2488 self_params.did_create_new_entry = false; | 2512 self_params.did_create_new_entry = false; |
2489 self_params.url = url1; | 2513 self_params.url = url1; |
2490 self_params.transition = ui::PAGE_TRANSITION_LINK; | 2514 self_params.transition = ui::PAGE_TRANSITION_LINK; |
2491 self_params.should_update_history = false; | 2515 self_params.should_update_history = false; |
2492 self_params.gesture = NavigationGestureUser; | 2516 self_params.gesture = NavigationGestureUser; |
2493 self_params.is_post = false; | 2517 self_params.is_post = false; |
2494 self_params.page_state = PageState::CreateFromURL(url1); | 2518 self_params.page_state = PageState::CreateFromURL(url1); |
2495 self_params.was_within_same_page = true; | 2519 self_params.was_within_same_page = true; |
2496 | 2520 |
2497 LoadCommittedDetails details; | 2521 LoadCommittedDetailsObserver observer(contents()); |
2498 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), self_params, | 2522 main_test_rfh()->PrepareForCommit(); |
2499 &details)); | 2523 main_test_rfh()->SendNavigateWithParams(&self_params); |
2500 NavigationEntry* entry1 = controller.GetLastCommittedEntry(); | 2524 NavigationEntry* entry1 = controller.GetLastCommittedEntry(); |
2501 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2525 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2502 navigation_entry_committed_counter_ = 0; | 2526 navigation_entry_committed_counter_ = 0; |
2503 EXPECT_TRUE(details.is_in_page); | 2527 EXPECT_TRUE(observer.details().is_in_page); |
2504 EXPECT_TRUE(details.did_replace_entry); | 2528 EXPECT_TRUE(observer.details().did_replace_entry); |
2505 EXPECT_EQ(1, controller.GetEntryCount()); | 2529 EXPECT_EQ(1, controller.GetEntryCount()); |
2506 | 2530 |
2507 // Fragment navigation to a new page_id. | 2531 // Fragment navigation to a new page_id. |
2508 const GURL url2("http://foo#a"); | 2532 const GURL url2("http://foo#a"); |
2509 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2533 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2510 params.page_id = 1; | 2534 params.page_id = 1; |
2511 params.nav_entry_id = 0; | 2535 params.nav_entry_id = 0; |
2512 params.did_create_new_entry = true; | 2536 params.did_create_new_entry = true; |
2513 params.url = url2; | 2537 params.url = url2; |
2514 params.transition = ui::PAGE_TRANSITION_LINK; | 2538 params.transition = ui::PAGE_TRANSITION_LINK; |
2515 params.should_update_history = false; | 2539 params.should_update_history = false; |
2516 params.gesture = NavigationGestureUser; | 2540 params.gesture = NavigationGestureUser; |
2517 params.is_post = false; | 2541 params.is_post = false; |
2518 params.page_state = PageState::CreateFromURL(url2); | 2542 params.page_state = PageState::CreateFromURL(url2); |
2519 params.was_within_same_page = true; | 2543 params.was_within_same_page = true; |
2520 | 2544 |
2521 // This should generate a new entry. | 2545 // This should generate a new entry. |
2522 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, | 2546 main_test_rfh()->PrepareForCommit(); |
2523 &details)); | 2547 main_test_rfh()->SendNavigateWithParams(¶ms); |
2524 NavigationEntry* entry2 = controller.GetLastCommittedEntry(); | 2548 NavigationEntry* entry2 = controller.GetLastCommittedEntry(); |
2525 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2549 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2526 navigation_entry_committed_counter_ = 0; | 2550 navigation_entry_committed_counter_ = 0; |
2527 EXPECT_TRUE(details.is_in_page); | 2551 EXPECT_TRUE(observer.details().is_in_page); |
2528 EXPECT_FALSE(details.did_replace_entry); | 2552 EXPECT_FALSE(observer.details().did_replace_entry); |
2529 EXPECT_EQ(2, controller.GetEntryCount()); | 2553 EXPECT_EQ(2, controller.GetEntryCount()); |
2530 | 2554 |
2531 // Go back one. | 2555 // Go back one. |
2532 FrameHostMsg_DidCommitProvisionalLoad_Params back_params(params); | 2556 FrameHostMsg_DidCommitProvisionalLoad_Params back_params(params); |
2533 controller.GoBack(); | 2557 controller.GoBack(); |
2534 back_params.url = url1; | 2558 back_params.url = url1; |
2535 back_params.page_id = 0; | 2559 back_params.page_id = 0; |
2536 back_params.nav_entry_id = entry1->GetUniqueID(); | 2560 back_params.nav_entry_id = entry1->GetUniqueID(); |
2537 back_params.did_create_new_entry = false; | 2561 back_params.did_create_new_entry = false; |
2538 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), back_params, | 2562 main_test_rfh()->PrepareForCommit(); |
2539 &details)); | 2563 main_test_rfh()->SendNavigateWithParams(&back_params); |
2540 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2564 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2541 navigation_entry_committed_counter_ = 0; | 2565 navigation_entry_committed_counter_ = 0; |
2542 EXPECT_TRUE(details.is_in_page); | 2566 EXPECT_TRUE(observer.details().is_in_page); |
2543 EXPECT_EQ(2, controller.GetEntryCount()); | 2567 EXPECT_EQ(2, controller.GetEntryCount()); |
2544 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); | 2568 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); |
2545 EXPECT_EQ(back_params.url, controller.GetVisibleEntry()->GetURL()); | 2569 EXPECT_EQ(back_params.url, controller.GetVisibleEntry()->GetURL()); |
2546 | 2570 |
2547 // Go forward. | 2571 // Go forward. |
2548 FrameHostMsg_DidCommitProvisionalLoad_Params forward_params(params); | 2572 FrameHostMsg_DidCommitProvisionalLoad_Params forward_params(params); |
2549 controller.GoForward(); | 2573 controller.GoForward(); |
2550 forward_params.url = url2; | 2574 forward_params.url = url2; |
2551 forward_params.page_id = 1; | 2575 forward_params.page_id = 1; |
2552 forward_params.nav_entry_id = entry2->GetUniqueID(); | 2576 forward_params.nav_entry_id = entry2->GetUniqueID(); |
2553 forward_params.did_create_new_entry = false; | 2577 forward_params.did_create_new_entry = false; |
2554 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), forward_params, | 2578 main_test_rfh()->PrepareForCommit(); |
2555 &details)); | 2579 main_test_rfh()->SendNavigateWithParams(&forward_params); |
2556 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2580 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2557 navigation_entry_committed_counter_ = 0; | 2581 navigation_entry_committed_counter_ = 0; |
2558 EXPECT_TRUE(details.is_in_page); | 2582 EXPECT_TRUE(observer.details().is_in_page); |
2559 EXPECT_EQ(2, controller.GetEntryCount()); | 2583 EXPECT_EQ(2, controller.GetEntryCount()); |
2560 EXPECT_EQ(1, controller.GetCurrentEntryIndex()); | 2584 EXPECT_EQ(1, controller.GetCurrentEntryIndex()); |
2561 EXPECT_EQ(forward_params.url, | 2585 EXPECT_EQ(forward_params.url, |
2562 controller.GetVisibleEntry()->GetURL()); | 2586 controller.GetVisibleEntry()->GetURL()); |
2563 | 2587 |
2564 // Now go back and forward again. This is to work around a bug where we would | 2588 // Now go back and forward again. This is to work around a bug where we would |
2565 // compare the incoming URL with the last committed entry rather than the | 2589 // compare the incoming URL with the last committed entry rather than the |
2566 // one identified by an existing page ID. This would result in the second URL | 2590 // one identified by an existing page ID. This would result in the second URL |
2567 // losing the reference fragment when you navigate away from it and then back. | 2591 // losing the reference fragment when you navigate away from it and then back. |
2568 controller.GoBack(); | 2592 controller.GoBack(); |
2569 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), back_params, | 2593 main_test_rfh()->PrepareForCommit(); |
2570 &details)); | 2594 main_test_rfh()->SendNavigateWithParams(&back_params); |
2571 controller.GoForward(); | 2595 controller.GoForward(); |
2572 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), forward_params, | 2596 main_test_rfh()->PrepareForCommit(); |
2573 &details)); | 2597 main_test_rfh()->SendNavigateWithParams(&forward_params); |
2574 EXPECT_EQ(forward_params.url, | 2598 EXPECT_EQ(forward_params.url, |
2575 controller.GetVisibleEntry()->GetURL()); | 2599 controller.GetVisibleEntry()->GetURL()); |
2576 | 2600 |
2577 // Finally, navigate to an unrelated URL to make sure in_page is not sticky. | 2601 // Finally, navigate to an unrelated URL to make sure in_page is not sticky. |
2578 const GURL url3("http://bar"); | 2602 const GURL url3("http://bar"); |
2579 params.page_id = 2; | 2603 params.page_id = 2; |
2580 params.nav_entry_id = 0; | 2604 params.nav_entry_id = 0; |
2581 params.did_create_new_entry = true; | 2605 params.did_create_new_entry = true; |
2582 params.url = url3; | 2606 params.url = url3; |
2583 navigation_entry_committed_counter_ = 0; | 2607 navigation_entry_committed_counter_ = 0; |
2584 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, | 2608 main_test_rfh()->PrepareForCommit(); |
2585 &details)); | 2609 main_test_rfh()->SendNavigateWithParams(¶ms); |
2586 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2610 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2587 navigation_entry_committed_counter_ = 0; | 2611 navigation_entry_committed_counter_ = 0; |
2588 EXPECT_FALSE(details.is_in_page); | 2612 EXPECT_FALSE(observer.details().is_in_page); |
2589 EXPECT_EQ(3, controller.GetEntryCount()); | 2613 EXPECT_EQ(3, controller.GetEntryCount()); |
2590 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); | 2614 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); |
2591 } | 2615 } |
2592 | 2616 |
2593 TEST_F(NavigationControllerTest, InPage_Replace) { | 2617 TEST_F(NavigationControllerTest, InPage_Replace) { |
2594 NavigationControllerImpl& controller = controller_impl(); | 2618 NavigationControllerImpl& controller = controller_impl(); |
2595 TestNotificationTracker notifications; | 2619 TestNotificationTracker notifications; |
2596 RegisterForAllNavNotifications(¬ifications, &controller); | 2620 RegisterForAllNavNotifications(¬ifications, &controller); |
2597 | 2621 |
2598 // Main page. | 2622 // Main page. |
(...skipping 10 matching lines...) Expand all Loading... | |
2609 params.did_create_new_entry = false; | 2633 params.did_create_new_entry = false; |
2610 params.url = url2; | 2634 params.url = url2; |
2611 params.transition = ui::PAGE_TRANSITION_LINK; | 2635 params.transition = ui::PAGE_TRANSITION_LINK; |
2612 params.should_update_history = false; | 2636 params.should_update_history = false; |
2613 params.gesture = NavigationGestureUser; | 2637 params.gesture = NavigationGestureUser; |
2614 params.is_post = false; | 2638 params.is_post = false; |
2615 params.page_state = PageState::CreateFromURL(url2); | 2639 params.page_state = PageState::CreateFromURL(url2); |
2616 params.was_within_same_page = true; | 2640 params.was_within_same_page = true; |
2617 | 2641 |
2618 // This should NOT generate a new entry, nor prune the list. | 2642 // This should NOT generate a new entry, nor prune the list. |
2619 LoadCommittedDetails details; | 2643 LoadCommittedDetailsObserver observer(contents()); |
2620 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, | 2644 main_test_rfh()->PrepareForCommit(); |
2621 &details)); | 2645 main_test_rfh()->SendNavigateWithParams(¶ms); |
2622 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2646 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2623 navigation_entry_committed_counter_ = 0; | 2647 navigation_entry_committed_counter_ = 0; |
2624 EXPECT_TRUE(details.is_in_page); | 2648 EXPECT_TRUE(observer.details().is_in_page); |
2625 EXPECT_TRUE(details.did_replace_entry); | 2649 EXPECT_TRUE(observer.details().did_replace_entry); |
2626 EXPECT_EQ(1, controller.GetEntryCount()); | 2650 EXPECT_EQ(1, controller.GetEntryCount()); |
2627 } | 2651 } |
2628 | 2652 |
2629 // Tests for http://crbug.com/40395 | 2653 // Tests for http://crbug.com/40395 |
2630 // Simulates this: | 2654 // Simulates this: |
2631 // <script> | 2655 // <script> |
2632 // window.location.replace("#a"); | 2656 // window.location.replace("#a"); |
2633 // window.location='http://foo3/'; | 2657 // window.location='http://foo3/'; |
2634 // </script> | 2658 // </script> |
2635 TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) { | 2659 TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) { |
(...skipping 27 matching lines...) Expand all Loading... | |
2663 params.url = url; | 2687 params.url = url; |
2664 params.transition = ui::PAGE_TRANSITION_LINK; | 2688 params.transition = ui::PAGE_TRANSITION_LINK; |
2665 params.redirects.push_back(url); | 2689 params.redirects.push_back(url); |
2666 params.should_update_history = true; | 2690 params.should_update_history = true; |
2667 params.gesture = NavigationGestureUnknown; | 2691 params.gesture = NavigationGestureUnknown; |
2668 params.is_post = false; | 2692 params.is_post = false; |
2669 params.page_state = PageState::CreateFromURL(url); | 2693 params.page_state = PageState::CreateFromURL(url); |
2670 params.was_within_same_page = true; | 2694 params.was_within_same_page = true; |
2671 | 2695 |
2672 // This should NOT generate a new entry, nor prune the list. | 2696 // This should NOT generate a new entry, nor prune the list. |
2673 LoadCommittedDetails details; | 2697 LoadCommittedDetailsObserver observer(contents()); |
2674 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, | 2698 main_test_rfh()->PrepareForCommit(); |
2675 &details)); | 2699 main_test_rfh()->SendNavigateWithParams(¶ms); |
2676 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2700 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2677 navigation_entry_committed_counter_ = 0; | 2701 navigation_entry_committed_counter_ = 0; |
2678 EXPECT_TRUE(details.is_in_page); | 2702 EXPECT_TRUE(observer.details().is_in_page); |
2679 EXPECT_TRUE(details.did_replace_entry); | 2703 EXPECT_TRUE(observer.details().did_replace_entry); |
2680 EXPECT_EQ(2, controller.GetEntryCount()); | 2704 EXPECT_EQ(2, controller.GetEntryCount()); |
2681 } | 2705 } |
2682 | 2706 |
2683 // Perform a client redirect to a new page. | 2707 // Perform a client redirect to a new page. |
2684 { | 2708 { |
2685 const GURL url("http://foo3/"); | 2709 const GURL url("http://foo3/"); |
2686 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2710 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2687 params.page_id = 2; // New page_id | 2711 params.page_id = 2; // New page_id |
2688 params.nav_entry_id = 0; | 2712 params.nav_entry_id = 0; |
2689 params.did_create_new_entry = true; | 2713 params.did_create_new_entry = true; |
2690 params.url = url; | 2714 params.url = url; |
2691 params.transition = ui::PAGE_TRANSITION_CLIENT_REDIRECT; | 2715 params.transition = ui::PAGE_TRANSITION_CLIENT_REDIRECT; |
2692 params.redirects.push_back(GURL("http://foo2/#a")); | 2716 params.redirects.push_back(GURL("http://foo2/#a")); |
2693 params.redirects.push_back(url); | 2717 params.redirects.push_back(url); |
2694 params.should_update_history = true; | 2718 params.should_update_history = true; |
2695 params.gesture = NavigationGestureUnknown; | 2719 params.gesture = NavigationGestureUnknown; |
2696 params.is_post = false; | 2720 params.is_post = false; |
2697 params.page_state = PageState::CreateFromURL(url); | 2721 params.page_state = PageState::CreateFromURL(url); |
2698 | 2722 |
2699 // This SHOULD generate a new entry. | 2723 // This SHOULD generate a new entry. |
2700 LoadCommittedDetails details; | 2724 LoadCommittedDetailsObserver observer(contents()); |
2701 EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params, | 2725 main_test_rfh()->PrepareForCommit(); |
2702 &details)); | 2726 main_test_rfh()->SendNavigateWithParams(¶ms); |
2703 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2727 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2704 navigation_entry_committed_counter_ = 0; | 2728 navigation_entry_committed_counter_ = 0; |
2705 EXPECT_FALSE(details.is_in_page); | 2729 EXPECT_FALSE(observer.details().is_in_page); |
2706 EXPECT_EQ(3, controller.GetEntryCount()); | 2730 EXPECT_EQ(3, controller.GetEntryCount()); |
2707 } | 2731 } |
2708 | 2732 |
2709 // Verify that BACK brings us back to http://foo2/. | 2733 // Verify that BACK brings us back to http://foo2/. |
2710 { | 2734 { |
2711 const GURL url("http://foo2/"); | 2735 const GURL url("http://foo2/"); |
2712 controller.GoBack(); | 2736 controller.GoBack(); |
2713 int entry_id = controller.GetPendingEntry()->GetUniqueID(); | 2737 int entry_id = controller.GetPendingEntry()->GetUniqueID(); |
2714 main_test_rfh()->PrepareForCommit(); | 2738 main_test_rfh()->PrepareForCommit(); |
2715 main_test_rfh()->SendNavigate(1, entry_id, false, url); | 2739 main_test_rfh()->SendNavigate(1, entry_id, false, url); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2874 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2898 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2875 params.page_id = 0; | 2899 params.page_id = 0; |
2876 params.nav_entry_id = our_controller.GetPendingEntry()->GetUniqueID(); | 2900 params.nav_entry_id = our_controller.GetPendingEntry()->GetUniqueID(); |
2877 params.did_create_new_entry = false; | 2901 params.did_create_new_entry = false; |
2878 params.url = url; | 2902 params.url = url; |
2879 params.transition = ui::PAGE_TRANSITION_LINK; | 2903 params.transition = ui::PAGE_TRANSITION_LINK; |
2880 params.should_update_history = false; | 2904 params.should_update_history = false; |
2881 params.gesture = NavigationGestureUser; | 2905 params.gesture = NavigationGestureUser; |
2882 params.is_post = false; | 2906 params.is_post = false; |
2883 params.page_state = PageState::CreateFromURL(url); | 2907 params.page_state = PageState::CreateFromURL(url); |
2884 LoadCommittedDetails details; | 2908 TestRenderFrameHost* main_rfh = |
2885 our_controller.RendererDidNavigate(our_contents->GetMainFrame(), params, | 2909 static_cast<TestRenderFrameHost*>(our_contents->GetMainFrame()); |
2886 &details); | 2910 main_rfh->PrepareForCommit(); |
2911 main_rfh->SendNavigateWithParams(¶ms); | |
2887 | 2912 |
2888 // There should be no longer any pending entry and one committed one. This | 2913 // There should be no longer any pending entry and one committed one. This |
2889 // means that we were able to locate the entry, assign its site instance, and | 2914 // means that we were able to locate the entry, assign its site instance, and |
2890 // commit it properly. | 2915 // commit it properly. |
2891 EXPECT_EQ(1, our_controller.GetEntryCount()); | 2916 EXPECT_EQ(1, our_controller.GetEntryCount()); |
2892 EXPECT_EQ(0, our_controller.GetLastCommittedEntryIndex()); | 2917 EXPECT_EQ(0, our_controller.GetLastCommittedEntryIndex()); |
2893 EXPECT_FALSE(our_controller.GetPendingEntry()); | 2918 EXPECT_FALSE(our_controller.GetPendingEntry()); |
2894 EXPECT_EQ( | 2919 EXPECT_EQ( |
2895 url, | 2920 url, |
2896 our_controller.GetLastCommittedEntry()->site_instance()->GetSiteURL()); | 2921 our_controller.GetLastCommittedEntry()->site_instance()->GetSiteURL()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2956 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2981 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2957 params.page_id = 0; | 2982 params.page_id = 0; |
2958 params.nav_entry_id = entry->GetUniqueID(); | 2983 params.nav_entry_id = entry->GetUniqueID(); |
2959 params.did_create_new_entry = false; | 2984 params.did_create_new_entry = false; |
2960 params.url = url; | 2985 params.url = url; |
2961 params.transition = ui::PAGE_TRANSITION_LINK; | 2986 params.transition = ui::PAGE_TRANSITION_LINK; |
2962 params.should_update_history = false; | 2987 params.should_update_history = false; |
2963 params.gesture = NavigationGestureUser; | 2988 params.gesture = NavigationGestureUser; |
2964 params.is_post = false; | 2989 params.is_post = false; |
2965 params.page_state = PageState::CreateFromURL(url); | 2990 params.page_state = PageState::CreateFromURL(url); |
2966 LoadCommittedDetails details; | 2991 TestRenderFrameHost* main_rfh = |
2967 our_controller.RendererDidNavigate(our_contents->GetMainFrame(), params, | 2992 static_cast<TestRenderFrameHost*>(our_contents->GetMainFrame()); |
2968 &details); | 2993 main_rfh->PrepareForCommit(); |
2994 main_rfh->SendNavigateWithParams(¶ms); | |
2969 | 2995 |
2970 // There should be no pending entry and one committed one. | 2996 // There should be no pending entry and one committed one. |
2971 EXPECT_EQ(1, our_controller.GetEntryCount()); | 2997 EXPECT_EQ(1, our_controller.GetEntryCount()); |
2972 EXPECT_EQ(0, our_controller.GetLastCommittedEntryIndex()); | 2998 EXPECT_EQ(0, our_controller.GetLastCommittedEntryIndex()); |
2973 EXPECT_FALSE(our_controller.GetPendingEntry()); | 2999 EXPECT_FALSE(our_controller.GetPendingEntry()); |
2974 EXPECT_EQ( | 3000 EXPECT_EQ( |
2975 url, | 3001 url, |
2976 our_controller.GetLastCommittedEntry()->site_instance()->GetSiteURL()); | 3002 our_controller.GetLastCommittedEntry()->site_instance()->GetSiteURL()); |
2977 EXPECT_EQ(NavigationEntryImpl::RESTORE_NONE, | 3003 EXPECT_EQ(NavigationEntryImpl::RESTORE_NONE, |
2978 our_controller.GetEntryAtIndex(0)->restore_type()); | 3004 our_controller.GetEntryAtIndex(0)->restore_type()); |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3763 | 3789 |
3764 // We should be at the first navigation entry. | 3790 // We should be at the first navigation entry. |
3765 EXPECT_EQ(controller.GetEntryCount(), 1); | 3791 EXPECT_EQ(controller.GetEntryCount(), 1); |
3766 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 3792 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
3767 | 3793 |
3768 // Add and navigate a subframe that would normally count as in-page. | 3794 // Add and navigate a subframe that would normally count as in-page. |
3769 main_test_rfh()->OnCreateChildFrame( | 3795 main_test_rfh()->OnCreateChildFrame( |
3770 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, | 3796 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, |
3771 std::string(), "uniqueName0", blink::WebSandboxFlags::None, | 3797 std::string(), "uniqueName0", blink::WebSandboxFlags::None, |
3772 blink::WebFrameOwnerProperties()); | 3798 blink::WebFrameOwnerProperties()); |
3773 RenderFrameHostImpl* subframe = | 3799 TestRenderFrameHost* subframe = static_cast<TestRenderFrameHost*>( |
3774 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host(); | 3800 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host()); |
3775 const GURL subframe_url("http://www.google.com/#"); | 3801 const GURL subframe_url("http://www.google.com/#"); |
3776 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 3802 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
3777 params.page_id = 0; | 3803 params.page_id = 0; |
3778 params.nav_entry_id = 0; | 3804 params.nav_entry_id = 0; |
3779 params.did_create_new_entry = false; | 3805 params.did_create_new_entry = false; |
3780 params.url = subframe_url; | 3806 params.url = subframe_url; |
3781 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 3807 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
3782 params.should_update_history = false; | 3808 params.should_update_history = false; |
3783 params.gesture = NavigationGestureAuto; | 3809 params.gesture = NavigationGestureAuto; |
3784 params.is_post = false; | 3810 params.is_post = false; |
3785 params.page_state = PageState::CreateFromURL(subframe_url); | 3811 params.page_state = PageState::CreateFromURL(subframe_url); |
3786 LoadCommittedDetails details; | 3812 subframe->PrepareForCommit(); |
3787 EXPECT_FALSE(controller.RendererDidNavigate(subframe, params, &details)); | 3813 subframe->SendNavigateWithParams(¶ms); |
3788 | 3814 |
3789 // Nothing should have changed. | 3815 // Nothing should have changed. |
3790 EXPECT_EQ(controller.GetEntryCount(), 1); | 3816 EXPECT_EQ(controller.GetEntryCount(), 1); |
3791 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 3817 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
3792 } | 3818 } |
3793 | 3819 |
3794 // Make sure that on cloning a WebContentsImpl and going back needs_reload is | 3820 // Make sure that on cloning a WebContentsImpl and going back needs_reload is |
3795 // false. | 3821 // false. |
3796 TEST_F(NavigationControllerTest, CloneAndGoBack) { | 3822 TEST_F(NavigationControllerTest, CloneAndGoBack) { |
3797 NavigationControllerImpl& controller = controller_impl(); | 3823 NavigationControllerImpl& controller = controller_impl(); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3930 const GURL url2("http://bar/"); | 3956 const GURL url2("http://bar/"); |
3931 controller.LoadURL( | 3957 controller.LoadURL( |
3932 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 3958 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
3933 | 3959 |
3934 // Send a subframe update from the first page, as if one had just | 3960 // Send a subframe update from the first page, as if one had just |
3935 // automatically loaded. Auto subframes don't increment the page ID. | 3961 // automatically loaded. Auto subframes don't increment the page ID. |
3936 main_test_rfh()->OnCreateChildFrame( | 3962 main_test_rfh()->OnCreateChildFrame( |
3937 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, | 3963 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, |
3938 std::string(), "uniqueName0", blink::WebSandboxFlags::None, | 3964 std::string(), "uniqueName0", blink::WebSandboxFlags::None, |
3939 blink::WebFrameOwnerProperties()); | 3965 blink::WebFrameOwnerProperties()); |
3940 RenderFrameHostImpl* subframe = | 3966 TestRenderFrameHost* subframe = static_cast<TestRenderFrameHost*>( |
3941 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host(); | 3967 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host()); |
3942 const GURL url1_sub("http://foo/subframe"); | 3968 const GURL url1_sub("http://foo/subframe"); |
3943 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 3969 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
3944 params.page_id = controller.GetLastCommittedEntry()->GetPageID(); | 3970 params.page_id = controller.GetLastCommittedEntry()->GetPageID(); |
3945 params.nav_entry_id = 0; | 3971 params.nav_entry_id = 0; |
3946 params.did_create_new_entry = false; | 3972 params.did_create_new_entry = false; |
3947 params.url = url1_sub; | 3973 params.url = url1_sub; |
3948 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 3974 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
3949 params.should_update_history = false; | 3975 params.should_update_history = false; |
3950 params.gesture = NavigationGestureAuto; | 3976 params.gesture = NavigationGestureAuto; |
3951 params.is_post = false; | 3977 params.is_post = false; |
3952 params.page_state = PageState::CreateFromURL(url1_sub); | 3978 params.page_state = PageState::CreateFromURL(url1_sub); |
3953 LoadCommittedDetails details; | |
3954 | 3979 |
3955 // This should return false meaning that nothing was actually updated. | 3980 // This should return false meaning that nothing was actually updated. |
3956 EXPECT_FALSE(controller.RendererDidNavigate(subframe, params, &details)); | 3981 subframe->PrepareForCommit(); |
3982 subframe->SendNavigateWithParams(¶ms); | |
3957 | 3983 |
3958 // The notification should have updated the last committed one, and not | 3984 // The notification should have updated the last committed one, and not |
3959 // the pending load. | 3985 // the pending load. |
3960 EXPECT_EQ(url1, controller.GetLastCommittedEntry()->GetURL()); | 3986 EXPECT_EQ(url1, controller.GetLastCommittedEntry()->GetURL()); |
3961 | 3987 |
3962 // The active entry should be unchanged by the subframe load. | 3988 // The active entry should be unchanged by the subframe load. |
3963 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); | 3989 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); |
3964 } | 3990 } |
3965 | 3991 |
3966 // Test CopyStateFrom with 2 urls, the first selected and nothing in the target. | 3992 // Test CopyStateFrom with 2 urls, the first selected and nothing in the target. |
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5005 contents()->GetMainFrame()->SendNavigateWithParams(¶ms); | 5031 contents()->GetMainFrame()->SendNavigateWithParams(¶ms); |
5006 | 5032 |
5007 // Now reload. replaceState overrides the POST, so we should not show a | 5033 // Now reload. replaceState overrides the POST, so we should not show a |
5008 // repost warning dialog. | 5034 // repost warning dialog. |
5009 controller_impl().Reload(true); | 5035 controller_impl().Reload(true); |
5010 EXPECT_EQ(0, delegate->repost_form_warning_count()); | 5036 EXPECT_EQ(0, delegate->repost_form_warning_count()); |
5011 } | 5037 } |
5012 | 5038 |
5013 TEST_F(NavigationControllerTest, UnreachableURLGivesErrorPage) { | 5039 TEST_F(NavigationControllerTest, UnreachableURLGivesErrorPage) { |
5014 GURL url("http://foo"); | 5040 GURL url("http://foo"); |
5041 controller().LoadURL(url, Referrer(), ui::PAGE_TRANSITION_TYPED, | |
5042 std::string()); | |
5015 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 5043 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
5016 params.page_id = 1; | 5044 params.page_id = 1; |
5017 params.nav_entry_id = 0; | 5045 params.nav_entry_id = 0; |
5018 params.did_create_new_entry = true; | 5046 params.did_create_new_entry = true; |
5019 params.url = url; | 5047 params.url = url; |
5020 params.transition = ui::PAGE_TRANSITION_LINK; | 5048 params.transition = ui::PAGE_TRANSITION_LINK; |
5021 params.gesture = NavigationGestureUser; | 5049 params.gesture = NavigationGestureUser; |
5022 params.page_state = PageState::CreateFromURL(url); | 5050 params.page_state = PageState::CreateFromURL(url); |
5023 params.was_within_same_page = false; | 5051 params.was_within_same_page = false; |
5024 params.is_post = true; | 5052 params.is_post = true; |
5025 params.post_id = 2; | 5053 params.post_id = 2; |
5026 params.url_is_unreachable = true; | 5054 params.url_is_unreachable = true; |
5027 | 5055 |
5028 // Navigate to new page. | 5056 // Navigate to new page. |
5029 { | 5057 { |
5030 LoadCommittedDetails details; | 5058 LoadCommittedDetailsObserver observer(contents()); |
5031 controller_impl().RendererDidNavigate(main_test_rfh(), params, &details); | 5059 main_test_rfh()->PrepareForCommit(); |
5060 main_test_rfh()->SendNavigateWithParams(¶ms); | |
5032 EXPECT_EQ(PAGE_TYPE_ERROR, | 5061 EXPECT_EQ(PAGE_TYPE_ERROR, |
5033 controller_impl().GetLastCommittedEntry()->GetPageType()); | 5062 controller_impl().GetLastCommittedEntry()->GetPageType()); |
5034 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, details.type); | 5063 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, observer.details().type); |
5035 } | 5064 } |
5036 | 5065 |
5037 // Navigate to existing page. | 5066 // Navigate to existing page. |
5038 { | 5067 { |
5039 params.did_create_new_entry = false; | 5068 params.did_create_new_entry = false; |
5040 LoadCommittedDetails details; | 5069 LoadCommittedDetailsObserver observer(contents()); |
5041 controller_impl().RendererDidNavigate(main_test_rfh(), params, &details); | 5070 main_test_rfh()->PrepareForCommit(); |
5071 main_test_rfh()->SendNavigateWithParams(¶ms); | |
5042 EXPECT_EQ(PAGE_TYPE_ERROR, | 5072 EXPECT_EQ(PAGE_TYPE_ERROR, |
5043 controller_impl().GetLastCommittedEntry()->GetPageType()); | 5073 controller_impl().GetLastCommittedEntry()->GetPageType()); |
5044 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, details.type); | 5074 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, observer.details().type); |
5045 } | 5075 } |
5046 | 5076 |
5047 // Navigate to same page. | 5077 // Navigate to same page. |
5048 // Note: The call to LoadURL() creates a pending entry in order to trigger the | 5078 // Note: The call to LoadURL() creates a pending entry in order to trigger the |
5049 // same-page transition. | 5079 // same-page transition. |
5050 controller_impl().LoadURL( | 5080 controller_impl().LoadURL( |
5051 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 5081 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
5052 params.nav_entry_id = controller_impl().GetPendingEntry()->GetUniqueID(); | 5082 params.nav_entry_id = controller_impl().GetPendingEntry()->GetUniqueID(); |
5053 params.transition = ui::PAGE_TRANSITION_TYPED; | 5083 params.transition = ui::PAGE_TRANSITION_TYPED; |
5054 { | 5084 { |
5055 LoadCommittedDetails details; | 5085 LoadCommittedDetailsObserver observer(contents()); |
5056 controller_impl().RendererDidNavigate(main_test_rfh(), params, &details); | 5086 main_test_rfh()->PrepareForCommit(); |
5087 main_test_rfh()->SendNavigateWithParams(¶ms); | |
5057 EXPECT_EQ(PAGE_TYPE_ERROR, | 5088 EXPECT_EQ(PAGE_TYPE_ERROR, |
5058 controller_impl().GetLastCommittedEntry()->GetPageType()); | 5089 controller_impl().GetLastCommittedEntry()->GetPageType()); |
5059 EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, details.type); | 5090 EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, observer.details().type); |
5060 } | 5091 } |
5061 | 5092 |
5062 // Navigate in page. | 5093 // Navigate in page. |
5063 params.url = GURL("http://foo#foo"); | 5094 params.url = GURL("http://foo#foo"); |
5064 params.transition = ui::PAGE_TRANSITION_LINK; | 5095 params.transition = ui::PAGE_TRANSITION_LINK; |
5065 params.was_within_same_page = true; | 5096 params.was_within_same_page = true; |
5066 { | 5097 { |
5067 LoadCommittedDetails details; | 5098 LoadCommittedDetailsObserver observer(contents()); |
5068 controller_impl().RendererDidNavigate(main_test_rfh(), params, &details); | 5099 main_test_rfh()->PrepareForCommit(); |
5100 main_test_rfh()->SendNavigateWithParams(¶ms); | |
5069 EXPECT_EQ(PAGE_TYPE_ERROR, | 5101 EXPECT_EQ(PAGE_TYPE_ERROR, |
5070 controller_impl().GetLastCommittedEntry()->GetPageType()); | 5102 controller_impl().GetLastCommittedEntry()->GetPageType()); |
5071 EXPECT_TRUE(details.is_in_page); | 5103 EXPECT_TRUE(observer.details().is_in_page); |
5072 } | 5104 } |
5073 } | 5105 } |
5074 | 5106 |
5075 // Tests that if a stale navigation comes back from the renderer, it is properly | 5107 // Tests that if a stale navigation comes back from the renderer, it is properly |
5076 // resurrected. | 5108 // resurrected. |
5077 TEST_F(NavigationControllerTest, StaleNavigationsResurrected) { | 5109 TEST_F(NavigationControllerTest, StaleNavigationsResurrected) { |
5078 NavigationControllerImpl& controller = controller_impl(); | 5110 NavigationControllerImpl& controller = controller_impl(); |
5079 TestNotificationTracker notifications; | 5111 TestNotificationTracker notifications; |
5080 RegisterForAllNavNotifications(¬ifications, &controller); | 5112 RegisterForAllNavNotifications(¬ifications, &controller); |
5081 | 5113 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5132 EXPECT_EQ(url_a, controller.GetEntryAtIndex(0)->GetURL()); | 5164 EXPECT_EQ(url_a, controller.GetEntryAtIndex(0)->GetURL()); |
5133 EXPECT_EQ(url_c, controller.GetEntryAtIndex(1)->GetURL()); | 5165 EXPECT_EQ(url_c, controller.GetEntryAtIndex(1)->GetURL()); |
5134 EXPECT_EQ(url_b, controller.GetEntryAtIndex(2)->GetURL()); | 5166 EXPECT_EQ(url_b, controller.GetEntryAtIndex(2)->GetURL()); |
5135 } | 5167 } |
5136 | 5168 |
5137 // Test that if a renderer provides bogus security info (that fails to | 5169 // Test that if a renderer provides bogus security info (that fails to |
5138 // deserialize properly) when reporting a navigation, the renderer gets | 5170 // deserialize properly) when reporting a navigation, the renderer gets |
5139 // killed. | 5171 // killed. |
5140 TEST_F(NavigationControllerTest, RendererNavigateBogusSecurityInfo) { | 5172 TEST_F(NavigationControllerTest, RendererNavigateBogusSecurityInfo) { |
5141 GURL url("http://foo.test"); | 5173 GURL url("http://foo.test"); |
5174 controller().LoadURL(url, Referrer(), ui::PAGE_TRANSITION_TYPED, | |
5175 std::string()); | |
5142 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 5176 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
5143 params.page_id = 0; | 5177 params.page_id = 0; |
5144 params.nav_entry_id = 0; | 5178 params.nav_entry_id = 0; |
5145 params.did_create_new_entry = true; | 5179 params.did_create_new_entry = true; |
5146 params.url = url; | 5180 params.url = url; |
5147 params.transition = ui::PAGE_TRANSITION_LINK; | 5181 params.transition = ui::PAGE_TRANSITION_LINK; |
5148 params.should_update_history = true; | 5182 params.should_update_history = true; |
5149 params.gesture = NavigationGestureUser; | 5183 params.gesture = NavigationGestureUser; |
5150 params.is_post = false; | 5184 params.is_post = false; |
5151 params.page_state = PageState::CreateFromURL(url); | 5185 params.page_state = PageState::CreateFromURL(url); |
5152 params.was_within_same_page = false; | 5186 params.was_within_same_page = false; |
5153 params.security_info = "bogus security info!"; | 5187 params.security_info = "bogus security info!"; |
5154 | 5188 |
5155 LoadCommittedDetails details; | 5189 LoadCommittedDetailsObserver observer(contents()); |
5156 EXPECT_EQ(0, main_test_rfh()->GetProcess()->bad_msg_count()); | 5190 EXPECT_EQ(0, main_test_rfh()->GetProcess()->bad_msg_count()); |
5157 EXPECT_TRUE( | 5191 main_test_rfh()->PrepareForCommit(); |
5158 controller_impl().RendererDidNavigate(main_test_rfh(), params, &details)); | 5192 main_test_rfh()->SendNavigateWithParams(¶ms); |
5159 | 5193 |
5160 SSLStatus default_ssl_status; | 5194 SSLStatus default_ssl_status; |
5161 EXPECT_EQ(default_ssl_status.security_style, | 5195 EXPECT_EQ(default_ssl_status.security_style, |
5162 details.ssl_status.security_style); | 5196 observer.details().ssl_status.security_style); |
5163 EXPECT_EQ(default_ssl_status.cert_id, details.ssl_status.cert_id); | 5197 EXPECT_EQ(default_ssl_status.cert_id, observer.details().ssl_status.cert_id); |
5164 EXPECT_EQ(default_ssl_status.cert_status, details.ssl_status.cert_status); | 5198 EXPECT_EQ(default_ssl_status.cert_status, |
5165 EXPECT_EQ(default_ssl_status.security_bits, details.ssl_status.security_bits); | 5199 observer.details().ssl_status.cert_status); |
5200 EXPECT_EQ(default_ssl_status.security_bits, | |
5201 observer.details().ssl_status.security_bits); | |
5166 EXPECT_EQ(default_ssl_status.connection_status, | 5202 EXPECT_EQ(default_ssl_status.connection_status, |
5167 details.ssl_status.connection_status); | 5203 observer.details().ssl_status.connection_status); |
5168 EXPECT_EQ(default_ssl_status.content_status, | 5204 EXPECT_EQ(default_ssl_status.content_status, |
5169 details.ssl_status.content_status); | 5205 observer.details().ssl_status.content_status); |
5170 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); | 5206 EXPECT_EQ( |
5207 0u, | |
5208 observer.details().ssl_status.signed_certificate_timestamp_ids.size()); | |
5171 | 5209 |
5172 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); | 5210 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); |
5173 } | 5211 } |
5174 | 5212 |
5175 } // namespace content | 5213 } // namespace content |
OLD | NEW |