OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/site_per_process_browsertest.h" | 5 #include "content/browser/site_per_process_browsertest.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1282 EXPECT_EQ( | 1282 EXPECT_EQ( |
1283 " Site A\n" | 1283 " Site A\n" |
1284 " |--Site A\n" | 1284 " |--Site A\n" |
1285 " +--Site A\n" | 1285 " +--Site A\n" |
1286 " +--Site A\n" | 1286 " +--Site A\n" |
1287 "Where A = http://a.com/", | 1287 "Where A = http://a.com/", |
1288 DepictFrameTree(root)); | 1288 DepictFrameTree(root)); |
1289 | 1289 |
1290 // Load cross-site page into iframe. | 1290 // Load cross-site page into iframe. |
1291 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); | 1291 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); |
1292 NavigateFrameToURL(root->child_at(0), url); | 1292 NavigateFrameToURL(child, url); |
1293 EXPECT_TRUE(observer.last_navigation_succeeded()); | 1293 EXPECT_TRUE(observer.last_navigation_succeeded()); |
1294 EXPECT_EQ(url, observer.last_navigation_url()); | 1294 EXPECT_EQ(url, observer.last_navigation_url()); |
1295 EXPECT_EQ( | 1295 EXPECT_EQ( |
1296 " Site A ------------ proxies for B\n" | 1296 " Site A ------------ proxies for B\n" |
1297 " |--Site B ------- proxies for A\n" | 1297 " |--Site B ------- proxies for A\n" |
1298 " +--Site A ------- proxies for B\n" | 1298 " +--Site A ------- proxies for B\n" |
1299 " +--Site A -- proxies for B\n" | 1299 " +--Site A -- proxies for B\n" |
1300 "Where A = http://a.com/\n" | 1300 "Where A = http://a.com/\n" |
1301 " B = http://foo.com/", | 1301 " B = http://foo.com/", |
1302 DepictFrameTree(root)); | 1302 DepictFrameTree(root)); |
(...skipping 10 matching lines...) Expand all Loading... | |
1313 EXPECT_EQ( | 1313 EXPECT_EQ( |
1314 " Site A\n" | 1314 " Site A\n" |
1315 " |--Site A\n" | 1315 " |--Site A\n" |
1316 " +--Site A\n" | 1316 " +--Site A\n" |
1317 " +--Site A\n" | 1317 " +--Site A\n" |
1318 "Where A = http://a.com/", | 1318 "Where A = http://a.com/", |
1319 DepictFrameTree(root)); | 1319 DepictFrameTree(root)); |
1320 | 1320 |
1321 // Load cross-site page into iframe. | 1321 // Load cross-site page into iframe. |
1322 url = embedded_test_server()->GetURL("bar.com", "/title2.html"); | 1322 url = embedded_test_server()->GetURL("bar.com", "/title2.html"); |
1323 NavigateFrameToURL(root->child_at(0), url); | 1323 NavigateFrameToURL(child, url); |
1324 EXPECT_TRUE(observer.last_navigation_succeeded()); | 1324 EXPECT_TRUE(observer.last_navigation_succeeded()); |
1325 EXPECT_EQ(url, observer.last_navigation_url()); | 1325 EXPECT_EQ(url, observer.last_navigation_url()); |
1326 EXPECT_EQ( | 1326 EXPECT_EQ( |
1327 " Site A ------------ proxies for C\n" | 1327 " Site A ------------ proxies for C\n" |
1328 " |--Site C ------- proxies for A\n" | 1328 " |--Site C ------- proxies for A\n" |
1329 " +--Site A ------- proxies for C\n" | 1329 " +--Site A ------- proxies for C\n" |
1330 " +--Site A -- proxies for C\n" | 1330 " +--Site A -- proxies for C\n" |
1331 "Where A = http://a.com/\n" | 1331 "Where A = http://a.com/\n" |
1332 " C = http://bar.com/", | 1332 " C = http://bar.com/", |
1333 DepictFrameTree(root)); | 1333 DepictFrameTree(root)); |
1334 | 1334 |
1335 // Navigate iframe to about:blank. The navigation happens from a script in the | 1335 // Navigate iframe to about:blank. The navigation happens from a script in the |
1336 // parent frame, so it should be committed in the same SiteInstance as the | 1336 // parent frame, so it should be committed in the same SiteInstance as the |
1337 // parent frame. | 1337 // parent frame. |
1338 GURL about_blank_url("about:blank"); | 1338 GURL about_blank_url("about:blank"); |
1339 NavigateIframeToURL(shell()->web_contents(), "child-0", about_blank_url); | 1339 NavigateIframeToURL(shell()->web_contents(), "child-0", about_blank_url); |
1340 EXPECT_TRUE(observer.last_navigation_succeeded()); | 1340 EXPECT_TRUE(observer.last_navigation_succeeded()); |
1341 EXPECT_EQ(about_blank_url, observer.last_navigation_url()); | 1341 EXPECT_EQ(about_blank_url, observer.last_navigation_url()); |
1342 | 1342 |
1343 // Ensure that we have navigated using the top level process. | 1343 // Ensure that we have navigated using the top level process. |
1344 EXPECT_EQ( | 1344 EXPECT_EQ( |
1345 " Site A\n" | 1345 " Site A\n" |
1346 " |--Site A\n" | 1346 " |--Site A\n" |
1347 " +--Site A\n" | 1347 " +--Site A\n" |
1348 " +--Site A\n" | 1348 " +--Site A\n" |
1349 "Where A = http://a.com/", | 1349 "Where A = http://a.com/", |
1350 DepictFrameTree(root)); | 1350 DepictFrameTree(root)); |
1351 | |
1352 // Load cross-site page into iframe again. | |
1353 url = embedded_test_server()->GetURL("f00.com", "/title3.html"); | |
1354 NavigateFrameToURL(child, url); | |
1355 EXPECT_TRUE(observer.last_navigation_succeeded()); | |
1356 EXPECT_EQ(url, observer.last_navigation_url()); | |
1357 EXPECT_EQ( | |
1358 " Site A ------------ proxies for D\n" | |
1359 " |--Site D ------- proxies for A\n" | |
1360 " +--Site A ------- proxies for D\n" | |
1361 " +--Site A -- proxies for D\n" | |
1362 "Where A = http://a.com/\n" | |
1363 " D = http://f00.com/", | |
1364 DepictFrameTree(root)); | |
1365 | |
1366 // Navigate the iframe itself to about:blank using a script executing in its | |
1367 // own context. It should stay in the same SiteInstance as before, not the | |
1368 // parent one. | |
1369 std::string script( | |
1370 "window.domAutomationController.send(" | |
1371 "window.location.href = 'about:blank');"); | |
1372 TestFrameNavigationObserver frame_observer(child); | |
1373 EXPECT_TRUE(ExecuteScript(child->current_frame_host(), script)); | |
1374 frame_observer.Wait(); | |
1375 EXPECT_EQ(about_blank_url, child->current_url()); | |
1376 | |
1377 // Ensure that we have navigated using the top level process. | |
1378 EXPECT_EQ( | |
1379 " Site A ------------ proxies for D\n" | |
1380 " |--Site D ------- proxies for A\n" | |
1381 " +--Site A ------- proxies for D\n" | |
1382 " +--Site A -- proxies for D\n" | |
1383 "Where A = http://a.com/\n" | |
1384 " D = http://f00.com/", | |
1385 DepictFrameTree(root)); | |
ncarter (slow)
2016/04/26 18:40:27
lgtm
If you are working on improving the resoluti
| |
1351 } | 1386 } |
1352 | 1387 |
1353 // This test checks that killing a renderer process of a remote frame | 1388 // This test checks that killing a renderer process of a remote frame |
1354 // and then navigating some other frame to the same SiteInstance of the killed | 1389 // and then navigating some other frame to the same SiteInstance of the killed |
1355 // process works properly. | 1390 // process works properly. |
1356 // This can be illustrated as follows, | 1391 // This can be illustrated as follows, |
1357 // where 1/2/3 are FrameTreeNode-s and A/B are processes and B* is the killed | 1392 // where 1/2/3 are FrameTreeNode-s and A/B are processes and B* is the killed |
1358 // B process: | 1393 // B process: |
1359 // | 1394 // |
1360 // 1 A A A | 1395 // 1 A A A |
(...skipping 4726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6087 EXPECT_EQ(b_url, root->current_url()); | 6122 EXPECT_EQ(b_url, root->current_url()); |
6088 | 6123 |
6089 // Verify that the same RenderViewHost is preserved and that it is no longer | 6124 // Verify that the same RenderViewHost is preserved and that it is no longer |
6090 // in swapped out state. | 6125 // in swapped out state. |
6091 EXPECT_EQ(rvh, contents->GetFrameTree()->GetRenderViewHost( | 6126 EXPECT_EQ(rvh, contents->GetFrameTree()->GetRenderViewHost( |
6092 root->current_frame_host()->GetSiteInstance())); | 6127 root->current_frame_host()->GetSiteInstance())); |
6093 EXPECT_FALSE(rvh->is_swapped_out_); | 6128 EXPECT_FALSE(rvh->is_swapped_out_); |
6094 } | 6129 } |
6095 | 6130 |
6096 } // namespace content | 6131 } // namespace content |
OLD | NEW |