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

Side by Side Diff: content/browser/top_document_isolation_browsertest.cc

Issue 2478933002: Fix flaky OOPIF tests by waiting for the old RenderFrame to be deleted. (Closed)
Patch Set: Fix additional flakiness. Created 4 years, 1 month 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 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
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.
282 IN_PROC_BROWSER_TEST_F(TopDocumentIsolationTest, 281 IN_PROC_BROWSER_TEST_F(TopDocumentIsolationTest,
283 DISABLED_NavigateToSubframeSiteWithPopup2) { 282 NavigateToSubframeSiteWithPopup2) {
284 if (content::AreAllSitesIsolatedForTesting()) 283 if (content::AreAllSitesIsolatedForTesting())
285 return; // Top Document Isolation is disabled in this mode. 284 return; // Top Document Isolation is disabled in this mode.
286 285
287 // A(B, C) -> C(A, B), but while a separate C(A) popup exists. 286 // A(B, C) -> C(A, B), but while a separate C(A) popup exists.
288 // 287 //
289 // This test is constructed so that c.com is the second site to commit in the 288 // This test is constructed so that c.com is the second site to commit in the
290 // default subframe SiteInstance, so the default subframe SiteInstance does 289 // default subframe SiteInstance, so the default subframe SiteInstance does
291 // not have a "c.com" as the value of GetSiteURL(). 290 // not have a "c.com" as the value of GetSiteURL().
292 GURL abb_url(embedded_test_server()->GetURL( 291 GURL abb_url(embedded_test_server()->GetURL(
293 "a.com", "/cross_site_iframe_factory.html?a(b, b)")); 292 "a.com", "/cross_site_iframe_factory.html?a(b, b)"));
294 293
295 NavigateToURL(shell(), abb_url); 294 NavigateToURL(shell(), abb_url);
296 295
297 EXPECT_EQ( 296 EXPECT_EQ(
298 " Site A ------------ proxies for B\n" 297 " Site A ------------ proxies for B\n"
299 " |--Site B ------- proxies for A\n" 298 " |--Site B ------- proxies for A\n"
300 " +--Site B ------- proxies for A\n" 299 " +--Site B ------- proxies for A\n"
301 "Where A = http://a.com/\n" 300 "Where A = http://a.com/\n"
302 " B = default subframe process", 301 " B = default subframe process",
303 DepictFrameTree(root())); 302 DepictFrameTree(root()));
304 303
305 // A(B, B) -> A(B, C) 304 // A(B, B) -> A(B, C)
306 GURL c_url(embedded_test_server()->GetURL( 305 GURL c_url(embedded_test_server()->GetURL(
307 "c.com", "/cross_site_iframe_factory.html?c")); 306 "c.com", "/cross_site_iframe_factory.html?c"));
308 NavigateFrameToURL(root()->child_at(1), c_url); 307 NavigateFrameToURL(root()->child_at(1), c_url);
Łukasz Anforowicz 2016/11/07 22:08:40 No need for RenderFrameDeletedObserver here (in-be
Charlie Reis 2016/11/07 22:58:08 Interestingly, there's no process swap here, since
309 308
310 EXPECT_EQ( 309 EXPECT_EQ(
311 " Site A ------------ proxies for B\n" 310 " Site A ------------ proxies for B\n"
312 " |--Site B ------- proxies for A\n" 311 " |--Site B ------- proxies for A\n"
313 " +--Site B ------- proxies for A\n" 312 " +--Site B ------- proxies for A\n"
314 "Where A = http://a.com/\n" 313 "Where A = http://a.com/\n"
315 " B = default subframe process", 314 " B = default subframe process",
316 DepictFrameTree(root())); 315 DepictFrameTree(root()));
317 316
318 // This test exercises what happens when the SiteURL of the default subframe 317 // This test exercises what happens when the SiteURL of the default subframe
(...skipping 16 matching lines...) Expand all
335 334
336 // The popup must stay with its opener, in the default subframe process. 335 // The popup must stay with its opener, in the default subframe process.
337 EXPECT_EQ( 336 EXPECT_EQ(
338 " Site B\n" 337 " Site B\n"
339 " +--Site B\n" 338 " +--Site B\n"
340 "Where B = default subframe process", 339 "Where B = default subframe process",
341 DepictFrameTree(popup_root)); 340 DepictFrameTree(popup_root));
342 341
343 GURL cab_url(embedded_test_server()->GetURL( 342 GURL cab_url(embedded_test_server()->GetURL(
344 "c.com", "/cross_site_iframe_factory.html?c(a, b)")); 343 "c.com", "/cross_site_iframe_factory.html?c(a, b)"));
345 NavigateToURL(shell(), cab_url); 344 {
345 RenderFrameDeletedObserver deleted_observer(root()->current_frame_host());
346 NavigateToURL(shell(), cab_url);
347 deleted_observer.WaitUntilDeleted();
348 }
346 349
347 // This c.com navigation currently breaks out of the default subframe process, 350 // This c.com navigation currently breaks out of the default subframe process,
348 // even though that process houses a c.com pop-up. 351 // even though that process houses a c.com pop-up.
349 EXPECT_EQ( 352 EXPECT_EQ(
350 " Site C ------------ proxies for B\n" 353 " Site C ------------ proxies for B\n"
351 " |--Site B ------- proxies for C\n" 354 " |--Site B ------- proxies for C\n"
352 " +--Site B ------- proxies for C\n" 355 " +--Site B ------- proxies for C\n"
353 "Where B = default subframe process\n" 356 "Where B = default subframe process\n"
354 " C = http://c.com/", 357 " C = http://c.com/",
355 DepictFrameTree(root())); 358 DepictFrameTree(root()));
356 359
357 // c.com popup should remain where it was, in the subframe process. 360 // c.com popup should remain where it was, in the subframe process.
358 EXPECT_EQ( 361 EXPECT_EQ(
359 " Site B\n" 362 " Site B\n"
360 " +--Site B\n" 363 " +--Site B\n"
361 "Where B = default subframe process", 364 "Where B = default subframe process",
362 DepictFrameTree(popup_root)); 365 DepictFrameTree(popup_root));
363 EXPECT_EQ(nullptr, popup_root->opener()); 366 EXPECT_EQ(nullptr, popup_root->opener());
364 367
365 // If we navigate the popup to a new site, it ought to transfer processes. 368 // If we navigate the popup to a new site, it ought to transfer processes.
366 GURL d_url(embedded_test_server()->GetURL( 369 GURL d_url(embedded_test_server()->GetURL(
367 "d.com", "/cross_site_iframe_factory.html?d")); 370 "d.com", "/cross_site_iframe_factory.html?d"));
368 NavigateToURL(popup, d_url); 371 {
372 RenderFrameDeletedObserver deleted_observer(
373 popup_root->current_frame_host());
374 NavigateToURL(popup, d_url);
375 deleted_observer.WaitUntilDeleted();
376 }
369 EXPECT_EQ( 377 EXPECT_EQ(
370 " Site D ------------ proxies for B\n" 378 " Site D ------------ proxies for B\n"
371 "Where B = default subframe process\n" 379 "Where B = default subframe process\n"
372 " D = http://d.com/", 380 " D = http://d.com/",
373 DepictFrameTree(popup_root)); 381 DepictFrameTree(popup_root));
374 NavigateToURL(shell(), d_url); 382 {
383 RenderFrameDeletedObserver deleted_observer(root()->current_frame_host());
384 NavigateToURL(shell(), d_url);
385 deleted_observer.WaitUntilDeleted();
386 }
375 EXPECT_EQ( 387 EXPECT_EQ(
376 " Site D\n" 388 " Site D\n"
377 "Where D = http://d.com/", 389 "Where D = http://d.com/",
378 DepictFrameTree(popup_root)); 390 DepictFrameTree(popup_root));
379 EXPECT_EQ( 391 EXPECT_EQ(
380 " Site D\n" 392 " Site D\n"
381 "Where D = http://d.com/", 393 "Where D = http://d.com/",
382 DepictFrameTree(root())); 394 DepictFrameTree(root()));
383 } 395 }
384 396
385 // Flaky on Mac. See https://crbug.com/611344. 397 IN_PROC_BROWSER_TEST_F(TopDocumentIsolationTest, FramesForSitesInHistory) {
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) {
394 if (content::AreAllSitesIsolatedForTesting()) 398 if (content::AreAllSitesIsolatedForTesting())
395 return; // Top Document Isolation is disabled in this mode. 399 return; // Top Document Isolation is disabled in this mode.
396 400
397 // First, do a series of navigations. 401 // First, do a series of navigations.
398 GURL a_url = embedded_test_server()->GetURL( 402 GURL a_url = embedded_test_server()->GetURL(
399 "a.com", "/cross_site_iframe_factory.html?a"); 403 "a.com", "/cross_site_iframe_factory.html?a");
400 GURL b_url = embedded_test_server()->GetURL( 404 GURL b_url = embedded_test_server()->GetURL(
401 "b.com", "/cross_site_iframe_factory.html?b"); 405 "b.com", "/cross_site_iframe_factory.html?b");
402 GURL c_url = embedded_test_server()->GetURL( 406 GURL c_url = embedded_test_server()->GetURL(
403 "c.com", "/cross_site_iframe_factory.html?c"); 407 "c.com", "/cross_site_iframe_factory.html?c");
404 408
405 // Browser-initiated navigation to a.com. 409 // Browser-initiated navigation to a.com.
406 NavigateToURL(shell(), a_url); 410 NavigateToURL(shell(), a_url);
407 EXPECT_EQ( 411 EXPECT_EQ(
408 " Site A\n" 412 " Site A\n"
409 "Where A = http://a.com/", 413 "Where A = http://a.com/",
410 DepictFrameTree(root())); 414 DepictFrameTree(root()));
411 415
412 // Browser-initiated navigation to b.com. 416 // Browser-initiated navigation to b.com.
413 NavigateToURL(shell(), b_url); 417 {
418 // For any cross-process navigations, we must wait for the old RenderFrame
419 // to be deleted before calling DepictFrameTree, or else there's a chance
420 // the old SiteInstance could be listed while pending deletion.
421 RenderFrameDeletedObserver deleted_observer(root()->current_frame_host());
422 NavigateToURL(shell(), b_url);
423 deleted_observer.WaitUntilDeleted();
424 }
414 EXPECT_EQ( 425 EXPECT_EQ(
415 " Site B\n" 426 " Site B\n"
416 "Where B = http://b.com/", 427 "Where B = http://b.com/",
417 DepictFrameTree(root())); 428 DepictFrameTree(root()));
418 429
419 // Renderer-initiated navigation back to a.com. This shouldn't swap processes. 430 // Renderer-initiated navigation back to a.com. This shouldn't swap processes.
420 RendererInitiatedNavigateToURL(root(), a_url); 431 RendererInitiatedNavigateToURL(root(), a_url);
421 EXPECT_EQ( 432 EXPECT_EQ(
422 " Site B\n" 433 " Site B\n"
423 "Where B = http://b.com/", 434 "Where B = http://b.com/",
424 DepictFrameTree(root())); 435 DepictFrameTree(root()));
425 436
426 // Browser-initiated navigation to c.com. 437 // Browser-initiated navigation to c.com.
427 NavigateToURL(shell(), c_url); 438 {
439 RenderFrameDeletedObserver deleted_observer(root()->current_frame_host());
440 NavigateToURL(shell(), c_url);
441 deleted_observer.WaitUntilDeleted();
442 }
428 EXPECT_EQ( 443 EXPECT_EQ(
429 " Site C\n" 444 " Site C\n"
430 "Where C = http://c.com/", 445 "Where C = http://c.com/",
431 DepictFrameTree(root())); 446 DepictFrameTree(root()));
432 447
433 // Now, navigate to a fourth site with iframes to the sites in the history. 448 // Now, navigate to a fourth site with iframes to the sites in the history.
434 NavigateToURL(shell(), 449 {
435 embedded_test_server()->GetURL( 450 RenderFrameDeletedObserver deleted_observer(root()->current_frame_host());
436 "d.com", "/cross_site_iframe_factory.html?d(a,b,c)")); 451 NavigateToURL(shell(),
452 embedded_test_server()->GetURL(
453 "d.com", "/cross_site_iframe_factory.html?d(a,b,c)"));
454 deleted_observer.WaitUntilDeleted();
455 }
437 456
438 EXPECT_EQ( 457 EXPECT_EQ(
439 " Site D ------------ proxies for E\n" 458 " Site D ------------ proxies for E\n"
440 " |--Site E ------- proxies for D\n" 459 " |--Site E ------- proxies for D\n"
441 " |--Site E ------- proxies for D\n" 460 " |--Site E ------- proxies for D\n"
442 " +--Site E ------- proxies for D\n" 461 " +--Site E ------- proxies for D\n"
443 "Where D = http://d.com/\n" 462 "Where D = http://d.com/\n"
444 " E = default subframe process", 463 " E = default subframe process",
445 DepictFrameTree(root())); 464 DepictFrameTree(root()));
446 465
447 // Now try going back. 466 // Now try going back.
448 GoBack(); 467 {
468 RenderFrameDeletedObserver deleted_observer(root()->current_frame_host());
469 GoBack();
470 deleted_observer.WaitUntilDeleted();
471 }
449 EXPECT_EQ( 472 EXPECT_EQ(
450 " Site C\n" 473 " Site C\n"
451 "Where C = http://c.com/", 474 "Where C = http://c.com/",
452 DepictFrameTree(root())); 475 DepictFrameTree(root()));
453 GoBack(); 476 {
477 RenderFrameDeletedObserver deleted_observer(root()->current_frame_host());
478 GoBack();
479 deleted_observer.WaitUntilDeleted();
480 }
454 EXPECT_EQ( 481 EXPECT_EQ(
455 " Site B\n" 482 " Site B\n"
456 "Where B = http://b.com/", 483 "Where B = http://b.com/",
457 DepictFrameTree(root())); 484 DepictFrameTree(root()));
458 GoBack(); 485 GoBack();
459 EXPECT_EQ( 486 EXPECT_EQ(
460 " Site B\n" 487 " Site B\n"
461 "Where B = http://b.com/", 488 "Where B = http://b.com/",
462 DepictFrameTree(root())); 489 DepictFrameTree(root()));
463 GoBack(); 490 {
491 RenderFrameDeletedObserver deleted_observer(root()->current_frame_host());
492 GoBack();
493 deleted_observer.WaitUntilDeleted();
494 }
464 EXPECT_EQ( 495 EXPECT_EQ(
465 " Site A\n" 496 " Site A\n"
466 "Where A = http://a.com/", 497 "Where A = http://a.com/",
467 DepictFrameTree(root())); 498 DepictFrameTree(root()));
468 } 499 }
469 500
470 IN_PROC_BROWSER_TEST_F(TopDocumentIsolationTest, CrossSiteAtLevelTwo) { 501 IN_PROC_BROWSER_TEST_F(TopDocumentIsolationTest, CrossSiteAtLevelTwo) {
471 if (content::AreAllSitesIsolatedForTesting()) 502 if (content::AreAllSitesIsolatedForTesting())
472 return; // Top Document Isolation is disabled in this mode. 503 return; // Top Document Isolation is disabled in this mode.
473 504
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 " C = http://adnetwork.com/", 602 " C = http://adnetwork.com/",
572 DepictFrameTree(root())); 603 DepictFrameTree(root()));
573 EXPECT_EQ( 604 EXPECT_EQ(
574 " Site C ------------ proxies for B\n" 605 " Site C ------------ proxies for B\n"
575 "Where B = default subframe process\n" 606 "Where B = default subframe process\n"
576 " C = http://adnetwork.com/", 607 " C = http://adnetwork.com/",
577 DepictFrameTree(popup_root)); 608 DepictFrameTree(popup_root));
578 } 609 }
579 610
580 } // namespace content 611 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698