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/command_line.h" | |
7 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
8 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
9 #include "content/browser/frame_host/frame_navigation_entry.h" | 8 #include "content/browser/frame_host/frame_navigation_entry.h" |
10 #include "content/browser/frame_host/frame_tree.h" | 9 #include "content/browser/frame_host/frame_tree.h" |
11 #include "content/browser/frame_host/navigation_controller_impl.h" | 10 #include "content/browser/frame_host/navigation_controller_impl.h" |
12 #include "content/browser/frame_host/navigation_entry_impl.h" | 11 #include "content/browser/frame_host/navigation_entry_impl.h" |
13 #include "content/browser/web_contents/web_contents_impl.h" | 12 #include "content/browser/web_contents/web_contents_impl.h" |
14 #include "content/public/browser/render_view_host.h" | 13 #include "content/public/browser/render_view_host.h" |
15 #include "content/public/browser/resource_controller.h" | 14 #include "content/public/browser/resource_controller.h" |
16 #include "content/public/browser/resource_dispatcher_host.h" | 15 #include "content/public/browser/resource_dispatcher_host.h" |
17 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 16 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
18 #include "content/public/browser/resource_throttle.h" | 17 #include "content/public/browser/resource_throttle.h" |
19 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
20 #include "content/public/browser/web_contents_observer.h" | 19 #include "content/public/browser/web_contents_observer.h" |
21 #include "content/public/common/bindings_policy.h" | 20 #include "content/public/common/bindings_policy.h" |
22 #include "content/public/common/content_switches.h" | |
23 #include "content/public/common/url_constants.h" | 21 #include "content/public/common/url_constants.h" |
24 #include "content/public/test/browser_test_utils.h" | 22 #include "content/public/test/browser_test_utils.h" |
25 #include "content/public/test/content_browser_test.h" | 23 #include "content/public/test/content_browser_test.h" |
26 #include "content/public/test/content_browser_test_utils.h" | 24 #include "content/public/test/content_browser_test_utils.h" |
27 #include "content/public/test/test_navigation_observer.h" | 25 #include "content/public/test/test_navigation_observer.h" |
28 #include "content/public/test/test_utils.h" | 26 #include "content/public/test/test_utils.h" |
29 #include "content/shell/browser/shell.h" | 27 #include "content/shell/browser/shell.h" |
30 #include "content/test/content_browser_test_utils_internal.h" | 28 #include "content/test/content_browser_test_utils_internal.h" |
31 #include "net/dns/mock_host_resolver.h" | 29 #include "net/dns/mock_host_resolver.h" |
32 #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 Loading... | |
57 | 55 |
58 // Use NavigateFrameToURL to go cross-site in the subframe. | 56 // Use NavigateFrameToURL to go cross-site in the subframe. |
59 GURL foo_url(embedded_test_server()->GetURL( | 57 GURL foo_url(embedded_test_server()->GetURL( |
60 "foo.com", "/navigation_controller/simple_page_1.html")); | 58 "foo.com", "/navigation_controller/simple_page_1.html")); |
61 NavigateFrameToURL(root->child_at(0), foo_url); | 59 NavigateFrameToURL(root->child_at(0), foo_url); |
62 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 60 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
63 | 61 |
64 // We should only have swapped processes in --site-per-process. | 62 // We should only have swapped processes in --site-per-process. |
65 bool cross_process = root->current_frame_host()->GetProcess() != | 63 bool cross_process = root->current_frame_host()->GetProcess() != |
66 root->child_at(0)->current_frame_host()->GetProcess(); | 64 root->child_at(0)->current_frame_host()->GetProcess(); |
67 EXPECT_EQ(base::CommandLine::ForCurrentProcess()->HasSwitch( | 65 EXPECT_EQ(AreAllSitesIsolatedForTesting(), |
68 switches::kSitePerProcess), | |
69 cross_process); | 66 cross_process); |
70 } | 67 } |
71 | 68 |
72 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, LoadDataWithBaseURL) { | 69 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, LoadDataWithBaseURL) { |
73 const GURL base_url("http://baseurl"); | 70 const GURL base_url("http://baseurl"); |
74 const GURL history_url("http://historyurl"); | 71 const GURL history_url("http://historyurl"); |
75 const std::string data = "<html><body>foo</body></html>"; | 72 const std::string data = "<html><body>foo</body></html>"; |
76 | 73 |
77 const NavigationController& controller = | 74 const NavigationController& controller = |
78 shell()->web_contents()->GetController(); | 75 shell()->web_contents()->GetController(); |
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1204 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); | 1201 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); |
1205 capturer.Wait(); | 1202 capturer.Wait(); |
1206 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 1203 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
1207 } | 1204 } |
1208 | 1205 |
1209 // Check last committed NavigationEntry. | 1206 // Check last committed NavigationEntry. |
1210 EXPECT_EQ(1, controller.GetEntryCount()); | 1207 EXPECT_EQ(1, controller.GetEntryCount()); |
1211 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); | 1208 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); |
1212 | 1209 |
1213 // Verify subframe entries if we're in --site-per-process mode. | 1210 // Verify subframe entries if we're in --site-per-process mode. |
1214 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1211 if (AreAllSitesIsolatedForTesting()) { |
Charlie Reis
2015/07/21 16:58:23
On second thought, this is UseSubframeNavigationEn
ncarter (slow)
2015/07/22 23:29:08
Done. I didn't actually switch over the FrameTreeV
| |
1215 switches::kSitePerProcess)) { | |
1216 // The entry should now have one subframe FrameNavigationEntry. | 1212 // The entry should now have one subframe FrameNavigationEntry. |
1217 ASSERT_EQ(1U, entry->root_node()->children.size()); | 1213 ASSERT_EQ(1U, entry->root_node()->children.size()); |
1218 FrameNavigationEntry* frame_entry = | 1214 FrameNavigationEntry* frame_entry = |
1219 entry->root_node()->children[0]->frame_entry.get(); | 1215 entry->root_node()->children[0]->frame_entry.get(); |
1220 EXPECT_EQ(frame_url, frame_entry->url()); | 1216 EXPECT_EQ(frame_url, frame_entry->url()); |
1221 EXPECT_TRUE(controller.HasCommittedRealLoad(root->child_at(0))); | 1217 EXPECT_TRUE(controller.HasCommittedRealLoad(root->child_at(0))); |
1222 EXPECT_FALSE(controller.HasCommittedRealLoad(root->child_at(1))); | 1218 EXPECT_FALSE(controller.HasCommittedRealLoad(root->child_at(1))); |
1223 } else { | 1219 } else { |
1224 // There are no subframe FrameNavigationEntries by default. | 1220 // There are no subframe FrameNavigationEntries by default. |
1225 EXPECT_EQ(0U, entry->root_node()->children.size()); | 1221 EXPECT_EQ(0U, entry->root_node()->children.size()); |
1226 } | 1222 } |
1227 | 1223 |
1228 // 4. A real cross-site navigation in the second iframe should be AUTO. | 1224 // 4. A real cross-site navigation in the second iframe should be AUTO. |
1229 GURL foo_url(embedded_test_server()->GetURL( | 1225 GURL foo_url(embedded_test_server()->GetURL( |
1230 "foo.com", "/navigation_controller/simple_page_2.html")); | 1226 "foo.com", "/navigation_controller/simple_page_2.html")); |
1231 { | 1227 { |
1232 LoadCommittedCapturer capturer(root->child_at(1)); | 1228 LoadCommittedCapturer capturer(root->child_at(1)); |
1233 std::string script = "var frames = document.getElementsByTagName('iframe');" | 1229 std::string script = "var frames = document.getElementsByTagName('iframe');" |
1234 "frames[1].src = '" + foo_url.spec() + "';"; | 1230 "frames[1].src = '" + foo_url.spec() + "';"; |
1235 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); | 1231 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); |
1236 capturer.Wait(); | 1232 capturer.Wait(); |
1237 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 1233 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
1238 } | 1234 } |
1239 | 1235 |
1240 // Check last committed NavigationEntry. | 1236 // Check last committed NavigationEntry. |
1241 EXPECT_EQ(1, controller.GetEntryCount()); | 1237 EXPECT_EQ(1, controller.GetEntryCount()); |
1242 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); | 1238 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); |
1243 | 1239 |
1244 // Verify subframe entries if we're in --site-per-process mode. | 1240 // Verify subframe entries if we're in --site-per-process mode. |
1245 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1241 if (AreAllSitesIsolatedForTesting()) { |
1246 switches::kSitePerProcess)) { | |
1247 // The entry should now have two subframe FrameNavigationEntries. | 1242 // The entry should now have two subframe FrameNavigationEntries. |
1248 ASSERT_EQ(2U, entry->root_node()->children.size()); | 1243 ASSERT_EQ(2U, entry->root_node()->children.size()); |
1249 FrameNavigationEntry* frame_entry = | 1244 FrameNavigationEntry* frame_entry = |
1250 entry->root_node()->children[1]->frame_entry.get(); | 1245 entry->root_node()->children[1]->frame_entry.get(); |
1251 EXPECT_EQ(foo_url, frame_entry->url()); | 1246 EXPECT_EQ(foo_url, frame_entry->url()); |
1252 EXPECT_TRUE(controller.HasCommittedRealLoad(root->child_at(1))); | 1247 EXPECT_TRUE(controller.HasCommittedRealLoad(root->child_at(1))); |
1253 } else { | 1248 } else { |
1254 // There are no subframe FrameNavigationEntries by default. | 1249 // There are no subframe FrameNavigationEntries by default. |
1255 EXPECT_EQ(0U, entry->root_node()->children.size()); | 1250 EXPECT_EQ(0U, entry->root_node()->children.size()); |
1256 } | 1251 } |
1257 | 1252 |
1258 // Check the end result of the frame tree. | 1253 // Check the end result of the frame tree. |
1259 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1254 if (AreAllSitesIsolatedForTesting()) { |
1260 switches::kSitePerProcess)) { | |
1261 FrameTreeVisualizer visualizer; | 1255 FrameTreeVisualizer visualizer; |
1262 EXPECT_EQ( | 1256 EXPECT_EQ( |
1263 " Site A ------------ proxies for B\n" | 1257 " Site A ------------ proxies for B\n" |
1264 " |--Site A ------- proxies for B\n" | 1258 " |--Site A ------- proxies for B\n" |
1265 " +--Site B ------- proxies for A\n" | 1259 " +--Site B ------- proxies for A\n" |
1266 "Where A = http://127.0.0.1/\n" | 1260 "Where A = http://127.0.0.1/\n" |
1267 " B = http://foo.com/", | 1261 " B = http://foo.com/", |
1268 visualizer.DepictFrameTree(root)); | 1262 visualizer.DepictFrameTree(root)); |
1269 } | 1263 } |
1270 } | 1264 } |
(...skipping 28 matching lines...) Expand all Loading... | |
1299 | 1293 |
1300 // Check last committed NavigationEntry. | 1294 // Check last committed NavigationEntry. |
1301 EXPECT_EQ(1, controller.GetEntryCount()); | 1295 EXPECT_EQ(1, controller.GetEntryCount()); |
1302 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 1296 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
1303 EXPECT_EQ(main_url, entry->GetURL()); | 1297 EXPECT_EQ(main_url, entry->GetURL()); |
1304 FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get(); | 1298 FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get(); |
1305 EXPECT_EQ(main_url, root_entry->url()); | 1299 EXPECT_EQ(main_url, root_entry->url()); |
1306 EXPECT_FALSE(controller.GetPendingEntry()); | 1300 EXPECT_FALSE(controller.GetPendingEntry()); |
1307 | 1301 |
1308 // Verify subframe entries if we're in --site-per-process mode. | 1302 // Verify subframe entries if we're in --site-per-process mode. |
1309 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1303 if (AreAllSitesIsolatedForTesting()) { |
1310 switches::kSitePerProcess)) { | |
1311 // The entry should now have a subframe FrameNavigationEntry. | 1304 // The entry should now have a subframe FrameNavigationEntry. |
1312 ASSERT_EQ(1U, entry->root_node()->children.size()); | 1305 ASSERT_EQ(1U, entry->root_node()->children.size()); |
1313 FrameNavigationEntry* frame_entry = | 1306 FrameNavigationEntry* frame_entry = |
1314 entry->root_node()->children[0]->frame_entry.get(); | 1307 entry->root_node()->children[0]->frame_entry.get(); |
1315 EXPECT_EQ(frame_url, frame_entry->url()); | 1308 EXPECT_EQ(frame_url, frame_entry->url()); |
1316 EXPECT_TRUE(controller.HasCommittedRealLoad(root->child_at(0))); | 1309 EXPECT_TRUE(controller.HasCommittedRealLoad(root->child_at(0))); |
1317 } else { | 1310 } else { |
1318 // There are no subframe FrameNavigationEntries by default. | 1311 // There are no subframe FrameNavigationEntries by default. |
1319 EXPECT_EQ(0U, entry->root_node()->children.size()); | 1312 EXPECT_EQ(0U, entry->root_node()->children.size()); |
1320 } | 1313 } |
(...skipping 13 matching lines...) Expand all Loading... | |
1334 | 1327 |
1335 // The last committed NavigationEntry shouldn't have changed. | 1328 // The last committed NavigationEntry shouldn't have changed. |
1336 EXPECT_EQ(1, controller.GetEntryCount()); | 1329 EXPECT_EQ(1, controller.GetEntryCount()); |
1337 entry = controller.GetLastCommittedEntry(); | 1330 entry = controller.GetLastCommittedEntry(); |
1338 EXPECT_EQ(main_url, entry->GetURL()); | 1331 EXPECT_EQ(main_url, entry->GetURL()); |
1339 root_entry = entry->root_node()->frame_entry.get(); | 1332 root_entry = entry->root_node()->frame_entry.get(); |
1340 EXPECT_EQ(main_url, root_entry->url()); | 1333 EXPECT_EQ(main_url, root_entry->url()); |
1341 EXPECT_FALSE(controller.GetPendingEntry()); | 1334 EXPECT_FALSE(controller.GetPendingEntry()); |
1342 | 1335 |
1343 // Verify subframe entries if we're in --site-per-process mode. | 1336 // Verify subframe entries if we're in --site-per-process mode. |
1344 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1337 if (AreAllSitesIsolatedForTesting()) { |
1345 switches::kSitePerProcess)) { | |
1346 // The entry should now have 2 subframe FrameNavigationEntries. | 1338 // The entry should now have 2 subframe FrameNavigationEntries. |
1347 ASSERT_EQ(2U, entry->root_node()->children.size()); | 1339 ASSERT_EQ(2U, entry->root_node()->children.size()); |
1348 FrameNavigationEntry* frame_entry = | 1340 FrameNavigationEntry* frame_entry = |
1349 entry->root_node()->children[1]->frame_entry.get(); | 1341 entry->root_node()->children[1]->frame_entry.get(); |
1350 EXPECT_EQ(foo_url, frame_entry->url()); | 1342 EXPECT_EQ(foo_url, frame_entry->url()); |
1351 EXPECT_TRUE(controller.HasCommittedRealLoad(root->child_at(1))); | 1343 EXPECT_TRUE(controller.HasCommittedRealLoad(root->child_at(1))); |
1352 } else { | 1344 } else { |
1353 // There are no subframe FrameNavigationEntries by default. | 1345 // There are no subframe FrameNavigationEntries by default. |
1354 EXPECT_EQ(0U, entry->root_node()->children.size()); | 1346 EXPECT_EQ(0U, entry->root_node()->children.size()); |
1355 } | 1347 } |
(...skipping 11 matching lines...) Expand all Loading... | |
1367 } | 1359 } |
1368 | 1360 |
1369 // The last committed NavigationEntry shouldn't have changed. | 1361 // The last committed NavigationEntry shouldn't have changed. |
1370 EXPECT_EQ(1, controller.GetEntryCount()); | 1362 EXPECT_EQ(1, controller.GetEntryCount()); |
1371 entry = controller.GetLastCommittedEntry(); | 1363 entry = controller.GetLastCommittedEntry(); |
1372 EXPECT_EQ(main_url, entry->GetURL()); | 1364 EXPECT_EQ(main_url, entry->GetURL()); |
1373 root_entry = entry->root_node()->frame_entry.get(); | 1365 root_entry = entry->root_node()->frame_entry.get(); |
1374 EXPECT_EQ(main_url, root_entry->url()); | 1366 EXPECT_EQ(main_url, root_entry->url()); |
1375 | 1367 |
1376 // Verify subframe entries if we're in --site-per-process mode. | 1368 // Verify subframe entries if we're in --site-per-process mode. |
1377 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1369 if (AreAllSitesIsolatedForTesting()) { |
1378 switches::kSitePerProcess)) { | |
1379 // The entry should now have 2 subframe FrameNavigationEntries. | 1370 // The entry should now have 2 subframe FrameNavigationEntries. |
1380 ASSERT_EQ(2U, entry->root_node()->children.size()); | 1371 ASSERT_EQ(2U, entry->root_node()->children.size()); |
1381 ASSERT_EQ(1U, entry->root_node()->children[1]->children.size()); | 1372 ASSERT_EQ(1U, entry->root_node()->children[1]->children.size()); |
1382 FrameNavigationEntry* frame_entry = | 1373 FrameNavigationEntry* frame_entry = |
1383 entry->root_node()->children[1]->children[0]->frame_entry.get(); | 1374 entry->root_node()->children[1]->children[0]->frame_entry.get(); |
1384 EXPECT_EQ(foo_url, frame_entry->url()); | 1375 EXPECT_EQ(foo_url, frame_entry->url()); |
1385 } else { | 1376 } else { |
1386 // There are no subframe FrameNavigationEntries by default. | 1377 // There are no subframe FrameNavigationEntries by default. |
1387 EXPECT_EQ(0U, entry->root_node()->children.size()); | 1378 EXPECT_EQ(0U, entry->root_node()->children.size()); |
1388 } | 1379 } |
1389 | 1380 |
1390 // TODO(creis): Add tests for another subframe on B, and for a subframe on A | 1381 // TODO(creis): Add tests for another subframe on B, and for a subframe on A |
1391 // within it. Both are currently broken. | 1382 // within it. Both are currently broken. |
1392 | 1383 |
1393 // Check the end result of the frame tree. | 1384 // Check the end result of the frame tree. |
1394 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1385 if (AreAllSitesIsolatedForTesting()) { |
1395 switches::kSitePerProcess)) { | |
1396 FrameTreeVisualizer visualizer; | 1386 FrameTreeVisualizer visualizer; |
1397 EXPECT_EQ( | 1387 EXPECT_EQ( |
1398 " Site A ------------ proxies for B\n" | 1388 " Site A ------------ proxies for B\n" |
1399 " |--Site A ------- proxies for B\n" | 1389 " |--Site A ------- proxies for B\n" |
1400 " +--Site B ------- proxies for A\n" | 1390 " +--Site B ------- proxies for A\n" |
1401 " +--Site B -- proxies for A\n" | 1391 " +--Site B -- proxies for A\n" |
1402 "Where A = http://127.0.0.1/\n" | 1392 "Where A = http://127.0.0.1/\n" |
1403 " B = http://foo.com/", | 1393 " B = http://foo.com/", |
1404 visualizer.DepictFrameTree(root)); | 1394 visualizer.DepictFrameTree(root)); |
1405 } | 1395 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1447 // We should have created a new NavigationEntry with the same main frame URL. | 1437 // We should have created a new NavigationEntry with the same main frame URL. |
1448 EXPECT_EQ(2, controller.GetEntryCount()); | 1438 EXPECT_EQ(2, controller.GetEntryCount()); |
1449 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 1439 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
1450 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); | 1440 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); |
1451 EXPECT_NE(entry, entry2); | 1441 EXPECT_NE(entry, entry2); |
1452 EXPECT_EQ(main_url, entry2->GetURL()); | 1442 EXPECT_EQ(main_url, entry2->GetURL()); |
1453 FrameNavigationEntry* root_entry2 = entry2->root_node()->frame_entry.get(); | 1443 FrameNavigationEntry* root_entry2 = entry2->root_node()->frame_entry.get(); |
1454 EXPECT_EQ(main_url, root_entry2->url()); | 1444 EXPECT_EQ(main_url, root_entry2->url()); |
1455 | 1445 |
1456 // Verify subframe entries if we're in --site-per-process mode. | 1446 // Verify subframe entries if we're in --site-per-process mode. |
1457 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1447 if (AreAllSitesIsolatedForTesting()) { |
1458 switches::kSitePerProcess)) { | |
1459 // The entry should have a new FrameNavigationEntries for the subframe. | 1448 // The entry should have a new FrameNavigationEntries for the subframe. |
1460 ASSERT_EQ(1U, entry2->root_node()->children.size()); | 1449 ASSERT_EQ(1U, entry2->root_node()->children.size()); |
1461 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url()); | 1450 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url()); |
1462 } else { | 1451 } else { |
1463 // There are no subframe FrameNavigationEntries by default. | 1452 // There are no subframe FrameNavigationEntries by default. |
1464 EXPECT_EQ(0U, entry2->root_node()->children.size()); | 1453 EXPECT_EQ(0U, entry2->root_node()->children.size()); |
1465 } | 1454 } |
1466 | 1455 |
1467 // 3. Create a second, initially cross-site iframe. | 1456 // 3. Create a second, initially cross-site iframe. |
1468 GURL foo_url(embedded_test_server()->GetURL( | 1457 GURL foo_url(embedded_test_server()->GetURL( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1501 // We should have created a new NavigationEntry with the same main frame URL. | 1490 // We should have created a new NavigationEntry with the same main frame URL. |
1502 EXPECT_EQ(3, controller.GetEntryCount()); | 1491 EXPECT_EQ(3, controller.GetEntryCount()); |
1503 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 1492 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
1504 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry(); | 1493 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry(); |
1505 EXPECT_NE(entry, entry3); | 1494 EXPECT_NE(entry, entry3); |
1506 EXPECT_EQ(main_url, entry3->GetURL()); | 1495 EXPECT_EQ(main_url, entry3->GetURL()); |
1507 FrameNavigationEntry* root_entry3 = entry3->root_node()->frame_entry.get(); | 1496 FrameNavigationEntry* root_entry3 = entry3->root_node()->frame_entry.get(); |
1508 EXPECT_EQ(main_url, root_entry3->url()); | 1497 EXPECT_EQ(main_url, root_entry3->url()); |
1509 | 1498 |
1510 // Verify subframe entries if we're in --site-per-process mode. | 1499 // Verify subframe entries if we're in --site-per-process mode. |
1511 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1500 if (AreAllSitesIsolatedForTesting()) { |
1512 switches::kSitePerProcess)) { | |
1513 // The entry should still have FrameNavigationEntries for all 3 subframes. | 1501 // The entry should still have FrameNavigationEntries for all 3 subframes. |
1514 ASSERT_EQ(2U, entry3->root_node()->children.size()); | 1502 ASSERT_EQ(2U, entry3->root_node()->children.size()); |
1515 EXPECT_EQ(frame_url2, entry3->root_node()->children[0]->frame_entry->url()); | 1503 EXPECT_EQ(frame_url2, entry3->root_node()->children[0]->frame_entry->url()); |
1516 EXPECT_EQ(foo_url, entry3->root_node()->children[1]->frame_entry->url()); | 1504 EXPECT_EQ(foo_url, entry3->root_node()->children[1]->frame_entry->url()); |
1517 ASSERT_EQ(1U, entry3->root_node()->children[1]->children.size()); | 1505 ASSERT_EQ(1U, entry3->root_node()->children[1]->children.size()); |
1518 EXPECT_EQ( | 1506 EXPECT_EQ( |
1519 bar_url, | 1507 bar_url, |
1520 entry3->root_node()->children[1]->children[0]->frame_entry->url()); | 1508 entry3->root_node()->children[1]->children[0]->frame_entry->url()); |
1521 } else { | 1509 } else { |
1522 // There are no subframe FrameNavigationEntries by default. | 1510 // There are no subframe FrameNavigationEntries by default. |
(...skipping 17 matching lines...) Expand all Loading... | |
1540 // We should have created a new NavigationEntry with the same main frame URL. | 1528 // We should have created a new NavigationEntry with the same main frame URL. |
1541 EXPECT_EQ(4, controller.GetEntryCount()); | 1529 EXPECT_EQ(4, controller.GetEntryCount()); |
1542 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); | 1530 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); |
1543 NavigationEntryImpl* entry4 = controller.GetLastCommittedEntry(); | 1531 NavigationEntryImpl* entry4 = controller.GetLastCommittedEntry(); |
1544 EXPECT_NE(entry, entry4); | 1532 EXPECT_NE(entry, entry4); |
1545 EXPECT_EQ(main_url, entry4->GetURL()); | 1533 EXPECT_EQ(main_url, entry4->GetURL()); |
1546 FrameNavigationEntry* root_entry4 = entry4->root_node()->frame_entry.get(); | 1534 FrameNavigationEntry* root_entry4 = entry4->root_node()->frame_entry.get(); |
1547 EXPECT_EQ(main_url, root_entry4->url()); | 1535 EXPECT_EQ(main_url, root_entry4->url()); |
1548 | 1536 |
1549 // Verify subframe entries if we're in --site-per-process mode. | 1537 // Verify subframe entries if we're in --site-per-process mode. |
1550 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1538 if (AreAllSitesIsolatedForTesting()) { |
1551 switches::kSitePerProcess)) { | |
1552 // The entry should still have FrameNavigationEntries for all 3 subframes. | 1539 // The entry should still have FrameNavigationEntries for all 3 subframes. |
1553 ASSERT_EQ(2U, entry4->root_node()->children.size()); | 1540 ASSERT_EQ(2U, entry4->root_node()->children.size()); |
1554 EXPECT_EQ(frame_url2, entry4->root_node()->children[0]->frame_entry->url()); | 1541 EXPECT_EQ(frame_url2, entry4->root_node()->children[0]->frame_entry->url()); |
1555 EXPECT_EQ(baz_url, entry4->root_node()->children[1]->frame_entry->url()); | 1542 EXPECT_EQ(baz_url, entry4->root_node()->children[1]->frame_entry->url()); |
1556 ASSERT_EQ(0U, entry4->root_node()->children[1]->children.size()); | 1543 ASSERT_EQ(0U, entry4->root_node()->children[1]->children.size()); |
1557 } else { | 1544 } else { |
1558 // There are no subframe FrameNavigationEntries by default. | 1545 // There are no subframe FrameNavigationEntries by default. |
1559 EXPECT_EQ(0U, entry4->root_node()->children.size()); | 1546 EXPECT_EQ(0U, entry4->root_node()->children.size()); |
1560 } | 1547 } |
1561 | 1548 |
1562 // Check the end result of the frame tree. | 1549 // Check the end result of the frame tree. |
1563 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1550 if (AreAllSitesIsolatedForTesting()) { |
1564 switches::kSitePerProcess)) { | |
1565 FrameTreeVisualizer visualizer; | 1551 FrameTreeVisualizer visualizer; |
1566 EXPECT_EQ( | 1552 EXPECT_EQ( |
1567 " Site A ------------ proxies for B\n" | 1553 " Site A ------------ proxies for B\n" |
1568 " |--Site A ------- proxies for B\n" | 1554 " |--Site A ------- proxies for B\n" |
1569 " +--Site B ------- proxies for A\n" | 1555 " +--Site B ------- proxies for A\n" |
1570 "Where A = http://127.0.0.1/\n" | 1556 "Where A = http://127.0.0.1/\n" |
1571 " B = http://baz.com/", | 1557 " B = http://baz.com/", |
1572 visualizer.DepictFrameTree(root)); | 1558 visualizer.DepictFrameTree(root)); |
1573 } | 1559 } |
1574 } | 1560 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1630 shell()->web_contents()->GetController().GoBack(); | 1616 shell()->web_contents()->GetController().GoBack(); |
1631 capturer.Wait(); | 1617 capturer.Wait(); |
1632 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); | 1618 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); |
1633 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); | 1619 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); |
1634 } | 1620 } |
1635 EXPECT_EQ(3, controller.GetEntryCount()); | 1621 EXPECT_EQ(3, controller.GetEntryCount()); |
1636 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 1622 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
1637 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); | 1623 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); |
1638 | 1624 |
1639 // Verify subframe entries if we're in --site-per-process mode. | 1625 // Verify subframe entries if we're in --site-per-process mode. |
1640 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1626 if (AreAllSitesIsolatedForTesting()) { |
1641 switches::kSitePerProcess)) { | |
1642 // The entry should have a new FrameNavigationEntries for the subframe. | 1627 // The entry should have a new FrameNavigationEntries for the subframe. |
1643 ASSERT_EQ(1U, entry2->root_node()->children.size()); | 1628 ASSERT_EQ(1U, entry2->root_node()->children.size()); |
1644 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url()); | 1629 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url()); |
1645 } else { | 1630 } else { |
1646 // There are no subframe FrameNavigationEntries by default. | 1631 // There are no subframe FrameNavigationEntries by default. |
1647 EXPECT_EQ(0U, entry2->root_node()->children.size()); | 1632 EXPECT_EQ(0U, entry2->root_node()->children.size()); |
1648 } | 1633 } |
1649 | 1634 |
1650 // 5. Go back in the subframe again to the parent page's site. | 1635 // 5. Go back in the subframe again to the parent page's site. |
1651 { | 1636 { |
1652 FrameNavigateParamsCapturer capturer(root->child_at(0)); | 1637 FrameNavigateParamsCapturer capturer(root->child_at(0)); |
1653 shell()->web_contents()->GetController().GoBack(); | 1638 shell()->web_contents()->GetController().GoBack(); |
1654 capturer.Wait(); | 1639 capturer.Wait(); |
1655 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); | 1640 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); |
1656 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); | 1641 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); |
1657 } | 1642 } |
1658 EXPECT_EQ(3, controller.GetEntryCount()); | 1643 EXPECT_EQ(3, controller.GetEntryCount()); |
1659 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 1644 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
1660 EXPECT_EQ(entry1, controller.GetLastCommittedEntry()); | 1645 EXPECT_EQ(entry1, controller.GetLastCommittedEntry()); |
1661 | 1646 |
1662 // Verify subframe entries if we're in --site-per-process mode. | 1647 // Verify subframe entries if we're in --site-per-process mode. |
1663 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1648 if (AreAllSitesIsolatedForTesting()) { |
1664 switches::kSitePerProcess)) { | |
1665 // The entry should have a new FrameNavigationEntries for the subframe. | 1649 // The entry should have a new FrameNavigationEntries for the subframe. |
1666 ASSERT_EQ(1U, entry1->root_node()->children.size()); | 1650 ASSERT_EQ(1U, entry1->root_node()->children.size()); |
1667 EXPECT_EQ(frame_url, entry1->root_node()->children[0]->frame_entry->url()); | 1651 EXPECT_EQ(frame_url, entry1->root_node()->children[0]->frame_entry->url()); |
1668 } else { | 1652 } else { |
1669 // There are no subframe FrameNavigationEntries by default. | 1653 // There are no subframe FrameNavigationEntries by default. |
1670 EXPECT_EQ(0U, entry1->root_node()->children.size()); | 1654 EXPECT_EQ(0U, entry1->root_node()->children.size()); |
1671 } | 1655 } |
1672 | 1656 |
1673 // 6. Go forward in the subframe cross-site. | 1657 // 6. Go forward in the subframe cross-site. |
1674 { | 1658 { |
1675 FrameNavigateParamsCapturer capturer(root->child_at(0)); | 1659 FrameNavigateParamsCapturer capturer(root->child_at(0)); |
1676 shell()->web_contents()->GetController().GoForward(); | 1660 shell()->web_contents()->GetController().GoForward(); |
1677 capturer.Wait(); | 1661 capturer.Wait(); |
1678 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); | 1662 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); |
1679 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); | 1663 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); |
1680 } | 1664 } |
1681 EXPECT_EQ(3, controller.GetEntryCount()); | 1665 EXPECT_EQ(3, controller.GetEntryCount()); |
1682 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 1666 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
1683 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); | 1667 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); |
1684 | 1668 |
1685 // Verify subframe entries if we're in --site-per-process mode. | 1669 // Verify subframe entries if we're in --site-per-process mode. |
1686 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1670 if (AreAllSitesIsolatedForTesting()) { |
1687 switches::kSitePerProcess)) { | |
1688 // The entry should have a new FrameNavigationEntries for the subframe. | 1671 // The entry should have a new FrameNavigationEntries for the subframe. |
1689 ASSERT_EQ(1U, entry2->root_node()->children.size()); | 1672 ASSERT_EQ(1U, entry2->root_node()->children.size()); |
1690 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url()); | 1673 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url()); |
1691 } else { | 1674 } else { |
1692 // There are no subframe FrameNavigationEntries by default. | 1675 // There are no subframe FrameNavigationEntries by default. |
1693 EXPECT_EQ(0U, entry2->root_node()->children.size()); | 1676 EXPECT_EQ(0U, entry2->root_node()->children.size()); |
1694 } | 1677 } |
1695 | 1678 |
1696 // 7. Go forward in the subframe again, cross-site. | 1679 // 7. Go forward in the subframe again, cross-site. |
1697 { | 1680 { |
1698 FrameNavigateParamsCapturer capturer(root->child_at(0)); | 1681 FrameNavigateParamsCapturer capturer(root->child_at(0)); |
1699 shell()->web_contents()->GetController().GoForward(); | 1682 shell()->web_contents()->GetController().GoForward(); |
1700 capturer.Wait(); | 1683 capturer.Wait(); |
1701 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); | 1684 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); |
1702 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); | 1685 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); |
1703 } | 1686 } |
1704 EXPECT_EQ(3, controller.GetEntryCount()); | 1687 EXPECT_EQ(3, controller.GetEntryCount()); |
1705 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 1688 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
1706 EXPECT_EQ(entry3, controller.GetLastCommittedEntry()); | 1689 EXPECT_EQ(entry3, controller.GetLastCommittedEntry()); |
1707 | 1690 |
1708 // Verify subframe entries if we're in --site-per-process mode. | 1691 // Verify subframe entries if we're in --site-per-process mode. |
1709 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1692 if (AreAllSitesIsolatedForTesting()) { |
1710 switches::kSitePerProcess)) { | |
1711 // The entry should have a new FrameNavigationEntries for the subframe. | 1693 // The entry should have a new FrameNavigationEntries for the subframe. |
1712 ASSERT_EQ(1U, entry3->root_node()->children.size()); | 1694 ASSERT_EQ(1U, entry3->root_node()->children.size()); |
1713 EXPECT_EQ(frame_url3, entry3->root_node()->children[0]->frame_entry->url()); | 1695 EXPECT_EQ(frame_url3, entry3->root_node()->children[0]->frame_entry->url()); |
1714 } else { | 1696 } else { |
1715 // There are no subframe FrameNavigationEntries by default. | 1697 // There are no subframe FrameNavigationEntries by default. |
1716 EXPECT_EQ(0U, entry3->root_node()->children.size()); | 1698 EXPECT_EQ(0U, entry3->root_node()->children.size()); |
1717 } | 1699 } |
1718 } | 1700 } |
1719 | 1701 |
1720 // Verifies that item sequence numbers and document sequence numbers update | 1702 // Verifies that item sequence numbers and document sequence numbers update |
(...skipping 26 matching lines...) Expand all Loading... | |
1747 | 1729 |
1748 frame_entry = controller.GetLastCommittedEntry()->GetFrameEntry(root); | 1730 frame_entry = controller.GetLastCommittedEntry()->GetFrameEntry(root); |
1749 int64 isn_2 = frame_entry->item_sequence_number(); | 1731 int64 isn_2 = frame_entry->item_sequence_number(); |
1750 int64 dsn_2 = frame_entry->document_sequence_number(); | 1732 int64 dsn_2 = frame_entry->document_sequence_number(); |
1751 EXPECT_NE(-1, isn_2); | 1733 EXPECT_NE(-1, isn_2); |
1752 EXPECT_NE(isn_1, isn_2); | 1734 EXPECT_NE(isn_1, isn_2); |
1753 EXPECT_EQ(dsn_1, dsn_2); | 1735 EXPECT_EQ(dsn_1, dsn_2); |
1754 | 1736 |
1755 // Also test subframe sequence numbers, but only in --site-per-proces mode. | 1737 // Also test subframe sequence numbers, but only in --site-per-proces mode. |
1756 // (We do not create subframe FrameNavigationEntries in default mode yet.) | 1738 // (We do not create subframe FrameNavigationEntries in default mode yet.) |
1757 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 1739 if (!AreAllSitesIsolatedForTesting()) |
1758 switches::kSitePerProcess)) | |
1759 return; | 1740 return; |
1760 | 1741 |
1761 // 3. Add a subframe, which does an AUTO_SUBFRAME navigation. | 1742 // 3. Add a subframe, which does an AUTO_SUBFRAME navigation. |
1762 { | 1743 { |
1763 LoadCommittedCapturer capturer(shell()->web_contents()); | 1744 LoadCommittedCapturer capturer(shell()->web_contents()); |
1764 std::string script = "var iframe = document.createElement('iframe');" | 1745 std::string script = "var iframe = document.createElement('iframe');" |
1765 "iframe.src = '" + url.spec() + "';" | 1746 "iframe.src = '" + url.spec() + "';" |
1766 "document.body.appendChild(iframe);"; | 1747 "document.body.appendChild(iframe);"; |
1767 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); | 1748 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); |
1768 capturer.Wait(); | 1749 capturer.Wait(); |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2221 EXPECT_EQ(original_url, capturer.all_params()[1].url); | 2202 EXPECT_EQ(original_url, capturer.all_params()[1].url); |
2222 EXPECT_EQ(original_url, shell()->web_contents()->GetLastCommittedURL()); | 2203 EXPECT_EQ(original_url, shell()->web_contents()->GetLastCommittedURL()); |
2223 } | 2204 } |
2224 | 2205 |
2225 // Make sure the renderer is still alive. | 2206 // Make sure the renderer is still alive. |
2226 EXPECT_TRUE( | 2207 EXPECT_TRUE( |
2227 ExecuteScript(shell()->web_contents(), "console.log('Success');")); | 2208 ExecuteScript(shell()->web_contents(), "console.log('Success');")); |
2228 } | 2209 } |
2229 | 2210 |
2230 } // namespace content | 2211 } // namespace content |
OLD | NEW |