OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 5 #include "base/logging.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "content/browser/mock_content_browser_client.h" | 7 #include "content/browser/mock_content_browser_client.h" |
8 #include "content/browser/renderer_host/render_view_host.h" | 8 #include "content/browser/renderer_host/render_view_host.h" |
9 #include "content/browser/renderer_host/render_widget_host_view.h" | 9 #include "content/browser/renderer_host/render_widget_host_view.h" |
10 #include "content/browser/renderer_host/test_render_view_host.h" | 10 #include "content/browser/renderer_host/test_render_view_host.h" |
11 #include "content/browser/site_instance.h" | 11 #include "content/browser/site_instance.h" |
12 #include "content/browser/tab_contents/interstitial_page.h" | 12 #include "content/browser/tab_contents/interstitial_page.h" |
13 #include "content/browser/tab_contents/navigation_entry.h" | 13 #include "content/browser/tab_contents/navigation_entry_impl.h" |
14 #include "content/browser/tab_contents/test_tab_contents.h" | 14 #include "content/browser/tab_contents/test_tab_contents.h" |
15 #include "content/browser/webui/empty_web_ui_factory.h" | 15 #include "content/browser/webui/empty_web_ui_factory.h" |
16 #include "content/common/view_messages.h" | 16 #include "content/common/view_messages.h" |
17 #include "content/public/browser/navigation_details.h" | 17 #include "content/public/browser/navigation_details.h" |
18 #include "content/public/browser/notification_details.h" | 18 #include "content/public/browser/notification_details.h" |
19 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
20 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
21 #include "content/public/common/bindings_policy.h" | 21 #include "content/public/common/bindings_policy.h" |
22 #include "content/public/common/content_constants.h" | 22 #include "content/public/common/content_constants.h" |
23 #include "content/public/common/url_constants.h" | 23 #include "content/public/common/url_constants.h" |
24 #include "content/test/test_browser_thread.h" | 24 #include "content/test/test_browser_thread.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
26 #include "webkit/glue/webkit_glue.h" | 26 #include "webkit/glue/webkit_glue.h" |
27 | 27 |
28 using content::BrowserThread; | 28 using content::BrowserThread; |
| 29 using content::NavigationEntry; |
| 30 using content::NavigationEntryImpl; |
29 using webkit::forms::PasswordForm; | 31 using webkit::forms::PasswordForm; |
30 | 32 |
31 namespace { | 33 namespace { |
32 | 34 |
33 class TabContentsTestWebUIFactory : public content::EmptyWebUIFactory { | 35 class TabContentsTestWebUIFactory : public content::EmptyWebUIFactory { |
34 public: | 36 public: |
35 virtual WebUI* CreateWebUIForURL(TabContents* source, | 37 virtual WebUI* CreateWebUIForURL(TabContents* source, |
36 const GURL& url) const OVERRIDE { | 38 const GURL& url) const OVERRIDE { |
37 if (!HasWebUIScheme(url)) | 39 if (!HasWebUIScheme(url)) |
38 return NULL; | 40 return NULL; |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 | 300 |
299 // Navigate to URL | 301 // Navigate to URL |
300 const GURL url("http://www.google.com"); | 302 const GURL url("http://www.google.com"); |
301 controller().LoadURL( | 303 controller().LoadURL( |
302 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 304 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
303 EXPECT_FALSE(contents()->cross_navigation_pending()); | 305 EXPECT_FALSE(contents()->cross_navigation_pending()); |
304 EXPECT_EQ(instance1, orig_rvh->site_instance()); | 306 EXPECT_EQ(instance1, orig_rvh->site_instance()); |
305 // Controller's pending entry will have a NULL site instance until we assign | 307 // Controller's pending entry will have a NULL site instance until we assign |
306 // it in DidNavigate. | 308 // it in DidNavigate. |
307 EXPECT_TRUE( | 309 EXPECT_TRUE( |
308 NavigationEntry::FromNavigationEntry(controller().GetActiveEntry())-> | 310 NavigationEntryImpl::FromNavigationEntry(controller().GetActiveEntry())-> |
309 site_instance() == NULL); | 311 site_instance() == NULL); |
310 | 312 |
311 // DidNavigate from the page | 313 // DidNavigate from the page |
312 contents()->TestDidNavigate(orig_rvh, 1, url, content::PAGE_TRANSITION_TYPED); | 314 contents()->TestDidNavigate(orig_rvh, 1, url, content::PAGE_TRANSITION_TYPED); |
313 EXPECT_FALSE(contents()->cross_navigation_pending()); | 315 EXPECT_FALSE(contents()->cross_navigation_pending()); |
314 EXPECT_EQ(orig_rvh, contents()->GetRenderViewHost()); | 316 EXPECT_EQ(orig_rvh, contents()->GetRenderViewHost()); |
315 EXPECT_EQ(instance1, orig_rvh->site_instance()); | 317 EXPECT_EQ(instance1, orig_rvh->site_instance()); |
316 // Controller's entry should now have the SiteInstance, or else we won't be | 318 // Controller's entry should now have the SiteInstance, or else we won't be |
317 // able to find it later. | 319 // able to find it later. |
318 EXPECT_EQ( | 320 EXPECT_EQ( |
319 instance1, | 321 instance1, |
320 NavigationEntry::FromNavigationEntry(controller().GetActiveEntry())-> | 322 NavigationEntryImpl::FromNavigationEntry(controller().GetActiveEntry())-> |
321 site_instance()); | 323 site_instance()); |
322 } | 324 } |
323 | 325 |
324 // Test that we reject NavigateToEntry if the url is over content::kMaxURLChars. | 326 // Test that we reject NavigateToEntry if the url is over content::kMaxURLChars. |
325 TEST_F(TabContentsTest, NavigateToExcessivelyLongURL) { | 327 TEST_F(TabContentsTest, NavigateToExcessivelyLongURL) { |
326 // Construct a URL that's kMaxURLChars + 1 long of all 'a's. | 328 // Construct a URL that's kMaxURLChars + 1 long of all 'a's. |
327 const GURL url(std::string("http://example.org/").append( | 329 const GURL url(std::string("http://example.org/").append( |
328 content::kMaxURLChars + 1, 'a')); | 330 content::kMaxURLChars + 1, 'a')); |
329 | 331 |
330 controller().LoadURL( | 332 controller().LoadURL( |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 | 653 |
652 TEST_F(TabContentsTest, CrossSiteNavigationBackPreempted) { | 654 TEST_F(TabContentsTest, CrossSiteNavigationBackPreempted) { |
653 contents()->transition_cross_site = true; | 655 contents()->transition_cross_site = true; |
654 | 656 |
655 // Start with a web ui page, which gets a new RVH with WebUI bindings. | 657 // Start with a web ui page, which gets a new RVH with WebUI bindings. |
656 const GURL url1("tabcontentstest://blah"); | 658 const GURL url1("tabcontentstest://blah"); |
657 controller().LoadURL( | 659 controller().LoadURL( |
658 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 660 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
659 TestRenderViewHost* ntp_rvh = rvh(); | 661 TestRenderViewHost* ntp_rvh = rvh(); |
660 contents()->TestDidNavigate(ntp_rvh, 1, url1, content::PAGE_TRANSITION_TYPED); | 662 contents()->TestDidNavigate(ntp_rvh, 1, url1, content::PAGE_TRANSITION_TYPED); |
661 content::NavigationEntry* entry1 = controller().GetLastCommittedEntry(); | 663 NavigationEntry* entry1 = controller().GetLastCommittedEntry(); |
662 SiteInstance* instance1 = contents()->GetSiteInstance(); | 664 SiteInstance* instance1 = contents()->GetSiteInstance(); |
663 | 665 |
664 EXPECT_FALSE(contents()->cross_navigation_pending()); | 666 EXPECT_FALSE(contents()->cross_navigation_pending()); |
665 EXPECT_EQ(ntp_rvh, contents()->GetRenderViewHost()); | 667 EXPECT_EQ(ntp_rvh, contents()->GetRenderViewHost()); |
666 EXPECT_EQ(url1, entry1->GetURL()); | 668 EXPECT_EQ(url1, entry1->GetURL()); |
667 EXPECT_EQ(instance1, | 669 EXPECT_EQ(instance1, |
668 NavigationEntry::FromNavigationEntry(entry1)->site_instance()); | 670 NavigationEntryImpl::FromNavigationEntry(entry1)->site_instance()); |
669 EXPECT_TRUE(ntp_rvh->enabled_bindings() & content::BINDINGS_POLICY_WEB_UI); | 671 EXPECT_TRUE(ntp_rvh->enabled_bindings() & content::BINDINGS_POLICY_WEB_UI); |
670 | 672 |
671 // Navigate to new site. | 673 // Navigate to new site. |
672 const GURL url2("http://www.google.com"); | 674 const GURL url2("http://www.google.com"); |
673 controller().LoadURL( | 675 controller().LoadURL( |
674 url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 676 url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
675 EXPECT_TRUE(contents()->cross_navigation_pending()); | 677 EXPECT_TRUE(contents()->cross_navigation_pending()); |
676 TestRenderViewHost* google_rvh = contents()->pending_rvh(); | 678 TestRenderViewHost* google_rvh = contents()->pending_rvh(); |
677 | 679 |
678 // Simulate beforeunload approval. | 680 // Simulate beforeunload approval. |
679 EXPECT_TRUE(ntp_rvh->is_waiting_for_beforeunload_ack()); | 681 EXPECT_TRUE(ntp_rvh->is_waiting_for_beforeunload_ack()); |
680 ntp_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true)); | 682 ntp_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true)); |
681 | 683 |
682 // DidNavigate from the pending page. | 684 // DidNavigate from the pending page. |
683 contents()->TestDidNavigate( | 685 contents()->TestDidNavigate( |
684 google_rvh, 1, url2, content::PAGE_TRANSITION_TYPED); | 686 google_rvh, 1, url2, content::PAGE_TRANSITION_TYPED); |
685 content::NavigationEntry* entry2 = controller().GetLastCommittedEntry(); | 687 NavigationEntry* entry2 = controller().GetLastCommittedEntry(); |
686 SiteInstance* instance2 = contents()->GetSiteInstance(); | 688 SiteInstance* instance2 = contents()->GetSiteInstance(); |
687 | 689 |
688 EXPECT_FALSE(contents()->cross_navigation_pending()); | 690 EXPECT_FALSE(contents()->cross_navigation_pending()); |
689 EXPECT_EQ(google_rvh, contents()->GetRenderViewHost()); | 691 EXPECT_EQ(google_rvh, contents()->GetRenderViewHost()); |
690 EXPECT_NE(instance1, instance2); | 692 EXPECT_NE(instance1, instance2); |
691 EXPECT_FALSE(contents()->pending_rvh()); | 693 EXPECT_FALSE(contents()->pending_rvh()); |
692 EXPECT_EQ(url2, entry2->GetURL()); | 694 EXPECT_EQ(url2, entry2->GetURL()); |
693 EXPECT_EQ(instance2, | 695 EXPECT_EQ(instance2, |
694 NavigationEntry::FromNavigationEntry(entry2)->site_instance()); | 696 NavigationEntryImpl::FromNavigationEntry(entry2)->site_instance()); |
695 EXPECT_FALSE(google_rvh->enabled_bindings() & | 697 EXPECT_FALSE(google_rvh->enabled_bindings() & |
696 content::BINDINGS_POLICY_WEB_UI); | 698 content::BINDINGS_POLICY_WEB_UI); |
697 | 699 |
698 // Navigate to third page on same site. | 700 // Navigate to third page on same site. |
699 const GURL url3("http://news.google.com"); | 701 const GURL url3("http://news.google.com"); |
700 controller().LoadURL( | 702 controller().LoadURL( |
701 url3, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 703 url3, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
702 EXPECT_FALSE(contents()->cross_navigation_pending()); | 704 EXPECT_FALSE(contents()->cross_navigation_pending()); |
703 contents()->TestDidNavigate( | 705 contents()->TestDidNavigate( |
704 google_rvh, 2, url3, content::PAGE_TRANSITION_TYPED); | 706 google_rvh, 2, url3, content::PAGE_TRANSITION_TYPED); |
705 content::NavigationEntry* entry3 = controller().GetLastCommittedEntry(); | 707 NavigationEntry* entry3 = controller().GetLastCommittedEntry(); |
706 SiteInstance* instance3 = contents()->GetSiteInstance(); | 708 SiteInstance* instance3 = contents()->GetSiteInstance(); |
707 | 709 |
708 EXPECT_FALSE(contents()->cross_navigation_pending()); | 710 EXPECT_FALSE(contents()->cross_navigation_pending()); |
709 EXPECT_EQ(google_rvh, contents()->GetRenderViewHost()); | 711 EXPECT_EQ(google_rvh, contents()->GetRenderViewHost()); |
710 EXPECT_EQ(instance2, instance3); | 712 EXPECT_EQ(instance2, instance3); |
711 EXPECT_FALSE(contents()->pending_rvh()); | 713 EXPECT_FALSE(contents()->pending_rvh()); |
712 EXPECT_EQ(url3, entry3->GetURL()); | 714 EXPECT_EQ(url3, entry3->GetURL()); |
713 EXPECT_EQ(instance3, | 715 EXPECT_EQ(instance3, |
714 NavigationEntry::FromNavigationEntry(entry3)->site_instance()); | 716 NavigationEntryImpl::FromNavigationEntry(entry3)->site_instance()); |
715 | 717 |
716 // Go back within the site. | 718 // Go back within the site. |
717 controller().GoBack(); | 719 controller().GoBack(); |
718 EXPECT_FALSE(contents()->cross_navigation_pending()); | 720 EXPECT_FALSE(contents()->cross_navigation_pending()); |
719 EXPECT_EQ(entry2, controller().GetPendingEntry()); | 721 EXPECT_EQ(entry2, controller().GetPendingEntry()); |
720 | 722 |
721 // Before that commits, go back again. | 723 // Before that commits, go back again. |
722 controller().GoBack(); | 724 controller().GoBack(); |
723 EXPECT_TRUE(contents()->cross_navigation_pending()); | 725 EXPECT_TRUE(contents()->cross_navigation_pending()); |
724 EXPECT_TRUE(contents()->pending_rvh()); | 726 EXPECT_TRUE(contents()->pending_rvh()); |
725 EXPECT_EQ(entry1, controller().GetPendingEntry()); | 727 EXPECT_EQ(entry1, controller().GetPendingEntry()); |
726 | 728 |
727 // Simulate beforeunload approval. | 729 // Simulate beforeunload approval. |
728 EXPECT_TRUE(google_rvh->is_waiting_for_beforeunload_ack()); | 730 EXPECT_TRUE(google_rvh->is_waiting_for_beforeunload_ack()); |
729 google_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true)); | 731 google_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true)); |
730 | 732 |
731 // DidNavigate from the first back. This aborts the second back's pending RVH. | 733 // DidNavigate from the first back. This aborts the second back's pending RVH. |
732 contents()->TestDidNavigate( | 734 contents()->TestDidNavigate( |
733 google_rvh, 1, url2, content::PAGE_TRANSITION_TYPED); | 735 google_rvh, 1, url2, content::PAGE_TRANSITION_TYPED); |
734 | 736 |
735 // We should commit this page and forget about the second back. | 737 // We should commit this page and forget about the second back. |
736 EXPECT_FALSE(contents()->cross_navigation_pending()); | 738 EXPECT_FALSE(contents()->cross_navigation_pending()); |
737 EXPECT_FALSE(controller().GetPendingEntry()); | 739 EXPECT_FALSE(controller().GetPendingEntry()); |
738 EXPECT_EQ(google_rvh, contents()->GetRenderViewHost()); | 740 EXPECT_EQ(google_rvh, contents()->GetRenderViewHost()); |
739 EXPECT_EQ(url2, controller().GetLastCommittedEntry()->GetURL()); | 741 EXPECT_EQ(url2, controller().GetLastCommittedEntry()->GetURL()); |
740 | 742 |
741 // We should not have corrupted the NTP entry. | 743 // We should not have corrupted the NTP entry. |
742 EXPECT_EQ(instance3, | 744 EXPECT_EQ(instance3, |
743 NavigationEntry::FromNavigationEntry(entry3)->site_instance()); | 745 NavigationEntryImpl::FromNavigationEntry(entry3)->site_instance()); |
744 EXPECT_EQ(instance2, | 746 EXPECT_EQ(instance2, |
745 NavigationEntry::FromNavigationEntry(entry2)->site_instance()); | 747 NavigationEntryImpl::FromNavigationEntry(entry2)->site_instance()); |
746 EXPECT_EQ(instance1, | 748 EXPECT_EQ(instance1, |
747 NavigationEntry::FromNavigationEntry(entry1)->site_instance()); | 749 NavigationEntryImpl::FromNavigationEntry(entry1)->site_instance()); |
748 EXPECT_EQ(url1, entry1->GetURL()); | 750 EXPECT_EQ(url1, entry1->GetURL()); |
749 } | 751 } |
750 | 752 |
751 // Test that during a slow cross-site navigation, a sub-frame navigation in the | 753 // Test that during a slow cross-site navigation, a sub-frame navigation in the |
752 // original renderer will not cancel the slow navigation (bug 42029). | 754 // original renderer will not cancel the slow navigation (bug 42029). |
753 TEST_F(TabContentsTest, CrossSiteNavigationNotPreemptedByFrame) { | 755 TEST_F(TabContentsTest, CrossSiteNavigationNotPreemptedByFrame) { |
754 contents()->transition_cross_site = true; | 756 contents()->transition_cross_site = true; |
755 TestRenderViewHost* orig_rvh = rvh(); | 757 TestRenderViewHost* orig_rvh = rvh(); |
756 | 758 |
757 // Navigate to URL. First URL should use first RenderViewHost. | 759 // Navigate to URL. First URL should use first RenderViewHost. |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 | 916 |
915 // Test that NavigationEntries have the correct content state after going | 917 // Test that NavigationEntries have the correct content state after going |
916 // forward and back. Prevents regression for bug 1116137. | 918 // forward and back. Prevents regression for bug 1116137. |
917 TEST_F(TabContentsTest, NavigationEntryContentState) { | 919 TEST_F(TabContentsTest, NavigationEntryContentState) { |
918 TestRenderViewHost* orig_rvh = rvh(); | 920 TestRenderViewHost* orig_rvh = rvh(); |
919 | 921 |
920 // Navigate to URL. There should be no committed entry yet. | 922 // Navigate to URL. There should be no committed entry yet. |
921 const GURL url("http://www.google.com"); | 923 const GURL url("http://www.google.com"); |
922 controller().LoadURL( | 924 controller().LoadURL( |
923 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 925 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
924 content::NavigationEntry* entry = controller().GetLastCommittedEntry(); | 926 NavigationEntry* entry = controller().GetLastCommittedEntry(); |
925 EXPECT_TRUE(entry == NULL); | 927 EXPECT_TRUE(entry == NULL); |
926 | 928 |
927 // Committed entry should have content state after DidNavigate. | 929 // Committed entry should have content state after DidNavigate. |
928 contents()->TestDidNavigate(orig_rvh, 1, url, content::PAGE_TRANSITION_TYPED); | 930 contents()->TestDidNavigate(orig_rvh, 1, url, content::PAGE_TRANSITION_TYPED); |
929 entry = controller().GetLastCommittedEntry(); | 931 entry = controller().GetLastCommittedEntry(); |
930 EXPECT_FALSE(entry->GetContentState().empty()); | 932 EXPECT_FALSE(entry->GetContentState().empty()); |
931 | 933 |
932 // Navigate to same site. | 934 // Navigate to same site. |
933 const GURL url2("http://images.google.com"); | 935 const GURL url2("http://images.google.com"); |
934 controller().LoadURL( | 936 controller().LoadURL( |
(...skipping 19 matching lines...) Expand all Loading... |
954 TEST_F(TabContentsTest, NavigationEntryContentStateNewWindow) { | 956 TEST_F(TabContentsTest, NavigationEntryContentStateNewWindow) { |
955 TestRenderViewHost* orig_rvh = rvh(); | 957 TestRenderViewHost* orig_rvh = rvh(); |
956 | 958 |
957 // When opening a new window, it is navigated to about:blank internally. | 959 // When opening a new window, it is navigated to about:blank internally. |
958 // Currently, this results in two DidNavigate events. | 960 // Currently, this results in two DidNavigate events. |
959 const GURL url(chrome::kAboutBlankURL); | 961 const GURL url(chrome::kAboutBlankURL); |
960 contents()->TestDidNavigate(orig_rvh, 1, url, content::PAGE_TRANSITION_TYPED); | 962 contents()->TestDidNavigate(orig_rvh, 1, url, content::PAGE_TRANSITION_TYPED); |
961 contents()->TestDidNavigate(orig_rvh, 1, url, content::PAGE_TRANSITION_TYPED); | 963 contents()->TestDidNavigate(orig_rvh, 1, url, content::PAGE_TRANSITION_TYPED); |
962 | 964 |
963 // Should have a content state here. | 965 // Should have a content state here. |
964 content::NavigationEntry* entry = controller().GetLastCommittedEntry(); | 966 NavigationEntry* entry = controller().GetLastCommittedEntry(); |
965 EXPECT_FALSE(entry->GetContentState().empty()); | 967 EXPECT_FALSE(entry->GetContentState().empty()); |
966 } | 968 } |
967 | 969 |
968 //////////////////////////////////////////////////////////////////////////////// | 970 //////////////////////////////////////////////////////////////////////////////// |
969 // Interstitial Tests | 971 // Interstitial Tests |
970 //////////////////////////////////////////////////////////////////////////////// | 972 //////////////////////////////////////////////////////////////////////////////// |
971 | 973 |
972 // Test navigating to a page (with the navigation initiated from the browser, | 974 // Test navigating to a page (with the navigation initiated from the browser, |
973 // as when a URL is typed in the location bar) that shows an interstitial and | 975 // as when a URL is typed in the location bar) that shows an interstitial and |
974 // creates a new navigation entry, then hiding it without proceeding. | 976 // creates a new navigation entry, then hiding it without proceeding. |
(...skipping 19 matching lines...) Expand all Loading... |
994 interstitial->Show(); | 996 interstitial->Show(); |
995 // The interstitial should not show until its navigation has committed. | 997 // The interstitial should not show until its navigation has committed. |
996 EXPECT_FALSE(interstitial->is_showing()); | 998 EXPECT_FALSE(interstitial->is_showing()); |
997 EXPECT_FALSE(contents()->ShowingInterstitialPage()); | 999 EXPECT_FALSE(contents()->ShowingInterstitialPage()); |
998 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); | 1000 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); |
999 // Let's commit the interstitial navigation. | 1001 // Let's commit the interstitial navigation. |
1000 interstitial->TestDidNavigate(1, url2); | 1002 interstitial->TestDidNavigate(1, url2); |
1001 EXPECT_TRUE(interstitial->is_showing()); | 1003 EXPECT_TRUE(interstitial->is_showing()); |
1002 EXPECT_TRUE(contents()->ShowingInterstitialPage()); | 1004 EXPECT_TRUE(contents()->ShowingInterstitialPage()); |
1003 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); | 1005 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); |
1004 content::NavigationEntry* entry = controller().GetActiveEntry(); | 1006 NavigationEntry* entry = controller().GetActiveEntry(); |
1005 ASSERT_TRUE(entry != NULL); | 1007 ASSERT_TRUE(entry != NULL); |
1006 EXPECT_TRUE(entry->GetURL() == url2); | 1008 EXPECT_TRUE(entry->GetURL() == url2); |
1007 | 1009 |
1008 // Now don't proceed. | 1010 // Now don't proceed. |
1009 interstitial->DontProceed(); | 1011 interstitial->DontProceed(); |
1010 EXPECT_TRUE(deleted); | 1012 EXPECT_TRUE(deleted); |
1011 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 1013 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
1012 EXPECT_FALSE(contents()->ShowingInterstitialPage()); | 1014 EXPECT_FALSE(contents()->ShowingInterstitialPage()); |
1013 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); | 1015 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); |
1014 entry = controller().GetActiveEntry(); | 1016 entry = controller().GetActiveEntry(); |
(...skipping 24 matching lines...) Expand all Loading... |
1039 interstitial->Show(); | 1041 interstitial->Show(); |
1040 // The interstitial should not show until its navigation has committed. | 1042 // The interstitial should not show until its navigation has committed. |
1041 EXPECT_FALSE(interstitial->is_showing()); | 1043 EXPECT_FALSE(interstitial->is_showing()); |
1042 EXPECT_FALSE(contents()->ShowingInterstitialPage()); | 1044 EXPECT_FALSE(contents()->ShowingInterstitialPage()); |
1043 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); | 1045 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); |
1044 // Let's commit the interstitial navigation. | 1046 // Let's commit the interstitial navigation. |
1045 interstitial->TestDidNavigate(1, url2); | 1047 interstitial->TestDidNavigate(1, url2); |
1046 EXPECT_TRUE(interstitial->is_showing()); | 1048 EXPECT_TRUE(interstitial->is_showing()); |
1047 EXPECT_TRUE(contents()->ShowingInterstitialPage()); | 1049 EXPECT_TRUE(contents()->ShowingInterstitialPage()); |
1048 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); | 1050 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); |
1049 content::NavigationEntry* entry = controller().GetActiveEntry(); | 1051 NavigationEntry* entry = controller().GetActiveEntry(); |
1050 ASSERT_TRUE(entry != NULL); | 1052 ASSERT_TRUE(entry != NULL); |
1051 EXPECT_TRUE(entry->GetURL() == url2); | 1053 EXPECT_TRUE(entry->GetURL() == url2); |
1052 | 1054 |
1053 // Now don't proceed. | 1055 // Now don't proceed. |
1054 interstitial->DontProceed(); | 1056 interstitial->DontProceed(); |
1055 EXPECT_TRUE(deleted); | 1057 EXPECT_TRUE(deleted); |
1056 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 1058 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
1057 EXPECT_FALSE(contents()->ShowingInterstitialPage()); | 1059 EXPECT_FALSE(contents()->ShowingInterstitialPage()); |
1058 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); | 1060 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); |
1059 entry = controller().GetActiveEntry(); | 1061 entry = controller().GetActiveEntry(); |
(...skipping 22 matching lines...) Expand all Loading... |
1082 interstitial->Show(); | 1084 interstitial->Show(); |
1083 // The interstitial should not show until its navigation has committed. | 1085 // The interstitial should not show until its navigation has committed. |
1084 EXPECT_FALSE(interstitial->is_showing()); | 1086 EXPECT_FALSE(interstitial->is_showing()); |
1085 EXPECT_FALSE(contents()->ShowingInterstitialPage()); | 1087 EXPECT_FALSE(contents()->ShowingInterstitialPage()); |
1086 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); | 1088 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); |
1087 // Let's commit the interstitial navigation. | 1089 // Let's commit the interstitial navigation. |
1088 interstitial->TestDidNavigate(1, url2); | 1090 interstitial->TestDidNavigate(1, url2); |
1089 EXPECT_TRUE(interstitial->is_showing()); | 1091 EXPECT_TRUE(interstitial->is_showing()); |
1090 EXPECT_TRUE(contents()->ShowingInterstitialPage()); | 1092 EXPECT_TRUE(contents()->ShowingInterstitialPage()); |
1091 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); | 1093 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); |
1092 content::NavigationEntry* entry = controller().GetActiveEntry(); | 1094 NavigationEntry* entry = controller().GetActiveEntry(); |
1093 ASSERT_TRUE(entry != NULL); | 1095 ASSERT_TRUE(entry != NULL); |
1094 // The URL specified to the interstitial should have been ignored. | 1096 // The URL specified to the interstitial should have been ignored. |
1095 EXPECT_TRUE(entry->GetURL() == url1); | 1097 EXPECT_TRUE(entry->GetURL() == url1); |
1096 | 1098 |
1097 // Now don't proceed. | 1099 // Now don't proceed. |
1098 interstitial->DontProceed(); | 1100 interstitial->DontProceed(); |
1099 EXPECT_TRUE(deleted); | 1101 EXPECT_TRUE(deleted); |
1100 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 1102 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
1101 EXPECT_FALSE(contents()->ShowingInterstitialPage()); | 1103 EXPECT_FALSE(contents()->ShowingInterstitialPage()); |
1102 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); | 1104 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); |
(...skipping 28 matching lines...) Expand all Loading... |
1131 interstitial->Show(); | 1133 interstitial->Show(); |
1132 // The interstitial should not show until its navigation has committed. | 1134 // The interstitial should not show until its navigation has committed. |
1133 EXPECT_FALSE(interstitial->is_showing()); | 1135 EXPECT_FALSE(interstitial->is_showing()); |
1134 EXPECT_FALSE(contents()->ShowingInterstitialPage()); | 1136 EXPECT_FALSE(contents()->ShowingInterstitialPage()); |
1135 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); | 1137 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); |
1136 // Let's commit the interstitial navigation. | 1138 // Let's commit the interstitial navigation. |
1137 interstitial->TestDidNavigate(1, url2); | 1139 interstitial->TestDidNavigate(1, url2); |
1138 EXPECT_TRUE(interstitial->is_showing()); | 1140 EXPECT_TRUE(interstitial->is_showing()); |
1139 EXPECT_TRUE(contents()->ShowingInterstitialPage()); | 1141 EXPECT_TRUE(contents()->ShowingInterstitialPage()); |
1140 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); | 1142 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); |
1141 content::NavigationEntry* entry = controller().GetActiveEntry(); | 1143 NavigationEntry* entry = controller().GetActiveEntry(); |
1142 ASSERT_TRUE(entry != NULL); | 1144 ASSERT_TRUE(entry != NULL); |
1143 EXPECT_TRUE(entry->GetURL() == url2); | 1145 EXPECT_TRUE(entry->GetURL() == url2); |
1144 | 1146 |
1145 // Then proceed. | 1147 // Then proceed. |
1146 interstitial->Proceed(); | 1148 interstitial->Proceed(); |
1147 // The interstitial should show until the new navigation commits. | 1149 // The interstitial should show until the new navigation commits. |
1148 ASSERT_FALSE(deleted); | 1150 ASSERT_FALSE(deleted); |
1149 EXPECT_EQ(TestInterstitialPage::OKED, state); | 1151 EXPECT_EQ(TestInterstitialPage::OKED, state); |
1150 EXPECT_TRUE(contents()->ShowingInterstitialPage()); | 1152 EXPECT_TRUE(contents()->ShowingInterstitialPage()); |
1151 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); | 1153 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1186 interstitial->Show(); | 1188 interstitial->Show(); |
1187 // The interstitial should not show until its navigation has committed. | 1189 // The interstitial should not show until its navigation has committed. |
1188 EXPECT_FALSE(interstitial->is_showing()); | 1190 EXPECT_FALSE(interstitial->is_showing()); |
1189 EXPECT_FALSE(contents()->ShowingInterstitialPage()); | 1191 EXPECT_FALSE(contents()->ShowingInterstitialPage()); |
1190 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); | 1192 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); |
1191 // Let's commit the interstitial navigation. | 1193 // Let's commit the interstitial navigation. |
1192 interstitial->TestDidNavigate(1, url2); | 1194 interstitial->TestDidNavigate(1, url2); |
1193 EXPECT_TRUE(interstitial->is_showing()); | 1195 EXPECT_TRUE(interstitial->is_showing()); |
1194 EXPECT_TRUE(contents()->ShowingInterstitialPage()); | 1196 EXPECT_TRUE(contents()->ShowingInterstitialPage()); |
1195 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); | 1197 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); |
1196 content::NavigationEntry* entry = controller().GetActiveEntry(); | 1198 NavigationEntry* entry = controller().GetActiveEntry(); |
1197 ASSERT_TRUE(entry != NULL); | 1199 ASSERT_TRUE(entry != NULL); |
1198 EXPECT_TRUE(entry->GetURL() == url2); | 1200 EXPECT_TRUE(entry->GetURL() == url2); |
1199 | 1201 |
1200 // Then proceed. | 1202 // Then proceed. |
1201 interstitial->Proceed(); | 1203 interstitial->Proceed(); |
1202 // The interstitial should show until the new navigation commits. | 1204 // The interstitial should show until the new navigation commits. |
1203 ASSERT_FALSE(deleted); | 1205 ASSERT_FALSE(deleted); |
1204 EXPECT_EQ(TestInterstitialPage::OKED, state); | 1206 EXPECT_EQ(TestInterstitialPage::OKED, state); |
1205 EXPECT_TRUE(contents()->ShowingInterstitialPage()); | 1207 EXPECT_TRUE(contents()->ShowingInterstitialPage()); |
1206 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); | 1208 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 interstitial->Show(); | 1242 interstitial->Show(); |
1241 // The interstitial should not show until its navigation has committed. | 1243 // The interstitial should not show until its navigation has committed. |
1242 EXPECT_FALSE(interstitial->is_showing()); | 1244 EXPECT_FALSE(interstitial->is_showing()); |
1243 EXPECT_FALSE(contents()->ShowingInterstitialPage()); | 1245 EXPECT_FALSE(contents()->ShowingInterstitialPage()); |
1244 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); | 1246 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); |
1245 // Let's commit the interstitial navigation. | 1247 // Let's commit the interstitial navigation. |
1246 interstitial->TestDidNavigate(1, url2); | 1248 interstitial->TestDidNavigate(1, url2); |
1247 EXPECT_TRUE(interstitial->is_showing()); | 1249 EXPECT_TRUE(interstitial->is_showing()); |
1248 EXPECT_TRUE(contents()->ShowingInterstitialPage()); | 1250 EXPECT_TRUE(contents()->ShowingInterstitialPage()); |
1249 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); | 1251 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); |
1250 content::NavigationEntry* entry = controller().GetActiveEntry(); | 1252 NavigationEntry* entry = controller().GetActiveEntry(); |
1251 ASSERT_TRUE(entry != NULL); | 1253 ASSERT_TRUE(entry != NULL); |
1252 // The URL specified to the interstitial should have been ignored. | 1254 // The URL specified to the interstitial should have been ignored. |
1253 EXPECT_TRUE(entry->GetURL() == url1); | 1255 EXPECT_TRUE(entry->GetURL() == url1); |
1254 | 1256 |
1255 // Then proceed. | 1257 // Then proceed. |
1256 interstitial->Proceed(); | 1258 interstitial->Proceed(); |
1257 // Since this is not a new navigation, the previous page is dismissed right | 1259 // Since this is not a new navigation, the previous page is dismissed right |
1258 // away and shows the original page. | 1260 // away and shows the original page. |
1259 EXPECT_TRUE(deleted); | 1261 EXPECT_TRUE(deleted); |
1260 EXPECT_EQ(TestInterstitialPage::OKED, state); | 1262 EXPECT_EQ(TestInterstitialPage::OKED, state); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1308 interstitial->TestDidNavigate(2, interstitial_url); | 1310 interstitial->TestDidNavigate(2, interstitial_url); |
1309 | 1311 |
1310 // While the interstitial is showing, go back. | 1312 // While the interstitial is showing, go back. |
1311 controller().GoBack(); | 1313 controller().GoBack(); |
1312 rvh()->SendNavigate(1, url1); | 1314 rvh()->SendNavigate(1, url1); |
1313 | 1315 |
1314 // Make sure we are back to the original page and that the interstitial is | 1316 // Make sure we are back to the original page and that the interstitial is |
1315 // gone. | 1317 // gone. |
1316 EXPECT_TRUE(deleted); | 1318 EXPECT_TRUE(deleted); |
1317 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 1319 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
1318 content::NavigationEntry* entry = controller().GetActiveEntry(); | 1320 NavigationEntry* entry = controller().GetActiveEntry(); |
1319 ASSERT_TRUE(entry); | 1321 ASSERT_TRUE(entry); |
1320 EXPECT_EQ(url1.spec(), entry->GetURL().spec()); | 1322 EXPECT_EQ(url1.spec(), entry->GetURL().spec()); |
1321 } | 1323 } |
1322 | 1324 |
1323 // Test navigating to a page that shows an interstitial, has a renderer crash, | 1325 // Test navigating to a page that shows an interstitial, has a renderer crash, |
1324 // and then goes back. | 1326 // and then goes back. |
1325 TEST_F(TabContentsTest, ShowInterstitialCrashRendererThenGoBack) { | 1327 TEST_F(TabContentsTest, ShowInterstitialCrashRendererThenGoBack) { |
1326 // Navigate to a page so we have a navigation entry in the controller. | 1328 // Navigate to a page so we have a navigation entry in the controller. |
1327 GURL url1("http://www.google.com"); | 1329 GURL url1("http://www.google.com"); |
1328 rvh()->SendNavigate(1, url1); | 1330 rvh()->SendNavigate(1, url1); |
(...skipping 17 matching lines...) Expand all Loading... |
1346 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); | 1348 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); |
1347 | 1349 |
1348 // While the interstitial is showing, go back. | 1350 // While the interstitial is showing, go back. |
1349 controller().GoBack(); | 1351 controller().GoBack(); |
1350 rvh()->SendNavigate(1, url1); | 1352 rvh()->SendNavigate(1, url1); |
1351 | 1353 |
1352 // Make sure we are back to the original page and that the interstitial is | 1354 // Make sure we are back to the original page and that the interstitial is |
1353 // gone. | 1355 // gone. |
1354 EXPECT_TRUE(deleted); | 1356 EXPECT_TRUE(deleted); |
1355 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 1357 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
1356 content::NavigationEntry* entry = controller().GetActiveEntry(); | 1358 NavigationEntry* entry = controller().GetActiveEntry(); |
1357 ASSERT_TRUE(entry); | 1359 ASSERT_TRUE(entry); |
1358 EXPECT_EQ(url1.spec(), entry->GetURL().spec()); | 1360 EXPECT_EQ(url1.spec(), entry->GetURL().spec()); |
1359 } | 1361 } |
1360 | 1362 |
1361 // Test navigating to a page that shows an interstitial, has the renderer crash, | 1363 // Test navigating to a page that shows an interstitial, has the renderer crash, |
1362 // and then navigates to the interstitial. | 1364 // and then navigates to the interstitial. |
1363 TEST_F(TabContentsTest, ShowInterstitialCrashRendererThenNavigate) { | 1365 TEST_F(TabContentsTest, ShowInterstitialCrashRendererThenNavigate) { |
1364 // Navigate to a page so we have a navigation entry in the controller. | 1366 // Navigate to a page so we have a navigation entry in the controller. |
1365 GURL url1("http://www.google.com"); | 1367 GURL url1("http://www.google.com"); |
1366 rvh()->SendNavigate(1, url1); | 1368 rvh()->SendNavigate(1, url1); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1475 // Let's make sure interstitial2 is working as intended. | 1477 // Let's make sure interstitial2 is working as intended. |
1476 ASSERT_FALSE(deleted2); | 1478 ASSERT_FALSE(deleted2); |
1477 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2); | 1479 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2); |
1478 interstitial2->Proceed(); | 1480 interstitial2->Proceed(); |
1479 GURL landing_url("http://www.thepage.com"); | 1481 GURL landing_url("http://www.thepage.com"); |
1480 rvh()->SendNavigate(2, landing_url); | 1482 rvh()->SendNavigate(2, landing_url); |
1481 | 1483 |
1482 EXPECT_TRUE(deleted2); | 1484 EXPECT_TRUE(deleted2); |
1483 EXPECT_FALSE(contents()->ShowingInterstitialPage()); | 1485 EXPECT_FALSE(contents()->ShowingInterstitialPage()); |
1484 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); | 1486 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); |
1485 content::NavigationEntry* entry = controller().GetActiveEntry(); | 1487 NavigationEntry* entry = controller().GetActiveEntry(); |
1486 ASSERT_TRUE(entry != NULL); | 1488 ASSERT_TRUE(entry != NULL); |
1487 EXPECT_TRUE(entry->GetURL() == landing_url); | 1489 EXPECT_TRUE(entry->GetURL() == landing_url); |
1488 EXPECT_EQ(2, controller().entry_count()); | 1490 EXPECT_EQ(2, controller().entry_count()); |
1489 } | 1491 } |
1490 | 1492 |
1491 // Test showing an interstitial, proceeding and then navigating to another | 1493 // Test showing an interstitial, proceeding and then navigating to another |
1492 // interstitial. | 1494 // interstitial. |
1493 TEST_F(TabContentsTest, ShowInterstitialProceedShowInterstitial) { | 1495 TEST_F(TabContentsTest, ShowInterstitialProceedShowInterstitial) { |
1494 // Navigate to a page so we have a navigation entry in the controller. | 1496 // Navigate to a page so we have a navigation entry in the controller. |
1495 GURL start_url("http://www.google.com"); | 1497 GURL start_url("http://www.google.com"); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1530 // Let's make sure interstitial2 is working as intended. | 1532 // Let's make sure interstitial2 is working as intended. |
1531 ASSERT_FALSE(deleted2); | 1533 ASSERT_FALSE(deleted2); |
1532 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2); | 1534 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2); |
1533 interstitial2->Proceed(); | 1535 interstitial2->Proceed(); |
1534 GURL landing_url("http://www.thepage.com"); | 1536 GURL landing_url("http://www.thepage.com"); |
1535 rvh()->SendNavigate(2, landing_url); | 1537 rvh()->SendNavigate(2, landing_url); |
1536 | 1538 |
1537 EXPECT_TRUE(deleted2); | 1539 EXPECT_TRUE(deleted2); |
1538 EXPECT_FALSE(contents()->ShowingInterstitialPage()); | 1540 EXPECT_FALSE(contents()->ShowingInterstitialPage()); |
1539 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); | 1541 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); |
1540 content::NavigationEntry* entry = controller().GetActiveEntry(); | 1542 NavigationEntry* entry = controller().GetActiveEntry(); |
1541 ASSERT_TRUE(entry != NULL); | 1543 ASSERT_TRUE(entry != NULL); |
1542 EXPECT_TRUE(entry->GetURL() == landing_url); | 1544 EXPECT_TRUE(entry->GetURL() == landing_url); |
1543 EXPECT_EQ(2, controller().entry_count()); | 1545 EXPECT_EQ(2, controller().entry_count()); |
1544 } | 1546 } |
1545 | 1547 |
1546 // Test that navigating away from an interstitial while it's loading cause it | 1548 // Test that navigating away from an interstitial while it's loading cause it |
1547 // not to show. | 1549 // not to show. |
1548 TEST_F(TabContentsTest, NavigateBeforeInterstitialShows) { | 1550 TEST_F(TabContentsTest, NavigateBeforeInterstitialShows) { |
1549 // Show an interstitial. | 1551 // Show an interstitial. |
1550 TestInterstitialPage::InterstitialState state = | 1552 TestInterstitialPage::InterstitialState state = |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1673 TestInterstitialPage::InterstitialState state2 = | 1675 TestInterstitialPage::InterstitialState state2 = |
1674 TestInterstitialPage::UNDECIDED; | 1676 TestInterstitialPage::UNDECIDED; |
1675 bool deleted2 = false; | 1677 bool deleted2 = false; |
1676 TestInterstitialPage* interstitial2 = | 1678 TestInterstitialPage* interstitial2 = |
1677 new TestInterstitialPage(contents(), true, kGURL, &state, &deleted); | 1679 new TestInterstitialPage(contents(), true, kGURL, &state, &deleted); |
1678 TestInterstitialPageStateGuard state_guard2(interstitial2); | 1680 TestInterstitialPageStateGuard state_guard2(interstitial2); |
1679 interstitial2->Show(); | 1681 interstitial2->Show(); |
1680 interstitial2->TestDidNavigate(1, kGURL); | 1682 interstitial2->TestDidNavigate(1, kGURL); |
1681 | 1683 |
1682 // Make sure we still have an entry. | 1684 // Make sure we still have an entry. |
1683 content::NavigationEntry* entry = | 1685 NavigationEntry* entry = contents()->GetController().GetPendingEntry(); |
1684 contents()->GetController().GetPendingEntry(); | |
1685 ASSERT_TRUE(entry); | 1686 ASSERT_TRUE(entry); |
1686 EXPECT_EQ(kUrl, entry->GetURL().spec()); | 1687 EXPECT_EQ(kUrl, entry->GetURL().spec()); |
1687 | 1688 |
1688 // And that the first interstitial is gone, but not the second. | 1689 // And that the first interstitial is gone, but not the second. |
1689 EXPECT_TRUE(deleted); | 1690 EXPECT_TRUE(deleted); |
1690 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 1691 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
1691 EXPECT_FALSE(deleted2); | 1692 EXPECT_FALSE(deleted2); |
1692 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2); | 1693 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2); |
1693 } | 1694 } |
1694 | 1695 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1750 interstitial->TestDidNavigate(1, url2); | 1751 interstitial->TestDidNavigate(1, url2); |
1751 EXPECT_TRUE(interstitial->is_showing()); | 1752 EXPECT_TRUE(interstitial->is_showing()); |
1752 EXPECT_EQ(2, controller().entry_count()); | 1753 EXPECT_EQ(2, controller().entry_count()); |
1753 | 1754 |
1754 // Create another NavigationController. | 1755 // Create another NavigationController. |
1755 GURL url3("http://foo2"); | 1756 GURL url3("http://foo2"); |
1756 scoped_ptr<TestTabContents> other_contents(CreateTestTabContents()); | 1757 scoped_ptr<TestTabContents> other_contents(CreateTestTabContents()); |
1757 NavigationController& other_controller = other_contents->GetController(); | 1758 NavigationController& other_controller = other_contents->GetController(); |
1758 other_contents->NavigateAndCommit(url3); | 1759 other_contents->NavigateAndCommit(url3); |
1759 other_contents->ExpectSetHistoryLengthAndPrune( | 1760 other_contents->ExpectSetHistoryLengthAndPrune( |
1760 NavigationEntry::FromNavigationEntry( | 1761 NavigationEntryImpl::FromNavigationEntry( |
1761 other_controller.GetEntryAtIndex(0))->site_instance(), 1, | 1762 other_controller.GetEntryAtIndex(0))->site_instance(), 1, |
1762 other_controller.GetEntryAtIndex(0)->GetPageID()); | 1763 other_controller.GetEntryAtIndex(0)->GetPageID()); |
1763 other_controller.CopyStateFromAndPrune(&controller()); | 1764 other_controller.CopyStateFromAndPrune(&controller()); |
1764 | 1765 |
1765 // The merged controller should only have two entries: url1 and url2. | 1766 // The merged controller should only have two entries: url1 and url2. |
1766 ASSERT_EQ(2, other_controller.entry_count()); | 1767 ASSERT_EQ(2, other_controller.entry_count()); |
1767 EXPECT_EQ(1, other_controller.GetCurrentEntryIndex()); | 1768 EXPECT_EQ(1, other_controller.GetCurrentEntryIndex()); |
1768 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->GetURL()); | 1769 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->GetURL()); |
1769 EXPECT_EQ(url3, other_controller.GetEntryAtIndex(1)->GetURL()); | 1770 EXPECT_EQ(url3, other_controller.GetEntryAtIndex(1)->GetURL()); |
1770 | 1771 |
(...skipping 23 matching lines...) Expand all Loading... |
1794 GURL url3("http://interstitial"); | 1795 GURL url3("http://interstitial"); |
1795 TestInterstitialPage* interstitial = | 1796 TestInterstitialPage* interstitial = |
1796 new TestInterstitialPage(other_contents.get(), true, url3, &state, | 1797 new TestInterstitialPage(other_contents.get(), true, url3, &state, |
1797 &deleted); | 1798 &deleted); |
1798 TestInterstitialPageStateGuard state_guard(interstitial); | 1799 TestInterstitialPageStateGuard state_guard(interstitial); |
1799 interstitial->Show(); | 1800 interstitial->Show(); |
1800 interstitial->TestDidNavigate(1, url3); | 1801 interstitial->TestDidNavigate(1, url3); |
1801 EXPECT_TRUE(interstitial->is_showing()); | 1802 EXPECT_TRUE(interstitial->is_showing()); |
1802 EXPECT_EQ(2, other_controller.entry_count()); | 1803 EXPECT_EQ(2, other_controller.entry_count()); |
1803 other_contents->ExpectSetHistoryLengthAndPrune( | 1804 other_contents->ExpectSetHistoryLengthAndPrune( |
1804 NavigationEntry::FromNavigationEntry( | 1805 NavigationEntryImpl::FromNavigationEntry( |
1805 other_controller.GetEntryAtIndex(0))->site_instance(), 1, | 1806 other_controller.GetEntryAtIndex(0))->site_instance(), 1, |
1806 other_controller.GetEntryAtIndex(0)->GetPageID()); | 1807 other_controller.GetEntryAtIndex(0)->GetPageID()); |
1807 other_controller.CopyStateFromAndPrune(&controller()); | 1808 other_controller.CopyStateFromAndPrune(&controller()); |
1808 | 1809 |
1809 // The merged controller should only have two entries: url1 and url2. | 1810 // The merged controller should only have two entries: url1 and url2. |
1810 ASSERT_EQ(2, other_controller.entry_count()); | 1811 ASSERT_EQ(2, other_controller.entry_count()); |
1811 EXPECT_EQ(1, other_controller.GetCurrentEntryIndex()); | 1812 EXPECT_EQ(1, other_controller.GetCurrentEntryIndex()); |
1812 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->GetURL()); | 1813 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->GetURL()); |
1813 EXPECT_EQ(url3, other_controller.GetEntryAtIndex(1)->GetURL()); | 1814 EXPECT_EQ(url3, other_controller.GetEntryAtIndex(1)->GetURL()); |
1814 | 1815 |
1815 // It should have a transient entry. | 1816 // It should have a transient entry. |
1816 EXPECT_TRUE(other_controller.GetTransientEntry()); | 1817 EXPECT_TRUE(other_controller.GetTransientEntry()); |
1817 | 1818 |
1818 // And the interstitial should be showing. | 1819 // And the interstitial should be showing. |
1819 EXPECT_TRUE(other_contents->ShowingInterstitialPage()); | 1820 EXPECT_TRUE(other_contents->ShowingInterstitialPage()); |
1820 | 1821 |
1821 // And the interstitial should do a reload on don't proceed. | 1822 // And the interstitial should do a reload on don't proceed. |
1822 EXPECT_TRUE(other_contents->GetInterstitialPage()->reload_on_dont_proceed()); | 1823 EXPECT_TRUE(other_contents->GetInterstitialPage()->reload_on_dont_proceed()); |
1823 } | 1824 } |
OLD | NEW |