OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "content/browser/frame_host/cross_site_transferring_request.h" | 14 #include "content/browser/frame_host/cross_site_transferring_request.h" |
15 #include "content/browser/frame_host/frame_navigation_entry.h" | 15 #include "content/browser/frame_host/frame_navigation_entry.h" |
16 #include "content/browser/frame_host/navigation_controller_impl.h" | 16 #include "content/browser/frame_host/navigation_controller_impl.h" |
17 #include "content/browser/frame_host/navigation_entry_impl.h" | 17 #include "content/browser/frame_host/navigation_entry_impl.h" |
18 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" | 18 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" |
19 #include "content/browser/frame_host/navigation_request.h" | 19 #include "content/browser/frame_host/navigation_request.h" |
20 #include "content/browser/frame_host/navigator.h" | 20 #include "content/browser/frame_host/navigator.h" |
21 #include "content/browser/frame_host/navigator_impl.h" | 21 #include "content/browser/frame_host/navigator_impl.h" |
22 #include "content/browser/site_instance_impl.h" | 22 #include "content/browser/site_instance_impl.h" |
23 #include "content/browser/web_contents/web_contents_impl.h" | 23 #include "content/browser/web_contents/web_contents_impl.h" |
24 #include "content/common/frame_messages.h" | 24 #include "content/common/frame_messages.h" |
| 25 #include "content/common/site_isolation_policy.h" |
25 #include "content/common/ssl_status_serialization.h" | 26 #include "content/common/ssl_status_serialization.h" |
26 #include "content/common/view_messages.h" | 27 #include "content/common/view_messages.h" |
27 #include "content/public/browser/navigation_details.h" | 28 #include "content/public/browser/navigation_details.h" |
28 #include "content/public/browser/notification_registrar.h" | 29 #include "content/public/browser/notification_registrar.h" |
29 #include "content/public/browser/notification_types.h" | 30 #include "content/public/browser/notification_types.h" |
30 #include "content/public/browser/render_view_host.h" | 31 #include "content/public/browser/render_view_host.h" |
31 #include "content/public/browser/web_contents_delegate.h" | 32 #include "content/public/browser/web_contents_delegate.h" |
32 #include "content/public/browser/web_contents_observer.h" | 33 #include "content/public/browser/web_contents_observer.h" |
33 #include "content/public/common/content_switches.h" | 34 #include "content/public/common/content_switches.h" |
34 #include "content/public/common/page_state.h" | 35 #include "content/public/common/page_state.h" |
(...skipping 2041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2076 // The new entry should be appended. | 2077 // The new entry should be appended. |
2077 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 2078 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
2078 EXPECT_EQ(2, controller.GetEntryCount()); | 2079 EXPECT_EQ(2, controller.GetEntryCount()); |
2079 EXPECT_EQ(entry, details.entry); | 2080 EXPECT_EQ(entry, details.entry); |
2080 | 2081 |
2081 // New entry should refer to the new page, but the old URL (entries only | 2082 // New entry should refer to the new page, but the old URL (entries only |
2082 // reflect the toplevel URL). | 2083 // reflect the toplevel URL). |
2083 EXPECT_EQ(url1, entry->GetURL()); | 2084 EXPECT_EQ(url1, entry->GetURL()); |
2084 EXPECT_EQ(params.page_id, entry->GetPageID()); | 2085 EXPECT_EQ(params.page_id, entry->GetPageID()); |
2085 | 2086 |
2086 // Verify subframe entries if we're in --site-per-process mode. | 2087 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
2087 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 2088 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
2088 switches::kSitePerProcess)) { | |
2089 // The entry should have a subframe FrameNavigationEntry. | 2089 // The entry should have a subframe FrameNavigationEntry. |
2090 ASSERT_EQ(1U, entry->root_node()->children.size()); | 2090 ASSERT_EQ(1U, entry->root_node()->children.size()); |
2091 EXPECT_EQ(url2, entry->root_node()->children[0]->frame_entry->url()); | 2091 EXPECT_EQ(url2, entry->root_node()->children[0]->frame_entry->url()); |
2092 } else { | 2092 } else { |
2093 // There are no subframe FrameNavigationEntries by default. | 2093 // There are no subframe FrameNavigationEntries by default. |
2094 EXPECT_EQ(0U, entry->root_node()->children.size()); | 2094 EXPECT_EQ(0U, entry->root_node()->children.size()); |
2095 } | 2095 } |
2096 } | 2096 } |
2097 | 2097 |
2098 // Auto subframes are ones the page loads automatically like ads. They should | 2098 // Auto subframes are ones the page loads automatically like ads. They should |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2134 } | 2134 } |
2135 | 2135 |
2136 // There should still be only one entry. | 2136 // There should still be only one entry. |
2137 EXPECT_EQ(1, controller.GetEntryCount()); | 2137 EXPECT_EQ(1, controller.GetEntryCount()); |
2138 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 2138 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
2139 EXPECT_EQ(url1, entry->GetURL()); | 2139 EXPECT_EQ(url1, entry->GetURL()); |
2140 EXPECT_EQ(1, entry->GetPageID()); | 2140 EXPECT_EQ(1, entry->GetPageID()); |
2141 FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get(); | 2141 FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get(); |
2142 EXPECT_EQ(url1, root_entry->url()); | 2142 EXPECT_EQ(url1, root_entry->url()); |
2143 | 2143 |
2144 // Verify subframe entries if we're in --site-per-process mode. | 2144 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
2145 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 2145 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
2146 switches::kSitePerProcess)) { | |
2147 // The entry should now have a subframe FrameNavigationEntry. | 2146 // The entry should now have a subframe FrameNavigationEntry. |
2148 ASSERT_EQ(1U, entry->root_node()->children.size()); | 2147 ASSERT_EQ(1U, entry->root_node()->children.size()); |
2149 FrameNavigationEntry* frame_entry = | 2148 FrameNavigationEntry* frame_entry = |
2150 entry->root_node()->children[0]->frame_entry.get(); | 2149 entry->root_node()->children[0]->frame_entry.get(); |
2151 EXPECT_EQ(url2, frame_entry->url()); | 2150 EXPECT_EQ(url2, frame_entry->url()); |
2152 } else { | 2151 } else { |
2153 // There are no subframe FrameNavigationEntries by default. | 2152 // There are no subframe FrameNavigationEntries by default. |
2154 EXPECT_EQ(0U, entry->root_node()->children.size()); | 2153 EXPECT_EQ(0U, entry->root_node()->children.size()); |
2155 } | 2154 } |
2156 | 2155 |
(...skipping 23 matching lines...) Expand all Loading... |
2180 } | 2179 } |
2181 | 2180 |
2182 // There should still be only one entry, mostly unchanged. | 2181 // There should still be only one entry, mostly unchanged. |
2183 EXPECT_EQ(1, controller.GetEntryCount()); | 2182 EXPECT_EQ(1, controller.GetEntryCount()); |
2184 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); | 2183 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); |
2185 EXPECT_EQ(url1, entry->GetURL()); | 2184 EXPECT_EQ(url1, entry->GetURL()); |
2186 EXPECT_EQ(1, entry->GetPageID()); | 2185 EXPECT_EQ(1, entry->GetPageID()); |
2187 EXPECT_EQ(root_entry, entry->root_node()->frame_entry.get()); | 2186 EXPECT_EQ(root_entry, entry->root_node()->frame_entry.get()); |
2188 EXPECT_EQ(url1, root_entry->url()); | 2187 EXPECT_EQ(url1, root_entry->url()); |
2189 | 2188 |
2190 // Verify subframe entries if we're in --site-per-process mode. | 2189 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
2191 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 2190 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
2192 switches::kSitePerProcess)) { | |
2193 // The entry should now have 2 subframe FrameNavigationEntries. | 2191 // The entry should now have 2 subframe FrameNavigationEntries. |
2194 ASSERT_EQ(2U, entry->root_node()->children.size()); | 2192 ASSERT_EQ(2U, entry->root_node()->children.size()); |
2195 FrameNavigationEntry* new_frame_entry = | 2193 FrameNavigationEntry* new_frame_entry = |
2196 entry->root_node()->children[1]->frame_entry.get(); | 2194 entry->root_node()->children[1]->frame_entry.get(); |
2197 EXPECT_EQ(url3, new_frame_entry->url()); | 2195 EXPECT_EQ(url3, new_frame_entry->url()); |
2198 } else { | 2196 } else { |
2199 // There are no subframe FrameNavigationEntries by default. | 2197 // There are no subframe FrameNavigationEntries by default. |
2200 EXPECT_EQ(0U, entry->root_node()->children.size()); | 2198 EXPECT_EQ(0U, entry->root_node()->children.size()); |
2201 } | 2199 } |
2202 | 2200 |
(...skipping 27 matching lines...) Expand all Loading... |
2230 } | 2228 } |
2231 | 2229 |
2232 // There should still be only one entry, mostly unchanged. | 2230 // There should still be only one entry, mostly unchanged. |
2233 EXPECT_EQ(1, controller.GetEntryCount()); | 2231 EXPECT_EQ(1, controller.GetEntryCount()); |
2234 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); | 2232 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); |
2235 EXPECT_EQ(url1, entry->GetURL()); | 2233 EXPECT_EQ(url1, entry->GetURL()); |
2236 EXPECT_EQ(1, entry->GetPageID()); | 2234 EXPECT_EQ(1, entry->GetPageID()); |
2237 EXPECT_EQ(root_entry, entry->root_node()->frame_entry.get()); | 2235 EXPECT_EQ(root_entry, entry->root_node()->frame_entry.get()); |
2238 EXPECT_EQ(url1, root_entry->url()); | 2236 EXPECT_EQ(url1, root_entry->url()); |
2239 | 2237 |
2240 // Verify subframe entries if we're in --site-per-process mode. | 2238 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
2241 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 2239 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
2242 switches::kSitePerProcess)) { | |
2243 // The entry should now have a nested FrameNavigationEntry. | 2240 // The entry should now have a nested FrameNavigationEntry. |
2244 EXPECT_EQ(2U, entry->root_node()->children.size()); | 2241 EXPECT_EQ(2U, entry->root_node()->children.size()); |
2245 ASSERT_EQ(1U, entry->root_node()->children[0]->children.size()); | 2242 ASSERT_EQ(1U, entry->root_node()->children[0]->children.size()); |
2246 FrameNavigationEntry* new_frame_entry = | 2243 FrameNavigationEntry* new_frame_entry = |
2247 entry->root_node()->children[0]->children[0]->frame_entry.get(); | 2244 entry->root_node()->children[0]->children[0]->frame_entry.get(); |
2248 EXPECT_EQ(url4, new_frame_entry->url()); | 2245 EXPECT_EQ(url4, new_frame_entry->url()); |
2249 } else { | 2246 } else { |
2250 // There are no subframe FrameNavigationEntries by default. | 2247 // There are no subframe FrameNavigationEntries by default. |
2251 EXPECT_EQ(0U, entry->root_node()->children.size()); | 2248 EXPECT_EQ(0U, entry->root_node()->children.size()); |
2252 } | 2249 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2304 params.page_state = PageState::CreateFromURL(url2); | 2301 params.page_state = PageState::CreateFromURL(url2); |
2305 | 2302 |
2306 // This should generate a new entry. | 2303 // This should generate a new entry. |
2307 LoadCommittedDetails details; | 2304 LoadCommittedDetails details; |
2308 EXPECT_TRUE(controller.RendererDidNavigate(subframe, params, &details)); | 2305 EXPECT_TRUE(controller.RendererDidNavigate(subframe, params, &details)); |
2309 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); | 2306 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); |
2310 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2307 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2311 navigation_entry_committed_counter_ = 0; | 2308 navigation_entry_committed_counter_ = 0; |
2312 EXPECT_EQ(2, controller.GetEntryCount()); | 2309 EXPECT_EQ(2, controller.GetEntryCount()); |
2313 | 2310 |
2314 // Verify subframe entries if we're in --site-per-process mode. | 2311 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
2315 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 2312 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
2316 switches::kSitePerProcess)) { | |
2317 // The entry should have a subframe FrameNavigationEntry. | 2313 // The entry should have a subframe FrameNavigationEntry. |
2318 ASSERT_EQ(1U, entry2->root_node()->children.size()); | 2314 ASSERT_EQ(1U, entry2->root_node()->children.size()); |
2319 EXPECT_EQ(url2, entry2->root_node()->children[0]->frame_entry->url()); | 2315 EXPECT_EQ(url2, entry2->root_node()->children[0]->frame_entry->url()); |
2320 } else { | 2316 } else { |
2321 // There are no subframe FrameNavigationEntries by default. | 2317 // There are no subframe FrameNavigationEntries by default. |
2322 EXPECT_EQ(0U, entry2->root_node()->children.size()); | 2318 EXPECT_EQ(0U, entry2->root_node()->children.size()); |
2323 } | 2319 } |
2324 | 2320 |
2325 // Second manual subframe navigation should also make a new entry. | 2321 // Second manual subframe navigation should also make a new entry. |
2326 const GURL url3("http://foo3"); | 2322 const GURL url3("http://foo3"); |
2327 params.page_id = 3; | 2323 params.page_id = 3; |
2328 params.nav_entry_id = 0; | 2324 params.nav_entry_id = 0; |
2329 params.did_create_new_entry = true; | 2325 params.did_create_new_entry = true; |
2330 params.url = url3; | 2326 params.url = url3; |
2331 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; | 2327 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; |
2332 EXPECT_TRUE(controller.RendererDidNavigate(subframe, params, &details)); | 2328 EXPECT_TRUE(controller.RendererDidNavigate(subframe, params, &details)); |
2333 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2329 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2334 navigation_entry_committed_counter_ = 0; | 2330 navigation_entry_committed_counter_ = 0; |
2335 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry(); | 2331 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry(); |
2336 EXPECT_EQ(3, controller.GetEntryCount()); | 2332 EXPECT_EQ(3, controller.GetEntryCount()); |
2337 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); | 2333 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); |
2338 | 2334 |
2339 // Verify subframe entries if we're in --site-per-process mode. | 2335 // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
2340 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 2336 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
2341 switches::kSitePerProcess)) { | |
2342 // The entry should have a subframe FrameNavigationEntry. | 2337 // The entry should have a subframe FrameNavigationEntry. |
2343 ASSERT_EQ(1U, entry3->root_node()->children.size()); | 2338 ASSERT_EQ(1U, entry3->root_node()->children.size()); |
2344 EXPECT_EQ(url3, entry3->root_node()->children[0]->frame_entry->url()); | 2339 EXPECT_EQ(url3, entry3->root_node()->children[0]->frame_entry->url()); |
2345 } else { | 2340 } else { |
2346 // There are no subframe FrameNavigationEntries by default. | 2341 // There are no subframe FrameNavigationEntries by default. |
2347 EXPECT_EQ(0U, entry3->root_node()->children.size()); | 2342 EXPECT_EQ(0U, entry3->root_node()->children.size()); |
2348 } | 2343 } |
2349 | 2344 |
2350 // Go back one. | 2345 // Go back one. |
2351 controller.GoBack(); | 2346 controller.GoBack(); |
(...skipping 2690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5042 EXPECT_EQ(default_ssl_status.connection_status, | 5037 EXPECT_EQ(default_ssl_status.connection_status, |
5043 details.ssl_status.connection_status); | 5038 details.ssl_status.connection_status); |
5044 EXPECT_EQ(default_ssl_status.content_status, | 5039 EXPECT_EQ(default_ssl_status.content_status, |
5045 details.ssl_status.content_status); | 5040 details.ssl_status.content_status); |
5046 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); | 5041 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); |
5047 | 5042 |
5048 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); | 5043 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); |
5049 } | 5044 } |
5050 | 5045 |
5051 } // namespace content | 5046 } // namespace content |
OLD | NEW |