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

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

Issue 1208143002: Move existing kSitePerProcess checks to a policy-oracle object (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@swapped_out_cmdline_checks
Patch Set: Fix some includes Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/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"
(...skipping 16 matching lines...) Expand all
27 #include "content/public/browser/navigation_details.h" 27 #include "content/public/browser/navigation_details.h"
28 #include "content/public/browser/notification_registrar.h" 28 #include "content/public/browser/notification_registrar.h"
29 #include "content/public/browser/notification_types.h" 29 #include "content/public/browser/notification_types.h"
30 #include "content/public/browser/render_view_host.h" 30 #include "content/public/browser/render_view_host.h"
31 #include "content/public/browser/web_contents_delegate.h" 31 #include "content/public/browser/web_contents_delegate.h"
32 #include "content/public/browser/web_contents_observer.h" 32 #include "content/public/browser/web_contents_observer.h"
33 #include "content/public/common/content_switches.h" 33 #include "content/public/common/content_switches.h"
34 #include "content/public/common/page_state.h" 34 #include "content/public/common/page_state.h"
35 #include "content/public/common/page_type.h" 35 #include "content/public/common/page_type.h"
36 #include "content/public/common/url_constants.h" 36 #include "content/public/common/url_constants.h"
37 #include "content/public/test/browser_test_utils.h"
37 #include "content/public/test/mock_render_process_host.h" 38 #include "content/public/test/mock_render_process_host.h"
38 #include "content/public/test/test_notification_tracker.h" 39 #include "content/public/test/test_notification_tracker.h"
39 #include "content/public/test/test_utils.h" 40 #include "content/public/test/test_utils.h"
40 #include "content/test/test_render_frame_host.h" 41 #include "content/test/test_render_frame_host.h"
41 #include "content/test/test_render_view_host.h" 42 #include "content/test/test_render_view_host.h"
42 #include "content/test/test_web_contents.h" 43 #include "content/test/test_web_contents.h"
43 #include "net/base/net_util.h" 44 #include "net/base/net_util.h"
44 #include "skia/ext/platform_canvas.h" 45 #include "skia/ext/platform_canvas.h"
45 #include "testing/gtest/include/gtest/gtest.h" 46 #include "testing/gtest/include/gtest/gtest.h"
46 #include "third_party/WebKit/public/web/WebSandboxFlags.h" 47 #include "third_party/WebKit/public/web/WebSandboxFlags.h"
(...skipping 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 we're in --site-per-process mode.
2087 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 2088 if (AreAllSitesIsolatedForTesting()) {
Charlie Reis 2015/07/21 16:58:23 UseSubframeNavigationEntries. Same for all the ca
ncarter (slow) 2015/07/22 23:29:08 Done.
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 we're in --site-per-process mode.
2145 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 2145 if (AreAllSitesIsolatedForTesting()) {
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 24 matching lines...) Expand all
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 we're in --site-per-process mode.
2191 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 2190 if (AreAllSitesIsolatedForTesting()) {
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 28 matching lines...) Expand all
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 we're in --site-per-process mode.
2241 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 2239 if (AreAllSitesIsolatedForTesting()) {
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 we're in --site-per-process mode.
2315 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 2312 if (AreAllSitesIsolatedForTesting()) {
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 we're in --site-per-process mode.
2340 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 2336 if (AreAllSitesIsolatedForTesting()) {
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698