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

Side by Side Diff: content/browser/frame_host/navigation_controller_impl_browsertest.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: Partial fixes to Nasko's comments. 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 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/command_line.h"
7 #include "base/strings/stringprintf.h" 6 #include "base/strings/stringprintf.h"
8 #include "content/browser/frame_host/frame_navigation_entry.h" 7 #include "content/browser/frame_host/frame_navigation_entry.h"
9 #include "content/browser/frame_host/frame_tree.h" 8 #include "content/browser/frame_host/frame_tree.h"
10 #include "content/browser/frame_host/navigation_controller_impl.h" 9 #include "content/browser/frame_host/navigation_controller_impl.h"
11 #include "content/browser/frame_host/navigation_entry_impl.h" 10 #include "content/browser/frame_host/navigation_entry_impl.h"
12 #include "content/browser/web_contents/web_contents_impl.h" 11 #include "content/browser/web_contents/web_contents_impl.h"
13 #include "content/public/browser/render_view_host.h" 12 #include "content/public/browser/render_view_host.h"
14 #include "content/public/browser/resource_controller.h" 13 #include "content/public/browser/resource_controller.h"
15 #include "content/public/browser/resource_dispatcher_host.h" 14 #include "content/public/browser/resource_dispatcher_host.h"
16 #include "content/public/browser/resource_dispatcher_host_delegate.h" 15 #include "content/public/browser/resource_dispatcher_host_delegate.h"
17 #include "content/public/browser/resource_throttle.h" 16 #include "content/public/browser/resource_throttle.h"
18 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
19 #include "content/public/browser/web_contents_observer.h" 18 #include "content/public/browser/web_contents_observer.h"
20 #include "content/public/common/bindings_policy.h" 19 #include "content/public/common/bindings_policy.h"
21 #include "content/public/common/content_switches.h" 20 #include "content/public/common/site_isolation_policy.h"
22 #include "content/public/common/url_constants.h" 21 #include "content/public/common/url_constants.h"
23 #include "content/public/test/browser_test_utils.h" 22 #include "content/public/test/browser_test_utils.h"
24 #include "content/public/test/content_browser_test.h" 23 #include "content/public/test/content_browser_test.h"
25 #include "content/public/test/content_browser_test_utils.h" 24 #include "content/public/test/content_browser_test_utils.h"
26 #include "content/public/test/test_navigation_observer.h" 25 #include "content/public/test/test_navigation_observer.h"
27 #include "content/public/test/test_utils.h" 26 #include "content/public/test/test_utils.h"
28 #include "content/shell/browser/shell.h" 27 #include "content/shell/browser/shell.h"
29 #include "content/test/content_browser_test_utils_internal.h" 28 #include "content/test/content_browser_test_utils_internal.h"
30 #include "net/dns/mock_host_resolver.h" 29 #include "net/dns/mock_host_resolver.h"
31 #include "net/test/embedded_test_server/embedded_test_server.h" 30 #include "net/test/embedded_test_server/embedded_test_server.h"
(...skipping 24 matching lines...) Expand all
56 55
57 // Use NavigateFrameToURL to go cross-site in the subframe. 56 // Use NavigateFrameToURL to go cross-site in the subframe.
58 GURL foo_url(embedded_test_server()->GetURL( 57 GURL foo_url(embedded_test_server()->GetURL(
59 "foo.com", "/navigation_controller/simple_page_1.html")); 58 "foo.com", "/navigation_controller/simple_page_1.html"));
60 NavigateFrameToURL(root->child_at(0), foo_url); 59 NavigateFrameToURL(root->child_at(0), foo_url);
61 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); 60 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
62 61
63 // We should only have swapped processes in --site-per-process. 62 // We should only have swapped processes in --site-per-process.
64 bool cross_process = root->current_frame_host()->GetProcess() != 63 bool cross_process = root->current_frame_host()->GetProcess() !=
65 root->child_at(0)->current_frame_host()->GetProcess(); 64 root->child_at(0)->current_frame_host()->GetProcess();
66 EXPECT_EQ(base::CommandLine::ForCurrentProcess()->HasSwitch( 65 EXPECT_EQ(SiteIsolationPolicy::AreAllSitesIsolatedForTesting(),
67 switches::kSitePerProcess),
68 cross_process); 66 cross_process);
69 } 67 }
70 68
71 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, LoadDataWithBaseURL) { 69 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, LoadDataWithBaseURL) {
72 const GURL base_url("http://baseurl"); 70 const GURL base_url("http://baseurl");
73 const GURL history_url("http://historyurl"); 71 const GURL history_url("http://historyurl");
74 const std::string data = "<html><body>foo</body></html>"; 72 const std::string data = "<html><body>foo</body></html>";
75 73
76 const NavigationController& controller = 74 const NavigationController& controller =
77 shell()->web_contents()->GetController(); 75 shell()->web_contents()->GetController();
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); 1176 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script));
1179 capturer.Wait(); 1177 capturer.Wait();
1180 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); 1178 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type());
1181 } 1179 }
1182 1180
1183 // Check last committed NavigationEntry. 1181 // Check last committed NavigationEntry.
1184 EXPECT_EQ(1, controller.GetEntryCount()); 1182 EXPECT_EQ(1, controller.GetEntryCount());
1185 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); 1183 EXPECT_EQ(entry, controller.GetLastCommittedEntry());
1186 1184
1187 // Verify subframe entries if we're in --site-per-process mode. 1185 // Verify subframe entries if we're in --site-per-process mode.
1188 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1186 if (SiteIsolationPolicy::AreAllSitesIsolatedForTesting()) {
1189 switches::kSitePerProcess)) {
1190 // The entry should now have one subframe FrameNavigationEntry. 1187 // The entry should now have one subframe FrameNavigationEntry.
1191 ASSERT_EQ(1U, entry->root_node()->children.size()); 1188 ASSERT_EQ(1U, entry->root_node()->children.size());
1192 FrameNavigationEntry* frame_entry = 1189 FrameNavigationEntry* frame_entry =
1193 entry->root_node()->children[0]->frame_entry.get(); 1190 entry->root_node()->children[0]->frame_entry.get();
1194 EXPECT_EQ(frame_url, frame_entry->url()); 1191 EXPECT_EQ(frame_url, frame_entry->url());
1195 EXPECT_TRUE(controller.HasCommittedRealLoad(root->child_at(0))); 1192 EXPECT_TRUE(controller.HasCommittedRealLoad(root->child_at(0)));
1196 EXPECT_FALSE(controller.HasCommittedRealLoad(root->child_at(1))); 1193 EXPECT_FALSE(controller.HasCommittedRealLoad(root->child_at(1)));
1197 } else { 1194 } else {
1198 // There are no subframe FrameNavigationEntries by default. 1195 // There are no subframe FrameNavigationEntries by default.
1199 EXPECT_EQ(0U, entry->root_node()->children.size()); 1196 EXPECT_EQ(0U, entry->root_node()->children.size());
1200 } 1197 }
1201 1198
1202 // 4. A real cross-site navigation in the second iframe should be AUTO. 1199 // 4. A real cross-site navigation in the second iframe should be AUTO.
1203 GURL foo_url(embedded_test_server()->GetURL( 1200 GURL foo_url(embedded_test_server()->GetURL(
1204 "foo.com", "/navigation_controller/simple_page_2.html")); 1201 "foo.com", "/navigation_controller/simple_page_2.html"));
1205 { 1202 {
1206 LoadCommittedCapturer capturer(root->child_at(1)); 1203 LoadCommittedCapturer capturer(root->child_at(1));
1207 std::string script = "var frames = document.getElementsByTagName('iframe');" 1204 std::string script = "var frames = document.getElementsByTagName('iframe');"
1208 "frames[1].src = '" + foo_url.spec() + "';"; 1205 "frames[1].src = '" + foo_url.spec() + "';";
1209 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); 1206 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script));
1210 capturer.Wait(); 1207 capturer.Wait();
1211 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); 1208 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type());
1212 } 1209 }
1213 1210
1214 // Check last committed NavigationEntry. 1211 // Check last committed NavigationEntry.
1215 EXPECT_EQ(1, controller.GetEntryCount()); 1212 EXPECT_EQ(1, controller.GetEntryCount());
1216 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); 1213 EXPECT_EQ(entry, controller.GetLastCommittedEntry());
1217 1214
1218 // Verify subframe entries if we're in --site-per-process mode. 1215 // Verify subframe entries if we're in --site-per-process mode.
1219 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1216 if (SiteIsolationPolicy::AreAllSitesIsolatedForTesting()) {
1220 switches::kSitePerProcess)) {
1221 // The entry should now have two subframe FrameNavigationEntries. 1217 // The entry should now have two subframe FrameNavigationEntries.
1222 ASSERT_EQ(2U, entry->root_node()->children.size()); 1218 ASSERT_EQ(2U, entry->root_node()->children.size());
1223 FrameNavigationEntry* frame_entry = 1219 FrameNavigationEntry* frame_entry =
1224 entry->root_node()->children[1]->frame_entry.get(); 1220 entry->root_node()->children[1]->frame_entry.get();
1225 EXPECT_EQ(foo_url, frame_entry->url()); 1221 EXPECT_EQ(foo_url, frame_entry->url());
1226 EXPECT_TRUE(controller.HasCommittedRealLoad(root->child_at(1))); 1222 EXPECT_TRUE(controller.HasCommittedRealLoad(root->child_at(1)));
1227 } else { 1223 } else {
1228 // There are no subframe FrameNavigationEntries by default. 1224 // There are no subframe FrameNavigationEntries by default.
1229 EXPECT_EQ(0U, entry->root_node()->children.size()); 1225 EXPECT_EQ(0U, entry->root_node()->children.size());
1230 } 1226 }
1231 1227
1232 // Check the end result of the frame tree. 1228 // Check the end result of the frame tree.
1233 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1229 if (SiteIsolationPolicy::AreAllSitesIsolatedForTesting()) {
1234 switches::kSitePerProcess)) {
1235 FrameTreeVisualizer visualizer; 1230 FrameTreeVisualizer visualizer;
1236 EXPECT_EQ( 1231 EXPECT_EQ(
1237 " Site A ------------ proxies for B\n" 1232 " Site A ------------ proxies for B\n"
1238 " |--Site A ------- proxies for B\n" 1233 " |--Site A ------- proxies for B\n"
1239 " +--Site B ------- proxies for A\n" 1234 " +--Site B ------- proxies for A\n"
1240 "Where A = http://127.0.0.1/\n" 1235 "Where A = http://127.0.0.1/\n"
1241 " B = http://foo.com/", 1236 " B = http://foo.com/",
1242 visualizer.DepictFrameTree(root)); 1237 visualizer.DepictFrameTree(root));
1243 } 1238 }
1244 } 1239 }
(...skipping 28 matching lines...) Expand all
1273 1268
1274 // Check last committed NavigationEntry. 1269 // Check last committed NavigationEntry.
1275 EXPECT_EQ(1, controller.GetEntryCount()); 1270 EXPECT_EQ(1, controller.GetEntryCount());
1276 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); 1271 NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
1277 EXPECT_EQ(main_url, entry->GetURL()); 1272 EXPECT_EQ(main_url, entry->GetURL());
1278 FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get(); 1273 FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get();
1279 EXPECT_EQ(main_url, root_entry->url()); 1274 EXPECT_EQ(main_url, root_entry->url());
1280 EXPECT_FALSE(controller.GetPendingEntry()); 1275 EXPECT_FALSE(controller.GetPendingEntry());
1281 1276
1282 // Verify subframe entries if we're in --site-per-process mode. 1277 // Verify subframe entries if we're in --site-per-process mode.
1283 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1278 if (SiteIsolationPolicy::AreAllSitesIsolatedForTesting()) {
1284 switches::kSitePerProcess)) {
1285 // The entry should now have a subframe FrameNavigationEntry. 1279 // The entry should now have a subframe FrameNavigationEntry.
1286 ASSERT_EQ(1U, entry->root_node()->children.size()); 1280 ASSERT_EQ(1U, entry->root_node()->children.size());
1287 FrameNavigationEntry* frame_entry = 1281 FrameNavigationEntry* frame_entry =
1288 entry->root_node()->children[0]->frame_entry.get(); 1282 entry->root_node()->children[0]->frame_entry.get();
1289 EXPECT_EQ(frame_url, frame_entry->url()); 1283 EXPECT_EQ(frame_url, frame_entry->url());
1290 EXPECT_TRUE(controller.HasCommittedRealLoad(root->child_at(0))); 1284 EXPECT_TRUE(controller.HasCommittedRealLoad(root->child_at(0)));
1291 } else { 1285 } else {
1292 // There are no subframe FrameNavigationEntries by default. 1286 // There are no subframe FrameNavigationEntries by default.
1293 EXPECT_EQ(0U, entry->root_node()->children.size()); 1287 EXPECT_EQ(0U, entry->root_node()->children.size());
1294 } 1288 }
(...skipping 13 matching lines...) Expand all
1308 1302
1309 // The last committed NavigationEntry shouldn't have changed. 1303 // The last committed NavigationEntry shouldn't have changed.
1310 EXPECT_EQ(1, controller.GetEntryCount()); 1304 EXPECT_EQ(1, controller.GetEntryCount());
1311 entry = controller.GetLastCommittedEntry(); 1305 entry = controller.GetLastCommittedEntry();
1312 EXPECT_EQ(main_url, entry->GetURL()); 1306 EXPECT_EQ(main_url, entry->GetURL());
1313 root_entry = entry->root_node()->frame_entry.get(); 1307 root_entry = entry->root_node()->frame_entry.get();
1314 EXPECT_EQ(main_url, root_entry->url()); 1308 EXPECT_EQ(main_url, root_entry->url());
1315 EXPECT_FALSE(controller.GetPendingEntry()); 1309 EXPECT_FALSE(controller.GetPendingEntry());
1316 1310
1317 // Verify subframe entries if we're in --site-per-process mode. 1311 // Verify subframe entries if we're in --site-per-process mode.
1318 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1312 if (SiteIsolationPolicy::AreAllSitesIsolatedForTesting()) {
1319 switches::kSitePerProcess)) {
1320 // The entry should now have 2 subframe FrameNavigationEntries. 1313 // The entry should now have 2 subframe FrameNavigationEntries.
1321 ASSERT_EQ(2U, entry->root_node()->children.size()); 1314 ASSERT_EQ(2U, entry->root_node()->children.size());
1322 FrameNavigationEntry* frame_entry = 1315 FrameNavigationEntry* frame_entry =
1323 entry->root_node()->children[1]->frame_entry.get(); 1316 entry->root_node()->children[1]->frame_entry.get();
1324 EXPECT_EQ(foo_url, frame_entry->url()); 1317 EXPECT_EQ(foo_url, frame_entry->url());
1325 EXPECT_TRUE(controller.HasCommittedRealLoad(root->child_at(1))); 1318 EXPECT_TRUE(controller.HasCommittedRealLoad(root->child_at(1)));
1326 } else { 1319 } else {
1327 // There are no subframe FrameNavigationEntries by default. 1320 // There are no subframe FrameNavigationEntries by default.
1328 EXPECT_EQ(0U, entry->root_node()->children.size()); 1321 EXPECT_EQ(0U, entry->root_node()->children.size());
1329 } 1322 }
(...skipping 11 matching lines...) Expand all
1341 } 1334 }
1342 1335
1343 // The last committed NavigationEntry shouldn't have changed. 1336 // The last committed NavigationEntry shouldn't have changed.
1344 EXPECT_EQ(1, controller.GetEntryCount()); 1337 EXPECT_EQ(1, controller.GetEntryCount());
1345 entry = controller.GetLastCommittedEntry(); 1338 entry = controller.GetLastCommittedEntry();
1346 EXPECT_EQ(main_url, entry->GetURL()); 1339 EXPECT_EQ(main_url, entry->GetURL());
1347 root_entry = entry->root_node()->frame_entry.get(); 1340 root_entry = entry->root_node()->frame_entry.get();
1348 EXPECT_EQ(main_url, root_entry->url()); 1341 EXPECT_EQ(main_url, root_entry->url());
1349 1342
1350 // Verify subframe entries if we're in --site-per-process mode. 1343 // Verify subframe entries if we're in --site-per-process mode.
1351 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1344 if (SiteIsolationPolicy::AreAllSitesIsolatedForTesting()) {
1352 switches::kSitePerProcess)) {
1353 // The entry should now have 2 subframe FrameNavigationEntries. 1345 // The entry should now have 2 subframe FrameNavigationEntries.
1354 ASSERT_EQ(2U, entry->root_node()->children.size()); 1346 ASSERT_EQ(2U, entry->root_node()->children.size());
1355 ASSERT_EQ(1U, entry->root_node()->children[1]->children.size()); 1347 ASSERT_EQ(1U, entry->root_node()->children[1]->children.size());
1356 FrameNavigationEntry* frame_entry = 1348 FrameNavigationEntry* frame_entry =
1357 entry->root_node()->children[1]->children[0]->frame_entry.get(); 1349 entry->root_node()->children[1]->children[0]->frame_entry.get();
1358 EXPECT_EQ(foo_url, frame_entry->url()); 1350 EXPECT_EQ(foo_url, frame_entry->url());
1359 } else { 1351 } else {
1360 // There are no subframe FrameNavigationEntries by default. 1352 // There are no subframe FrameNavigationEntries by default.
1361 EXPECT_EQ(0U, entry->root_node()->children.size()); 1353 EXPECT_EQ(0U, entry->root_node()->children.size());
1362 } 1354 }
1363 1355
1364 // TODO(creis): Add tests for another subframe on B, and for a subframe on A 1356 // TODO(creis): Add tests for another subframe on B, and for a subframe on A
1365 // within it. Both are currently broken. 1357 // within it. Both are currently broken.
1366 1358
1367 // Check the end result of the frame tree. 1359 // Check the end result of the frame tree.
1368 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1360 if (SiteIsolationPolicy::AreAllSitesIsolatedForTesting()) {
1369 switches::kSitePerProcess)) {
1370 FrameTreeVisualizer visualizer; 1361 FrameTreeVisualizer visualizer;
1371 EXPECT_EQ( 1362 EXPECT_EQ(
1372 " Site A ------------ proxies for B\n" 1363 " Site A ------------ proxies for B\n"
1373 " |--Site A ------- proxies for B\n" 1364 " |--Site A ------- proxies for B\n"
1374 " +--Site B ------- proxies for A\n" 1365 " +--Site B ------- proxies for A\n"
1375 " +--Site B -- proxies for A\n" 1366 " +--Site B -- proxies for A\n"
1376 "Where A = http://127.0.0.1/\n" 1367 "Where A = http://127.0.0.1/\n"
1377 " B = http://foo.com/", 1368 " B = http://foo.com/",
1378 visualizer.DepictFrameTree(root)); 1369 visualizer.DepictFrameTree(root));
1379 } 1370 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1421 // We should have created a new NavigationEntry with the same main frame URL. 1412 // We should have created a new NavigationEntry with the same main frame URL.
1422 EXPECT_EQ(2, controller.GetEntryCount()); 1413 EXPECT_EQ(2, controller.GetEntryCount());
1423 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); 1414 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
1424 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); 1415 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry();
1425 EXPECT_NE(entry, entry2); 1416 EXPECT_NE(entry, entry2);
1426 EXPECT_EQ(main_url, entry2->GetURL()); 1417 EXPECT_EQ(main_url, entry2->GetURL());
1427 FrameNavigationEntry* root_entry2 = entry2->root_node()->frame_entry.get(); 1418 FrameNavigationEntry* root_entry2 = entry2->root_node()->frame_entry.get();
1428 EXPECT_EQ(main_url, root_entry2->url()); 1419 EXPECT_EQ(main_url, root_entry2->url());
1429 1420
1430 // Verify subframe entries if we're in --site-per-process mode. 1421 // Verify subframe entries if we're in --site-per-process mode.
1431 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1422 if (SiteIsolationPolicy::AreAllSitesIsolatedForTesting()) {
1432 switches::kSitePerProcess)) {
1433 // The entry should have a new FrameNavigationEntries for the subframe. 1423 // The entry should have a new FrameNavigationEntries for the subframe.
1434 ASSERT_EQ(1U, entry2->root_node()->children.size()); 1424 ASSERT_EQ(1U, entry2->root_node()->children.size());
1435 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url()); 1425 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url());
1436 } else { 1426 } else {
1437 // There are no subframe FrameNavigationEntries by default. 1427 // There are no subframe FrameNavigationEntries by default.
1438 EXPECT_EQ(0U, entry2->root_node()->children.size()); 1428 EXPECT_EQ(0U, entry2->root_node()->children.size());
1439 } 1429 }
1440 1430
1441 // 3. Create a second, initially cross-site iframe. 1431 // 3. Create a second, initially cross-site iframe.
1442 GURL foo_url(embedded_test_server()->GetURL( 1432 GURL foo_url(embedded_test_server()->GetURL(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 // We should have created a new NavigationEntry with the same main frame URL. 1465 // We should have created a new NavigationEntry with the same main frame URL.
1476 EXPECT_EQ(3, controller.GetEntryCount()); 1466 EXPECT_EQ(3, controller.GetEntryCount());
1477 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); 1467 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
1478 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry(); 1468 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry();
1479 EXPECT_NE(entry, entry3); 1469 EXPECT_NE(entry, entry3);
1480 EXPECT_EQ(main_url, entry3->GetURL()); 1470 EXPECT_EQ(main_url, entry3->GetURL());
1481 FrameNavigationEntry* root_entry3 = entry3->root_node()->frame_entry.get(); 1471 FrameNavigationEntry* root_entry3 = entry3->root_node()->frame_entry.get();
1482 EXPECT_EQ(main_url, root_entry3->url()); 1472 EXPECT_EQ(main_url, root_entry3->url());
1483 1473
1484 // Verify subframe entries if we're in --site-per-process mode. 1474 // Verify subframe entries if we're in --site-per-process mode.
1485 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1475 if (SiteIsolationPolicy::AreAllSitesIsolatedForTesting()) {
1486 switches::kSitePerProcess)) {
1487 // The entry should still have FrameNavigationEntries for all 3 subframes. 1476 // The entry should still have FrameNavigationEntries for all 3 subframes.
1488 ASSERT_EQ(2U, entry3->root_node()->children.size()); 1477 ASSERT_EQ(2U, entry3->root_node()->children.size());
1489 EXPECT_EQ(frame_url2, entry3->root_node()->children[0]->frame_entry->url()); 1478 EXPECT_EQ(frame_url2, entry3->root_node()->children[0]->frame_entry->url());
1490 EXPECT_EQ(foo_url, entry3->root_node()->children[1]->frame_entry->url()); 1479 EXPECT_EQ(foo_url, entry3->root_node()->children[1]->frame_entry->url());
1491 ASSERT_EQ(1U, entry3->root_node()->children[1]->children.size()); 1480 ASSERT_EQ(1U, entry3->root_node()->children[1]->children.size());
1492 EXPECT_EQ( 1481 EXPECT_EQ(
1493 bar_url, 1482 bar_url,
1494 entry3->root_node()->children[1]->children[0]->frame_entry->url()); 1483 entry3->root_node()->children[1]->children[0]->frame_entry->url());
1495 } else { 1484 } else {
1496 // There are no subframe FrameNavigationEntries by default. 1485 // There are no subframe FrameNavigationEntries by default.
(...skipping 17 matching lines...) Expand all
1514 // We should have created a new NavigationEntry with the same main frame URL. 1503 // We should have created a new NavigationEntry with the same main frame URL.
1515 EXPECT_EQ(4, controller.GetEntryCount()); 1504 EXPECT_EQ(4, controller.GetEntryCount());
1516 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); 1505 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex());
1517 NavigationEntryImpl* entry4 = controller.GetLastCommittedEntry(); 1506 NavigationEntryImpl* entry4 = controller.GetLastCommittedEntry();
1518 EXPECT_NE(entry, entry4); 1507 EXPECT_NE(entry, entry4);
1519 EXPECT_EQ(main_url, entry4->GetURL()); 1508 EXPECT_EQ(main_url, entry4->GetURL());
1520 FrameNavigationEntry* root_entry4 = entry4->root_node()->frame_entry.get(); 1509 FrameNavigationEntry* root_entry4 = entry4->root_node()->frame_entry.get();
1521 EXPECT_EQ(main_url, root_entry4->url()); 1510 EXPECT_EQ(main_url, root_entry4->url());
1522 1511
1523 // Verify subframe entries if we're in --site-per-process mode. 1512 // Verify subframe entries if we're in --site-per-process mode.
1524 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1513 if (SiteIsolationPolicy::AreAllSitesIsolatedForTesting()) {
1525 switches::kSitePerProcess)) {
1526 // The entry should still have FrameNavigationEntries for all 3 subframes. 1514 // The entry should still have FrameNavigationEntries for all 3 subframes.
1527 ASSERT_EQ(2U, entry4->root_node()->children.size()); 1515 ASSERT_EQ(2U, entry4->root_node()->children.size());
1528 EXPECT_EQ(frame_url2, entry4->root_node()->children[0]->frame_entry->url()); 1516 EXPECT_EQ(frame_url2, entry4->root_node()->children[0]->frame_entry->url());
1529 EXPECT_EQ(baz_url, entry4->root_node()->children[1]->frame_entry->url()); 1517 EXPECT_EQ(baz_url, entry4->root_node()->children[1]->frame_entry->url());
1530 ASSERT_EQ(0U, entry4->root_node()->children[1]->children.size()); 1518 ASSERT_EQ(0U, entry4->root_node()->children[1]->children.size());
1531 } else { 1519 } else {
1532 // There are no subframe FrameNavigationEntries by default. 1520 // There are no subframe FrameNavigationEntries by default.
1533 EXPECT_EQ(0U, entry4->root_node()->children.size()); 1521 EXPECT_EQ(0U, entry4->root_node()->children.size());
1534 } 1522 }
1535 1523
1536 // Check the end result of the frame tree. 1524 // Check the end result of the frame tree.
1537 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1525 if (SiteIsolationPolicy::AreAllSitesIsolatedForTesting()) {
1538 switches::kSitePerProcess)) {
1539 FrameTreeVisualizer visualizer; 1526 FrameTreeVisualizer visualizer;
1540 EXPECT_EQ( 1527 EXPECT_EQ(
1541 " Site A ------------ proxies for B\n" 1528 " Site A ------------ proxies for B\n"
1542 " |--Site A ------- proxies for B\n" 1529 " |--Site A ------- proxies for B\n"
1543 " +--Site B ------- proxies for A\n" 1530 " +--Site B ------- proxies for A\n"
1544 "Where A = http://127.0.0.1/\n" 1531 "Where A = http://127.0.0.1/\n"
1545 " B = http://baz.com/", 1532 " B = http://baz.com/",
1546 visualizer.DepictFrameTree(root)); 1533 visualizer.DepictFrameTree(root));
1547 } 1534 }
1548 } 1535 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 shell()->web_contents()->GetController().GoBack(); 1591 shell()->web_contents()->GetController().GoBack();
1605 capturer.Wait(); 1592 capturer.Wait();
1606 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); 1593 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition);
1607 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); 1594 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type);
1608 } 1595 }
1609 EXPECT_EQ(3, controller.GetEntryCount()); 1596 EXPECT_EQ(3, controller.GetEntryCount());
1610 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); 1597 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
1611 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); 1598 EXPECT_EQ(entry2, controller.GetLastCommittedEntry());
1612 1599
1613 // Verify subframe entries if we're in --site-per-process mode. 1600 // Verify subframe entries if we're in --site-per-process mode.
1614 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1601 if (SiteIsolationPolicy::AreAllSitesIsolatedForTesting()) {
1615 switches::kSitePerProcess)) {
1616 // The entry should have a new FrameNavigationEntries for the subframe. 1602 // The entry should have a new FrameNavigationEntries for the subframe.
1617 ASSERT_EQ(1U, entry2->root_node()->children.size()); 1603 ASSERT_EQ(1U, entry2->root_node()->children.size());
1618 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url()); 1604 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url());
1619 } else { 1605 } else {
1620 // There are no subframe FrameNavigationEntries by default. 1606 // There are no subframe FrameNavigationEntries by default.
1621 EXPECT_EQ(0U, entry2->root_node()->children.size()); 1607 EXPECT_EQ(0U, entry2->root_node()->children.size());
1622 } 1608 }
1623 1609
1624 // 5. Go back in the subframe again to the parent page's site. 1610 // 5. Go back in the subframe again to the parent page's site.
1625 { 1611 {
1626 FrameNavigateParamsCapturer capturer(root->child_at(0)); 1612 FrameNavigateParamsCapturer capturer(root->child_at(0));
1627 shell()->web_contents()->GetController().GoBack(); 1613 shell()->web_contents()->GetController().GoBack();
1628 capturer.Wait(); 1614 capturer.Wait();
1629 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); 1615 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition);
1630 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); 1616 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type);
1631 } 1617 }
1632 EXPECT_EQ(3, controller.GetEntryCount()); 1618 EXPECT_EQ(3, controller.GetEntryCount());
1633 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); 1619 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
1634 EXPECT_EQ(entry1, controller.GetLastCommittedEntry()); 1620 EXPECT_EQ(entry1, controller.GetLastCommittedEntry());
1635 1621
1636 // Verify subframe entries if we're in --site-per-process mode. 1622 // Verify subframe entries if we're in --site-per-process mode.
1637 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1623 if (SiteIsolationPolicy::AreAllSitesIsolatedForTesting()) {
1638 switches::kSitePerProcess)) {
1639 // The entry should have a new FrameNavigationEntries for the subframe. 1624 // The entry should have a new FrameNavigationEntries for the subframe.
1640 ASSERT_EQ(1U, entry1->root_node()->children.size()); 1625 ASSERT_EQ(1U, entry1->root_node()->children.size());
1641 EXPECT_EQ(frame_url, entry1->root_node()->children[0]->frame_entry->url()); 1626 EXPECT_EQ(frame_url, entry1->root_node()->children[0]->frame_entry->url());
1642 } else { 1627 } else {
1643 // There are no subframe FrameNavigationEntries by default. 1628 // There are no subframe FrameNavigationEntries by default.
1644 EXPECT_EQ(0U, entry1->root_node()->children.size()); 1629 EXPECT_EQ(0U, entry1->root_node()->children.size());
1645 } 1630 }
1646 1631
1647 // 6. Go forward in the subframe cross-site. 1632 // 6. Go forward in the subframe cross-site.
1648 { 1633 {
1649 FrameNavigateParamsCapturer capturer(root->child_at(0)); 1634 FrameNavigateParamsCapturer capturer(root->child_at(0));
1650 shell()->web_contents()->GetController().GoForward(); 1635 shell()->web_contents()->GetController().GoForward();
1651 capturer.Wait(); 1636 capturer.Wait();
1652 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); 1637 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition);
1653 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); 1638 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type);
1654 } 1639 }
1655 EXPECT_EQ(3, controller.GetEntryCount()); 1640 EXPECT_EQ(3, controller.GetEntryCount());
1656 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); 1641 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
1657 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); 1642 EXPECT_EQ(entry2, controller.GetLastCommittedEntry());
1658 1643
1659 // Verify subframe entries if we're in --site-per-process mode. 1644 // Verify subframe entries if we're in --site-per-process mode.
1660 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1645 if (SiteIsolationPolicy::AreAllSitesIsolatedForTesting()) {
1661 switches::kSitePerProcess)) {
1662 // The entry should have a new FrameNavigationEntries for the subframe. 1646 // The entry should have a new FrameNavigationEntries for the subframe.
1663 ASSERT_EQ(1U, entry2->root_node()->children.size()); 1647 ASSERT_EQ(1U, entry2->root_node()->children.size());
1664 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url()); 1648 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url());
1665 } else { 1649 } else {
1666 // There are no subframe FrameNavigationEntries by default. 1650 // There are no subframe FrameNavigationEntries by default.
1667 EXPECT_EQ(0U, entry2->root_node()->children.size()); 1651 EXPECT_EQ(0U, entry2->root_node()->children.size());
1668 } 1652 }
1669 1653
1670 // 7. Go forward in the subframe again, cross-site. 1654 // 7. Go forward in the subframe again, cross-site.
1671 { 1655 {
1672 FrameNavigateParamsCapturer capturer(root->child_at(0)); 1656 FrameNavigateParamsCapturer capturer(root->child_at(0));
1673 shell()->web_contents()->GetController().GoForward(); 1657 shell()->web_contents()->GetController().GoForward();
1674 capturer.Wait(); 1658 capturer.Wait();
1675 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); 1659 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition);
1676 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); 1660 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type);
1677 } 1661 }
1678 EXPECT_EQ(3, controller.GetEntryCount()); 1662 EXPECT_EQ(3, controller.GetEntryCount());
1679 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); 1663 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
1680 EXPECT_EQ(entry3, controller.GetLastCommittedEntry()); 1664 EXPECT_EQ(entry3, controller.GetLastCommittedEntry());
1681 1665
1682 // Verify subframe entries if we're in --site-per-process mode. 1666 // Verify subframe entries if we're in --site-per-process mode.
1683 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1667 if (SiteIsolationPolicy::AreAllSitesIsolatedForTesting()) {
1684 switches::kSitePerProcess)) {
1685 // The entry should have a new FrameNavigationEntries for the subframe. 1668 // The entry should have a new FrameNavigationEntries for the subframe.
1686 ASSERT_EQ(1U, entry3->root_node()->children.size()); 1669 ASSERT_EQ(1U, entry3->root_node()->children.size());
1687 EXPECT_EQ(frame_url3, entry3->root_node()->children[0]->frame_entry->url()); 1670 EXPECT_EQ(frame_url3, entry3->root_node()->children[0]->frame_entry->url());
1688 } else { 1671 } else {
1689 // There are no subframe FrameNavigationEntries by default. 1672 // There are no subframe FrameNavigationEntries by default.
1690 EXPECT_EQ(0U, entry3->root_node()->children.size()); 1673 EXPECT_EQ(0U, entry3->root_node()->children.size());
1691 } 1674 }
1692 } 1675 }
1693 1676
1694 // Verifies that item sequence numbers and document sequence numbers update 1677 // Verifies that item sequence numbers and document sequence numbers update
(...skipping 26 matching lines...) Expand all
1721 1704
1722 frame_entry = controller.GetLastCommittedEntry()->GetFrameEntry(root); 1705 frame_entry = controller.GetLastCommittedEntry()->GetFrameEntry(root);
1723 int64 isn_2 = frame_entry->item_sequence_number(); 1706 int64 isn_2 = frame_entry->item_sequence_number();
1724 int64 dsn_2 = frame_entry->document_sequence_number(); 1707 int64 dsn_2 = frame_entry->document_sequence_number();
1725 EXPECT_NE(-1, isn_2); 1708 EXPECT_NE(-1, isn_2);
1726 EXPECT_NE(isn_1, isn_2); 1709 EXPECT_NE(isn_1, isn_2);
1727 EXPECT_EQ(dsn_1, dsn_2); 1710 EXPECT_EQ(dsn_1, dsn_2);
1728 1711
1729 // Also test subframe sequence numbers, but only in --site-per-proces mode. 1712 // Also test subframe sequence numbers, but only in --site-per-proces mode.
1730 // (We do not create subframe FrameNavigationEntries in default mode yet.) 1713 // (We do not create subframe FrameNavigationEntries in default mode yet.)
1731 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 1714 if (!SiteIsolationPolicy::AreAllSitesIsolatedForTesting())
1732 switches::kSitePerProcess))
1733 return; 1715 return;
1734 1716
1735 // 3. Add a subframe, which does an AUTO_SUBFRAME navigation. 1717 // 3. Add a subframe, which does an AUTO_SUBFRAME navigation.
1736 { 1718 {
1737 LoadCommittedCapturer capturer(shell()->web_contents()); 1719 LoadCommittedCapturer capturer(shell()->web_contents());
1738 std::string script = "var iframe = document.createElement('iframe');" 1720 std::string script = "var iframe = document.createElement('iframe');"
1739 "iframe.src = '" + url.spec() + "';" 1721 "iframe.src = '" + url.spec() + "';"
1740 "document.body.appendChild(iframe);"; 1722 "document.body.appendChild(iframe);";
1741 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); 1723 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script));
1742 capturer.Wait(); 1724 capturer.Wait();
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
2119 // tricky. 2101 // tricky.
2120 EXPECT_EQ(nullptr, controller.GetPendingEntry()); 2102 EXPECT_EQ(nullptr, controller.GetPendingEntry());
2121 shell()->web_contents()->Stop(); 2103 shell()->web_contents()->Stop();
2122 watcher.Wait(); 2104 watcher.Wait();
2123 } 2105 }
2124 2106
2125 ResourceDispatcherHost::Get()->SetDelegate(nullptr); 2107 ResourceDispatcherHost::Get()->SetDelegate(nullptr);
2126 } 2108 }
2127 2109
2128 } // namespace content 2110 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698