| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "content/browser/frame_host/frame_tree_node.h" | 8 #include "content/browser/frame_host/frame_tree_node.h" |
| 9 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
| 10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 EXPECT_EQ( | 271 EXPECT_EQ( |
| 272 " Site D\n" | 272 " Site D\n" |
| 273 " |--Site D\n" | 273 " |--Site D\n" |
| 274 " |--Site D\n" | 274 " |--Site D\n" |
| 275 " |--Site D\n" | 275 " |--Site D\n" |
| 276 " +--Site D\n" | 276 " +--Site D\n" |
| 277 "Where D = http://c.com/", | 277 "Where D = http://c.com/", |
| 278 DepictFrameTree(root())); | 278 DepictFrameTree(root())); |
| 279 } | 279 } |
| 280 | 280 |
| 281 // Flaky. See http://crbug.com/611300. |
| 281 IN_PROC_BROWSER_TEST_F(TopDocumentIsolationTest, | 282 IN_PROC_BROWSER_TEST_F(TopDocumentIsolationTest, |
| 282 NavigateToSubframeSiteWithPopup2) { | 283 DISABLED_NavigateToSubframeSiteWithPopup2) { |
| 283 if (content::AreAllSitesIsolatedForTesting()) | 284 if (content::AreAllSitesIsolatedForTesting()) |
| 284 return; // Top Document Isolation is disabled in this mode. | 285 return; // Top Document Isolation is disabled in this mode. |
| 285 | 286 |
| 286 // A(B, C) -> C(A, B), but while a separate C(A) popup exists. | 287 // A(B, C) -> C(A, B), but while a separate C(A) popup exists. |
| 287 // | 288 // |
| 288 // This test is constructed so that c.com is the second site to commit in the | 289 // This test is constructed so that c.com is the second site to commit in the |
| 289 // default subframe SiteInstance, so the default subframe SiteInstance does | 290 // default subframe SiteInstance, so the default subframe SiteInstance does |
| 290 // not have a "c.com" as the value of GetSiteURL(). | 291 // not have a "c.com" as the value of GetSiteURL(). |
| 291 GURL abb_url(embedded_test_server()->GetURL( | 292 GURL abb_url(embedded_test_server()->GetURL( |
| 292 "a.com", "/cross_site_iframe_factory.html?a(b, b)")); | 293 "a.com", "/cross_site_iframe_factory.html?a(b, b)")); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 EXPECT_EQ( | 358 EXPECT_EQ( |
| 358 " Site B\n" | 359 " Site B\n" |
| 359 " +--Site B\n" | 360 " +--Site B\n" |
| 360 "Where B = default subframe process", | 361 "Where B = default subframe process", |
| 361 DepictFrameTree(popup_root)); | 362 DepictFrameTree(popup_root)); |
| 362 EXPECT_EQ(nullptr, popup_root->opener()); | 363 EXPECT_EQ(nullptr, popup_root->opener()); |
| 363 | 364 |
| 364 // If we navigate the popup to a new site, it ought to transfer processes. | 365 // If we navigate the popup to a new site, it ought to transfer processes. |
| 365 GURL d_url(embedded_test_server()->GetURL( | 366 GURL d_url(embedded_test_server()->GetURL( |
| 366 "d.com", "/cross_site_iframe_factory.html?d")); | 367 "d.com", "/cross_site_iframe_factory.html?d")); |
| 367 RenderFrameDeletedObserver deleted_observer(popup_root->current_frame_host()); | |
| 368 NavigateToURL(popup, d_url); | 368 NavigateToURL(popup, d_url); |
| 369 deleted_observer.WaitUntilDeleted(); | |
| 370 EXPECT_EQ( | 369 EXPECT_EQ( |
| 371 " Site D ------------ proxies for B\n" | 370 " Site D ------------ proxies for B\n" |
| 372 "Where B = default subframe process\n" | 371 "Where B = default subframe process\n" |
| 373 " D = http://d.com/", | 372 " D = http://d.com/", |
| 374 DepictFrameTree(popup_root)); | 373 DepictFrameTree(popup_root)); |
| 375 NavigateToURL(shell(), d_url); | 374 NavigateToURL(shell(), d_url); |
| 376 EXPECT_EQ( | 375 EXPECT_EQ( |
| 377 " Site D\n" | 376 " Site D\n" |
| 378 "Where D = http://d.com/", | 377 "Where D = http://d.com/", |
| 379 DepictFrameTree(popup_root)); | 378 DepictFrameTree(popup_root)); |
| 380 EXPECT_EQ( | 379 EXPECT_EQ( |
| 381 " Site D\n" | 380 " Site D\n" |
| 382 "Where D = http://d.com/", | 381 "Where D = http://d.com/", |
| 383 DepictFrameTree(root())); | 382 DepictFrameTree(root())); |
| 384 } | 383 } |
| 385 | 384 |
| 386 IN_PROC_BROWSER_TEST_F(TopDocumentIsolationTest, FramesForSitesInHistory) { | 385 // Flaky on Mac. See https://crbug.com/611344. |
| 386 #if defined(OS_MACOSX) |
| 387 #define MAYBE_FramesForSitesInHistory DISABLED_FramesForSitesInHistory |
| 388 #else |
| 389 #define MAYBE_FramesForSitesInHistory FramesForSitesInHistory |
| 390 #endif |
| 391 |
| 392 IN_PROC_BROWSER_TEST_F(TopDocumentIsolationTest, |
| 393 MAYBE_FramesForSitesInHistory) { |
| 387 if (content::AreAllSitesIsolatedForTesting()) | 394 if (content::AreAllSitesIsolatedForTesting()) |
| 388 return; // Top Document Isolation is disabled in this mode. | 395 return; // Top Document Isolation is disabled in this mode. |
| 389 | 396 |
| 390 // First, do a series of navigations. | 397 // First, do a series of navigations. |
| 391 GURL a_url = embedded_test_server()->GetURL( | 398 GURL a_url = embedded_test_server()->GetURL( |
| 392 "a.com", "/cross_site_iframe_factory.html?a"); | 399 "a.com", "/cross_site_iframe_factory.html?a"); |
| 393 GURL b_url = embedded_test_server()->GetURL( | 400 GURL b_url = embedded_test_server()->GetURL( |
| 394 "b.com", "/cross_site_iframe_factory.html?b"); | 401 "b.com", "/cross_site_iframe_factory.html?b"); |
| 395 GURL c_url = embedded_test_server()->GetURL( | 402 GURL c_url = embedded_test_server()->GetURL( |
| 396 "c.com", "/cross_site_iframe_factory.html?c"); | 403 "c.com", "/cross_site_iframe_factory.html?c"); |
| 397 | 404 |
| 398 // Browser-initiated navigation to a.com. | 405 // Browser-initiated navigation to a.com. |
| 399 NavigateToURL(shell(), a_url); | 406 NavigateToURL(shell(), a_url); |
| 400 EXPECT_EQ( | 407 EXPECT_EQ( |
| 401 " Site A\n" | 408 " Site A\n" |
| 402 "Where A = http://a.com/", | 409 "Where A = http://a.com/", |
| 403 DepictFrameTree(root())); | 410 DepictFrameTree(root())); |
| 404 | 411 |
| 405 // Browser-initiated navigation to b.com. | 412 // Browser-initiated navigation to b.com. |
| 406 { | 413 NavigateToURL(shell(), b_url); |
| 407 // For any cross-process navigations, we must wait for the old RenderFrame | |
| 408 // to be deleted before calling DepictFrameTree, or else there's a chance | |
| 409 // the old SiteInstance could be listed while pending deletion. | |
| 410 RenderFrameDeletedObserver deleted_observer(root()->current_frame_host()); | |
| 411 NavigateToURL(shell(), b_url); | |
| 412 deleted_observer.WaitUntilDeleted(); | |
| 413 } | |
| 414 EXPECT_EQ( | 414 EXPECT_EQ( |
| 415 " Site B\n" | 415 " Site B\n" |
| 416 "Where B = http://b.com/", | 416 "Where B = http://b.com/", |
| 417 DepictFrameTree(root())); | 417 DepictFrameTree(root())); |
| 418 | 418 |
| 419 // Renderer-initiated navigation back to a.com. This shouldn't swap processes. | 419 // Renderer-initiated navigation back to a.com. This shouldn't swap processes. |
| 420 RendererInitiatedNavigateToURL(root(), a_url); | 420 RendererInitiatedNavigateToURL(root(), a_url); |
| 421 EXPECT_EQ( | 421 EXPECT_EQ( |
| 422 " Site B\n" | 422 " Site B\n" |
| 423 "Where B = http://b.com/", | 423 "Where B = http://b.com/", |
| 424 DepictFrameTree(root())); | 424 DepictFrameTree(root())); |
| 425 | 425 |
| 426 // Browser-initiated navigation to c.com. | 426 // Browser-initiated navigation to c.com. |
| 427 { | 427 NavigateToURL(shell(), c_url); |
| 428 RenderFrameDeletedObserver deleted_observer(root()->current_frame_host()); | |
| 429 NavigateToURL(shell(), c_url); | |
| 430 deleted_observer.WaitUntilDeleted(); | |
| 431 } | |
| 432 EXPECT_EQ( | 428 EXPECT_EQ( |
| 433 " Site C\n" | 429 " Site C\n" |
| 434 "Where C = http://c.com/", | 430 "Where C = http://c.com/", |
| 435 DepictFrameTree(root())); | 431 DepictFrameTree(root())); |
| 436 | 432 |
| 437 // Now, navigate to a fourth site with iframes to the sites in the history. | 433 // Now, navigate to a fourth site with iframes to the sites in the history. |
| 438 { | 434 NavigateToURL(shell(), |
| 439 RenderFrameDeletedObserver deleted_observer(root()->current_frame_host()); | 435 embedded_test_server()->GetURL( |
| 440 NavigateToURL(shell(), | 436 "d.com", "/cross_site_iframe_factory.html?d(a,b,c)")); |
| 441 embedded_test_server()->GetURL( | |
| 442 "d.com", "/cross_site_iframe_factory.html?d(a,b,c)")); | |
| 443 deleted_observer.WaitUntilDeleted(); | |
| 444 } | |
| 445 | 437 |
| 446 EXPECT_EQ( | 438 EXPECT_EQ( |
| 447 " Site D ------------ proxies for E\n" | 439 " Site D ------------ proxies for E\n" |
| 448 " |--Site E ------- proxies for D\n" | 440 " |--Site E ------- proxies for D\n" |
| 449 " |--Site E ------- proxies for D\n" | 441 " |--Site E ------- proxies for D\n" |
| 450 " +--Site E ------- proxies for D\n" | 442 " +--Site E ------- proxies for D\n" |
| 451 "Where D = http://d.com/\n" | 443 "Where D = http://d.com/\n" |
| 452 " E = default subframe process", | 444 " E = default subframe process", |
| 453 DepictFrameTree(root())); | 445 DepictFrameTree(root())); |
| 454 | 446 |
| 455 // Now try going back. | 447 // Now try going back. |
| 456 { | 448 GoBack(); |
| 457 RenderFrameDeletedObserver deleted_observer(root()->current_frame_host()); | |
| 458 GoBack(); | |
| 459 deleted_observer.WaitUntilDeleted(); | |
| 460 } | |
| 461 EXPECT_EQ( | 449 EXPECT_EQ( |
| 462 " Site C\n" | 450 " Site C\n" |
| 463 "Where C = http://c.com/", | 451 "Where C = http://c.com/", |
| 464 DepictFrameTree(root())); | 452 DepictFrameTree(root())); |
| 465 { | 453 GoBack(); |
| 466 RenderFrameDeletedObserver deleted_observer(root()->current_frame_host()); | |
| 467 GoBack(); | |
| 468 deleted_observer.WaitUntilDeleted(); | |
| 469 } | |
| 470 EXPECT_EQ( | 454 EXPECT_EQ( |
| 471 " Site B\n" | 455 " Site B\n" |
| 472 "Where B = http://b.com/", | 456 "Where B = http://b.com/", |
| 473 DepictFrameTree(root())); | 457 DepictFrameTree(root())); |
| 474 GoBack(); | 458 GoBack(); |
| 475 EXPECT_EQ( | 459 EXPECT_EQ( |
| 476 " Site B\n" | 460 " Site B\n" |
| 477 "Where B = http://b.com/", | 461 "Where B = http://b.com/", |
| 478 DepictFrameTree(root())); | 462 DepictFrameTree(root())); |
| 479 { | 463 GoBack(); |
| 480 RenderFrameDeletedObserver deleted_observer(root()->current_frame_host()); | |
| 481 GoBack(); | |
| 482 deleted_observer.WaitUntilDeleted(); | |
| 483 } | |
| 484 EXPECT_EQ( | 464 EXPECT_EQ( |
| 485 " Site A\n" | 465 " Site A\n" |
| 486 "Where A = http://a.com/", | 466 "Where A = http://a.com/", |
| 487 DepictFrameTree(root())); | 467 DepictFrameTree(root())); |
| 488 } | 468 } |
| 489 | 469 |
| 490 IN_PROC_BROWSER_TEST_F(TopDocumentIsolationTest, CrossSiteAtLevelTwo) { | 470 IN_PROC_BROWSER_TEST_F(TopDocumentIsolationTest, CrossSiteAtLevelTwo) { |
| 491 if (content::AreAllSitesIsolatedForTesting()) | 471 if (content::AreAllSitesIsolatedForTesting()) |
| 492 return; // Top Document Isolation is disabled in this mode. | 472 return; // Top Document Isolation is disabled in this mode. |
| 493 | 473 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 " C = http://adnetwork.com/", | 571 " C = http://adnetwork.com/", |
| 592 DepictFrameTree(root())); | 572 DepictFrameTree(root())); |
| 593 EXPECT_EQ( | 573 EXPECT_EQ( |
| 594 " Site C ------------ proxies for B\n" | 574 " Site C ------------ proxies for B\n" |
| 595 "Where B = default subframe process\n" | 575 "Where B = default subframe process\n" |
| 596 " C = http://adnetwork.com/", | 576 " C = http://adnetwork.com/", |
| 597 DepictFrameTree(popup_root)); | 577 DepictFrameTree(popup_root)); |
| 598 } | 578 } |
| 599 | 579 |
| 600 } // namespace content | 580 } // namespace content |
| OLD | NEW |