| 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 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateRemoteAfterError) { | 1335 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateRemoteAfterError) { |
| 1336 GURL main_url(embedded_test_server()->GetURL( | 1336 GURL main_url(embedded_test_server()->GetURL( |
| 1337 "a.com", "/cross_site_iframe_factory.html?a(a)")); | 1337 "a.com", "/cross_site_iframe_factory.html?a(a)")); |
| 1338 NavigateToURL(shell(), main_url); | 1338 NavigateToURL(shell(), main_url); |
| 1339 | 1339 |
| 1340 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1340 // It is safe to obtain the root frame tree node here, as it doesn't change. |
| 1341 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 1341 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 1342 ->GetFrameTree() | 1342 ->GetFrameTree() |
| 1343 ->root(); | 1343 ->root(); |
| 1344 | 1344 |
| 1345 TestNavigationObserver observer(shell()->web_contents()); | |
| 1346 | |
| 1347 // Load same-site page into iframe. | 1345 // Load same-site page into iframe. |
| 1348 FrameTreeNode* child = root->child_at(0); | 1346 { |
| 1349 GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html")); | 1347 TestNavigationObserver observer(shell()->web_contents()); |
| 1350 NavigateFrameToURL(child, http_url); | 1348 FrameTreeNode* child = root->child_at(0); |
| 1351 EXPECT_EQ(http_url, observer.last_navigation_url()); | 1349 GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html")); |
| 1352 EXPECT_TRUE(observer.last_navigation_succeeded()); | 1350 NavigateFrameToURL(child, http_url); |
| 1351 EXPECT_EQ(http_url, observer.last_navigation_url()); |
| 1352 EXPECT_TRUE(observer.last_navigation_succeeded()); |
| 1353 observer.Wait(); |
| 1354 } |
| 1353 | 1355 |
| 1354 // Load cross-site page into iframe. | 1356 // Load cross-site page into iframe. |
| 1355 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); | 1357 { |
| 1356 NavigateFrameToURL(root->child_at(0), url); | 1358 TestNavigationObserver observer(shell()->web_contents()); |
| 1357 EXPECT_TRUE(observer.last_navigation_succeeded()); | 1359 FrameTreeNode* child = root->child_at(0); |
| 1358 EXPECT_EQ(url, observer.last_navigation_url()); | 1360 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); |
| 1361 NavigateFrameToURL(root->child_at(0), url); |
| 1362 EXPECT_TRUE(observer.last_navigation_succeeded()); |
| 1363 EXPECT_EQ(url, observer.last_navigation_url()); |
| 1364 observer.Wait(); |
| 1359 | 1365 |
| 1360 // Ensure that we have created a new process for the subframe. | 1366 // Ensure that we have created a new process for the subframe. |
| 1361 EXPECT_EQ( | 1367 EXPECT_EQ( |
| 1362 " Site A ------------ proxies for B\n" | 1368 " Site A ------------ proxies for B\n" |
| 1363 " +--Site B ------- proxies for A\n" | 1369 " +--Site B ------- proxies for A\n" |
| 1364 "Where A = http://a.com/\n" | 1370 "Where A = http://a.com/\n" |
| 1365 " B = http://foo.com/", | 1371 " B = http://foo.com/", |
| 1366 DepictFrameTree(root)); | 1372 DepictFrameTree(root)); |
| 1367 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); | 1373 SiteInstance* site_instance = |
| 1368 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); | 1374 child->current_frame_host()->GetSiteInstance(); |
| 1375 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); |
| 1376 } |
| 1369 | 1377 |
| 1370 // Stop the test server and try to navigate the remote frame. | 1378 // Stop the test server and try to navigate the remote frame. |
| 1371 url = embedded_test_server()->GetURL("bar.com", "/title3.html"); | 1379 { |
| 1372 EXPECT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete()); | 1380 GURL url = embedded_test_server()->GetURL("bar.com", "/title3.html"); |
| 1373 NavigateIframeToURL(shell()->web_contents(), "child-0", url); | 1381 EXPECT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete()); |
| 1382 NavigateIframeToURL(shell()->web_contents(), "child-0", url); |
| 1383 } |
| 1374 } | 1384 } |
| 1375 | 1385 |
| 1376 // Ensure that a cross-site page ends up in the correct process when it | 1386 // Ensure that a cross-site page ends up in the correct process when it |
| 1377 // successfully loads after earlier encountering a network error for it. | 1387 // successfully loads after earlier encountering a network error for it. |
| 1378 // See https://crbug.com/560511. | 1388 // See https://crbug.com/560511. |
| 1379 // TODO(creis): Make the net error page show in the correct process as well, | 1389 // TODO(creis): Make the net error page show in the correct process as well, |
| 1380 // per https://crbug.com/588314. | 1390 // per https://crbug.com/588314. |
| 1381 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ProcessTransferAfterError) { | 1391 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ProcessTransferAfterError) { |
| 1382 GURL main_url(embedded_test_server()->GetURL( | 1392 GURL main_url(embedded_test_server()->GetURL( |
| 1383 "a.com", "/cross_site_iframe_factory.html?a(a)")); | 1393 "a.com", "/cross_site_iframe_factory.html?a(a)")); |
| (...skipping 3994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5378 | 5388 |
| 5379 // Force the renderer to generate a new frame. | 5389 // Force the renderer to generate a new frame. |
| 5380 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), | 5390 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), |
| 5381 "document.body.style.background = 'black'")); | 5391 "document.body.style.background = 'black'")); |
| 5382 | 5392 |
| 5383 // Waits for the next frame. | 5393 // Waits for the next frame. |
| 5384 observer->Wait(); | 5394 observer->Wait(); |
| 5385 } | 5395 } |
| 5386 | 5396 |
| 5387 } // namespace content | 5397 } // namespace content |
| OLD | NEW |