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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "content/browser/frame_host/cross_site_transferring_request.h" | 8 #include "content/browser/frame_host/cross_site_transferring_request.h" |
9 #include "content/browser/frame_host/interstitial_page_impl.h" | 9 #include "content/browser/frame_host/interstitial_page_impl.h" |
10 #include "content/browser/frame_host/navigation_entry_impl.h" | 10 #include "content/browser/frame_host/navigation_entry_impl.h" |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
432 // Test simple same-SiteInstance navigation. | 432 // Test simple same-SiteInstance navigation. |
433 TEST_F(WebContentsImplTest, SimpleNavigation) { | 433 TEST_F(WebContentsImplTest, SimpleNavigation) { |
434 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); | 434 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); |
435 SiteInstance* instance1 = contents()->GetSiteInstance(); | 435 SiteInstance* instance1 = contents()->GetSiteInstance(); |
436 EXPECT_EQ(nullptr, contents()->GetPendingMainFrame()); | 436 EXPECT_EQ(nullptr, contents()->GetPendingMainFrame()); |
437 | 437 |
438 // Navigate to URL | 438 // Navigate to URL |
439 const GURL url("http://www.google.com"); | 439 const GURL url("http://www.google.com"); |
440 controller().LoadURL( | 440 controller().LoadURL( |
441 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 441 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
442 EXPECT_FALSE(contents()->cross_navigation_pending()); | 442 EXPECT_FALSE(contents()->CrossNavigationPending()); |
443 EXPECT_EQ(instance1, orig_rfh->GetSiteInstance()); | 443 EXPECT_EQ(instance1, orig_rfh->GetSiteInstance()); |
444 // Controller's pending entry will have a null site instance until we assign | 444 // Controller's pending entry will have a null site instance until we assign |
445 // it in DidNavigate. | 445 // it in DidNavigate. |
446 EXPECT_EQ( | 446 EXPECT_EQ( |
447 nullptr, | 447 nullptr, |
448 NavigationEntryImpl::FromNavigationEntry(controller().GetVisibleEntry())-> | 448 NavigationEntryImpl::FromNavigationEntry(controller().GetVisibleEntry())-> |
449 site_instance()); | 449 site_instance()); |
450 | 450 |
451 // DidNavigate from the page | 451 // DidNavigate from the page |
452 main_test_rfh()->PrepareForCommit(); | |
nasko
2015/04/15 21:12:46
What condition requires us to call PrepareForCommi
clamy
2015/04/16 13:18:36
Calling TestDidNavigate. This dates from when I ad
| |
452 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); | 453 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); |
453 EXPECT_FALSE(contents()->cross_navigation_pending()); | 454 EXPECT_FALSE(contents()->CrossNavigationPending()); |
454 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); | 455 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); |
455 EXPECT_EQ(instance1, orig_rfh->GetSiteInstance()); | 456 EXPECT_EQ(instance1, orig_rfh->GetSiteInstance()); |
456 // Controller's entry should now have the SiteInstance, or else we won't be | 457 // Controller's entry should now have the SiteInstance, or else we won't be |
457 // able to find it later. | 458 // able to find it later. |
458 EXPECT_EQ( | 459 EXPECT_EQ( |
459 instance1, | 460 instance1, |
460 NavigationEntryImpl::FromNavigationEntry(controller().GetVisibleEntry())-> | 461 NavigationEntryImpl::FromNavigationEntry(controller().GetVisibleEntry())-> |
461 site_instance()); | 462 site_instance()); |
462 } | 463 } |
463 | 464 |
(...skipping 20 matching lines...) Expand all Loading... | |
484 const GURL url("http://www.google.com"); | 485 const GURL url("http://www.google.com"); |
485 controller().LoadURL( | 486 controller().LoadURL( |
486 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 487 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
487 orig_rfh->PrepareForCommit(); | 488 orig_rfh->PrepareForCommit(); |
488 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); | 489 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); |
489 | 490 |
490 // Keep the number of active frames in orig_rfh's SiteInstance non-zero so | 491 // Keep the number of active frames in orig_rfh's SiteInstance non-zero so |
491 // that orig_rfh doesn't get deleted when it gets swapped out. | 492 // that orig_rfh doesn't get deleted when it gets swapped out. |
492 orig_rfh->GetSiteInstance()->increment_active_frame_count(); | 493 orig_rfh->GetSiteInstance()->increment_active_frame_count(); |
493 | 494 |
494 EXPECT_FALSE(contents()->cross_navigation_pending()); | 495 EXPECT_FALSE(contents()->CrossNavigationPending()); |
495 EXPECT_EQ(orig_rfh->GetRenderViewHost(), contents()->GetRenderViewHost()); | 496 EXPECT_EQ(orig_rfh->GetRenderViewHost(), contents()->GetRenderViewHost()); |
496 EXPECT_EQ(url, contents()->GetLastCommittedURL()); | 497 EXPECT_EQ(url, contents()->GetLastCommittedURL()); |
497 EXPECT_EQ(url, contents()->GetVisibleURL()); | 498 EXPECT_EQ(url, contents()->GetVisibleURL()); |
498 | 499 |
499 // Navigate to new site | 500 // Navigate to new site |
500 const GURL url2("http://www.yahoo.com"); | 501 const GURL url2("http://www.yahoo.com"); |
501 controller().LoadURL( | 502 controller().LoadURL( |
502 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 503 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
503 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 504 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
504 switches::kEnableBrowserSideNavigation)) { | 505 switches::kEnableBrowserSideNavigation)) { |
505 orig_rfh->PrepareForCommit(); | 506 orig_rfh->PrepareForCommit(); |
506 } | 507 } |
507 EXPECT_TRUE(contents()->cross_navigation_pending()); | 508 EXPECT_TRUE(contents()->CrossNavigationPending()); |
508 EXPECT_EQ(url, contents()->GetLastCommittedURL()); | 509 EXPECT_EQ(url, contents()->GetLastCommittedURL()); |
509 EXPECT_EQ(url2, contents()->GetVisibleURL()); | 510 EXPECT_EQ(url2, contents()->GetVisibleURL()); |
510 TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame(); | 511 TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame(); |
511 int pending_rvh_delete_count = 0; | 512 int pending_rvh_delete_count = 0; |
512 pending_rfh->GetRenderViewHost()->set_delete_counter( | 513 pending_rfh->GetRenderViewHost()->set_delete_counter( |
513 &pending_rvh_delete_count); | 514 &pending_rvh_delete_count); |
514 | 515 |
515 // Navigations should be suspended in pending_rfh until BeforeUnloadACK. | 516 // Navigations should be suspended in pending_rfh until BeforeUnloadACK. |
516 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 517 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
517 switches::kEnableBrowserSideNavigation)) { | 518 switches::kEnableBrowserSideNavigation)) { |
518 EXPECT_TRUE(pending_rfh->are_navigations_suspended()); | 519 EXPECT_TRUE(pending_rfh->are_navigations_suspended()); |
519 orig_rfh->SendBeforeUnloadACK(true); | 520 orig_rfh->SendBeforeUnloadACK(true); |
520 EXPECT_FALSE(pending_rfh->are_navigations_suspended()); | 521 EXPECT_FALSE(pending_rfh->are_navigations_suspended()); |
521 } | 522 } |
522 | 523 |
523 // DidNavigate from the pending page | 524 // DidNavigate from the pending page |
524 contents()->TestDidNavigate( | 525 contents()->TestDidNavigate( |
525 pending_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); | 526 pending_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); |
526 SiteInstance* instance2 = contents()->GetSiteInstance(); | 527 SiteInstance* instance2 = contents()->GetSiteInstance(); |
527 | 528 |
528 // Keep the number of active frames in pending_rfh's SiteInstance | 529 // Keep the number of active frames in pending_rfh's SiteInstance |
529 // non-zero so that orig_rfh doesn't get deleted when it gets | 530 // non-zero so that orig_rfh doesn't get deleted when it gets |
530 // swapped out. | 531 // swapped out. |
531 pending_rfh->GetSiteInstance()->increment_active_frame_count(); | 532 pending_rfh->GetSiteInstance()->increment_active_frame_count(); |
532 | 533 |
533 EXPECT_FALSE(contents()->cross_navigation_pending()); | 534 EXPECT_FALSE(contents()->CrossNavigationPending()); |
534 EXPECT_EQ(pending_rfh, contents()->GetMainFrame()); | 535 EXPECT_EQ(pending_rfh, contents()->GetMainFrame()); |
535 EXPECT_EQ(url2, contents()->GetLastCommittedURL()); | 536 EXPECT_EQ(url2, contents()->GetLastCommittedURL()); |
536 EXPECT_EQ(url2, contents()->GetVisibleURL()); | 537 EXPECT_EQ(url2, contents()->GetVisibleURL()); |
537 EXPECT_NE(instance1, instance2); | 538 EXPECT_NE(instance1, instance2); |
538 EXPECT_EQ(nullptr, contents()->GetPendingMainFrame()); | 539 EXPECT_EQ(nullptr, contents()->GetPendingMainFrame()); |
539 // We keep the original RFH around, swapped out. | 540 // We keep the original RFH around, swapped out. |
540 EXPECT_TRUE(contents()->GetRenderManagerForTesting()->IsOnSwappedOutList( | 541 EXPECT_TRUE(contents()->GetRenderManagerForTesting()->IsOnSwappedOutList( |
541 orig_rfh)); | 542 orig_rfh)); |
542 EXPECT_EQ(orig_rvh_delete_count, 0); | 543 EXPECT_EQ(orig_rvh_delete_count, 0); |
543 | 544 |
544 // Going back should switch SiteInstances again. The first SiteInstance is | 545 // Going back should switch SiteInstances again. The first SiteInstance is |
545 // stored in the NavigationEntry, so it should be the same as at the start. | 546 // stored in the NavigationEntry, so it should be the same as at the start. |
546 // We should use the same RFH as before, swapping it back in. | 547 // We should use the same RFH as before, swapping it back in. |
547 controller().GoBack(); | 548 controller().GoBack(); |
548 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 549 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
549 switches::kEnableBrowserSideNavigation)) { | 550 switches::kEnableBrowserSideNavigation)) { |
550 contents()->GetMainFrame()->PrepareForCommit(); | 551 contents()->GetMainFrame()->PrepareForCommit(); |
551 } | 552 } |
552 TestRenderFrameHost* goback_rfh = contents()->GetPendingMainFrame(); | 553 TestRenderFrameHost* goback_rfh = contents()->GetPendingMainFrame(); |
553 EXPECT_EQ(orig_rfh, goback_rfh); | 554 EXPECT_EQ(orig_rfh, goback_rfh); |
554 EXPECT_TRUE(contents()->cross_navigation_pending()); | 555 EXPECT_TRUE(contents()->CrossNavigationPending()); |
555 | 556 |
556 // Navigations should be suspended in goback_rfh until BeforeUnloadACK. | 557 // Navigations should be suspended in goback_rfh until BeforeUnloadACK. |
557 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 558 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
558 switches::kEnableBrowserSideNavigation)) { | 559 switches::kEnableBrowserSideNavigation)) { |
559 EXPECT_TRUE(goback_rfh->are_navigations_suspended()); | 560 EXPECT_TRUE(goback_rfh->are_navigations_suspended()); |
560 pending_rfh->SendBeforeUnloadACK(true); | 561 pending_rfh->SendBeforeUnloadACK(true); |
561 EXPECT_FALSE(goback_rfh->are_navigations_suspended()); | 562 EXPECT_FALSE(goback_rfh->are_navigations_suspended()); |
562 } | 563 } |
563 | 564 |
564 // DidNavigate from the back action | 565 // DidNavigate from the back action |
565 contents()->TestDidNavigate(goback_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); | 566 contents()->TestDidNavigate(goback_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); |
566 EXPECT_FALSE(contents()->cross_navigation_pending()); | 567 EXPECT_FALSE(contents()->CrossNavigationPending()); |
567 EXPECT_EQ(goback_rfh, contents()->GetMainFrame()); | 568 EXPECT_EQ(goback_rfh, contents()->GetMainFrame()); |
568 EXPECT_EQ(instance1, contents()->GetSiteInstance()); | 569 EXPECT_EQ(instance1, contents()->GetSiteInstance()); |
569 // The pending RFH should now be swapped out, not deleted. | 570 // The pending RFH should now be swapped out, not deleted. |
570 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> | 571 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> |
571 IsOnSwappedOutList(pending_rfh)); | 572 IsOnSwappedOutList(pending_rfh)); |
572 EXPECT_EQ(pending_rvh_delete_count, 0); | 573 EXPECT_EQ(pending_rvh_delete_count, 0); |
573 pending_rfh->OnSwappedOut(); | 574 pending_rfh->OnSwappedOut(); |
574 | 575 |
575 // Close contents and ensure RVHs are deleted. | 576 // Close contents and ensure RVHs are deleted. |
576 DeleteContents(); | 577 DeleteContents(); |
(...skipping 10 matching lines...) Expand all Loading... | |
587 orig_rfh->GetRenderViewHost()->set_delete_counter(&orig_rvh_delete_count); | 588 orig_rfh->GetRenderViewHost()->set_delete_counter(&orig_rvh_delete_count); |
588 SiteInstance* instance1 = contents()->GetSiteInstance(); | 589 SiteInstance* instance1 = contents()->GetSiteInstance(); |
589 | 590 |
590 // Navigate to URL. First URL should use first RenderViewHost. | 591 // Navigate to URL. First URL should use first RenderViewHost. |
591 const GURL url("http://www.google.com"); | 592 const GURL url("http://www.google.com"); |
592 controller().LoadURL( | 593 controller().LoadURL( |
593 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 594 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
594 contents()->GetMainFrame()->PrepareForCommit(); | 595 contents()->GetMainFrame()->PrepareForCommit(); |
595 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); | 596 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); |
596 | 597 |
597 EXPECT_FALSE(contents()->cross_navigation_pending()); | 598 EXPECT_FALSE(contents()->CrossNavigationPending()); |
598 EXPECT_EQ(orig_rfh->GetRenderViewHost(), contents()->GetRenderViewHost()); | 599 EXPECT_EQ(orig_rfh->GetRenderViewHost(), contents()->GetRenderViewHost()); |
599 | 600 |
600 // Simulate a renderer crash. | 601 // Simulate a renderer crash. |
601 orig_rfh->GetRenderViewHost()->set_render_view_created(false); | 602 orig_rfh->GetRenderViewHost()->set_render_view_created(false); |
602 orig_rfh->SetRenderFrameCreated(false); | 603 orig_rfh->SetRenderFrameCreated(false); |
603 | 604 |
604 // Navigate to new site. We should not go into PENDING. | 605 // Navigate to new site. We should not go into PENDING. |
605 const GURL url2("http://www.yahoo.com"); | 606 const GURL url2("http://www.yahoo.com"); |
606 controller().LoadURL( | 607 controller().LoadURL( |
607 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 608 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
608 contents()->GetMainFrame()->PrepareForCommit(); | 609 contents()->GetMainFrame()->PrepareForCommit(); |
609 TestRenderFrameHost* new_rfh = contents()->GetMainFrame(); | 610 TestRenderFrameHost* new_rfh = contents()->GetMainFrame(); |
610 EXPECT_FALSE(contents()->cross_navigation_pending()); | 611 EXPECT_FALSE(contents()->CrossNavigationPending()); |
611 EXPECT_EQ(nullptr, contents()->GetPendingMainFrame()); | 612 EXPECT_EQ(nullptr, contents()->GetPendingMainFrame()); |
612 EXPECT_NE(orig_rfh, new_rfh); | 613 EXPECT_NE(orig_rfh, new_rfh); |
613 EXPECT_EQ(orig_rvh_delete_count, 1); | 614 EXPECT_EQ(orig_rvh_delete_count, 1); |
614 | 615 |
615 // DidNavigate from the new page | 616 // DidNavigate from the new page |
616 contents()->TestDidNavigate(new_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); | 617 contents()->TestDidNavigate(new_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); |
617 SiteInstance* instance2 = contents()->GetSiteInstance(); | 618 SiteInstance* instance2 = contents()->GetSiteInstance(); |
618 | 619 |
619 EXPECT_FALSE(contents()->cross_navigation_pending()); | 620 EXPECT_FALSE(contents()->CrossNavigationPending()); |
620 EXPECT_EQ(new_rfh, main_rfh()); | 621 EXPECT_EQ(new_rfh, main_rfh()); |
621 EXPECT_NE(instance1, instance2); | 622 EXPECT_NE(instance1, instance2); |
622 EXPECT_EQ(nullptr, contents()->GetPendingMainFrame()); | 623 EXPECT_EQ(nullptr, contents()->GetPendingMainFrame()); |
623 | 624 |
624 // Close contents and ensure RVHs are deleted. | 625 // Close contents and ensure RVHs are deleted. |
625 DeleteContents(); | 626 DeleteContents(); |
626 EXPECT_EQ(orig_rvh_delete_count, 1); | 627 EXPECT_EQ(orig_rvh_delete_count, 1); |
627 } | 628 } |
628 | 629 |
629 // Test that opening a new contents in the same SiteInstance and then navigating | 630 // Test that opening a new contents in the same SiteInstance and then navigating |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
665 | 666 |
666 // Navigate second contents to the same site as the first tab. | 667 // Navigate second contents to the same site as the first tab. |
667 const GURL url2b("http://mail.yahoo.com"); | 668 const GURL url2b("http://mail.yahoo.com"); |
668 contents2->GetController().LoadURL(url2b, Referrer(), | 669 contents2->GetController().LoadURL(url2b, Referrer(), |
669 ui::PAGE_TRANSITION_TYPED, | 670 ui::PAGE_TRANSITION_TYPED, |
670 std::string()); | 671 std::string()); |
671 TestRenderFrameHost* rfh2 = contents2->GetMainFrame(); | 672 TestRenderFrameHost* rfh2 = contents2->GetMainFrame(); |
672 rfh2->PrepareForCommit(); | 673 rfh2->PrepareForCommit(); |
673 TestRenderFrameHost* pending_rfh_b = contents2->GetPendingMainFrame(); | 674 TestRenderFrameHost* pending_rfh_b = contents2->GetPendingMainFrame(); |
674 EXPECT_NE(nullptr, pending_rfh_b); | 675 EXPECT_NE(nullptr, pending_rfh_b); |
675 EXPECT_TRUE(contents2->cross_navigation_pending()); | 676 EXPECT_TRUE(contents2->CrossNavigationPending()); |
676 | 677 |
677 // NOTE(creis): We used to be in danger of showing a crash page here if the | 678 // NOTE(creis): We used to be in danger of showing a crash page here if the |
678 // second contents hadn't navigated somewhere first (bug 1145430). That case | 679 // second contents hadn't navigated somewhere first (bug 1145430). That case |
679 // is now covered by the CrossSiteBoundariesAfterCrash test. | 680 // is now covered by the CrossSiteBoundariesAfterCrash test. |
680 contents2->TestDidNavigate( | 681 contents2->TestDidNavigate( |
681 pending_rfh_b, 2, url2b, ui::PAGE_TRANSITION_TYPED); | 682 pending_rfh_b, 2, url2b, ui::PAGE_TRANSITION_TYPED); |
682 SiteInstance* instance2b = contents2->GetSiteInstance(); | 683 SiteInstance* instance2b = contents2->GetSiteInstance(); |
683 EXPECT_NE(instance1, instance2b); | 684 EXPECT_NE(instance1, instance2b); |
684 | 685 |
685 // Both contentses should now be in the same SiteInstance. | 686 // Both contentses should now be in the same SiteInstance. |
(...skipping 15 matching lines...) Expand all Loading... | |
701 | 702 |
702 browser_client.set_assign_site_for_url(false); | 703 browser_client.set_assign_site_for_url(false); |
703 // Navigate to an URL that will not assign a new SiteInstance. | 704 // Navigate to an URL that will not assign a new SiteInstance. |
704 const GURL native_url("non-site-url://stuffandthings"); | 705 const GURL native_url("non-site-url://stuffandthings"); |
705 controller().LoadURL( | 706 controller().LoadURL( |
706 native_url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 707 native_url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
707 contents()->GetMainFrame()->PrepareForCommit(); | 708 contents()->GetMainFrame()->PrepareForCommit(); |
708 contents()->TestDidNavigate( | 709 contents()->TestDidNavigate( |
709 orig_rfh, 1, native_url, ui::PAGE_TRANSITION_TYPED); | 710 orig_rfh, 1, native_url, ui::PAGE_TRANSITION_TYPED); |
710 | 711 |
711 EXPECT_FALSE(contents()->cross_navigation_pending()); | 712 EXPECT_FALSE(contents()->CrossNavigationPending()); |
712 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); | 713 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); |
713 EXPECT_EQ(native_url, contents()->GetLastCommittedURL()); | 714 EXPECT_EQ(native_url, contents()->GetLastCommittedURL()); |
714 EXPECT_EQ(native_url, contents()->GetVisibleURL()); | 715 EXPECT_EQ(native_url, contents()->GetVisibleURL()); |
715 EXPECT_EQ(orig_instance, contents()->GetSiteInstance()); | 716 EXPECT_EQ(orig_instance, contents()->GetSiteInstance()); |
716 EXPECT_EQ(GURL(), contents()->GetSiteInstance()->GetSiteURL()); | 717 EXPECT_EQ(GURL(), contents()->GetSiteInstance()->GetSiteURL()); |
717 EXPECT_FALSE(orig_instance->HasSite()); | 718 EXPECT_FALSE(orig_instance->HasSite()); |
718 | 719 |
719 browser_client.set_assign_site_for_url(true); | 720 browser_client.set_assign_site_for_url(true); |
720 // Navigate to new site (should keep same site instance). | 721 // Navigate to new site (should keep same site instance). |
721 const GURL url("http://www.google.com"); | 722 const GURL url("http://www.google.com"); |
722 controller().LoadURL( | 723 controller().LoadURL( |
723 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 724 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
724 contents()->GetMainFrame()->PrepareForCommit(); | 725 contents()->GetMainFrame()->PrepareForCommit(); |
725 EXPECT_FALSE(contents()->cross_navigation_pending()); | 726 EXPECT_FALSE(contents()->CrossNavigationPending()); |
726 EXPECT_EQ(native_url, contents()->GetLastCommittedURL()); | 727 EXPECT_EQ(native_url, contents()->GetLastCommittedURL()); |
727 EXPECT_EQ(url, contents()->GetVisibleURL()); | 728 EXPECT_EQ(url, contents()->GetVisibleURL()); |
728 EXPECT_FALSE(contents()->GetPendingMainFrame()); | 729 EXPECT_FALSE(contents()->GetPendingMainFrame()); |
729 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); | 730 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); |
730 | 731 |
731 // Keep the number of active frames in orig_rfh's SiteInstance | 732 // Keep the number of active frames in orig_rfh's SiteInstance |
732 // non-zero so that orig_rfh doesn't get deleted when it gets | 733 // non-zero so that orig_rfh doesn't get deleted when it gets |
733 // swapped out. | 734 // swapped out. |
734 orig_rfh->GetSiteInstance()->increment_active_frame_count(); | 735 orig_rfh->GetSiteInstance()->increment_active_frame_count(); |
735 | 736 |
736 EXPECT_EQ(orig_instance, contents()->GetSiteInstance()); | 737 EXPECT_EQ(orig_instance, contents()->GetSiteInstance()); |
737 EXPECT_TRUE( | 738 EXPECT_TRUE( |
738 contents()->GetSiteInstance()->GetSiteURL().DomainIs("google.com")); | 739 contents()->GetSiteInstance()->GetSiteURL().DomainIs("google.com")); |
739 EXPECT_EQ(url, contents()->GetLastCommittedURL()); | 740 EXPECT_EQ(url, contents()->GetLastCommittedURL()); |
740 | 741 |
741 // Navigate to another new site (should create a new site instance). | 742 // Navigate to another new site (should create a new site instance). |
742 const GURL url2("http://www.yahoo.com"); | 743 const GURL url2("http://www.yahoo.com"); |
743 controller().LoadURL( | 744 controller().LoadURL( |
744 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 745 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
745 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 746 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
746 switches::kEnableBrowserSideNavigation)) { | 747 switches::kEnableBrowserSideNavigation)) { |
747 orig_rfh->PrepareForCommit(); | 748 orig_rfh->PrepareForCommit(); |
748 } | 749 } |
749 EXPECT_TRUE(contents()->cross_navigation_pending()); | 750 EXPECT_TRUE(contents()->CrossNavigationPending()); |
750 EXPECT_EQ(url, contents()->GetLastCommittedURL()); | 751 EXPECT_EQ(url, contents()->GetLastCommittedURL()); |
751 EXPECT_EQ(url2, contents()->GetVisibleURL()); | 752 EXPECT_EQ(url2, contents()->GetVisibleURL()); |
752 TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame(); | 753 TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame(); |
753 int pending_rvh_delete_count = 0; | 754 int pending_rvh_delete_count = 0; |
754 pending_rfh->GetRenderViewHost()->set_delete_counter( | 755 pending_rfh->GetRenderViewHost()->set_delete_counter( |
755 &pending_rvh_delete_count); | 756 &pending_rvh_delete_count); |
756 | 757 |
757 // Navigations should be suspended in pending_rvh until BeforeUnloadACK. | 758 // Navigations should be suspended in pending_rvh until BeforeUnloadACK. |
758 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 759 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
759 switches::kEnableBrowserSideNavigation)) { | 760 switches::kEnableBrowserSideNavigation)) { |
760 EXPECT_TRUE(pending_rfh->are_navigations_suspended()); | 761 EXPECT_TRUE(pending_rfh->are_navigations_suspended()); |
761 orig_rfh->SendBeforeUnloadACK(true); | 762 orig_rfh->SendBeforeUnloadACK(true); |
762 EXPECT_FALSE(pending_rfh->are_navigations_suspended()); | 763 EXPECT_FALSE(pending_rfh->are_navigations_suspended()); |
763 } | 764 } |
764 | 765 |
765 // DidNavigate from the pending page. | 766 // DidNavigate from the pending page. |
766 contents()->TestDidNavigate( | 767 contents()->TestDidNavigate( |
767 pending_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); | 768 pending_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); |
768 SiteInstance* new_instance = contents()->GetSiteInstance(); | 769 SiteInstance* new_instance = contents()->GetSiteInstance(); |
769 | 770 |
770 EXPECT_FALSE(contents()->cross_navigation_pending()); | 771 EXPECT_FALSE(contents()->CrossNavigationPending()); |
771 EXPECT_EQ(pending_rfh, contents()->GetMainFrame()); | 772 EXPECT_EQ(pending_rfh, contents()->GetMainFrame()); |
772 EXPECT_EQ(url2, contents()->GetLastCommittedURL()); | 773 EXPECT_EQ(url2, contents()->GetLastCommittedURL()); |
773 EXPECT_EQ(url2, contents()->GetVisibleURL()); | 774 EXPECT_EQ(url2, contents()->GetVisibleURL()); |
774 EXPECT_NE(new_instance, orig_instance); | 775 EXPECT_NE(new_instance, orig_instance); |
775 EXPECT_FALSE(contents()->GetPendingMainFrame()); | 776 EXPECT_FALSE(contents()->GetPendingMainFrame()); |
776 // We keep the original RFH around, swapped out. | 777 // We keep the original RFH around, swapped out. |
777 EXPECT_TRUE(contents()->GetRenderManagerForTesting()->IsOnSwappedOutList( | 778 EXPECT_TRUE(contents()->GetRenderManagerForTesting()->IsOnSwappedOutList( |
778 orig_rfh)); | 779 orig_rfh)); |
779 EXPECT_EQ(orig_rvh_delete_count, 0); | 780 EXPECT_EQ(orig_rvh_delete_count, 0); |
780 orig_rfh->OnSwappedOut(); | 781 orig_rfh->OnSwappedOut(); |
(...skipping 23 matching lines...) Expand all Loading... | |
804 browser_context()); | 805 browser_context()); |
805 entry->SetPageID(0); | 806 entry->SetPageID(0); |
806 entries.push_back(entry); | 807 entries.push_back(entry); |
807 controller().Restore( | 808 controller().Restore( |
808 0, | 809 0, |
809 NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, | 810 NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, |
810 &entries); | 811 &entries); |
811 ASSERT_EQ(0u, entries.size()); | 812 ASSERT_EQ(0u, entries.size()); |
812 ASSERT_EQ(1, controller().GetEntryCount()); | 813 ASSERT_EQ(1, controller().GetEntryCount()); |
813 controller().GoToIndex(0); | 814 controller().GoToIndex(0); |
815 main_test_rfh()->PrepareForCommit(); | |
nasko
2015/04/15 21:12:46
This looks strange. We are preparing for commit th
clamy
2015/04/16 13:18:36
I guess we should use orig_rfh. The thing is with
| |
814 contents()->TestDidNavigate( | 816 contents()->TestDidNavigate( |
815 orig_rfh, 0, native_url, ui::PAGE_TRANSITION_RELOAD); | 817 orig_rfh, 0, native_url, ui::PAGE_TRANSITION_RELOAD); |
816 EXPECT_EQ(orig_instance, contents()->GetSiteInstance()); | 818 EXPECT_EQ(orig_instance, contents()->GetSiteInstance()); |
817 EXPECT_EQ(GURL(), contents()->GetSiteInstance()->GetSiteURL()); | 819 EXPECT_EQ(GURL(), contents()->GetSiteInstance()->GetSiteURL()); |
818 EXPECT_FALSE(orig_instance->HasSite()); | 820 EXPECT_FALSE(orig_instance->HasSite()); |
819 | 821 |
820 // Navigate to a regular site and verify that the SiteInstance was kept. | 822 // Navigate to a regular site and verify that the SiteInstance was kept. |
821 browser_client.set_assign_site_for_url(true); | 823 browser_client.set_assign_site_for_url(true); |
822 const GURL url("http://www.google.com"); | 824 const GURL url("http://www.google.com"); |
823 controller().LoadURL( | 825 controller().LoadURL( |
824 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 826 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
827 main_test_rfh()->PrepareForCommit(); | |
825 contents()->TestDidNavigate(orig_rfh, 2, url, ui::PAGE_TRANSITION_TYPED); | 828 contents()->TestDidNavigate(orig_rfh, 2, url, ui::PAGE_TRANSITION_TYPED); |
826 EXPECT_EQ(orig_instance, contents()->GetSiteInstance()); | 829 EXPECT_EQ(orig_instance, contents()->GetSiteInstance()); |
827 | 830 |
828 // Cleanup. | 831 // Cleanup. |
829 DeleteContents(); | 832 DeleteContents(); |
830 } | 833 } |
831 | 834 |
832 // Complement for NavigateFromRestoredSitelessUrl, verifying that when a regular | 835 // Complement for NavigateFromRestoredSitelessUrl, verifying that when a regular |
833 // tab is restored, the SiteInstance will change upon navigation. | 836 // tab is restored, the SiteInstance will change upon navigation. |
834 TEST_F(WebContentsImplTest, NavigateFromRestoredRegularUrl) { | 837 TEST_F(WebContentsImplTest, NavigateFromRestoredRegularUrl) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
921 scoped_ptr<TestWebContents> contents2( | 924 scoped_ptr<TestWebContents> contents2( |
922 TestWebContents::Create(browser_context(), instance1)); | 925 TestWebContents::Create(browser_context(), instance1)); |
923 const GURL url2("http://www.yahoo.com"); | 926 const GURL url2("http://www.yahoo.com"); |
924 contents2->GetController().LoadURL(url2, Referrer(), | 927 contents2->GetController().LoadURL(url2, Referrer(), |
925 ui::PAGE_TRANSITION_TYPED, | 928 ui::PAGE_TRANSITION_TYPED, |
926 std::string()); | 929 std::string()); |
927 contents2->GetMainFrame()->PrepareForCommit(); | 930 contents2->GetMainFrame()->PrepareForCommit(); |
928 // The first RVH in contents2 isn't live yet, so we shortcut the cross site | 931 // The first RVH in contents2 isn't live yet, so we shortcut the cross site |
929 // pending. | 932 // pending. |
930 TestRenderFrameHost* rfh2 = contents2->GetMainFrame(); | 933 TestRenderFrameHost* rfh2 = contents2->GetMainFrame(); |
931 EXPECT_FALSE(contents2->cross_navigation_pending()); | 934 EXPECT_FALSE(contents2->CrossNavigationPending()); |
932 contents2->TestDidNavigate(rfh2, 2, url2, ui::PAGE_TRANSITION_TYPED); | 935 contents2->TestDidNavigate(rfh2, 2, url2, ui::PAGE_TRANSITION_TYPED); |
933 SiteInstance* instance2 = contents2->GetSiteInstance(); | 936 SiteInstance* instance2 = contents2->GetSiteInstance(); |
934 EXPECT_NE(instance1, instance2); | 937 EXPECT_NE(instance1, instance2); |
935 EXPECT_FALSE(contents2->cross_navigation_pending()); | 938 EXPECT_FALSE(contents2->CrossNavigationPending()); |
936 | 939 |
937 // Simulate a link click in first contents to second site. Doesn't switch | 940 // Simulate a link click in first contents to second site. Doesn't switch |
938 // SiteInstances, because we don't intercept WebKit navigations. | 941 // SiteInstances, because we don't intercept WebKit navigations. |
nasko
2015/04/15 21:12:46
nit: Might as well s/WebKit/Blink/ as we are touch
clamy
2015/04/16 13:18:36
Done.
| |
942 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, true); | |
943 main_test_rfh()->PrepareForCommit(); | |
939 contents()->TestDidNavigate( | 944 contents()->TestDidNavigate( |
940 orig_rfh, 2, url2, ui::PAGE_TRANSITION_TYPED); | 945 orig_rfh, 2, url2, ui::PAGE_TRANSITION_TYPED); |
941 SiteInstance* instance3 = contents()->GetSiteInstance(); | 946 SiteInstance* instance3 = contents()->GetSiteInstance(); |
942 EXPECT_EQ(instance1, instance3); | 947 EXPECT_EQ(instance1, instance3); |
943 EXPECT_FALSE(contents()->cross_navigation_pending()); | 948 EXPECT_FALSE(contents()->CrossNavigationPending()); |
944 | 949 |
945 // Navigate to the new site. Doesn't switch SiteInstancees, because we | 950 // Navigate to the new site. Doesn't switch SiteInstancees, because we |
946 // compare against the current URL, not the SiteInstance's site. | 951 // compare against the current URL, not the SiteInstance's site. |
947 const GURL url3("http://mail.yahoo.com"); | 952 const GURL url3("http://mail.yahoo.com"); |
948 controller().LoadURL( | 953 controller().LoadURL( |
949 url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 954 url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
950 EXPECT_FALSE(contents()->cross_navigation_pending()); | 955 EXPECT_FALSE(contents()->CrossNavigationPending()); |
951 contents()->GetMainFrame()->PrepareForCommit(); | 956 contents()->GetMainFrame()->PrepareForCommit(); |
952 contents()->TestDidNavigate( | 957 contents()->TestDidNavigate( |
953 orig_rfh, 3, url3, ui::PAGE_TRANSITION_TYPED); | 958 orig_rfh, 3, url3, ui::PAGE_TRANSITION_TYPED); |
954 SiteInstance* instance4 = contents()->GetSiteInstance(); | 959 SiteInstance* instance4 = contents()->GetSiteInstance(); |
955 EXPECT_EQ(instance1, instance4); | 960 EXPECT_EQ(instance1, instance4); |
956 } | 961 } |
957 | 962 |
958 // Test that the onbeforeunload and onunload handlers run when navigating | 963 // Test that the onbeforeunload and onunload handlers run when navigating |
959 // across site boundaries. | 964 // across site boundaries. |
960 TEST_F(WebContentsImplTest, CrossSiteUnloadHandlers) { | 965 TEST_F(WebContentsImplTest, CrossSiteUnloadHandlers) { |
961 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); | 966 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); |
962 SiteInstance* instance1 = contents()->GetSiteInstance(); | 967 SiteInstance* instance1 = contents()->GetSiteInstance(); |
963 | 968 |
964 // Navigate to URL. First URL should use first RenderViewHost. | 969 // Navigate to URL. First URL should use first RenderViewHost. |
965 const GURL url("http://www.google.com"); | 970 const GURL url("http://www.google.com"); |
966 controller().LoadURL( | 971 controller().LoadURL( |
967 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 972 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
968 contents()->GetMainFrame()->PrepareForCommit(); | 973 contents()->GetMainFrame()->PrepareForCommit(); |
969 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); | 974 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); |
970 EXPECT_FALSE(contents()->cross_navigation_pending()); | 975 EXPECT_FALSE(contents()->CrossNavigationPending()); |
971 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); | 976 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); |
972 | 977 |
973 // Navigate to new site, but simulate an onbeforeunload denial. | 978 // Navigate to new site, but simulate an onbeforeunload denial. |
974 const GURL url2("http://www.yahoo.com"); | 979 const GURL url2("http://www.yahoo.com"); |
975 controller().LoadURL( | 980 controller().LoadURL( |
976 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 981 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
977 EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK()); | 982 EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK()); |
978 base::TimeTicks now = base::TimeTicks::Now(); | 983 base::TimeTicks now = base::TimeTicks::Now(); |
979 orig_rfh->OnMessageReceived( | 984 orig_rfh->OnMessageReceived( |
980 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); | 985 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); |
981 EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK()); | 986 EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK()); |
982 EXPECT_FALSE(contents()->cross_navigation_pending()); | 987 EXPECT_FALSE(contents()->CrossNavigationPending()); |
983 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); | 988 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); |
984 | 989 |
985 // Navigate again, but simulate an onbeforeunload approval. | 990 // Navigate again, but simulate an onbeforeunload approval. |
986 controller().LoadURL( | 991 controller().LoadURL( |
987 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 992 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
988 EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK()); | 993 EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK()); |
989 now = base::TimeTicks::Now(); | 994 now = base::TimeTicks::Now(); |
990 orig_rfh->PrepareForCommit(); | 995 orig_rfh->PrepareForCommit(); |
991 EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK()); | 996 EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK()); |
992 EXPECT_TRUE(contents()->cross_navigation_pending()); | 997 EXPECT_TRUE(contents()->CrossNavigationPending()); |
993 TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame(); | 998 TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame(); |
994 | 999 |
995 // We won't hear DidNavigate until the onunload handler has finished running. | 1000 // We won't hear DidNavigate until the onunload handler has finished running. |
996 | 1001 |
997 // DidNavigate from the pending page. | 1002 // DidNavigate from the pending page. |
998 contents()->TestDidNavigate( | 1003 contents()->TestDidNavigate( |
999 pending_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); | 1004 pending_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); |
1000 SiteInstance* instance2 = contents()->GetSiteInstance(); | 1005 SiteInstance* instance2 = contents()->GetSiteInstance(); |
1001 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1006 EXPECT_FALSE(contents()->CrossNavigationPending()); |
1002 EXPECT_EQ(pending_rfh, contents()->GetMainFrame()); | 1007 EXPECT_EQ(pending_rfh, contents()->GetMainFrame()); |
1003 EXPECT_NE(instance1, instance2); | 1008 EXPECT_NE(instance1, instance2); |
1004 EXPECT_EQ(nullptr, contents()->GetPendingMainFrame()); | 1009 EXPECT_EQ(nullptr, contents()->GetPendingMainFrame()); |
1005 } | 1010 } |
1006 | 1011 |
1007 // Test that during a slow cross-site navigation, the original renderer can | 1012 // Test that during a slow cross-site navigation, the original renderer can |
1008 // navigate to a different URL and have it displayed, canceling the slow | 1013 // navigate to a different URL and have it displayed, canceling the slow |
1009 // navigation. | 1014 // navigation. |
1010 TEST_F(WebContentsImplTest, CrossSiteNavigationPreempted) { | 1015 TEST_F(WebContentsImplTest, CrossSiteNavigationPreempted) { |
1011 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); | 1016 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); |
1012 SiteInstance* instance1 = contents()->GetSiteInstance(); | 1017 SiteInstance* instance1 = contents()->GetSiteInstance(); |
1013 | 1018 |
1014 // Navigate to URL. First URL should use first RenderFrameHost. | 1019 // Navigate to URL. First URL should use first RenderFrameHost. |
1015 const GURL url("http://www.google.com"); | 1020 const GURL url("http://www.google.com"); |
1016 controller().LoadURL( | 1021 controller().LoadURL( |
1017 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1022 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1018 contents()->GetMainFrame()->PrepareForCommit(); | 1023 contents()->GetMainFrame()->PrepareForCommit(); |
1019 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); | 1024 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); |
1020 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1025 EXPECT_FALSE(contents()->CrossNavigationPending()); |
1021 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); | 1026 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); |
1022 | 1027 |
1023 // Navigate to new site, simulating an onbeforeunload approval. | 1028 // Navigate to new site, simulating an onbeforeunload approval. |
1024 const GURL url2("http://www.yahoo.com"); | 1029 const GURL url2("http://www.yahoo.com"); |
1025 controller().LoadURL( | 1030 controller().LoadURL( |
1026 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1031 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1027 EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK()); | 1032 EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK()); |
1028 orig_rfh->PrepareForCommit(); | 1033 orig_rfh->PrepareForCommit(); |
1029 EXPECT_TRUE(contents()->cross_navigation_pending()); | 1034 EXPECT_TRUE(contents()->CrossNavigationPending()); |
1030 | 1035 |
1031 // Suppose the original renderer navigates before the new one is ready. | 1036 // Suppose the original renderer navigates before the new one is ready. |
1032 orig_rfh->SendNavigate(2, GURL("http://www.google.com/foo")); | 1037 orig_rfh->SendNavigate(2, GURL("http://www.google.com/foo")); |
1033 | 1038 |
1034 // Verify that the pending navigation is cancelled. | 1039 // Verify that the pending navigation is cancelled. |
1035 EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK()); | 1040 EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK()); |
1036 SiteInstance* instance2 = contents()->GetSiteInstance(); | 1041 SiteInstance* instance2 = contents()->GetSiteInstance(); |
1037 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1042 EXPECT_FALSE(contents()->CrossNavigationPending()); |
1038 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); | 1043 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); |
1039 EXPECT_EQ(instance1, instance2); | 1044 EXPECT_EQ(instance1, instance2); |
1040 EXPECT_EQ(nullptr, contents()->GetPendingMainFrame()); | 1045 EXPECT_EQ(nullptr, contents()->GetPendingMainFrame()); |
1041 } | 1046 } |
1042 | 1047 |
1043 TEST_F(WebContentsImplTest, CrossSiteNavigationBackPreempted) { | 1048 TEST_F(WebContentsImplTest, CrossSiteNavigationBackPreempted) { |
1044 // Start with a web ui page, which gets a new RVH with WebUI bindings. | 1049 // Start with a web ui page, which gets a new RVH with WebUI bindings. |
1045 const GURL url1("chrome://blah"); | 1050 const GURL url1("chrome://blah"); |
1046 controller().LoadURL( | 1051 controller().LoadURL( |
1047 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1052 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1048 TestRenderFrameHost* ntp_rfh = contents()->GetMainFrame(); | 1053 TestRenderFrameHost* ntp_rfh = contents()->GetMainFrame(); |
1049 ntp_rfh->PrepareForCommit(); | 1054 ntp_rfh->PrepareForCommit(); |
1050 contents()->TestDidNavigate(ntp_rfh, 1, url1, ui::PAGE_TRANSITION_TYPED); | 1055 contents()->TestDidNavigate(ntp_rfh, 1, url1, ui::PAGE_TRANSITION_TYPED); |
1051 NavigationEntry* entry1 = controller().GetLastCommittedEntry(); | 1056 NavigationEntry* entry1 = controller().GetLastCommittedEntry(); |
1052 SiteInstance* instance1 = contents()->GetSiteInstance(); | 1057 SiteInstance* instance1 = contents()->GetSiteInstance(); |
1053 | 1058 |
1054 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1059 EXPECT_FALSE(contents()->CrossNavigationPending()); |
1055 EXPECT_EQ(ntp_rfh, contents()->GetMainFrame()); | 1060 EXPECT_EQ(ntp_rfh, contents()->GetMainFrame()); |
1056 EXPECT_EQ(url1, entry1->GetURL()); | 1061 EXPECT_EQ(url1, entry1->GetURL()); |
1057 EXPECT_EQ(instance1, | 1062 EXPECT_EQ(instance1, |
1058 NavigationEntryImpl::FromNavigationEntry(entry1)->site_instance()); | 1063 NavigationEntryImpl::FromNavigationEntry(entry1)->site_instance()); |
1059 EXPECT_TRUE(ntp_rfh->GetRenderViewHost()->GetEnabledBindings() & | 1064 EXPECT_TRUE(ntp_rfh->GetRenderViewHost()->GetEnabledBindings() & |
1060 BINDINGS_POLICY_WEB_UI); | 1065 BINDINGS_POLICY_WEB_UI); |
1061 | 1066 |
1062 // Navigate to new site. | 1067 // Navigate to new site. |
1063 const GURL url2("http://www.google.com"); | 1068 const GURL url2("http://www.google.com"); |
1064 controller().LoadURL( | 1069 controller().LoadURL( |
1065 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1070 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1066 EXPECT_TRUE(contents()->cross_navigation_pending()); | 1071 EXPECT_TRUE(contents()->CrossNavigationPending()); |
1067 TestRenderFrameHost* google_rfh = contents()->GetPendingMainFrame(); | 1072 TestRenderFrameHost* google_rfh = contents()->GetPendingMainFrame(); |
1068 | 1073 |
1069 // Simulate beforeunload approval. | 1074 // Simulate beforeunload approval. |
1070 EXPECT_TRUE(ntp_rfh->IsWaitingForBeforeUnloadACK()); | 1075 EXPECT_TRUE(ntp_rfh->IsWaitingForBeforeUnloadACK()); |
1071 base::TimeTicks now = base::TimeTicks::Now(); | 1076 base::TimeTicks now = base::TimeTicks::Now(); |
1072 ntp_rfh->PrepareForCommit(); | 1077 ntp_rfh->PrepareForCommit(); |
1073 | 1078 |
1074 // DidNavigate from the pending page. | 1079 // DidNavigate from the pending page. |
1075 contents()->TestDidNavigate( | 1080 contents()->TestDidNavigate( |
1076 google_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); | 1081 google_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); |
1077 NavigationEntry* entry2 = controller().GetLastCommittedEntry(); | 1082 NavigationEntry* entry2 = controller().GetLastCommittedEntry(); |
1078 SiteInstance* instance2 = contents()->GetSiteInstance(); | 1083 SiteInstance* instance2 = contents()->GetSiteInstance(); |
1079 | 1084 |
1080 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1085 EXPECT_FALSE(contents()->CrossNavigationPending()); |
1081 EXPECT_EQ(google_rfh, contents()->GetMainFrame()); | 1086 EXPECT_EQ(google_rfh, contents()->GetMainFrame()); |
1082 EXPECT_NE(instance1, instance2); | 1087 EXPECT_NE(instance1, instance2); |
1083 EXPECT_FALSE(contents()->GetPendingMainFrame()); | 1088 EXPECT_FALSE(contents()->GetPendingMainFrame()); |
1084 EXPECT_EQ(url2, entry2->GetURL()); | 1089 EXPECT_EQ(url2, entry2->GetURL()); |
1085 EXPECT_EQ(instance2, | 1090 EXPECT_EQ(instance2, |
1086 NavigationEntryImpl::FromNavigationEntry(entry2)->site_instance()); | 1091 NavigationEntryImpl::FromNavigationEntry(entry2)->site_instance()); |
1087 EXPECT_FALSE(google_rfh->GetRenderViewHost()->GetEnabledBindings() & | 1092 EXPECT_FALSE(google_rfh->GetRenderViewHost()->GetEnabledBindings() & |
1088 BINDINGS_POLICY_WEB_UI); | 1093 BINDINGS_POLICY_WEB_UI); |
1089 | 1094 |
1090 // Navigate to third page on same site. | 1095 // Navigate to third page on same site. |
1091 const GURL url3("http://news.google.com"); | 1096 const GURL url3("http://news.google.com"); |
1092 controller().LoadURL( | 1097 controller().LoadURL( |
1093 url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1098 url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1094 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1099 EXPECT_FALSE(contents()->CrossNavigationPending()); |
1095 contents()->GetMainFrame()->PrepareForCommit(); | 1100 contents()->GetMainFrame()->PrepareForCommit(); |
1096 contents()->TestDidNavigate( | 1101 contents()->TestDidNavigate( |
1097 google_rfh, 2, url3, ui::PAGE_TRANSITION_TYPED); | 1102 google_rfh, 2, url3, ui::PAGE_TRANSITION_TYPED); |
1098 NavigationEntry* entry3 = controller().GetLastCommittedEntry(); | 1103 NavigationEntry* entry3 = controller().GetLastCommittedEntry(); |
1099 SiteInstance* instance3 = contents()->GetSiteInstance(); | 1104 SiteInstance* instance3 = contents()->GetSiteInstance(); |
1100 | 1105 |
1101 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1106 EXPECT_FALSE(contents()->CrossNavigationPending()); |
1102 EXPECT_EQ(google_rfh, contents()->GetMainFrame()); | 1107 EXPECT_EQ(google_rfh, contents()->GetMainFrame()); |
1103 EXPECT_EQ(instance2, instance3); | 1108 EXPECT_EQ(instance2, instance3); |
1104 EXPECT_FALSE(contents()->GetPendingMainFrame()); | 1109 EXPECT_FALSE(contents()->GetPendingMainFrame()); |
1105 EXPECT_EQ(url3, entry3->GetURL()); | 1110 EXPECT_EQ(url3, entry3->GetURL()); |
1106 EXPECT_EQ(instance3, | 1111 EXPECT_EQ(instance3, |
1107 NavigationEntryImpl::FromNavigationEntry(entry3)->site_instance()); | 1112 NavigationEntryImpl::FromNavigationEntry(entry3)->site_instance()); |
1108 | 1113 |
1109 // Go back within the site. | 1114 // Go back within the site. |
1110 controller().GoBack(); | 1115 controller().GoBack(); |
1111 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1116 EXPECT_FALSE(contents()->CrossNavigationPending()); |
1112 EXPECT_EQ(entry2, controller().GetPendingEntry()); | 1117 EXPECT_EQ(entry2, controller().GetPendingEntry()); |
1113 | 1118 |
1114 // Before that commits, go back again. | 1119 // Before that commits, go back again. |
1115 controller().GoBack(); | 1120 controller().GoBack(); |
1116 EXPECT_TRUE(contents()->cross_navigation_pending()); | 1121 EXPECT_TRUE(contents()->CrossNavigationPending()); |
1117 EXPECT_TRUE(contents()->GetPendingMainFrame()); | 1122 EXPECT_TRUE(contents()->GetPendingMainFrame()); |
1118 EXPECT_EQ(entry1, controller().GetPendingEntry()); | 1123 EXPECT_EQ(entry1, controller().GetPendingEntry()); |
1119 | 1124 |
1120 // Simulate beforeunload approval. | 1125 // Simulate beforeunload approval. |
1121 EXPECT_TRUE(google_rfh->IsWaitingForBeforeUnloadACK()); | 1126 EXPECT_TRUE(google_rfh->IsWaitingForBeforeUnloadACK()); |
1122 now = base::TimeTicks::Now(); | 1127 now = base::TimeTicks::Now(); |
1123 google_rfh->PrepareForCommit(); | 1128 google_rfh->PrepareForCommit(); |
1124 google_rfh->OnMessageReceived( | 1129 google_rfh->OnMessageReceived( |
1125 FrameHostMsg_BeforeUnload_ACK(0, true, now, now)); | 1130 FrameHostMsg_BeforeUnload_ACK(0, true, now, now)); |
1126 | 1131 |
1127 // DidNavigate from the first back. This aborts the second back's pending RFH. | 1132 // DidNavigate from the first back. This aborts the second back's pending RFH. |
1128 contents()->TestDidNavigate(google_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); | 1133 contents()->TestDidNavigate(google_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); |
1129 | 1134 |
1130 // We should commit this page and forget about the second back. | 1135 // We should commit this page and forget about the second back. |
1131 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1136 EXPECT_FALSE(contents()->CrossNavigationPending()); |
1132 EXPECT_FALSE(controller().GetPendingEntry()); | 1137 EXPECT_FALSE(controller().GetPendingEntry()); |
1133 EXPECT_EQ(google_rfh, contents()->GetMainFrame()); | 1138 EXPECT_EQ(google_rfh, contents()->GetMainFrame()); |
1134 EXPECT_EQ(url2, controller().GetLastCommittedEntry()->GetURL()); | 1139 EXPECT_EQ(url2, controller().GetLastCommittedEntry()->GetURL()); |
1135 | 1140 |
1136 // We should not have corrupted the NTP entry. | 1141 // We should not have corrupted the NTP entry. |
1137 EXPECT_EQ(instance3, | 1142 EXPECT_EQ(instance3, |
1138 NavigationEntryImpl::FromNavigationEntry(entry3)->site_instance()); | 1143 NavigationEntryImpl::FromNavigationEntry(entry3)->site_instance()); |
1139 EXPECT_EQ(instance2, | 1144 EXPECT_EQ(instance2, |
1140 NavigationEntryImpl::FromNavigationEntry(entry2)->site_instance()); | 1145 NavigationEntryImpl::FromNavigationEntry(entry2)->site_instance()); |
1141 EXPECT_EQ(instance1, | 1146 EXPECT_EQ(instance1, |
1142 NavigationEntryImpl::FromNavigationEntry(entry1)->site_instance()); | 1147 NavigationEntryImpl::FromNavigationEntry(entry1)->site_instance()); |
1143 EXPECT_EQ(url1, entry1->GetURL()); | 1148 EXPECT_EQ(url1, entry1->GetURL()); |
1144 } | 1149 } |
1145 | 1150 |
1146 // Test that during a slow cross-site navigation, a sub-frame navigation in the | 1151 // Test that during a slow cross-site navigation, a sub-frame navigation in the |
1147 // original renderer will not cancel the slow navigation (bug 42029). | 1152 // original renderer will not cancel the slow navigation (bug 42029). |
1148 TEST_F(WebContentsImplTest, CrossSiteNavigationNotPreemptedByFrame) { | 1153 TEST_F(WebContentsImplTest, CrossSiteNavigationNotPreemptedByFrame) { |
1149 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); | 1154 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); |
1150 | 1155 |
1151 // Navigate to URL. First URL should use the original RenderFrameHost. | 1156 // Navigate to URL. First URL should use the original RenderFrameHost. |
1152 const GURL url("http://www.google.com"); | 1157 const GURL url("http://www.google.com"); |
1153 controller().LoadURL( | 1158 controller().LoadURL( |
1154 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1159 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1155 contents()->GetMainFrame()->PrepareForCommit(); | 1160 contents()->GetMainFrame()->PrepareForCommit(); |
1156 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); | 1161 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); |
1157 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1162 EXPECT_FALSE(contents()->CrossNavigationPending()); |
1158 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); | 1163 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); |
1159 | 1164 |
1160 // Start navigating to new site. | 1165 // Start navigating to new site. |
1161 const GURL url2("http://www.yahoo.com"); | 1166 const GURL url2("http://www.yahoo.com"); |
1162 controller().LoadURL( | 1167 controller().LoadURL( |
1163 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1168 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1164 | 1169 |
1165 // Simulate a sub-frame navigation arriving and ensure the RVH is still | 1170 // Simulate a sub-frame navigation arriving and ensure the RVH is still |
1166 // waiting for a before unload response. | 1171 // waiting for a before unload response. |
1167 TestRenderFrameHost* child_rfh = orig_rfh->AppendChild("subframe"); | 1172 TestRenderFrameHost* child_rfh = orig_rfh->AppendChild("subframe"); |
1168 child_rfh->SendNavigateWithTransition( | 1173 child_rfh->SendNavigateWithTransition( |
1169 1, GURL("http://google.com/frame"), ui::PAGE_TRANSITION_AUTO_SUBFRAME); | 1174 1, GURL("http://google.com/frame"), ui::PAGE_TRANSITION_AUTO_SUBFRAME); |
1170 EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK()); | 1175 EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK()); |
1171 | 1176 |
1172 // Now simulate the onbeforeunload approval and verify the navigation is | 1177 // Now simulate the onbeforeunload approval and verify the navigation is |
1173 // not canceled. | 1178 // not canceled. |
1174 orig_rfh->PrepareForCommit(); | 1179 orig_rfh->PrepareForCommit(); |
1175 EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK()); | 1180 EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK()); |
1176 EXPECT_TRUE(contents()->cross_navigation_pending()); | 1181 EXPECT_TRUE(contents()->CrossNavigationPending()); |
1177 } | 1182 } |
1178 | 1183 |
1179 // Test that a cross-site navigation is not preempted if the previous | 1184 // Test that a cross-site navigation is not preempted if the previous |
1180 // renderer sends a FrameNavigate message just before being told to stop. | 1185 // renderer sends a FrameNavigate message just before being told to stop. |
1181 // We should only preempt the cross-site navigation if the previous renderer | 1186 // We should only preempt the cross-site navigation if the previous renderer |
1182 // has started a new navigation. See http://crbug.com/79176. | 1187 // has started a new navigation. See http://crbug.com/79176. |
1183 TEST_F(WebContentsImplTest, CrossSiteNotPreemptedDuringBeforeUnload) { | 1188 TEST_F(WebContentsImplTest, CrossSiteNotPreemptedDuringBeforeUnload) { |
1184 // Navigate to NTP URL. | 1189 // Navigate to NTP URL. |
1185 const GURL url("chrome://blah"); | 1190 const GURL url("chrome://blah"); |
1186 controller().LoadURL( | 1191 controller().LoadURL( |
1187 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1192 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1188 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); | 1193 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); |
1189 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1194 EXPECT_FALSE(contents()->CrossNavigationPending()); |
1190 | 1195 |
1191 // Navigate to new site, with the beforeunload request in flight. | 1196 // Navigate to new site, with the beforeunload request in flight. |
1192 const GURL url2("http://www.yahoo.com"); | 1197 const GURL url2("http://www.yahoo.com"); |
1193 controller().LoadURL( | 1198 controller().LoadURL( |
1194 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1199 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1195 TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame(); | 1200 TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame(); |
1196 EXPECT_TRUE(contents()->cross_navigation_pending()); | 1201 EXPECT_TRUE(contents()->CrossNavigationPending()); |
1197 EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK()); | 1202 EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK()); |
1198 | 1203 |
1199 // Suppose the first navigation tries to commit now, with a | 1204 // Suppose the first navigation tries to commit now, with a |
1200 // FrameMsg_Stop in flight. This should not cancel the pending navigation, | 1205 // FrameMsg_Stop in flight. This should not cancel the pending navigation, |
1201 // but it should act as if the beforeunload ack arrived. | 1206 // but it should act as if the beforeunload ack arrived. |
1202 orig_rfh->SendNavigate(1, GURL("chrome://blah")); | 1207 orig_rfh->SendNavigate(1, GURL("chrome://blah")); |
1203 EXPECT_TRUE(contents()->cross_navigation_pending()); | 1208 EXPECT_TRUE(contents()->CrossNavigationPending()); |
1204 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); | 1209 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); |
1205 EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK()); | 1210 EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK()); |
1206 | 1211 |
1207 // The pending navigation should be able to commit successfully. | 1212 // The pending navigation should be able to commit successfully. |
1208 contents()->TestDidNavigate(pending_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); | 1213 contents()->TestDidNavigate(pending_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); |
1209 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1214 EXPECT_FALSE(contents()->CrossNavigationPending()); |
1210 EXPECT_EQ(pending_rfh, contents()->GetMainFrame()); | 1215 EXPECT_EQ(pending_rfh, contents()->GetMainFrame()); |
1211 } | 1216 } |
1212 | 1217 |
1213 // Test that NavigationEntries have the correct page state after going | 1218 // Test that NavigationEntries have the correct page state after going |
1214 // forward and back. Prevents regression for bug 1116137. | 1219 // forward and back. Prevents regression for bug 1116137. |
1215 TEST_F(WebContentsImplTest, NavigationEntryContentState) { | 1220 TEST_F(WebContentsImplTest, NavigationEntryContentState) { |
1216 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); | 1221 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); |
1217 | 1222 |
1218 // Navigate to URL. There should be no committed entry yet. | 1223 // Navigate to URL. There should be no committed entry yet. |
1219 const GURL url("http://www.google.com"); | 1224 const GURL url("http://www.google.com"); |
1220 controller().LoadURL( | 1225 controller().LoadURL( |
1221 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1226 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1222 NavigationEntry* entry = controller().GetLastCommittedEntry(); | 1227 NavigationEntry* entry = controller().GetLastCommittedEntry(); |
1223 EXPECT_EQ(nullptr, entry); | 1228 EXPECT_EQ(nullptr, entry); |
1224 | 1229 |
1225 // Committed entry should have page state after DidNavigate. | 1230 // Committed entry should have page state after DidNavigate. |
1231 main_test_rfh()->PrepareForCommit(); | |
nasko
2015/04/15 21:12:46
Same issue as pointed out above, discrepancy betwe
clamy
2015/04/16 13:18:36
Done.
| |
1226 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); | 1232 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); |
1227 entry = controller().GetLastCommittedEntry(); | 1233 entry = controller().GetLastCommittedEntry(); |
1228 EXPECT_TRUE(entry->GetPageState().IsValid()); | 1234 EXPECT_TRUE(entry->GetPageState().IsValid()); |
1229 | 1235 |
1230 // Navigate to same site. | 1236 // Navigate to same site. |
1231 const GURL url2("http://images.google.com"); | 1237 const GURL url2("http://images.google.com"); |
1232 controller().LoadURL( | 1238 controller().LoadURL( |
1233 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1239 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1234 entry = controller().GetLastCommittedEntry(); | 1240 entry = controller().GetLastCommittedEntry(); |
1235 EXPECT_TRUE(entry->GetPageState().IsValid()); | 1241 EXPECT_TRUE(entry->GetPageState().IsValid()); |
1236 | 1242 |
1237 // Committed entry should have page state after DidNavigate. | 1243 // Committed entry should have page state after DidNavigate. |
1244 main_test_rfh()->PrepareForCommit(); | |
1238 contents()->TestDidNavigate(orig_rfh, 2, url2, ui::PAGE_TRANSITION_TYPED); | 1245 contents()->TestDidNavigate(orig_rfh, 2, url2, ui::PAGE_TRANSITION_TYPED); |
1239 entry = controller().GetLastCommittedEntry(); | 1246 entry = controller().GetLastCommittedEntry(); |
1240 EXPECT_TRUE(entry->GetPageState().IsValid()); | 1247 EXPECT_TRUE(entry->GetPageState().IsValid()); |
1241 | 1248 |
1242 // Now go back. Committed entry should still have page state. | 1249 // Now go back. Committed entry should still have page state. |
1243 controller().GoBack(); | 1250 controller().GoBack(); |
1251 main_test_rfh()->PrepareForCommit(); | |
1244 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); | 1252 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); |
1245 entry = controller().GetLastCommittedEntry(); | 1253 entry = controller().GetLastCommittedEntry(); |
1246 EXPECT_TRUE(entry->GetPageState().IsValid()); | 1254 EXPECT_TRUE(entry->GetPageState().IsValid()); |
1247 } | 1255 } |
1248 | 1256 |
1249 // Test that NavigationEntries have the correct page state and SiteInstance | 1257 // Test that NavigationEntries have the correct page state and SiteInstance |
1250 // state after opening a new window to about:blank. Prevents regression for | 1258 // state after opening a new window to about:blank. Prevents regression for |
1251 // bugs b/1116137 and http://crbug.com/111975. | 1259 // bugs b/1116137 and http://crbug.com/111975. |
1252 TEST_F(WebContentsImplTest, NavigationEntryContentStateNewWindow) { | 1260 TEST_F(WebContentsImplTest, NavigationEntryContentStateNewWindow) { |
1253 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); | 1261 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); |
1254 | 1262 |
1255 // When opening a new window, it is navigated to about:blank internally. | 1263 // When opening a new window, it is navigated to about:blank internally. |
1256 // Currently, this results in two DidNavigate events. | 1264 // Currently, this results in two DidNavigate events. |
1257 const GURL url(url::kAboutBlankURL); | 1265 const GURL url(url::kAboutBlankURL); |
1266 main_test_rfh()->SendRendererInitiatedNavigationRequest(url, false); | |
1267 main_test_rfh()->PrepareForCommit(); | |
1258 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); | 1268 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); |
1269 main_test_rfh()->SendRendererInitiatedNavigationRequest(url, false); | |
1270 main_test_rfh()->PrepareForCommit(); | |
1259 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); | 1271 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); |
1260 | 1272 |
1261 // Should have a page state here. | 1273 // Should have a page state here. |
1262 NavigationEntry* entry = controller().GetLastCommittedEntry(); | 1274 NavigationEntry* entry = controller().GetLastCommittedEntry(); |
1263 EXPECT_TRUE(entry->GetPageState().IsValid()); | 1275 EXPECT_TRUE(entry->GetPageState().IsValid()); |
1264 | 1276 |
1265 // The SiteInstance should be available for other navigations to use. | 1277 // The SiteInstance should be available for other navigations to use. |
1266 NavigationEntryImpl* entry_impl = | 1278 NavigationEntryImpl* entry_impl = |
1267 NavigationEntryImpl::FromNavigationEntry(entry); | 1279 NavigationEntryImpl::FromNavigationEntry(entry); |
1268 EXPECT_FALSE(entry_impl->site_instance()->HasSite()); | 1280 EXPECT_FALSE(entry_impl->site_instance()->HasSite()); |
1269 int32 site_instance_id = entry_impl->site_instance()->GetId(); | 1281 int32 site_instance_id = entry_impl->site_instance()->GetId(); |
1270 | 1282 |
1271 // Navigating to a normal page should not cause a process swap. | 1283 // Navigating to a normal page should not cause a process swap. |
1272 const GURL new_url("http://www.google.com"); | 1284 const GURL new_url("http://www.google.com"); |
1273 controller().LoadURL(new_url, Referrer(), | 1285 controller().LoadURL(new_url, Referrer(), |
1274 ui::PAGE_TRANSITION_TYPED, std::string()); | 1286 ui::PAGE_TRANSITION_TYPED, std::string()); |
1275 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1287 EXPECT_FALSE(contents()->CrossNavigationPending()); |
1276 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); | 1288 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); |
1289 main_test_rfh()->PrepareForCommit(); | |
1277 contents()->TestDidNavigate(orig_rfh, 1, new_url, ui::PAGE_TRANSITION_TYPED); | 1290 contents()->TestDidNavigate(orig_rfh, 1, new_url, ui::PAGE_TRANSITION_TYPED); |
1278 NavigationEntryImpl* entry_impl2 = NavigationEntryImpl::FromNavigationEntry( | 1291 NavigationEntryImpl* entry_impl2 = NavigationEntryImpl::FromNavigationEntry( |
1279 controller().GetLastCommittedEntry()); | 1292 controller().GetLastCommittedEntry()); |
1280 EXPECT_EQ(site_instance_id, entry_impl2->site_instance()->GetId()); | 1293 EXPECT_EQ(site_instance_id, entry_impl2->site_instance()->GetId()); |
1281 EXPECT_TRUE(entry_impl2->site_instance()->HasSite()); | 1294 EXPECT_TRUE(entry_impl2->site_instance()->HasSite()); |
1282 } | 1295 } |
1283 | 1296 |
1284 // Tests that fullscreen is exited throughout the object hierarchy when | 1297 // Tests that fullscreen is exited throughout the object hierarchy when |
1285 // navigating to a new page. | 1298 // navigating to a new page. |
1286 TEST_F(WebContentsImplTest, NavigationExitsFullscreen) { | 1299 TEST_F(WebContentsImplTest, NavigationExitsFullscreen) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1329 TEST_F(WebContentsImplTest, HistoryNavigationExitsFullscreen) { | 1342 TEST_F(WebContentsImplTest, HistoryNavigationExitsFullscreen) { |
1330 FakeFullscreenDelegate fake_delegate; | 1343 FakeFullscreenDelegate fake_delegate; |
1331 contents()->SetDelegate(&fake_delegate); | 1344 contents()->SetDelegate(&fake_delegate); |
1332 TestRenderFrameHost* const orig_rfh = contents()->GetMainFrame(); | 1345 TestRenderFrameHost* const orig_rfh = contents()->GetMainFrame(); |
1333 TestRenderViewHost* const orig_rvh = orig_rfh->GetRenderViewHost(); | 1346 TestRenderViewHost* const orig_rvh = orig_rfh->GetRenderViewHost(); |
1334 | 1347 |
1335 // Navigate to a site. | 1348 // Navigate to a site. |
1336 const GURL url("http://www.google.com"); | 1349 const GURL url("http://www.google.com"); |
1337 controller().LoadURL( | 1350 controller().LoadURL( |
1338 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1351 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1352 main_test_rfh()->PrepareForCommit(); | |
1339 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); | 1353 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); |
1340 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); | 1354 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); |
1341 | 1355 |
1342 // Now, navigate to another page on the same site. | 1356 // Now, navigate to another page on the same site. |
1343 const GURL url2("http://www.google.com/search?q=kittens"); | 1357 const GURL url2("http://www.google.com/search?q=kittens"); |
1344 controller().LoadURL( | 1358 controller().LoadURL( |
1345 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1359 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1346 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1360 main_test_rfh()->PrepareForCommit(); |
1361 EXPECT_FALSE(contents()->CrossNavigationPending()); | |
1347 contents()->TestDidNavigate(orig_rfh, 2, url2, ui::PAGE_TRANSITION_TYPED); | 1362 contents()->TestDidNavigate(orig_rfh, 2, url2, ui::PAGE_TRANSITION_TYPED); |
1348 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); | 1363 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); |
1349 | 1364 |
1350 // Sanity-check: Confirm we're not starting out in fullscreen mode. | 1365 // Sanity-check: Confirm we're not starting out in fullscreen mode. |
1351 EXPECT_FALSE(orig_rvh->IsFullscreenGranted()); | 1366 EXPECT_FALSE(orig_rvh->IsFullscreenGranted()); |
1352 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab()); | 1367 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab()); |
1353 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents())); | 1368 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents())); |
1354 | 1369 |
1355 for (int i = 0; i < 2; ++i) { | 1370 for (int i = 0; i < 2; ++i) { |
1356 // Toggle fullscreen mode on (as if initiated via IPC from renderer). | 1371 // Toggle fullscreen mode on (as if initiated via IPC from renderer). |
1357 orig_rfh->OnMessageReceived( | 1372 orig_rfh->OnMessageReceived( |
1358 FrameHostMsg_ToggleFullscreen(orig_rfh->GetRoutingID(), true)); | 1373 FrameHostMsg_ToggleFullscreen(orig_rfh->GetRoutingID(), true)); |
1359 EXPECT_TRUE(orig_rvh->IsFullscreenGranted()); | 1374 EXPECT_TRUE(orig_rvh->IsFullscreenGranted()); |
1360 EXPECT_TRUE(contents()->IsFullscreenForCurrentTab()); | 1375 EXPECT_TRUE(contents()->IsFullscreenForCurrentTab()); |
1361 EXPECT_TRUE(fake_delegate.IsFullscreenForTabOrPending(contents())); | 1376 EXPECT_TRUE(fake_delegate.IsFullscreenForTabOrPending(contents())); |
1362 | 1377 |
1363 // Navigate backward (or forward). | 1378 // Navigate backward (or forward). |
1364 if (i == 0) | 1379 if (i == 0) |
1365 controller().GoBack(); | 1380 controller().GoBack(); |
1366 else | 1381 else |
1367 controller().GoForward(); | 1382 controller().GoForward(); |
1368 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1383 main_test_rfh()->PrepareForCommit(); |
1384 EXPECT_FALSE(contents()->CrossNavigationPending()); | |
1369 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); | 1385 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); |
1370 contents()->TestDidNavigate( | 1386 contents()->TestDidNavigate( |
1371 orig_rfh, i + 1, url, ui::PAGE_TRANSITION_FORWARD_BACK); | 1387 orig_rfh, i + 1, url, ui::PAGE_TRANSITION_FORWARD_BACK); |
1372 | 1388 |
1373 // Confirm fullscreen has exited. | 1389 // Confirm fullscreen has exited. |
1374 EXPECT_FALSE(orig_rvh->IsFullscreenGranted()); | 1390 EXPECT_FALSE(orig_rvh->IsFullscreenGranted()); |
1375 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab()); | 1391 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab()); |
1376 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents())); | 1392 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents())); |
1377 } | 1393 } |
1378 | 1394 |
(...skipping 19 matching lines...) Expand all Loading... | |
1398 // Tests that fullscreen is exited throughout the object hierarchy on a renderer | 1414 // Tests that fullscreen is exited throughout the object hierarchy on a renderer |
1399 // crash. | 1415 // crash. |
1400 TEST_F(WebContentsImplTest, CrashExitsFullscreen) { | 1416 TEST_F(WebContentsImplTest, CrashExitsFullscreen) { |
1401 FakeFullscreenDelegate fake_delegate; | 1417 FakeFullscreenDelegate fake_delegate; |
1402 contents()->SetDelegate(&fake_delegate); | 1418 contents()->SetDelegate(&fake_delegate); |
1403 | 1419 |
1404 // Navigate to a site. | 1420 // Navigate to a site. |
1405 const GURL url("http://www.google.com"); | 1421 const GURL url("http://www.google.com"); |
1406 controller().LoadURL( | 1422 controller().LoadURL( |
1407 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1423 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1424 main_test_rfh()->PrepareForCommit(); | |
1408 contents()->TestDidNavigate( | 1425 contents()->TestDidNavigate( |
1409 contents()->GetMainFrame(), 1, url, ui::PAGE_TRANSITION_TYPED); | 1426 contents()->GetMainFrame(), 1, url, ui::PAGE_TRANSITION_TYPED); |
1410 | 1427 |
1411 // Toggle fullscreen mode on (as if initiated via IPC from renderer). | 1428 // Toggle fullscreen mode on (as if initiated via IPC from renderer). |
1412 EXPECT_FALSE(test_rvh()->IsFullscreenGranted()); | 1429 EXPECT_FALSE(test_rvh()->IsFullscreenGranted()); |
1413 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab()); | 1430 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab()); |
1414 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents())); | 1431 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents())); |
1415 contents()->GetMainFrame()->OnMessageReceived(FrameHostMsg_ToggleFullscreen( | 1432 contents()->GetMainFrame()->OnMessageReceived(FrameHostMsg_ToggleFullscreen( |
1416 contents()->GetMainFrame()->GetRoutingID(), true)); | 1433 contents()->GetMainFrame()->GetRoutingID(), true)); |
1417 EXPECT_TRUE(test_rvh()->IsFullscreenGranted()); | 1434 EXPECT_TRUE(test_rvh()->IsFullscreenGranted()); |
(...skipping 17 matching lines...) Expand all Loading... | |
1435 // Interstitial Tests | 1452 // Interstitial Tests |
1436 //////////////////////////////////////////////////////////////////////////////// | 1453 //////////////////////////////////////////////////////////////////////////////// |
1437 | 1454 |
1438 // Test navigating to a page (with the navigation initiated from the browser, | 1455 // Test navigating to a page (with the navigation initiated from the browser, |
1439 // as when a URL is typed in the location bar) that shows an interstitial and | 1456 // as when a URL is typed in the location bar) that shows an interstitial and |
1440 // creates a new navigation entry, then hiding it without proceeding. | 1457 // creates a new navigation entry, then hiding it without proceeding. |
1441 TEST_F(WebContentsImplTest, | 1458 TEST_F(WebContentsImplTest, |
1442 ShowInterstitialFromBrowserWithNewNavigationDontProceed) { | 1459 ShowInterstitialFromBrowserWithNewNavigationDontProceed) { |
1443 // Navigate to a page. | 1460 // Navigate to a page. |
1444 GURL url1("http://www.google.com"); | 1461 GURL url1("http://www.google.com"); |
1445 contents()->GetMainFrame()->SendNavigate(1, url1); | 1462 main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); |
1446 EXPECT_EQ(1, controller().GetEntryCount()); | 1463 EXPECT_EQ(1, controller().GetEntryCount()); |
1447 | 1464 |
1448 // Initiate a browser navigation that will trigger the interstitial | 1465 // Initiate a browser navigation that will trigger the interstitial |
1449 controller().LoadURL(GURL("http://www.evil.com"), Referrer(), | 1466 controller().LoadURL(GURL("http://www.evil.com"), Referrer(), |
1450 ui::PAGE_TRANSITION_TYPED, std::string()); | 1467 ui::PAGE_TRANSITION_TYPED, std::string()); |
1451 | 1468 |
1452 // Show an interstitial. | 1469 // Show an interstitial. |
1453 TestInterstitialPage::InterstitialState state = | 1470 TestInterstitialPage::InterstitialState state = |
1454 TestInterstitialPage::INVALID; | 1471 TestInterstitialPage::INVALID; |
1455 bool deleted = false; | 1472 bool deleted = false; |
(...skipping 29 matching lines...) Expand all Loading... | |
1485 EXPECT_TRUE(deleted); | 1502 EXPECT_TRUE(deleted); |
1486 } | 1503 } |
1487 | 1504 |
1488 // Test navigating to a page (with the navigation initiated from the renderer, | 1505 // Test navigating to a page (with the navigation initiated from the renderer, |
1489 // as when clicking on a link in the page) that shows an interstitial and | 1506 // as when clicking on a link in the page) that shows an interstitial and |
1490 // creates a new navigation entry, then hiding it without proceeding. | 1507 // creates a new navigation entry, then hiding it without proceeding. |
1491 TEST_F(WebContentsImplTest, | 1508 TEST_F(WebContentsImplTest, |
1492 ShowInterstitiaFromRendererlWithNewNavigationDontProceed) { | 1509 ShowInterstitiaFromRendererlWithNewNavigationDontProceed) { |
1493 // Navigate to a page. | 1510 // Navigate to a page. |
1494 GURL url1("http://www.google.com"); | 1511 GURL url1("http://www.google.com"); |
1495 contents()->GetMainFrame()->SendNavigate(1, url1); | 1512 main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); |
1496 EXPECT_EQ(1, controller().GetEntryCount()); | 1513 EXPECT_EQ(1, controller().GetEntryCount()); |
1497 | 1514 |
1498 // Show an interstitial (no pending entry, the interstitial would have been | 1515 // Show an interstitial (no pending entry, the interstitial would have been |
1499 // triggered by clicking on a link). | 1516 // triggered by clicking on a link). |
1500 TestInterstitialPage::InterstitialState state = | 1517 TestInterstitialPage::InterstitialState state = |
1501 TestInterstitialPage::INVALID; | 1518 TestInterstitialPage::INVALID; |
1502 bool deleted = false; | 1519 bool deleted = false; |
1503 GURL url2("http://interstitial"); | 1520 GURL url2("http://interstitial"); |
1504 TestInterstitialPage* interstitial = | 1521 TestInterstitialPage* interstitial = |
1505 new TestInterstitialPage(contents(), true, url2, &state, &deleted); | 1522 new TestInterstitialPage(contents(), true, url2, &state, &deleted); |
(...skipping 25 matching lines...) Expand all Loading... | |
1531 RunAllPendingInMessageLoop(); | 1548 RunAllPendingInMessageLoop(); |
1532 EXPECT_TRUE(deleted); | 1549 EXPECT_TRUE(deleted); |
1533 } | 1550 } |
1534 | 1551 |
1535 // Test navigating to a page that shows an interstitial without creating a new | 1552 // Test navigating to a page that shows an interstitial without creating a new |
1536 // navigation entry (this happens when the interstitial is triggered by a | 1553 // navigation entry (this happens when the interstitial is triggered by a |
1537 // sub-resource in the page), then hiding it without proceeding. | 1554 // sub-resource in the page), then hiding it without proceeding. |
1538 TEST_F(WebContentsImplTest, ShowInterstitialNoNewNavigationDontProceed) { | 1555 TEST_F(WebContentsImplTest, ShowInterstitialNoNewNavigationDontProceed) { |
1539 // Navigate to a page. | 1556 // Navigate to a page. |
1540 GURL url1("http://www.google.com"); | 1557 GURL url1("http://www.google.com"); |
1541 contents()->GetMainFrame()->SendNavigate(1, url1); | 1558 main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); |
1542 EXPECT_EQ(1, controller().GetEntryCount()); | 1559 EXPECT_EQ(1, controller().GetEntryCount()); |
1543 | 1560 |
1544 // Show an interstitial. | 1561 // Show an interstitial. |
1545 TestInterstitialPage::InterstitialState state = | 1562 TestInterstitialPage::InterstitialState state = |
1546 TestInterstitialPage::INVALID; | 1563 TestInterstitialPage::INVALID; |
1547 bool deleted = false; | 1564 bool deleted = false; |
1548 GURL url2("http://interstitial"); | 1565 GURL url2("http://interstitial"); |
1549 TestInterstitialPage* interstitial = | 1566 TestInterstitialPage* interstitial = |
1550 new TestInterstitialPage(contents(), false, url2, &state, &deleted); | 1567 new TestInterstitialPage(contents(), false, url2, &state, &deleted); |
1551 TestInterstitialPageStateGuard state_guard(interstitial); | 1568 TestInterstitialPageStateGuard state_guard(interstitial); |
(...skipping 26 matching lines...) Expand all Loading... | |
1578 EXPECT_TRUE(deleted); | 1595 EXPECT_TRUE(deleted); |
1579 } | 1596 } |
1580 | 1597 |
1581 // Test navigating to a page (with the navigation initiated from the browser, | 1598 // Test navigating to a page (with the navigation initiated from the browser, |
1582 // as when a URL is typed in the location bar) that shows an interstitial and | 1599 // as when a URL is typed in the location bar) that shows an interstitial and |
1583 // creates a new navigation entry, then proceeding. | 1600 // creates a new navigation entry, then proceeding. |
1584 TEST_F(WebContentsImplTest, | 1601 TEST_F(WebContentsImplTest, |
1585 ShowInterstitialFromBrowserNewNavigationProceed) { | 1602 ShowInterstitialFromBrowserNewNavigationProceed) { |
1586 // Navigate to a page. | 1603 // Navigate to a page. |
1587 GURL url1("http://www.google.com"); | 1604 GURL url1("http://www.google.com"); |
1588 contents()->GetMainFrame()->SendNavigate(1, url1); | 1605 main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); |
1589 EXPECT_EQ(1, controller().GetEntryCount()); | 1606 EXPECT_EQ(1, controller().GetEntryCount()); |
1590 | 1607 |
1591 // Initiate a browser navigation that will trigger the interstitial | 1608 // Initiate a browser navigation that will trigger the interstitial |
1592 controller().LoadURL(GURL("http://www.evil.com"), Referrer(), | 1609 controller().LoadURL(GURL("http://www.evil.com"), Referrer(), |
1593 ui::PAGE_TRANSITION_TYPED, std::string()); | 1610 ui::PAGE_TRANSITION_TYPED, std::string()); |
1594 | 1611 |
1595 // Show an interstitial. | 1612 // Show an interstitial. |
1596 TestInterstitialPage::InterstitialState state = | 1613 TestInterstitialPage::InterstitialState state = |
1597 TestInterstitialPage::INVALID; | 1614 TestInterstitialPage::INVALID; |
1598 bool deleted = false; | 1615 bool deleted = false; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1640 EXPECT_TRUE(deleted); | 1657 EXPECT_TRUE(deleted); |
1641 } | 1658 } |
1642 | 1659 |
1643 // Test navigating to a page (with the navigation initiated from the renderer, | 1660 // Test navigating to a page (with the navigation initiated from the renderer, |
1644 // as when clicking on a link in the page) that shows an interstitial and | 1661 // as when clicking on a link in the page) that shows an interstitial and |
1645 // creates a new navigation entry, then proceeding. | 1662 // creates a new navigation entry, then proceeding. |
1646 TEST_F(WebContentsImplTest, | 1663 TEST_F(WebContentsImplTest, |
1647 ShowInterstitialFromRendererNewNavigationProceed) { | 1664 ShowInterstitialFromRendererNewNavigationProceed) { |
1648 // Navigate to a page. | 1665 // Navigate to a page. |
1649 GURL url1("http://www.google.com"); | 1666 GURL url1("http://www.google.com"); |
1650 contents()->GetMainFrame()->SendNavigate(1, url1); | 1667 main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); |
1651 EXPECT_EQ(1, controller().GetEntryCount()); | 1668 EXPECT_EQ(1, controller().GetEntryCount()); |
1652 | 1669 |
1653 // Show an interstitial. | 1670 // Show an interstitial. |
1654 TestInterstitialPage::InterstitialState state = | 1671 TestInterstitialPage::InterstitialState state = |
1655 TestInterstitialPage::INVALID; | 1672 TestInterstitialPage::INVALID; |
1656 bool deleted = false; | 1673 bool deleted = false; |
1657 GURL url2("http://interstitial"); | 1674 GURL url2("http://interstitial"); |
1658 TestInterstitialPage* interstitial = | 1675 TestInterstitialPage* interstitial = |
1659 new TestInterstitialPage(contents(), true, url2, &state, &deleted); | 1676 new TestInterstitialPage(contents(), true, url2, &state, &deleted); |
1660 TestInterstitialPageStateGuard state_guard(interstitial); | 1677 TestInterstitialPageStateGuard state_guard(interstitial); |
(...skipping 16 matching lines...) Expand all Loading... | |
1677 // The interstitial should show until the new navigation commits. | 1694 // The interstitial should show until the new navigation commits. |
1678 RunAllPendingInMessageLoop(); | 1695 RunAllPendingInMessageLoop(); |
1679 ASSERT_FALSE(deleted); | 1696 ASSERT_FALSE(deleted); |
1680 EXPECT_EQ(TestInterstitialPage::OKED, state); | 1697 EXPECT_EQ(TestInterstitialPage::OKED, state); |
1681 EXPECT_TRUE(contents()->ShowingInterstitialPage()); | 1698 EXPECT_TRUE(contents()->ShowingInterstitialPage()); |
1682 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); | 1699 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); |
1683 | 1700 |
1684 // Simulate the navigation to the page, that's when the interstitial gets | 1701 // Simulate the navigation to the page, that's when the interstitial gets |
1685 // hidden. | 1702 // hidden. |
1686 GURL url3("http://www.thepage.com"); | 1703 GURL url3("http://www.thepage.com"); |
1687 contents()->GetMainFrame()->SendNavigate(2, url3); | 1704 main_test_rfh()->NavigateAndCommitRendererInitiated(2, url3); |
1688 | 1705 |
1689 EXPECT_FALSE(contents()->ShowingInterstitialPage()); | 1706 EXPECT_FALSE(contents()->ShowingInterstitialPage()); |
1690 EXPECT_EQ(nullptr, contents()->GetInterstitialPage()); | 1707 EXPECT_EQ(nullptr, contents()->GetInterstitialPage()); |
1691 entry = controller().GetVisibleEntry(); | 1708 entry = controller().GetVisibleEntry(); |
1692 ASSERT_NE(nullptr, entry); | 1709 ASSERT_NE(nullptr, entry); |
1693 EXPECT_TRUE(entry->GetURL() == url3); | 1710 EXPECT_TRUE(entry->GetURL() == url3); |
1694 | 1711 |
1695 EXPECT_EQ(2, controller().GetEntryCount()); | 1712 EXPECT_EQ(2, controller().GetEntryCount()); |
1696 | 1713 |
1697 RunAllPendingInMessageLoop(); | 1714 RunAllPendingInMessageLoop(); |
1698 EXPECT_TRUE(deleted); | 1715 EXPECT_TRUE(deleted); |
1699 } | 1716 } |
1700 | 1717 |
1701 // Test navigating to a page that shows an interstitial without creating a new | 1718 // Test navigating to a page that shows an interstitial without creating a new |
1702 // navigation entry (this happens when the interstitial is triggered by a | 1719 // navigation entry (this happens when the interstitial is triggered by a |
1703 // sub-resource in the page), then proceeding. | 1720 // sub-resource in the page), then proceeding. |
1704 TEST_F(WebContentsImplTest, ShowInterstitialNoNewNavigationProceed) { | 1721 TEST_F(WebContentsImplTest, ShowInterstitialNoNewNavigationProceed) { |
1705 // Navigate to a page so we have a navigation entry in the controller. | 1722 // Navigate to a page so we have a navigation entry in the controller. |
1706 GURL url1("http://www.google.com"); | 1723 GURL url1("http://www.google.com"); |
1707 contents()->GetMainFrame()->SendNavigate(1, url1); | 1724 main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); |
1708 EXPECT_EQ(1, controller().GetEntryCount()); | 1725 EXPECT_EQ(1, controller().GetEntryCount()); |
1709 | 1726 |
1710 // Show an interstitial. | 1727 // Show an interstitial. |
1711 TestInterstitialPage::InterstitialState state = | 1728 TestInterstitialPage::InterstitialState state = |
1712 TestInterstitialPage::INVALID; | 1729 TestInterstitialPage::INVALID; |
1713 bool deleted = false; | 1730 bool deleted = false; |
1714 GURL url2("http://interstitial"); | 1731 GURL url2("http://interstitial"); |
1715 TestInterstitialPage* interstitial = | 1732 TestInterstitialPage* interstitial = |
1716 new TestInterstitialPage(contents(), false, url2, &state, &deleted); | 1733 new TestInterstitialPage(contents(), false, url2, &state, &deleted); |
1717 TestInterstitialPageStateGuard state_guard(interstitial); | 1734 TestInterstitialPageStateGuard state_guard(interstitial); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1755 bool deleted = false; | 1772 bool deleted = false; |
1756 GURL url("http://interstitial"); | 1773 GURL url("http://interstitial"); |
1757 TestInterstitialPage* interstitial = | 1774 TestInterstitialPage* interstitial = |
1758 new TestInterstitialPage(contents(), true, url, &state, &deleted); | 1775 new TestInterstitialPage(contents(), true, url, &state, &deleted); |
1759 TestInterstitialPageStateGuard state_guard(interstitial); | 1776 TestInterstitialPageStateGuard state_guard(interstitial); |
1760 interstitial->Show(); | 1777 interstitial->Show(); |
1761 interstitial->TestDidNavigate(1, url); | 1778 interstitial->TestDidNavigate(1, url); |
1762 | 1779 |
1763 // While interstitial showing, navigate to a new URL. | 1780 // While interstitial showing, navigate to a new URL. |
1764 const GURL url2("http://www.yahoo.com"); | 1781 const GURL url2("http://www.yahoo.com"); |
1765 contents()->GetMainFrame()->SendNavigate(1, url2); | 1782 main_test_rfh()->NavigateAndCommitRendererInitiated(1, url2); |
1766 | 1783 |
1767 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 1784 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
1768 | 1785 |
1769 RunAllPendingInMessageLoop(); | 1786 RunAllPendingInMessageLoop(); |
1770 EXPECT_TRUE(deleted); | 1787 EXPECT_TRUE(deleted); |
1771 } | 1788 } |
1772 | 1789 |
1773 // Test navigating to a page that shows an interstitial, then going back. | 1790 // Test navigating to a page that shows an interstitial, then going back. |
1774 TEST_F(WebContentsImplTest, ShowInterstitialThenGoBack) { | 1791 TEST_F(WebContentsImplTest, ShowInterstitialThenGoBack) { |
1775 // Navigate to a page so we have a navigation entry in the controller. | 1792 // Navigate to a page so we have a navigation entry in the controller. |
1776 GURL url1("http://www.google.com"); | 1793 GURL url1("http://www.google.com"); |
1777 contents()->GetMainFrame()->SendNavigate(1, url1); | 1794 main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); |
1778 EXPECT_EQ(1, controller().GetEntryCount()); | 1795 EXPECT_EQ(1, controller().GetEntryCount()); |
1779 | 1796 |
1780 // Show interstitial. | 1797 // Show interstitial. |
1781 TestInterstitialPage::InterstitialState state = | 1798 TestInterstitialPage::InterstitialState state = |
1782 TestInterstitialPage::INVALID; | 1799 TestInterstitialPage::INVALID; |
1783 bool deleted = false; | 1800 bool deleted = false; |
1784 GURL interstitial_url("http://interstitial"); | 1801 GURL interstitial_url("http://interstitial"); |
1785 TestInterstitialPage* interstitial = | 1802 TestInterstitialPage* interstitial = |
1786 new TestInterstitialPage(contents(), true, interstitial_url, | 1803 new TestInterstitialPage(contents(), true, interstitial_url, |
1787 &state, &deleted); | 1804 &state, &deleted); |
1788 TestInterstitialPageStateGuard state_guard(interstitial); | 1805 TestInterstitialPageStateGuard state_guard(interstitial); |
1789 interstitial->Show(); | 1806 interstitial->Show(); |
1790 interstitial->TestDidNavigate(2, interstitial_url); | 1807 interstitial->TestDidNavigate(2, interstitial_url); |
1791 | 1808 |
1792 // While the interstitial is showing, go back. | 1809 // While the interstitial is showing, go back. |
1793 controller().GoBack(); | 1810 controller().GoBack(); |
1811 main_test_rfh()->PrepareForCommit(); | |
1794 contents()->GetMainFrame()->SendNavigate(1, url1); | 1812 contents()->GetMainFrame()->SendNavigate(1, url1); |
1795 | 1813 |
1796 // Make sure we are back to the original page and that the interstitial is | 1814 // Make sure we are back to the original page and that the interstitial is |
1797 // gone. | 1815 // gone. |
1798 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 1816 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
1799 NavigationEntry* entry = controller().GetVisibleEntry(); | 1817 NavigationEntry* entry = controller().GetVisibleEntry(); |
1800 ASSERT_TRUE(entry); | 1818 ASSERT_TRUE(entry); |
1801 EXPECT_EQ(url1.spec(), entry->GetURL().spec()); | 1819 EXPECT_EQ(url1.spec(), entry->GetURL().spec()); |
1802 | 1820 |
1803 RunAllPendingInMessageLoop(); | 1821 RunAllPendingInMessageLoop(); |
1804 EXPECT_TRUE(deleted); | 1822 EXPECT_TRUE(deleted); |
1805 } | 1823 } |
1806 | 1824 |
1807 // Test navigating to a page that shows an interstitial, has a renderer crash, | 1825 // Test navigating to a page that shows an interstitial, has a renderer crash, |
1808 // and then goes back. | 1826 // and then goes back. |
1809 TEST_F(WebContentsImplTest, ShowInterstitialCrashRendererThenGoBack) { | 1827 TEST_F(WebContentsImplTest, ShowInterstitialCrashRendererThenGoBack) { |
1810 // Navigate to a page so we have a navigation entry in the controller. | 1828 // Navigate to a page so we have a navigation entry in the controller. |
1811 GURL url1("http://www.google.com"); | 1829 GURL url1("http://www.google.com"); |
1812 contents()->GetMainFrame()->SendNavigate(1, url1); | 1830 main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); |
1813 EXPECT_EQ(1, controller().GetEntryCount()); | 1831 EXPECT_EQ(1, controller().GetEntryCount()); |
1814 | 1832 |
1815 // Show interstitial. | 1833 // Show interstitial. |
1816 TestInterstitialPage::InterstitialState state = | 1834 TestInterstitialPage::InterstitialState state = |
1817 TestInterstitialPage::INVALID; | 1835 TestInterstitialPage::INVALID; |
1818 bool deleted = false; | 1836 bool deleted = false; |
1819 GURL interstitial_url("http://interstitial"); | 1837 GURL interstitial_url("http://interstitial"); |
1820 TestInterstitialPage* interstitial = | 1838 TestInterstitialPage* interstitial = |
1821 new TestInterstitialPage(contents(), true, interstitial_url, | 1839 new TestInterstitialPage(contents(), true, interstitial_url, |
1822 &state, &deleted); | 1840 &state, &deleted); |
1823 TestInterstitialPageStateGuard state_guard(interstitial); | 1841 TestInterstitialPageStateGuard state_guard(interstitial); |
1824 interstitial->Show(); | 1842 interstitial->Show(); |
1825 interstitial->TestDidNavigate(2, interstitial_url); | 1843 interstitial->TestDidNavigate(2, interstitial_url); |
1826 | 1844 |
1827 // Crash the renderer | 1845 // Crash the renderer |
1828 main_rfh()->OnMessageReceived( | 1846 main_rfh()->OnMessageReceived( |
1829 FrameHostMsg_RenderProcessGone( | 1847 FrameHostMsg_RenderProcessGone( |
1830 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); | 1848 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); |
1831 | 1849 |
1832 // While the interstitial is showing, go back. | 1850 // While the interstitial is showing, go back. |
1833 controller().GoBack(); | 1851 controller().GoBack(); |
1852 main_test_rfh()->PrepareForCommit(); | |
1834 contents()->GetMainFrame()->SendNavigate(1, url1); | 1853 contents()->GetMainFrame()->SendNavigate(1, url1); |
1835 | 1854 |
1836 // Make sure we are back to the original page and that the interstitial is | 1855 // Make sure we are back to the original page and that the interstitial is |
1837 // gone. | 1856 // gone. |
1838 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 1857 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
1839 NavigationEntry* entry = controller().GetVisibleEntry(); | 1858 NavigationEntry* entry = controller().GetVisibleEntry(); |
1840 ASSERT_TRUE(entry); | 1859 ASSERT_TRUE(entry); |
1841 EXPECT_EQ(url1.spec(), entry->GetURL().spec()); | 1860 EXPECT_EQ(url1.spec(), entry->GetURL().spec()); |
1842 | 1861 |
1843 RunAllPendingInMessageLoop(); | 1862 RunAllPendingInMessageLoop(); |
1844 EXPECT_TRUE(deleted); | 1863 EXPECT_TRUE(deleted); |
1845 } | 1864 } |
1846 | 1865 |
1847 // Test navigating to a page that shows an interstitial, has the renderer crash, | 1866 // Test navigating to a page that shows an interstitial, has the renderer crash, |
1848 // and then navigates to the interstitial. | 1867 // and then navigates to the interstitial. |
1849 TEST_F(WebContentsImplTest, ShowInterstitialCrashRendererThenNavigate) { | 1868 TEST_F(WebContentsImplTest, ShowInterstitialCrashRendererThenNavigate) { |
1850 // Navigate to a page so we have a navigation entry in the controller. | 1869 // Navigate to a page so we have a navigation entry in the controller. |
1851 GURL url1("http://www.google.com"); | 1870 GURL url1("http://www.google.com"); |
1852 contents()->GetMainFrame()->SendNavigate(1, url1); | 1871 main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); |
1853 EXPECT_EQ(1, controller().GetEntryCount()); | 1872 EXPECT_EQ(1, controller().GetEntryCount()); |
1854 | 1873 |
1855 // Show interstitial. | 1874 // Show interstitial. |
1856 TestInterstitialPage::InterstitialState state = | 1875 TestInterstitialPage::InterstitialState state = |
1857 TestInterstitialPage::INVALID; | 1876 TestInterstitialPage::INVALID; |
1858 bool deleted = false; | 1877 bool deleted = false; |
1859 GURL interstitial_url("http://interstitial"); | 1878 GURL interstitial_url("http://interstitial"); |
1860 TestInterstitialPage* interstitial = | 1879 TestInterstitialPage* interstitial = |
1861 new TestInterstitialPage(contents(), true, interstitial_url, | 1880 new TestInterstitialPage(contents(), true, interstitial_url, |
1862 &state, &deleted); | 1881 &state, &deleted); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1921 | 1940 |
1922 RunAllPendingInMessageLoop(); | 1941 RunAllPendingInMessageLoop(); |
1923 EXPECT_TRUE(deleted); | 1942 EXPECT_TRUE(deleted); |
1924 } | 1943 } |
1925 | 1944 |
1926 // Test that after Proceed is called and an interstitial is still shown, no more | 1945 // Test that after Proceed is called and an interstitial is still shown, no more |
1927 // commands get executed. | 1946 // commands get executed. |
1928 TEST_F(WebContentsImplTest, ShowInterstitialProceedMultipleCommands) { | 1947 TEST_F(WebContentsImplTest, ShowInterstitialProceedMultipleCommands) { |
1929 // Navigate to a page so we have a navigation entry in the controller. | 1948 // Navigate to a page so we have a navigation entry in the controller. |
1930 GURL url1("http://www.google.com"); | 1949 GURL url1("http://www.google.com"); |
1931 contents()->GetMainFrame()->SendNavigate(1, url1); | 1950 main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); |
1932 EXPECT_EQ(1, controller().GetEntryCount()); | 1951 EXPECT_EQ(1, controller().GetEntryCount()); |
1933 | 1952 |
1934 // Show an interstitial. | 1953 // Show an interstitial. |
1935 TestInterstitialPage::InterstitialState state = | 1954 TestInterstitialPage::InterstitialState state = |
1936 TestInterstitialPage::INVALID; | 1955 TestInterstitialPage::INVALID; |
1937 bool deleted = false; | 1956 bool deleted = false; |
1938 GURL url2("http://interstitial"); | 1957 GURL url2("http://interstitial"); |
1939 TestInterstitialPage* interstitial = | 1958 TestInterstitialPage* interstitial = |
1940 new TestInterstitialPage(contents(), true, url2, &state, &deleted); | 1959 new TestInterstitialPage(contents(), true, url2, &state, &deleted); |
1941 TestInterstitialPageStateGuard state_guard(interstitial); | 1960 TestInterstitialPageStateGuard state_guard(interstitial); |
(...skipping 14 matching lines...) Expand all Loading... | |
1956 // should be ignored. | 1975 // should be ignored. |
1957 interstitial->TestDomOperationResponse("hello"); | 1976 interstitial->TestDomOperationResponse("hello"); |
1958 interstitial->TestDomOperationResponse("hi"); | 1977 interstitial->TestDomOperationResponse("hi"); |
1959 EXPECT_EQ(1, interstitial->command_received_count()); | 1978 EXPECT_EQ(1, interstitial->command_received_count()); |
1960 } | 1979 } |
1961 | 1980 |
1962 // Test showing an interstitial while another interstitial is already showing. | 1981 // Test showing an interstitial while another interstitial is already showing. |
1963 TEST_F(WebContentsImplTest, ShowInterstitialOnInterstitial) { | 1982 TEST_F(WebContentsImplTest, ShowInterstitialOnInterstitial) { |
1964 // Navigate to a page so we have a navigation entry in the controller. | 1983 // Navigate to a page so we have a navigation entry in the controller. |
1965 GURL start_url("http://www.google.com"); | 1984 GURL start_url("http://www.google.com"); |
1966 contents()->GetMainFrame()->SendNavigate(1, start_url); | 1985 main_test_rfh()->NavigateAndCommitRendererInitiated(1, start_url); |
1967 EXPECT_EQ(1, controller().GetEntryCount()); | 1986 EXPECT_EQ(1, controller().GetEntryCount()); |
1968 | 1987 |
1969 // Show an interstitial. | 1988 // Show an interstitial. |
1970 TestInterstitialPage::InterstitialState state1 = | 1989 TestInterstitialPage::InterstitialState state1 = |
1971 TestInterstitialPage::INVALID; | 1990 TestInterstitialPage::INVALID; |
1972 bool deleted1 = false; | 1991 bool deleted1 = false; |
1973 GURL url1("http://interstitial1"); | 1992 GURL url1("http://interstitial1"); |
1974 TestInterstitialPage* interstitial1 = | 1993 TestInterstitialPage* interstitial1 = |
1975 new TestInterstitialPage(contents(), true, url1, &state1, &deleted1); | 1994 new TestInterstitialPage(contents(), true, url1, &state1, &deleted1); |
1976 TestInterstitialPageStateGuard state_guard1(interstitial1); | 1995 TestInterstitialPageStateGuard state_guard1(interstitial1); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2009 EXPECT_EQ(2, controller().GetEntryCount()); | 2028 EXPECT_EQ(2, controller().GetEntryCount()); |
2010 RunAllPendingInMessageLoop(); | 2029 RunAllPendingInMessageLoop(); |
2011 EXPECT_TRUE(deleted2); | 2030 EXPECT_TRUE(deleted2); |
2012 } | 2031 } |
2013 | 2032 |
2014 // Test showing an interstitial, proceeding and then navigating to another | 2033 // Test showing an interstitial, proceeding and then navigating to another |
2015 // interstitial. | 2034 // interstitial. |
2016 TEST_F(WebContentsImplTest, ShowInterstitialProceedShowInterstitial) { | 2035 TEST_F(WebContentsImplTest, ShowInterstitialProceedShowInterstitial) { |
2017 // Navigate to a page so we have a navigation entry in the controller. | 2036 // Navigate to a page so we have a navigation entry in the controller. |
2018 GURL start_url("http://www.google.com"); | 2037 GURL start_url("http://www.google.com"); |
2019 contents()->GetMainFrame()->SendNavigate(1, start_url); | 2038 main_test_rfh()->NavigateAndCommitRendererInitiated(1, start_url); |
2020 EXPECT_EQ(1, controller().GetEntryCount()); | 2039 EXPECT_EQ(1, controller().GetEntryCount()); |
2021 | 2040 |
2022 // Show an interstitial. | 2041 // Show an interstitial. |
2023 TestInterstitialPage::InterstitialState state1 = | 2042 TestInterstitialPage::InterstitialState state1 = |
2024 TestInterstitialPage::INVALID; | 2043 TestInterstitialPage::INVALID; |
2025 bool deleted1 = false; | 2044 bool deleted1 = false; |
2026 GURL url1("http://interstitial1"); | 2045 GURL url1("http://interstitial1"); |
2027 TestInterstitialPage* interstitial1 = | 2046 TestInterstitialPage* interstitial1 = |
2028 new TestInterstitialPage(contents(), true, url1, &state1, &deleted1); | 2047 new TestInterstitialPage(contents(), true, url1, &state1, &deleted1); |
2029 TestInterstitialPageStateGuard state_guard1(interstitial1); | 2048 TestInterstitialPageStateGuard state_guard1(interstitial1); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2223 | 2242 |
2224 // Tests that Javascript messages are not shown while an interstitial is | 2243 // Tests that Javascript messages are not shown while an interstitial is |
2225 // showing. | 2244 // showing. |
2226 TEST_F(WebContentsImplTest, NoJSMessageOnInterstitials) { | 2245 TEST_F(WebContentsImplTest, NoJSMessageOnInterstitials) { |
2227 const char kUrl[] = "http://www.badguys.com/"; | 2246 const char kUrl[] = "http://www.badguys.com/"; |
2228 const GURL kGURL(kUrl); | 2247 const GURL kGURL(kUrl); |
2229 | 2248 |
2230 // Start a navigation to a page | 2249 // Start a navigation to a page |
2231 contents()->GetController().LoadURL( | 2250 contents()->GetController().LoadURL( |
2232 kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2251 kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
2252 main_test_rfh()->PrepareForCommit(); | |
2233 // DidNavigate from the page | 2253 // DidNavigate from the page |
2234 contents()->TestDidNavigate( | 2254 contents()->TestDidNavigate( |
2235 contents()->GetMainFrame(), 1, kGURL, ui::PAGE_TRANSITION_TYPED); | 2255 contents()->GetMainFrame(), 1, kGURL, ui::PAGE_TRANSITION_TYPED); |
2236 | 2256 |
2237 // Simulate showing an interstitial while the page is showing. | 2257 // Simulate showing an interstitial while the page is showing. |
2238 TestInterstitialPage::InterstitialState state = | 2258 TestInterstitialPage::InterstitialState state = |
2239 TestInterstitialPage::INVALID; | 2259 TestInterstitialPage::INVALID; |
2240 bool deleted = false; | 2260 bool deleted = false; |
2241 TestInterstitialPage* interstitial = | 2261 TestInterstitialPage* interstitial = |
2242 new TestInterstitialPage(contents(), true, kGURL, &state, &deleted); | 2262 new TestInterstitialPage(contents(), true, kGURL, &state, &deleted); |
2243 TestInterstitialPageStateGuard state_guard(interstitial); | 2263 TestInterstitialPageStateGuard state_guard(interstitial); |
2244 interstitial->Show(); | 2264 interstitial->Show(); |
2245 interstitial->TestDidNavigate(1, kGURL); | 2265 interstitial->TestDidNavigate(1, kGURL); |
2246 | 2266 |
2247 // While the interstitial is showing, let's simulate the hidden page | 2267 // While the interstitial is showing, let's simulate the hidden page |
2248 // attempting to show a JS message. | 2268 // attempting to show a JS message. |
2249 IPC::Message* dummy_message = new IPC::Message; | 2269 IPC::Message* dummy_message = new IPC::Message; |
2250 contents()->RunJavaScriptMessage(contents()->GetMainFrame(), | 2270 contents()->RunJavaScriptMessage(contents()->GetMainFrame(), |
2251 base::ASCIIToUTF16("This is an informative message"), | 2271 base::ASCIIToUTF16("This is an informative message"), |
2252 base::ASCIIToUTF16("OK"), | 2272 base::ASCIIToUTF16("OK"), |
2253 kGURL, JAVASCRIPT_MESSAGE_TYPE_ALERT, dummy_message); | 2273 kGURL, JAVASCRIPT_MESSAGE_TYPE_ALERT, dummy_message); |
2254 EXPECT_TRUE(contents()->last_dialog_suppressed_); | 2274 EXPECT_TRUE(contents()->last_dialog_suppressed_); |
2255 } | 2275 } |
2256 | 2276 |
2257 // Makes sure that if the source passed to CopyStateFromAndPrune has an | 2277 // Makes sure that if the source passed to CopyStateFromAndPrune has an |
2258 // interstitial it isn't copied over to the destination. | 2278 // interstitial it isn't copied over to the destination. |
2259 TEST_F(WebContentsImplTest, CopyStateFromAndPruneSourceInterstitial) { | 2279 TEST_F(WebContentsImplTest, CopyStateFromAndPruneSourceInterstitial) { |
2260 // Navigate to a page. | 2280 // Navigate to a page. |
2261 GURL url1("http://www.google.com"); | 2281 GURL url1("http://www.google.com"); |
2262 contents()->GetMainFrame()->SendNavigate(1, url1); | 2282 main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); |
2263 EXPECT_EQ(1, controller().GetEntryCount()); | 2283 EXPECT_EQ(1, controller().GetEntryCount()); |
2264 | 2284 |
2265 // Initiate a browser navigation that will trigger the interstitial | 2285 // Initiate a browser navigation that will trigger the interstitial |
2266 controller().LoadURL(GURL("http://www.evil.com"), Referrer(), | 2286 controller().LoadURL(GURL("http://www.evil.com"), Referrer(), |
2267 ui::PAGE_TRANSITION_TYPED, std::string()); | 2287 ui::PAGE_TRANSITION_TYPED, std::string()); |
2268 | 2288 |
2269 // Show an interstitial. | 2289 // Show an interstitial. |
2270 TestInterstitialPage::InterstitialState state = | 2290 TestInterstitialPage::InterstitialState state = |
2271 TestInterstitialPage::INVALID; | 2291 TestInterstitialPage::INVALID; |
2272 bool deleted = false; | 2292 bool deleted = false; |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2653 EXPECT_EQ(1u, instance->GetRelatedActiveContentsCount()); | 2673 EXPECT_EQ(1u, instance->GetRelatedActiveContentsCount()); |
2654 | 2674 |
2655 // Navigate to a URL in a different site. | 2675 // Navigate to a URL in a different site. |
2656 const GURL kUrl = GURL("http://b.com"); | 2676 const GURL kUrl = GURL("http://b.com"); |
2657 contents->GetController().LoadURL(kUrl, | 2677 contents->GetController().LoadURL(kUrl, |
2658 Referrer(), | 2678 Referrer(), |
2659 ui::PAGE_TRANSITION_TYPED, | 2679 ui::PAGE_TRANSITION_TYPED, |
2660 std::string()); | 2680 std::string()); |
2661 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 2681 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
2662 switches::kEnableBrowserSideNavigation)) { | 2682 switches::kEnableBrowserSideNavigation)) { |
2663 contents->GetMainFrame()->SendBeforeUnloadACK(true); | 2683 contents->GetMainFrame()->PrepareForCommit(); |
2664 } | 2684 } |
2665 EXPECT_TRUE(contents->cross_navigation_pending()); | 2685 EXPECT_TRUE(contents->CrossNavigationPending()); |
2666 EXPECT_EQ(1u, instance->GetRelatedActiveContentsCount()); | 2686 EXPECT_EQ(1u, instance->GetRelatedActiveContentsCount()); |
2667 contents->CommitPendingNavigation(); | 2687 contents->GetPendingMainFrame()->SendNavigate(1, kUrl); |
2668 EXPECT_EQ(1u, instance->GetRelatedActiveContentsCount()); | 2688 EXPECT_EQ(1u, instance->GetRelatedActiveContentsCount()); |
2669 | 2689 |
2670 contents.reset(); | 2690 contents.reset(); |
2671 EXPECT_EQ(0u, instance->GetRelatedActiveContentsCount()); | 2691 EXPECT_EQ(0u, instance->GetRelatedActiveContentsCount()); |
2672 } | 2692 } |
2673 | 2693 |
2674 // Tests that GetRelatedActiveContentsCount tracks BrowsingInstance changes | 2694 // Tests that GetRelatedActiveContentsCount tracks BrowsingInstance changes |
2675 // from WebUI. | 2695 // from WebUI. |
2676 TEST_F(WebContentsImplTest, ActiveContentsCountChangeBrowsingInstance) { | 2696 TEST_F(WebContentsImplTest, ActiveContentsCountChangeBrowsingInstance) { |
2677 scoped_refptr<SiteInstance> instance( | 2697 scoped_refptr<SiteInstance> instance( |
2678 SiteInstance::Create(browser_context())); | 2698 SiteInstance::Create(browser_context())); |
2679 | 2699 |
2680 EXPECT_EQ(0u, instance->GetRelatedActiveContentsCount()); | 2700 EXPECT_EQ(0u, instance->GetRelatedActiveContentsCount()); |
2681 | 2701 |
2682 scoped_ptr<TestWebContents> contents( | 2702 scoped_ptr<TestWebContents> contents( |
2683 TestWebContents::Create(browser_context(), instance.get())); | 2703 TestWebContents::Create(browser_context(), instance.get())); |
2684 EXPECT_EQ(1u, instance->GetRelatedActiveContentsCount()); | 2704 EXPECT_EQ(1u, instance->GetRelatedActiveContentsCount()); |
2685 | 2705 |
2686 // Navigate to a URL. | 2706 // Navigate to a URL. |
2687 contents->NavigateAndCommit(GURL("http://a.com")); | 2707 contents->NavigateAndCommit(GURL("http://a.com")); |
2688 EXPECT_EQ(1u, instance->GetRelatedActiveContentsCount()); | 2708 EXPECT_EQ(1u, instance->GetRelatedActiveContentsCount()); |
2689 | 2709 |
2690 // Navigate to a URL with WebUI. This will change BrowsingInstances. | 2710 // Navigate to a URL with WebUI. This will change BrowsingInstances. |
2691 contents->GetController().LoadURL(GURL(kTestWebUIUrl), | 2711 contents->GetController().LoadURL(GURL(kTestWebUIUrl), |
2692 Referrer(), | 2712 Referrer(), |
2693 ui::PAGE_TRANSITION_TYPED, | 2713 ui::PAGE_TRANSITION_TYPED, |
2694 std::string()); | 2714 std::string()); |
2695 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 2715 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
2696 switches::kEnableBrowserSideNavigation)) { | 2716 switches::kEnableBrowserSideNavigation)) { |
2697 contents->GetMainFrame()->SendBeforeUnloadACK(true); | 2717 contents->GetMainFrame()->PrepareForCommit(); |
2698 } | 2718 } |
2699 EXPECT_TRUE(contents->cross_navigation_pending()); | 2719 EXPECT_TRUE(contents->CrossNavigationPending()); |
2700 scoped_refptr<SiteInstance> instance_webui( | 2720 scoped_refptr<SiteInstance> instance_webui( |
2701 contents->GetPendingMainFrame()->GetSiteInstance()); | 2721 contents->GetPendingMainFrame()->GetSiteInstance()); |
2702 EXPECT_FALSE(instance->IsRelatedSiteInstance(instance_webui.get())); | 2722 EXPECT_FALSE(instance->IsRelatedSiteInstance(instance_webui.get())); |
2703 | 2723 |
2704 // At this point, contents still counts for the old BrowsingInstance. | 2724 // At this point, contents still counts for the old BrowsingInstance. |
2705 EXPECT_EQ(1u, instance->GetRelatedActiveContentsCount()); | 2725 EXPECT_EQ(1u, instance->GetRelatedActiveContentsCount()); |
2706 EXPECT_EQ(0u, instance_webui->GetRelatedActiveContentsCount()); | 2726 EXPECT_EQ(0u, instance_webui->GetRelatedActiveContentsCount()); |
2707 | 2727 |
2708 // Commit and contents counts for the new one. | 2728 // Commit and contents counts for the new one. |
2709 contents->CommitPendingNavigation(); | 2729 contents->CommitPendingNavigation(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2742 // * Subframe navigates more than once before the top-level frame has had a | 2762 // * Subframe navigates more than once before the top-level frame has had a |
2743 // chance to complete the load. | 2763 // chance to complete the load. |
2744 // The subframe navigations cause the loading_frames_in_progress_ to drop down | 2764 // The subframe navigations cause the loading_frames_in_progress_ to drop down |
2745 // to 0, while the loading_progresses_ map is not reset. | 2765 // to 0, while the loading_progresses_ map is not reset. |
2746 TEST_F(WebContentsImplTest, StartStopEventsBalance) { | 2766 TEST_F(WebContentsImplTest, StartStopEventsBalance) { |
2747 // The bug manifests itself in regular mode as well, but browser-initiated | 2767 // The bug manifests itself in regular mode as well, but browser-initiated |
2748 // navigation of subframes is only possible in --site-per-process mode within | 2768 // navigation of subframes is only possible in --site-per-process mode within |
2749 // unit tests. | 2769 // unit tests. |
2750 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 2770 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
2751 switches::kSitePerProcess); | 2771 switches::kSitePerProcess); |
2772 const GURL initial_url("about:blank"); | |
2752 const GURL main_url("http://www.chromium.org"); | 2773 const GURL main_url("http://www.chromium.org"); |
2753 const GURL foo_url("http://foo.chromium.org"); | 2774 const GURL foo_url("http://foo.chromium.org"); |
2754 const GURL bar_url("http://bar.chromium.org"); | 2775 const GURL bar_url("http://bar.chromium.org"); |
2755 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); | 2776 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); |
2756 | 2777 |
2757 // Use a WebContentsObserver to approximate the behavior of the tab's spinner. | 2778 // Use a WebContentsObserver to approximate the behavior of the tab's spinner. |
2758 LoadingWebContentsObserver observer(contents()); | 2779 LoadingWebContentsObserver observer(contents()); |
2759 | 2780 |
2760 // Navigate the main RenderFrame, simulate the DidStartLoading, and commit. | 2781 // Navigate the main RenderFrame, simulate the DidStartLoading, and commit. |
2761 // The frame should still be loading. | 2782 // The frame should still be loading. |
2762 controller().LoadURL( | 2783 controller().LoadURL( |
2763 main_url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2784 main_url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
2785 orig_rfh->PrepareForCommit(); | |
2764 orig_rfh->OnMessageReceived( | 2786 orig_rfh->OnMessageReceived( |
2765 FrameHostMsg_DidStartLoading(orig_rfh->GetRoutingID(), false)); | 2787 FrameHostMsg_DidStartLoading(orig_rfh->GetRoutingID(), false)); |
2766 contents()->TestDidNavigate(orig_rfh, 1, main_url, ui::PAGE_TRANSITION_TYPED); | 2788 contents()->TestDidNavigate(orig_rfh, 1, main_url, ui::PAGE_TRANSITION_TYPED); |
2767 EXPECT_FALSE(contents()->cross_navigation_pending()); | 2789 EXPECT_FALSE(contents()->CrossNavigationPending()); |
2768 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); | 2790 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); |
2769 EXPECT_TRUE(contents()->IsLoading()); | 2791 EXPECT_TRUE(contents()->IsLoading()); |
2770 EXPECT_TRUE(observer.is_loading()); | 2792 EXPECT_TRUE(observer.is_loading()); |
2771 | 2793 |
2772 // Create a child frame to navigate multiple times. | 2794 // Create a child frame to navigate multiple times. |
2773 TestRenderFrameHost* subframe = orig_rfh->AppendChild("subframe"); | 2795 TestRenderFrameHost* subframe = orig_rfh->AppendChild("subframe"); |
2774 | 2796 |
2775 // Navigate the child frame to about:blank, which will send both | 2797 // Navigate the child frame to about:blank, which will send both |
2776 // DidStartLoading and DidStopLoading messages. | 2798 // DidStartLoading and DidStopLoading messages. |
2777 { | 2799 { |
2800 subframe->SendRendererInitiatedNavigationRequest(initial_url, false); | |
2801 subframe->PrepareForCommit(); | |
2778 subframe->OnMessageReceived( | 2802 subframe->OnMessageReceived( |
2779 FrameHostMsg_DidStartLoading(subframe->GetRoutingID(), true)); | 2803 FrameHostMsg_DidStartLoading(subframe->GetRoutingID(), true)); |
2780 subframe->SendNavigateWithTransition( | 2804 subframe->SendNavigateWithTransition(1, initial_url, |
2781 1, GURL("about:blank"), ui::PAGE_TRANSITION_AUTO_SUBFRAME); | 2805 ui::PAGE_TRANSITION_AUTO_SUBFRAME); |
2782 subframe->OnMessageReceived( | 2806 subframe->OnMessageReceived( |
2783 FrameHostMsg_DidStopLoading(subframe->GetRoutingID())); | 2807 FrameHostMsg_DidStopLoading(subframe->GetRoutingID())); |
2784 } | 2808 } |
2785 | 2809 |
2786 // Navigate the frame to another URL, which will send again | 2810 // Navigate the frame to another URL, which will send again |
2787 // DidStartLoading and DidStopLoading messages. | 2811 // DidStartLoading and DidStopLoading messages. |
2788 { | 2812 { |
2813 subframe->SendRendererInitiatedNavigationRequest(foo_url, false); | |
2814 subframe->PrepareForCommit(); | |
2789 subframe->OnMessageReceived( | 2815 subframe->OnMessageReceived( |
2790 FrameHostMsg_DidStartLoading(subframe->GetRoutingID(), true)); | 2816 FrameHostMsg_DidStartLoading(subframe->GetRoutingID(), true)); |
2791 subframe->SendNavigateWithTransition( | 2817 subframe->SendNavigateWithTransition( |
2792 1, foo_url, ui::PAGE_TRANSITION_AUTO_SUBFRAME); | 2818 1, foo_url, ui::PAGE_TRANSITION_AUTO_SUBFRAME); |
2793 subframe->OnMessageReceived( | 2819 subframe->OnMessageReceived( |
2794 FrameHostMsg_DidStopLoading(subframe->GetRoutingID())); | 2820 FrameHostMsg_DidStopLoading(subframe->GetRoutingID())); |
2795 } | 2821 } |
2796 | 2822 |
2797 // Since the main frame hasn't sent any DidStopLoading messages, it is | 2823 // Since the main frame hasn't sent any DidStopLoading messages, it is |
2798 // expected that the WebContents is still in loading state. | 2824 // expected that the WebContents is still in loading state. |
(...skipping 14 matching lines...) Expand all Loading... | |
2813 load_params.override_user_agent = NavigationController::UA_OVERRIDE_TRUE; | 2839 load_params.override_user_agent = NavigationController::UA_OVERRIDE_TRUE; |
2814 load_params.frame_tree_node_id = | 2840 load_params.frame_tree_node_id = |
2815 subframe->frame_tree_node()->frame_tree_node_id(); | 2841 subframe->frame_tree_node()->frame_tree_node_id(); |
2816 controller().LoadURLWithParams(load_params); | 2842 controller().LoadURLWithParams(load_params); |
2817 | 2843 |
2818 subframe->OnMessageReceived( | 2844 subframe->OnMessageReceived( |
2819 FrameHostMsg_DidStartLoading(subframe->GetRoutingID(), true)); | 2845 FrameHostMsg_DidStartLoading(subframe->GetRoutingID(), true)); |
2820 | 2846 |
2821 // Commit the navigation in the child frame and send the DidStopLoading | 2847 // Commit the navigation in the child frame and send the DidStopLoading |
2822 // message. | 2848 // message. |
2849 subframe->PrepareForCommit(); | |
2823 contents()->TestDidNavigate( | 2850 contents()->TestDidNavigate( |
2824 subframe, 3, bar_url, ui::PAGE_TRANSITION_MANUAL_SUBFRAME); | 2851 subframe, 3, bar_url, ui::PAGE_TRANSITION_MANUAL_SUBFRAME); |
2825 subframe->OnMessageReceived( | 2852 subframe->OnMessageReceived( |
2826 FrameHostMsg_DidStopLoading(subframe->GetRoutingID())); | 2853 FrameHostMsg_DidStopLoading(subframe->GetRoutingID())); |
2827 } | 2854 } |
2828 | 2855 |
2829 // At this point the status should still be loading, since the main frame | 2856 // At this point the status should still be loading, since the main frame |
2830 // hasn't sent the DidstopLoading message yet. | 2857 // hasn't sent the DidstopLoading message yet. |
2831 EXPECT_TRUE(contents()->IsLoading()); | 2858 EXPECT_TRUE(contents()->IsLoading()); |
2832 EXPECT_TRUE(observer.is_loading()); | 2859 EXPECT_TRUE(observer.is_loading()); |
(...skipping 17 matching lines...) Expand all Loading... | |
2850 const GURL kUrl3("http://www.wikipedia.org"); | 2877 const GURL kUrl3("http://www.wikipedia.org"); |
2851 | 2878 |
2852 contents()->NavigateAndCommit(kUrl1); | 2879 contents()->NavigateAndCommit(kUrl1); |
2853 | 2880 |
2854 TestRenderFrameHost* current_rfh = contents()->GetMainFrame(); | 2881 TestRenderFrameHost* current_rfh = contents()->GetMainFrame(); |
2855 | 2882 |
2856 // Start a browser-initiated cross-process navigation to |kUrl2|. There should | 2883 // Start a browser-initiated cross-process navigation to |kUrl2|. There should |
2857 // be a pending RenderFrameHost and the WebContents should be loading. | 2884 // be a pending RenderFrameHost and the WebContents should be loading. |
2858 controller().LoadURL( | 2885 controller().LoadURL( |
2859 kUrl2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2886 kUrl2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
2860 EXPECT_TRUE(contents()->cross_navigation_pending()); | 2887 EXPECT_TRUE(contents()->CrossNavigationPending()); |
2861 TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame(); | 2888 TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame(); |
2862 ASSERT_TRUE(pending_rfh); | 2889 ASSERT_TRUE(pending_rfh); |
2863 EXPECT_TRUE(contents()->IsLoading()); | 2890 EXPECT_TRUE(contents()->IsLoading()); |
2864 | 2891 |
2865 // The current RenderFrameHost starts a non user-initiated render-initiated | 2892 // The current RenderFrameHost starts a non user-initiated render-initiated |
2866 // navigation and sends a DidStartLoading IPC. The WebContents should still be | 2893 // navigation and sends a DidStartLoading IPC. The WebContents should still be |
2867 // loading. | 2894 // loading. |
2868 current_rfh->OnMessageReceived( | 2895 current_rfh->OnMessageReceived( |
2869 FrameHostMsg_DidStartLoading(current_rfh->GetRoutingID(), false)); | 2896 FrameHostMsg_DidStartLoading(current_rfh->GetRoutingID(), false)); |
2870 EXPECT_TRUE(contents()->IsLoading()); | 2897 EXPECT_TRUE(contents()->IsLoading()); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3014 contents()->GetMainFrame()->OnMessageReceived( | 3041 contents()->GetMainFrame()->OnMessageReceived( |
3015 FrameHostMsg_RenderProcessGone( | 3042 FrameHostMsg_RenderProcessGone( |
3016 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); | 3043 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); |
3017 | 3044 |
3018 // Verify that all the power save blockers have been released. | 3045 // Verify that all the power save blockers have been released. |
3019 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); | 3046 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); |
3020 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); | 3047 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); |
3021 } | 3048 } |
3022 | 3049 |
3023 } // namespace content | 3050 } // namespace content |
OLD | NEW |