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