OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "content/browser/frame_host/frame_navigation_entry.h" | 8 #include "content/browser/frame_host/frame_navigation_entry.h" |
9 #include "content/browser/frame_host/frame_tree.h" | 9 #include "content/browser/frame_host/frame_tree.h" |
10 #include "content/browser/frame_host/navigation_controller_impl.h" | 10 #include "content/browser/frame_host/navigation_controller_impl.h" |
(...skipping 1860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1871 capturer.Wait(); | 1871 capturer.Wait(); |
1872 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); | 1872 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); |
1873 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); | 1873 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); |
1874 } | 1874 } |
1875 EXPECT_EQ(3, controller.GetEntryCount()); | 1875 EXPECT_EQ(3, controller.GetEntryCount()); |
1876 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 1876 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
1877 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); | 1877 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); |
1878 | 1878 |
1879 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 1879 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
1880 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 1880 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
1881 // The entry should have a new FrameNavigationEntries for the subframe. | 1881 // The entry should have a FrameNavigationEntry for the subframe. |
1882 ASSERT_EQ(1U, entry2->root_node()->children.size()); | 1882 ASSERT_EQ(1U, entry2->root_node()->children.size()); |
1883 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url()); | 1883 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url()); |
1884 } else { | 1884 } else { |
1885 // There are no subframe FrameNavigationEntries by default. | 1885 // There are no subframe FrameNavigationEntries by default. |
1886 EXPECT_EQ(0U, entry2->root_node()->children.size()); | 1886 EXPECT_EQ(0U, entry2->root_node()->children.size()); |
1887 } | 1887 } |
1888 | 1888 |
1889 // 5. Go back in the subframe again to the parent page's site. | 1889 // 5. Go back in the subframe again to the parent page's site. |
1890 { | 1890 { |
1891 FrameNavigateParamsCapturer capturer(root->child_at(0)); | 1891 FrameNavigateParamsCapturer capturer(root->child_at(0)); |
1892 shell()->web_contents()->GetController().GoBack(); | 1892 shell()->web_contents()->GetController().GoBack(); |
1893 capturer.Wait(); | 1893 capturer.Wait(); |
1894 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); | 1894 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); |
1895 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); | 1895 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); |
1896 } | 1896 } |
1897 EXPECT_EQ(3, controller.GetEntryCount()); | 1897 EXPECT_EQ(3, controller.GetEntryCount()); |
1898 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 1898 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
1899 EXPECT_EQ(entry1, controller.GetLastCommittedEntry()); | 1899 EXPECT_EQ(entry1, controller.GetLastCommittedEntry()); |
1900 | 1900 |
1901 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 1901 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
1902 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 1902 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
1903 // The entry should have a new FrameNavigationEntries for the subframe. | 1903 // The entry should have a FrameNavigationEntry for the subframe. |
1904 ASSERT_EQ(1U, entry1->root_node()->children.size()); | 1904 ASSERT_EQ(1U, entry1->root_node()->children.size()); |
1905 EXPECT_EQ(frame_url, entry1->root_node()->children[0]->frame_entry->url()); | 1905 EXPECT_EQ(frame_url, entry1->root_node()->children[0]->frame_entry->url()); |
1906 } else { | 1906 } else { |
1907 // There are no subframe FrameNavigationEntries by default. | 1907 // There are no subframe FrameNavigationEntries by default. |
1908 EXPECT_EQ(0U, entry1->root_node()->children.size()); | 1908 EXPECT_EQ(0U, entry1->root_node()->children.size()); |
1909 } | 1909 } |
1910 | 1910 |
1911 // 6. Go forward in the subframe cross-site. | 1911 // 6. Go forward in the subframe cross-site. |
1912 { | 1912 { |
1913 FrameNavigateParamsCapturer capturer(root->child_at(0)); | 1913 FrameNavigateParamsCapturer capturer(root->child_at(0)); |
1914 shell()->web_contents()->GetController().GoForward(); | 1914 shell()->web_contents()->GetController().GoForward(); |
1915 capturer.Wait(); | 1915 capturer.Wait(); |
1916 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); | 1916 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); |
1917 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); | 1917 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); |
1918 } | 1918 } |
1919 EXPECT_EQ(3, controller.GetEntryCount()); | 1919 EXPECT_EQ(3, controller.GetEntryCount()); |
1920 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 1920 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
1921 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); | 1921 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); |
1922 | 1922 |
1923 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 1923 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
1924 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 1924 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
1925 // The entry should have a new FrameNavigationEntries for the subframe. | 1925 // The entry should have a FrameNavigationEntry for the subframe. |
1926 ASSERT_EQ(1U, entry2->root_node()->children.size()); | 1926 ASSERT_EQ(1U, entry2->root_node()->children.size()); |
1927 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url()); | 1927 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url()); |
1928 } else { | 1928 } else { |
1929 // There are no subframe FrameNavigationEntries by default. | 1929 // There are no subframe FrameNavigationEntries by default. |
1930 EXPECT_EQ(0U, entry2->root_node()->children.size()); | 1930 EXPECT_EQ(0U, entry2->root_node()->children.size()); |
1931 } | 1931 } |
1932 | 1932 |
1933 // 7. Go forward in the subframe again, cross-site. | 1933 // 7. Go forward in the subframe again, cross-site. |
1934 { | 1934 { |
1935 FrameNavigateParamsCapturer capturer(root->child_at(0)); | 1935 FrameNavigateParamsCapturer capturer(root->child_at(0)); |
1936 shell()->web_contents()->GetController().GoForward(); | 1936 shell()->web_contents()->GetController().GoForward(); |
1937 capturer.Wait(); | 1937 capturer.Wait(); |
1938 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); | 1938 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); |
1939 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); | 1939 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); |
1940 } | 1940 } |
1941 EXPECT_EQ(3, controller.GetEntryCount()); | 1941 EXPECT_EQ(3, controller.GetEntryCount()); |
1942 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 1942 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
1943 EXPECT_EQ(entry3, controller.GetLastCommittedEntry()); | 1943 EXPECT_EQ(entry3, controller.GetLastCommittedEntry()); |
1944 | 1944 |
1945 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 1945 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
1946 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 1946 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
1947 // The entry should have a new FrameNavigationEntries for the subframe. | 1947 // The entry should have a FrameNavigationEntry for the subframe. |
1948 ASSERT_EQ(1U, entry3->root_node()->children.size()); | 1948 ASSERT_EQ(1U, entry3->root_node()->children.size()); |
1949 EXPECT_EQ(frame_url3, entry3->root_node()->children[0]->frame_entry->url()); | 1949 EXPECT_EQ(frame_url3, entry3->root_node()->children[0]->frame_entry->url()); |
1950 } else { | 1950 } else { |
1951 // There are no subframe FrameNavigationEntries by default. | 1951 // There are no subframe FrameNavigationEntries by default. |
1952 EXPECT_EQ(0U, entry3->root_node()->children.size()); | 1952 EXPECT_EQ(0U, entry3->root_node()->children.size()); |
1953 } | 1953 } |
1954 } | 1954 } |
1955 | 1955 |
| 1956 // Verify the tree of FrameNavigationEntries after subframes are recreated in |
| 1957 // history navigations, including nested frames. The history will look like: |
| 1958 // 1. initial_url |
| 1959 // 2. main_url_a (data_url) |
| 1960 // 3. main_url_a (frame_url_b (data_url)) |
| 1961 // 4. main_url_a (frame_url_b (frame_url_c)) |
| 1962 // 5. main_url_d |
| 1963 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 1964 FrameNavigationEntry_RecreatedSubframeBackForward) { |
| 1965 // 1. Start on a page with no frames. |
| 1966 GURL initial_url(embedded_test_server()->GetURL( |
| 1967 "/navigation_controller/simple_page_1.html")); |
| 1968 NavigateToURL(shell(), initial_url); |
| 1969 const NavigationControllerImpl& controller = |
| 1970 static_cast<const NavigationControllerImpl&>( |
| 1971 shell()->web_contents()->GetController()); |
| 1972 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 1973 ->GetFrameTree() |
| 1974 ->root(); |
| 1975 EXPECT_EQ(initial_url, root->current_url()); |
| 1976 NavigationEntryImpl* entry1 = controller.GetLastCommittedEntry(); |
| 1977 EXPECT_EQ(0U, entry1->root_node()->children.size()); |
| 1978 |
| 1979 // 2. Navigate to a page with a data URL iframe. |
| 1980 GURL main_url_a(embedded_test_server()->GetURL( |
| 1981 "a.com", "/navigation_controller/page_with_data_iframe.html")); |
| 1982 GURL data_url("data:text/html,Subframe"); |
| 1983 NavigateToURL(shell(), main_url_a); |
| 1984 ASSERT_EQ(1U, root->child_count()); |
| 1985 ASSERT_EQ(0U, root->child_at(0)->child_count()); |
| 1986 EXPECT_EQ(main_url_a, root->current_url()); |
| 1987 EXPECT_EQ(data_url, root->child_at(0)->current_url()); |
| 1988 |
| 1989 EXPECT_EQ(2, controller.GetEntryCount()); |
| 1990 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 1991 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); |
| 1992 |
| 1993 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
| 1994 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| 1995 // The entry should have a FrameNavigationEntry for the data subframe. |
| 1996 ASSERT_EQ(1U, entry2->root_node()->children.size()); |
| 1997 EXPECT_EQ(data_url, entry2->root_node()->children[0]->frame_entry->url()); |
| 1998 } else { |
| 1999 // There are no subframe FrameNavigationEntries by default. |
| 2000 EXPECT_EQ(0U, entry2->root_node()->children.size()); |
| 2001 } |
| 2002 |
| 2003 // 3. Navigate the iframe cross-site to a page with a nested iframe. |
| 2004 GURL frame_url_b(embedded_test_server()->GetURL( |
| 2005 "b.com", "/navigation_controller/page_with_data_iframe.html")); |
| 2006 { |
| 2007 FrameNavigateParamsCapturer capturer(root->child_at(0)); |
| 2008 NavigateFrameToURL(root->child_at(0), frame_url_b); |
| 2009 capturer.Wait(); |
| 2010 } |
| 2011 ASSERT_EQ(1U, root->child_count()); |
| 2012 EXPECT_EQ(main_url_a, root->current_url()); |
| 2013 EXPECT_EQ(frame_url_b, root->child_at(0)->current_url()); |
| 2014 EXPECT_EQ(data_url, root->child_at(0)->child_at(0)->current_url()); |
| 2015 |
| 2016 EXPECT_EQ(3, controller.GetEntryCount()); |
| 2017 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
| 2018 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry(); |
| 2019 |
| 2020 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
| 2021 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| 2022 // The entry should have a FrameNavigationEntry for the b.com subframe. |
| 2023 ASSERT_EQ(1U, entry3->root_node()->children.size()); |
| 2024 ASSERT_EQ(1U, entry3->root_node()->children[0]->children.size()); |
| 2025 EXPECT_EQ(frame_url_b, |
| 2026 entry3->root_node()->children[0]->frame_entry->url()); |
| 2027 EXPECT_EQ( |
| 2028 data_url, |
| 2029 entry3->root_node()->children[0]->children[0]->frame_entry->url()); |
| 2030 } else { |
| 2031 // There are no subframe FrameNavigationEntries by default. |
| 2032 EXPECT_EQ(0U, entry3->root_node()->children.size()); |
| 2033 } |
| 2034 |
| 2035 // 4. Navigate the nested iframe cross-site. |
| 2036 GURL frame_url_c(embedded_test_server()->GetURL( |
| 2037 "c.com", "/navigation_controller/simple_page_2.html")); |
| 2038 { |
| 2039 FrameNavigateParamsCapturer capturer(root->child_at(0)->child_at(0)); |
| 2040 NavigateFrameToURL(root->child_at(0)->child_at(0), frame_url_c); |
| 2041 capturer.Wait(); |
| 2042 } |
| 2043 ASSERT_EQ(1U, root->child_count()); |
| 2044 EXPECT_EQ(main_url_a, root->current_url()); |
| 2045 EXPECT_EQ(frame_url_b, root->child_at(0)->current_url()); |
| 2046 EXPECT_EQ(frame_url_c, root->child_at(0)->child_at(0)->current_url()); |
| 2047 |
| 2048 EXPECT_EQ(4, controller.GetEntryCount()); |
| 2049 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); |
| 2050 NavigationEntryImpl* entry4 = controller.GetLastCommittedEntry(); |
| 2051 |
| 2052 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
| 2053 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| 2054 // The entry should have FrameNavigationEntries for the subframes. |
| 2055 ASSERT_EQ(1U, entry4->root_node()->children.size()); |
| 2056 ASSERT_EQ(1U, entry4->root_node()->children[0]->children.size()); |
| 2057 EXPECT_EQ(frame_url_b, |
| 2058 entry4->root_node()->children[0]->frame_entry->url()); |
| 2059 EXPECT_EQ( |
| 2060 frame_url_c, |
| 2061 entry4->root_node()->children[0]->children[0]->frame_entry->url()); |
| 2062 } else { |
| 2063 // There are no subframe FrameNavigationEntries by default. |
| 2064 EXPECT_EQ(0U, entry4->root_node()->children.size()); |
| 2065 } |
| 2066 |
| 2067 // 5. Navigate main frame cross-site, destroying the frames. |
| 2068 GURL main_url_d(embedded_test_server()->GetURL( |
| 2069 "d.com", "/navigation_controller/simple_page_2.html")); |
| 2070 NavigateToURL(shell(), main_url_d); |
| 2071 ASSERT_EQ(0U, root->child_count()); |
| 2072 EXPECT_EQ(main_url_d, root->current_url()); |
| 2073 |
| 2074 EXPECT_EQ(5, controller.GetEntryCount()); |
| 2075 EXPECT_EQ(4, controller.GetLastCommittedEntryIndex()); |
| 2076 NavigationEntryImpl* entry5 = controller.GetLastCommittedEntry(); |
| 2077 EXPECT_EQ(0U, entry5->root_node()->children.size()); |
| 2078 |
| 2079 // 6. Go back, recreating the iframe and its nested iframe. |
| 2080 { |
| 2081 TestNavigationObserver back_load_observer(shell()->web_contents()); |
| 2082 shell()->web_contents()->GetController().GoBack(); |
| 2083 back_load_observer.Wait(); |
| 2084 } |
| 2085 ASSERT_EQ(1U, root->child_count()); |
| 2086 ASSERT_EQ(1U, root->child_at(0)->child_count()); |
| 2087 EXPECT_EQ(main_url_a, root->current_url()); |
| 2088 EXPECT_EQ(frame_url_b, root->child_at(0)->current_url()); |
| 2089 EXPECT_EQ(frame_url_c, root->child_at(0)->child_at(0)->current_url()); |
| 2090 |
| 2091 EXPECT_EQ(5, controller.GetEntryCount()); |
| 2092 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); |
| 2093 EXPECT_EQ(entry4, controller.GetLastCommittedEntry()); |
| 2094 |
| 2095 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
| 2096 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| 2097 // The entry should have FrameNavigationEntries for the subframes. |
| 2098 ASSERT_EQ(1U, entry4->root_node()->children.size()); |
| 2099 ASSERT_EQ(1U, entry4->root_node()->children[0]->children.size()); |
| 2100 EXPECT_EQ(frame_url_b, |
| 2101 entry4->root_node()->children[0]->frame_entry->url()); |
| 2102 EXPECT_EQ( |
| 2103 frame_url_c, |
| 2104 entry4->root_node()->children[0]->children[0]->frame_entry->url()); |
| 2105 } else { |
| 2106 // There are no subframe FrameNavigationEntries by default. |
| 2107 EXPECT_EQ(0U, entry4->root_node()->children.size()); |
| 2108 } |
| 2109 |
| 2110 // 7. Go back again, to the data URL in the nested iframe. |
| 2111 { |
| 2112 TestNavigationObserver back_load_observer(shell()->web_contents()); |
| 2113 shell()->web_contents()->GetController().GoBack(); |
| 2114 back_load_observer.Wait(); |
| 2115 } |
| 2116 ASSERT_EQ(1U, root->child_count()); |
| 2117 ASSERT_EQ(1U, root->child_at(0)->child_count()); |
| 2118 EXPECT_EQ(main_url_a, root->current_url()); |
| 2119 EXPECT_EQ(frame_url_b, root->child_at(0)->current_url()); |
| 2120 EXPECT_EQ(data_url, root->child_at(0)->child_at(0)->current_url()); |
| 2121 |
| 2122 EXPECT_EQ(5, controller.GetEntryCount()); |
| 2123 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
| 2124 EXPECT_EQ(entry3, controller.GetLastCommittedEntry()); |
| 2125 |
| 2126 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
| 2127 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| 2128 // The entry should have FrameNavigationEntries for the subframes. |
| 2129 ASSERT_EQ(1U, entry3->root_node()->children.size()); |
| 2130 ASSERT_EQ(1U, entry3->root_node()->children[0]->children.size()); |
| 2131 EXPECT_EQ(frame_url_b, |
| 2132 entry3->root_node()->children[0]->frame_entry->url()); |
| 2133 EXPECT_EQ( |
| 2134 data_url, |
| 2135 entry3->root_node()->children[0]->children[0]->frame_entry->url()); |
| 2136 } else { |
| 2137 // There are no subframe FrameNavigationEntries by default. |
| 2138 EXPECT_EQ(0U, entry3->root_node()->children.size()); |
| 2139 } |
| 2140 |
| 2141 // 8. Go back again, to the data URL in the first subframe. |
| 2142 { |
| 2143 TestNavigationObserver back_load_observer(shell()->web_contents()); |
| 2144 shell()->web_contents()->GetController().GoBack(); |
| 2145 back_load_observer.Wait(); |
| 2146 } |
| 2147 ASSERT_EQ(1U, root->child_count()); |
| 2148 ASSERT_EQ(0U, root->child_at(0)->child_count()); |
| 2149 EXPECT_EQ(main_url_a, root->current_url()); |
| 2150 EXPECT_EQ(data_url, root->child_at(0)->current_url()); |
| 2151 |
| 2152 EXPECT_EQ(5, controller.GetEntryCount()); |
| 2153 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 2154 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); |
| 2155 |
| 2156 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
| 2157 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| 2158 // The entry should have a FrameNavigationEntry for the subframe. |
| 2159 ASSERT_EQ(1U, entry2->root_node()->children.size()); |
| 2160 EXPECT_EQ(data_url, entry2->root_node()->children[0]->frame_entry->url()); |
| 2161 } else { |
| 2162 // There are no subframe FrameNavigationEntries by default. |
| 2163 EXPECT_EQ(0U, entry2->root_node()->children.size()); |
| 2164 } |
| 2165 |
| 2166 // 9. Go back again, to the initial main frame page. |
| 2167 { |
| 2168 TestNavigationObserver back_load_observer(shell()->web_contents()); |
| 2169 shell()->web_contents()->GetController().GoBack(); |
| 2170 back_load_observer.Wait(); |
| 2171 } |
| 2172 ASSERT_EQ(0U, root->child_count()); |
| 2173 EXPECT_EQ(initial_url, root->current_url()); |
| 2174 |
| 2175 EXPECT_EQ(5, controller.GetEntryCount()); |
| 2176 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| 2177 EXPECT_EQ(entry1, controller.GetLastCommittedEntry()); |
| 2178 EXPECT_EQ(0U, entry1->root_node()->children.size()); |
| 2179 |
| 2180 // 10. Go forward multiple entries and verify the correct subframe URLs load. |
| 2181 { |
| 2182 TestNavigationObserver back_load_observer(shell()->web_contents()); |
| 2183 shell()->web_contents()->GetController().GoToOffset(2); |
| 2184 back_load_observer.Wait(); |
| 2185 } |
| 2186 ASSERT_EQ(1U, root->child_count()); |
| 2187 EXPECT_EQ(main_url_a, root->current_url()); |
| 2188 EXPECT_EQ(frame_url_b, root->child_at(0)->current_url()); |
| 2189 EXPECT_EQ(data_url, root->child_at(0)->child_at(0)->current_url()); |
| 2190 |
| 2191 EXPECT_EQ(5, controller.GetEntryCount()); |
| 2192 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
| 2193 EXPECT_EQ(entry3, controller.GetLastCommittedEntry()); |
| 2194 |
| 2195 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
| 2196 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| 2197 // The entry should have FrameNavigationEntries for the subframes. |
| 2198 ASSERT_EQ(1U, entry3->root_node()->children.size()); |
| 2199 EXPECT_EQ(frame_url_b, |
| 2200 entry3->root_node()->children[0]->frame_entry->url()); |
| 2201 EXPECT_EQ( |
| 2202 data_url, |
| 2203 entry3->root_node()->children[0]->children[0]->frame_entry->url()); |
| 2204 } else { |
| 2205 // There are no subframe FrameNavigationEntries by default. |
| 2206 EXPECT_EQ(0U, entry3->root_node()->children.size()); |
| 2207 } |
| 2208 } |
| 2209 |
1956 // Verifies that the |frame_unique_name| is set to the correct frame, so that we | 2210 // Verifies that the |frame_unique_name| is set to the correct frame, so that we |
1957 // can match subframe FrameNavigationEntries to newly created frames after | 2211 // can match subframe FrameNavigationEntries to newly created frames after |
1958 // back/forward and restore. | 2212 // back/forward and restore. |
1959 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 2213 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
1960 FrameNavigationEntry_FrameUniqueName) { | 2214 FrameNavigationEntry_FrameUniqueName) { |
1961 const NavigationControllerImpl& controller = | 2215 const NavigationControllerImpl& controller = |
1962 static_cast<const NavigationControllerImpl&>( | 2216 static_cast<const NavigationControllerImpl&>( |
1963 shell()->web_contents()->GetController()); | 2217 shell()->web_contents()->GetController()); |
1964 | 2218 |
1965 // 1. Navigate the main frame. | 2219 // 1. Navigate the main frame. |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2518 EXPECT_EQ(original_url, capturer.all_params()[1].url); | 2772 EXPECT_EQ(original_url, capturer.all_params()[1].url); |
2519 EXPECT_EQ(original_url, shell()->web_contents()->GetLastCommittedURL()); | 2773 EXPECT_EQ(original_url, shell()->web_contents()->GetLastCommittedURL()); |
2520 } | 2774 } |
2521 | 2775 |
2522 // Make sure the renderer is still alive. | 2776 // Make sure the renderer is still alive. |
2523 EXPECT_TRUE( | 2777 EXPECT_TRUE( |
2524 ExecuteScript(shell()->web_contents(), "console.log('Success');")); | 2778 ExecuteScript(shell()->web_contents(), "console.log('Success');")); |
2525 } | 2779 } |
2526 | 2780 |
2527 } // namespace content | 2781 } // namespace content |
OLD | NEW |