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

Side by Side Diff: content/browser/web_contents/web_contents_impl_unittest.cc

Issue 556703004: Remove page id from FrameNavigateParams. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (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/logging.h" 5 #include "base/logging.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "content/browser/frame_host/cross_site_transferring_request.h" 7 #include "content/browser/frame_host/cross_site_transferring_request.h"
8 #include "content/browser/frame_host/interstitial_page_impl.h" 8 #include "content/browser/frame_host/interstitial_page_impl.h"
9 #include "content/browser/frame_host/navigation_entry_impl.h" 9 #include "content/browser/frame_host/navigation_entry_impl.h"
10 #include "content/browser/media/audio_stream_monitor.h" 10 #include "content/browser/media/audio_stream_monitor.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 int command_received_count() const { 150 int command_received_count() const {
151 return command_received_count_; 151 return command_received_count_;
152 } 152 }
153 153
154 void TestDomOperationResponse(const std::string& json_string) { 154 void TestDomOperationResponse(const std::string& json_string) {
155 if (enabled()) 155 if (enabled())
156 CommandReceived(); 156 CommandReceived();
157 } 157 }
158 158
159 void TestDidNavigate(int page_id, const GURL& url) { 159 void TestDidNavigate(const GURL& url) {
160 FrameHostMsg_DidCommitProvisionalLoad_Params params; 160 FrameHostMsg_DidCommitProvisionalLoad_Params params;
161 InitNavigateParams(&params, page_id, url, ui::PAGE_TRANSITION_TYPED); 161 InitNavigateParams(&params, url, ui::PAGE_TRANSITION_TYPED);
162 DidNavigate(GetRenderViewHostForTesting(), params); 162 DidNavigate(GetRenderViewHostForTesting(), params);
163 } 163 }
164 164
165 void TestRenderViewTerminated(base::TerminationStatus status, 165 void TestRenderViewTerminated(base::TerminationStatus status,
166 int error_code) { 166 int error_code) {
167 RenderViewTerminated(GetRenderViewHostForTesting(), status, error_code); 167 RenderViewTerminated(GetRenderViewHostForTesting(), status, error_code);
168 } 168 }
169 169
170 bool is_showing() const { 170 bool is_showing() const {
171 return static_cast<TestRenderWidgetHostView*>( 171 return static_cast<TestRenderWidgetHostView*>(
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 }; 336 };
337 337
338 } // namespace 338 } // namespace
339 339
340 // Test to make sure that title updates get stripped of whitespace. 340 // Test to make sure that title updates get stripped of whitespace.
341 TEST_F(WebContentsImplTest, UpdateTitle) { 341 TEST_F(WebContentsImplTest, UpdateTitle) {
342 NavigationControllerImpl& cont = 342 NavigationControllerImpl& cont =
343 static_cast<NavigationControllerImpl&>(controller()); 343 static_cast<NavigationControllerImpl&>(controller());
344 FrameHostMsg_DidCommitProvisionalLoad_Params params; 344 FrameHostMsg_DidCommitProvisionalLoad_Params params;
345 InitNavigateParams( 345 InitNavigateParams(
346 &params, 0, GURL(url::kAboutBlankURL), ui::PAGE_TRANSITION_TYPED); 346 &params, GURL(url::kAboutBlankURL), ui::PAGE_TRANSITION_TYPED);
347 347
348 LoadCommittedDetails details; 348 LoadCommittedDetails details;
349 cont.RendererDidNavigate(contents()->GetMainFrame(), params, &details); 349 cont.RendererDidNavigate(contents()->GetMainFrame(), 0, params, &details);
350 350
351 contents()->UpdateTitle(contents()->GetMainFrame(), 0, 351 contents()->UpdateTitle(contents()->GetMainFrame(), 0,
352 base::ASCIIToUTF16(" Lots O' Whitespace\n"), 352 base::ASCIIToUTF16(" Lots O' Whitespace\n"),
353 base::i18n::LEFT_TO_RIGHT); 353 base::i18n::LEFT_TO_RIGHT);
354 EXPECT_EQ(base::ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle()); 354 EXPECT_EQ(base::ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle());
355 } 355 }
356 356
357 TEST_F(WebContentsImplTest, DontUseTitleFromPendingEntry) { 357 TEST_F(WebContentsImplTest, DontUseTitleFromPendingEntry) {
358 const GURL kGURL("chrome://blah"); 358 const GURL kGURL("chrome://blah");
359 controller().LoadURL( 359 controller().LoadURL(
(...skipping 24 matching lines...) Expand all
384 process()->sink().ClearMessages(); 384 process()->sink().ClearMessages();
385 385
386 cont.LoadURL( 386 cont.LoadURL(
387 kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 387 kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
388 rvh()->GetDelegate()->RenderViewCreated(rvh()); 388 rvh()->GetDelegate()->RenderViewCreated(rvh());
389 // Did we get the expected message? 389 // Did we get the expected message?
390 EXPECT_TRUE(process()->sink().GetFirstMessageMatching( 390 EXPECT_TRUE(process()->sink().GetFirstMessageMatching(
391 ViewMsg_EnableViewSourceMode::ID)); 391 ViewMsg_EnableViewSourceMode::ID));
392 392
393 FrameHostMsg_DidCommitProvisionalLoad_Params params; 393 FrameHostMsg_DidCommitProvisionalLoad_Params params;
394 InitNavigateParams(&params, 0, kGURL, ui::PAGE_TRANSITION_TYPED); 394 InitNavigateParams(&params, kGURL, ui::PAGE_TRANSITION_TYPED);
395 LoadCommittedDetails details; 395 LoadCommittedDetails details;
396 cont.RendererDidNavigate(contents()->GetMainFrame(), params, &details); 396 cont.RendererDidNavigate(contents()->GetMainFrame(), 0, params, &details);
397 // Also check title and url. 397 // Also check title and url.
398 EXPECT_EQ(base::ASCIIToUTF16(kUrl), contents()->GetTitle()); 398 EXPECT_EQ(base::ASCIIToUTF16(kUrl), contents()->GetTitle());
399 } 399 }
400 400
401 // Test to ensure UpdateMaxPageID is working properly. 401 // Test to ensure UpdateMaxPageID is working properly.
402 TEST_F(WebContentsImplTest, UpdateMaxPageID) { 402 TEST_F(WebContentsImplTest, UpdateMaxPageID) {
403 SiteInstance* instance1 = contents()->GetSiteInstance(); 403 SiteInstance* instance1 = contents()->GetSiteInstance();
404 scoped_refptr<SiteInstance> instance2(SiteInstance::Create(NULL)); 404 scoped_refptr<SiteInstance> instance2(SiteInstance::Create(NULL));
405 405
406 // Starts at -1. 406 // Starts at -1.
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 GURL url2("http://interstitial"); 1453 GURL url2("http://interstitial");
1454 TestInterstitialPage* interstitial = 1454 TestInterstitialPage* interstitial =
1455 new TestInterstitialPage(contents(), true, url2, &state, &deleted); 1455 new TestInterstitialPage(contents(), true, url2, &state, &deleted);
1456 TestInterstitialPageStateGuard state_guard(interstitial); 1456 TestInterstitialPageStateGuard state_guard(interstitial);
1457 interstitial->Show(); 1457 interstitial->Show();
1458 // The interstitial should not show until its navigation has committed. 1458 // The interstitial should not show until its navigation has committed.
1459 EXPECT_FALSE(interstitial->is_showing()); 1459 EXPECT_FALSE(interstitial->is_showing());
1460 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1460 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1461 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); 1461 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL);
1462 // Let's commit the interstitial navigation. 1462 // Let's commit the interstitial navigation.
1463 interstitial->TestDidNavigate(1, url2); 1463 interstitial->TestDidNavigate(url2);
1464 EXPECT_TRUE(interstitial->is_showing()); 1464 EXPECT_TRUE(interstitial->is_showing());
1465 EXPECT_TRUE(contents()->ShowingInterstitialPage()); 1465 EXPECT_TRUE(contents()->ShowingInterstitialPage());
1466 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); 1466 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial);
1467 NavigationEntry* entry = controller().GetVisibleEntry(); 1467 NavigationEntry* entry = controller().GetVisibleEntry();
1468 ASSERT_TRUE(entry != NULL); 1468 ASSERT_TRUE(entry != NULL);
1469 EXPECT_TRUE(entry->GetURL() == url2); 1469 EXPECT_TRUE(entry->GetURL() == url2);
1470 1470
1471 // Now don't proceed. 1471 // Now don't proceed.
1472 interstitial->DontProceed(); 1472 interstitial->DontProceed();
1473 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 1473 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
(...skipping 26 matching lines...) Expand all
1500 GURL url2("http://interstitial"); 1500 GURL url2("http://interstitial");
1501 TestInterstitialPage* interstitial = 1501 TestInterstitialPage* interstitial =
1502 new TestInterstitialPage(contents(), true, url2, &state, &deleted); 1502 new TestInterstitialPage(contents(), true, url2, &state, &deleted);
1503 TestInterstitialPageStateGuard state_guard(interstitial); 1503 TestInterstitialPageStateGuard state_guard(interstitial);
1504 interstitial->Show(); 1504 interstitial->Show();
1505 // The interstitial should not show until its navigation has committed. 1505 // The interstitial should not show until its navigation has committed.
1506 EXPECT_FALSE(interstitial->is_showing()); 1506 EXPECT_FALSE(interstitial->is_showing());
1507 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1507 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1508 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); 1508 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL);
1509 // Let's commit the interstitial navigation. 1509 // Let's commit the interstitial navigation.
1510 interstitial->TestDidNavigate(1, url2); 1510 interstitial->TestDidNavigate(url2);
1511 EXPECT_TRUE(interstitial->is_showing()); 1511 EXPECT_TRUE(interstitial->is_showing());
1512 EXPECT_TRUE(contents()->ShowingInterstitialPage()); 1512 EXPECT_TRUE(contents()->ShowingInterstitialPage());
1513 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); 1513 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial);
1514 NavigationEntry* entry = controller().GetVisibleEntry(); 1514 NavigationEntry* entry = controller().GetVisibleEntry();
1515 ASSERT_TRUE(entry != NULL); 1515 ASSERT_TRUE(entry != NULL);
1516 EXPECT_TRUE(entry->GetURL() == url2); 1516 EXPECT_TRUE(entry->GetURL() == url2);
1517 1517
1518 // Now don't proceed. 1518 // Now don't proceed.
1519 interstitial->DontProceed(); 1519 interstitial->DontProceed();
1520 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 1520 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
(...skipping 24 matching lines...) Expand all
1545 GURL url2("http://interstitial"); 1545 GURL url2("http://interstitial");
1546 TestInterstitialPage* interstitial = 1546 TestInterstitialPage* interstitial =
1547 new TestInterstitialPage(contents(), false, url2, &state, &deleted); 1547 new TestInterstitialPage(contents(), false, url2, &state, &deleted);
1548 TestInterstitialPageStateGuard state_guard(interstitial); 1548 TestInterstitialPageStateGuard state_guard(interstitial);
1549 interstitial->Show(); 1549 interstitial->Show();
1550 // The interstitial should not show until its navigation has committed. 1550 // The interstitial should not show until its navigation has committed.
1551 EXPECT_FALSE(interstitial->is_showing()); 1551 EXPECT_FALSE(interstitial->is_showing());
1552 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1552 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1553 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); 1553 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL);
1554 // Let's commit the interstitial navigation. 1554 // Let's commit the interstitial navigation.
1555 interstitial->TestDidNavigate(1, url2); 1555 interstitial->TestDidNavigate(url2);
1556 EXPECT_TRUE(interstitial->is_showing()); 1556 EXPECT_TRUE(interstitial->is_showing());
1557 EXPECT_TRUE(contents()->ShowingInterstitialPage()); 1557 EXPECT_TRUE(contents()->ShowingInterstitialPage());
1558 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); 1558 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial);
1559 NavigationEntry* entry = controller().GetVisibleEntry(); 1559 NavigationEntry* entry = controller().GetVisibleEntry();
1560 ASSERT_TRUE(entry != NULL); 1560 ASSERT_TRUE(entry != NULL);
1561 // The URL specified to the interstitial should have been ignored. 1561 // The URL specified to the interstitial should have been ignored.
1562 EXPECT_TRUE(entry->GetURL() == url1); 1562 EXPECT_TRUE(entry->GetURL() == url1);
1563 1563
1564 // Now don't proceed. 1564 // Now don't proceed.
1565 interstitial->DontProceed(); 1565 interstitial->DontProceed();
(...skipping 30 matching lines...) Expand all
1596 GURL url2("http://interstitial"); 1596 GURL url2("http://interstitial");
1597 TestInterstitialPage* interstitial = 1597 TestInterstitialPage* interstitial =
1598 new TestInterstitialPage(contents(), true, url2, &state, &deleted); 1598 new TestInterstitialPage(contents(), true, url2, &state, &deleted);
1599 TestInterstitialPageStateGuard state_guard(interstitial); 1599 TestInterstitialPageStateGuard state_guard(interstitial);
1600 interstitial->Show(); 1600 interstitial->Show();
1601 // The interstitial should not show until its navigation has committed. 1601 // The interstitial should not show until its navigation has committed.
1602 EXPECT_FALSE(interstitial->is_showing()); 1602 EXPECT_FALSE(interstitial->is_showing());
1603 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1603 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1604 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); 1604 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL);
1605 // Let's commit the interstitial navigation. 1605 // Let's commit the interstitial navigation.
1606 interstitial->TestDidNavigate(1, url2); 1606 interstitial->TestDidNavigate(url2);
1607 EXPECT_TRUE(interstitial->is_showing()); 1607 EXPECT_TRUE(interstitial->is_showing());
1608 EXPECT_TRUE(contents()->ShowingInterstitialPage()); 1608 EXPECT_TRUE(contents()->ShowingInterstitialPage());
1609 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); 1609 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial);
1610 NavigationEntry* entry = controller().GetVisibleEntry(); 1610 NavigationEntry* entry = controller().GetVisibleEntry();
1611 ASSERT_TRUE(entry != NULL); 1611 ASSERT_TRUE(entry != NULL);
1612 EXPECT_TRUE(entry->GetURL() == url2); 1612 EXPECT_TRUE(entry->GetURL() == url2);
1613 1613
1614 // Then proceed. 1614 // Then proceed.
1615 interstitial->Proceed(); 1615 interstitial->Proceed();
1616 // The interstitial should show until the new navigation commits. 1616 // The interstitial should show until the new navigation commits.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 GURL url2("http://interstitial"); 1654 GURL url2("http://interstitial");
1655 TestInterstitialPage* interstitial = 1655 TestInterstitialPage* interstitial =
1656 new TestInterstitialPage(contents(), true, url2, &state, &deleted); 1656 new TestInterstitialPage(contents(), true, url2, &state, &deleted);
1657 TestInterstitialPageStateGuard state_guard(interstitial); 1657 TestInterstitialPageStateGuard state_guard(interstitial);
1658 interstitial->Show(); 1658 interstitial->Show();
1659 // The interstitial should not show until its navigation has committed. 1659 // The interstitial should not show until its navigation has committed.
1660 EXPECT_FALSE(interstitial->is_showing()); 1660 EXPECT_FALSE(interstitial->is_showing());
1661 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1661 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1662 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); 1662 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL);
1663 // Let's commit the interstitial navigation. 1663 // Let's commit the interstitial navigation.
1664 interstitial->TestDidNavigate(1, url2); 1664 interstitial->TestDidNavigate(url2);
1665 EXPECT_TRUE(interstitial->is_showing()); 1665 EXPECT_TRUE(interstitial->is_showing());
1666 EXPECT_TRUE(contents()->ShowingInterstitialPage()); 1666 EXPECT_TRUE(contents()->ShowingInterstitialPage());
1667 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); 1667 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial);
1668 NavigationEntry* entry = controller().GetVisibleEntry(); 1668 NavigationEntry* entry = controller().GetVisibleEntry();
1669 ASSERT_TRUE(entry != NULL); 1669 ASSERT_TRUE(entry != NULL);
1670 EXPECT_TRUE(entry->GetURL() == url2); 1670 EXPECT_TRUE(entry->GetURL() == url2);
1671 1671
1672 // Then proceed. 1672 // Then proceed.
1673 interstitial->Proceed(); 1673 interstitial->Proceed();
1674 // The interstitial should show until the new navigation commits. 1674 // The interstitial should show until the new navigation commits.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1711 GURL url2("http://interstitial"); 1711 GURL url2("http://interstitial");
1712 TestInterstitialPage* interstitial = 1712 TestInterstitialPage* interstitial =
1713 new TestInterstitialPage(contents(), false, url2, &state, &deleted); 1713 new TestInterstitialPage(contents(), false, url2, &state, &deleted);
1714 TestInterstitialPageStateGuard state_guard(interstitial); 1714 TestInterstitialPageStateGuard state_guard(interstitial);
1715 interstitial->Show(); 1715 interstitial->Show();
1716 // The interstitial should not show until its navigation has committed. 1716 // The interstitial should not show until its navigation has committed.
1717 EXPECT_FALSE(interstitial->is_showing()); 1717 EXPECT_FALSE(interstitial->is_showing());
1718 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1718 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1719 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); 1719 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL);
1720 // Let's commit the interstitial navigation. 1720 // Let's commit the interstitial navigation.
1721 interstitial->TestDidNavigate(1, url2); 1721 interstitial->TestDidNavigate(url2);
1722 EXPECT_TRUE(interstitial->is_showing()); 1722 EXPECT_TRUE(interstitial->is_showing());
1723 EXPECT_TRUE(contents()->ShowingInterstitialPage()); 1723 EXPECT_TRUE(contents()->ShowingInterstitialPage());
1724 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); 1724 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial);
1725 NavigationEntry* entry = controller().GetVisibleEntry(); 1725 NavigationEntry* entry = controller().GetVisibleEntry();
1726 ASSERT_TRUE(entry != NULL); 1726 ASSERT_TRUE(entry != NULL);
1727 // The URL specified to the interstitial should have been ignored. 1727 // The URL specified to the interstitial should have been ignored.
1728 EXPECT_TRUE(entry->GetURL() == url1); 1728 EXPECT_TRUE(entry->GetURL() == url1);
1729 1729
1730 // Then proceed. 1730 // Then proceed.
1731 interstitial->Proceed(); 1731 interstitial->Proceed();
(...skipping 16 matching lines...) Expand all
1748 TEST_F(WebContentsImplTest, ShowInterstitialThenNavigate) { 1748 TEST_F(WebContentsImplTest, ShowInterstitialThenNavigate) {
1749 // Show interstitial. 1749 // Show interstitial.
1750 TestInterstitialPage::InterstitialState state = 1750 TestInterstitialPage::InterstitialState state =
1751 TestInterstitialPage::INVALID; 1751 TestInterstitialPage::INVALID;
1752 bool deleted = false; 1752 bool deleted = false;
1753 GURL url("http://interstitial"); 1753 GURL url("http://interstitial");
1754 TestInterstitialPage* interstitial = 1754 TestInterstitialPage* interstitial =
1755 new TestInterstitialPage(contents(), true, url, &state, &deleted); 1755 new TestInterstitialPage(contents(), true, url, &state, &deleted);
1756 TestInterstitialPageStateGuard state_guard(interstitial); 1756 TestInterstitialPageStateGuard state_guard(interstitial);
1757 interstitial->Show(); 1757 interstitial->Show();
1758 interstitial->TestDidNavigate(1, url); 1758 interstitial->TestDidNavigate(url);
1759 1759
1760 // While interstitial showing, navigate to a new URL. 1760 // While interstitial showing, navigate to a new URL.
1761 const GURL url2("http://www.yahoo.com"); 1761 const GURL url2("http://www.yahoo.com");
1762 contents()->GetMainFrame()->SendNavigate(1, url2); 1762 contents()->GetMainFrame()->SendNavigate(1, url2);
1763 1763
1764 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 1764 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
1765 1765
1766 RunAllPendingInMessageLoop(); 1766 RunAllPendingInMessageLoop();
1767 EXPECT_TRUE(deleted); 1767 EXPECT_TRUE(deleted);
1768 } 1768 }
1769 1769
1770 // Test navigating to a page that shows an interstitial, then going back. 1770 // Test navigating to a page that shows an interstitial, then going back.
1771 TEST_F(WebContentsImplTest, ShowInterstitialThenGoBack) { 1771 TEST_F(WebContentsImplTest, ShowInterstitialThenGoBack) {
1772 // Navigate to a page so we have a navigation entry in the controller. 1772 // Navigate to a page so we have a navigation entry in the controller.
1773 GURL url1("http://www.google.com"); 1773 GURL url1("http://www.google.com");
1774 contents()->GetMainFrame()->SendNavigate(1, url1); 1774 contents()->GetMainFrame()->SendNavigate(1, url1);
1775 EXPECT_EQ(1, controller().GetEntryCount()); 1775 EXPECT_EQ(1, controller().GetEntryCount());
1776 1776
1777 // Show interstitial. 1777 // Show interstitial.
1778 TestInterstitialPage::InterstitialState state = 1778 TestInterstitialPage::InterstitialState state =
1779 TestInterstitialPage::INVALID; 1779 TestInterstitialPage::INVALID;
1780 bool deleted = false; 1780 bool deleted = false;
1781 GURL interstitial_url("http://interstitial"); 1781 GURL interstitial_url("http://interstitial");
1782 TestInterstitialPage* interstitial = 1782 TestInterstitialPage* interstitial =
1783 new TestInterstitialPage(contents(), true, interstitial_url, 1783 new TestInterstitialPage(contents(), true, interstitial_url,
1784 &state, &deleted); 1784 &state, &deleted);
1785 TestInterstitialPageStateGuard state_guard(interstitial); 1785 TestInterstitialPageStateGuard state_guard(interstitial);
1786 interstitial->Show(); 1786 interstitial->Show();
1787 interstitial->TestDidNavigate(2, interstitial_url); 1787 interstitial->TestDidNavigate(interstitial_url);
1788 1788
1789 // While the interstitial is showing, go back. 1789 // While the interstitial is showing, go back.
1790 controller().GoBack(); 1790 controller().GoBack();
1791 contents()->GetMainFrame()->SendNavigate(1, url1); 1791 contents()->GetMainFrame()->SendNavigate(1, url1);
1792 1792
1793 // Make sure we are back to the original page and that the interstitial is 1793 // Make sure we are back to the original page and that the interstitial is
1794 // gone. 1794 // gone.
1795 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 1795 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
1796 NavigationEntry* entry = controller().GetVisibleEntry(); 1796 NavigationEntry* entry = controller().GetVisibleEntry();
1797 ASSERT_TRUE(entry); 1797 ASSERT_TRUE(entry);
(...skipping 14 matching lines...) Expand all
1812 // Show interstitial. 1812 // Show interstitial.
1813 TestInterstitialPage::InterstitialState state = 1813 TestInterstitialPage::InterstitialState state =
1814 TestInterstitialPage::INVALID; 1814 TestInterstitialPage::INVALID;
1815 bool deleted = false; 1815 bool deleted = false;
1816 GURL interstitial_url("http://interstitial"); 1816 GURL interstitial_url("http://interstitial");
1817 TestInterstitialPage* interstitial = 1817 TestInterstitialPage* interstitial =
1818 new TestInterstitialPage(contents(), true, interstitial_url, 1818 new TestInterstitialPage(contents(), true, interstitial_url,
1819 &state, &deleted); 1819 &state, &deleted);
1820 TestInterstitialPageStateGuard state_guard(interstitial); 1820 TestInterstitialPageStateGuard state_guard(interstitial);
1821 interstitial->Show(); 1821 interstitial->Show();
1822 interstitial->TestDidNavigate(2, interstitial_url); 1822 interstitial->TestDidNavigate(interstitial_url);
1823 1823
1824 // Crash the renderer 1824 // Crash the renderer
1825 test_rvh()->OnMessageReceived( 1825 test_rvh()->OnMessageReceived(
1826 ViewHostMsg_RenderProcessGone( 1826 ViewHostMsg_RenderProcessGone(
1827 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); 1827 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1));
1828 1828
1829 // While the interstitial is showing, go back. 1829 // While the interstitial is showing, go back.
1830 controller().GoBack(); 1830 controller().GoBack();
1831 contents()->GetMainFrame()->SendNavigate(1, url1); 1831 contents()->GetMainFrame()->SendNavigate(1, url1);
1832 1832
(...skipping 25 matching lines...) Expand all
1858 new TestInterstitialPage(contents(), true, interstitial_url, 1858 new TestInterstitialPage(contents(), true, interstitial_url,
1859 &state, &deleted); 1859 &state, &deleted);
1860 TestInterstitialPageStateGuard state_guard(interstitial); 1860 TestInterstitialPageStateGuard state_guard(interstitial);
1861 interstitial->Show(); 1861 interstitial->Show();
1862 1862
1863 // Crash the renderer 1863 // Crash the renderer
1864 test_rvh()->OnMessageReceived( 1864 test_rvh()->OnMessageReceived(
1865 ViewHostMsg_RenderProcessGone( 1865 ViewHostMsg_RenderProcessGone(
1866 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); 1866 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1));
1867 1867
1868 interstitial->TestDidNavigate(2, interstitial_url); 1868 interstitial->TestDidNavigate(interstitial_url);
1869 } 1869 }
1870 1870
1871 // Test navigating to a page that shows an interstitial, then close the 1871 // Test navigating to a page that shows an interstitial, then close the
1872 // contents. 1872 // contents.
1873 TEST_F(WebContentsImplTest, ShowInterstitialThenCloseTab) { 1873 TEST_F(WebContentsImplTest, ShowInterstitialThenCloseTab) {
1874 // Show interstitial. 1874 // Show interstitial.
1875 TestInterstitialPage::InterstitialState state = 1875 TestInterstitialPage::InterstitialState state =
1876 TestInterstitialPage::INVALID; 1876 TestInterstitialPage::INVALID;
1877 bool deleted = false; 1877 bool deleted = false;
1878 GURL url("http://interstitial"); 1878 GURL url("http://interstitial");
1879 TestInterstitialPage* interstitial = 1879 TestInterstitialPage* interstitial =
1880 new TestInterstitialPage(contents(), true, url, &state, &deleted); 1880 new TestInterstitialPage(contents(), true, url, &state, &deleted);
1881 TestInterstitialPageStateGuard state_guard(interstitial); 1881 TestInterstitialPageStateGuard state_guard(interstitial);
1882 interstitial->Show(); 1882 interstitial->Show();
1883 interstitial->TestDidNavigate(1, url); 1883 interstitial->TestDidNavigate(url);
1884 1884
1885 // Now close the contents. 1885 // Now close the contents.
1886 DeleteContents(); 1886 DeleteContents();
1887 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 1887 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
1888 1888
1889 RunAllPendingInMessageLoop(); 1889 RunAllPendingInMessageLoop();
1890 EXPECT_TRUE(deleted); 1890 EXPECT_TRUE(deleted);
1891 } 1891 }
1892 1892
1893 // Test navigating to a page that shows an interstitial, then close the 1893 // Test navigating to a page that shows an interstitial, then close the
1894 // contents. 1894 // contents.
1895 TEST_F(WebContentsImplTest, ShowInterstitialThenCloseAndShutdown) { 1895 TEST_F(WebContentsImplTest, ShowInterstitialThenCloseAndShutdown) {
1896 // Show interstitial. 1896 // Show interstitial.
1897 TestInterstitialPage::InterstitialState state = 1897 TestInterstitialPage::InterstitialState state =
1898 TestInterstitialPage::INVALID; 1898 TestInterstitialPage::INVALID;
1899 bool deleted = false; 1899 bool deleted = false;
1900 GURL url("http://interstitial"); 1900 GURL url("http://interstitial");
1901 TestInterstitialPage* interstitial = 1901 TestInterstitialPage* interstitial =
1902 new TestInterstitialPage(contents(), true, url, &state, &deleted); 1902 new TestInterstitialPage(contents(), true, url, &state, &deleted);
1903 TestInterstitialPageStateGuard state_guard(interstitial); 1903 TestInterstitialPageStateGuard state_guard(interstitial);
1904 interstitial->Show(); 1904 interstitial->Show();
1905 interstitial->TestDidNavigate(1, url); 1905 interstitial->TestDidNavigate(url);
1906 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( 1906 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
1907 interstitial->GetRenderViewHostForTesting()); 1907 interstitial->GetRenderViewHostForTesting());
1908 1908
1909 // Now close the contents. 1909 // Now close the contents.
1910 DeleteContents(); 1910 DeleteContents();
1911 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 1911 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
1912 1912
1913 // Before the interstitial has a chance to process its shutdown task, 1913 // Before the interstitial has a chance to process its shutdown task,
1914 // simulate quitting the browser. This goes through all processes and 1914 // simulate quitting the browser. This goes through all processes and
1915 // tells them to destruct. 1915 // tells them to destruct.
(...skipping 14 matching lines...) Expand all
1930 1930
1931 // Show an interstitial. 1931 // Show an interstitial.
1932 TestInterstitialPage::InterstitialState state = 1932 TestInterstitialPage::InterstitialState state =
1933 TestInterstitialPage::INVALID; 1933 TestInterstitialPage::INVALID;
1934 bool deleted = false; 1934 bool deleted = false;
1935 GURL url2("http://interstitial"); 1935 GURL url2("http://interstitial");
1936 TestInterstitialPage* interstitial = 1936 TestInterstitialPage* interstitial =
1937 new TestInterstitialPage(contents(), true, url2, &state, &deleted); 1937 new TestInterstitialPage(contents(), true, url2, &state, &deleted);
1938 TestInterstitialPageStateGuard state_guard(interstitial); 1938 TestInterstitialPageStateGuard state_guard(interstitial);
1939 interstitial->Show(); 1939 interstitial->Show();
1940 interstitial->TestDidNavigate(1, url2); 1940 interstitial->TestDidNavigate(url2);
1941 1941
1942 // Run a command. 1942 // Run a command.
1943 EXPECT_EQ(0, interstitial->command_received_count()); 1943 EXPECT_EQ(0, interstitial->command_received_count());
1944 interstitial->TestDomOperationResponse("toto"); 1944 interstitial->TestDomOperationResponse("toto");
1945 EXPECT_EQ(1, interstitial->command_received_count()); 1945 EXPECT_EQ(1, interstitial->command_received_count());
1946 1946
1947 // Then proceed. 1947 // Then proceed.
1948 interstitial->Proceed(); 1948 interstitial->Proceed();
1949 RunAllPendingInMessageLoop(); 1949 RunAllPendingInMessageLoop();
1950 ASSERT_FALSE(deleted); 1950 ASSERT_FALSE(deleted);
(...skipping 14 matching lines...) Expand all
1965 1965
1966 // Show an interstitial. 1966 // Show an interstitial.
1967 TestInterstitialPage::InterstitialState state1 = 1967 TestInterstitialPage::InterstitialState state1 =
1968 TestInterstitialPage::INVALID; 1968 TestInterstitialPage::INVALID;
1969 bool deleted1 = false; 1969 bool deleted1 = false;
1970 GURL url1("http://interstitial1"); 1970 GURL url1("http://interstitial1");
1971 TestInterstitialPage* interstitial1 = 1971 TestInterstitialPage* interstitial1 =
1972 new TestInterstitialPage(contents(), true, url1, &state1, &deleted1); 1972 new TestInterstitialPage(contents(), true, url1, &state1, &deleted1);
1973 TestInterstitialPageStateGuard state_guard1(interstitial1); 1973 TestInterstitialPageStateGuard state_guard1(interstitial1);
1974 interstitial1->Show(); 1974 interstitial1->Show();
1975 interstitial1->TestDidNavigate(1, url1); 1975 interstitial1->TestDidNavigate(url1);
1976 1976
1977 // Now show another interstitial. 1977 // Now show another interstitial.
1978 TestInterstitialPage::InterstitialState state2 = 1978 TestInterstitialPage::InterstitialState state2 =
1979 TestInterstitialPage::INVALID; 1979 TestInterstitialPage::INVALID;
1980 bool deleted2 = false; 1980 bool deleted2 = false;
1981 GURL url2("http://interstitial2"); 1981 GURL url2("http://interstitial2");
1982 TestInterstitialPage* interstitial2 = 1982 TestInterstitialPage* interstitial2 =
1983 new TestInterstitialPage(contents(), true, url2, &state2, &deleted2); 1983 new TestInterstitialPage(contents(), true, url2, &state2, &deleted2);
1984 TestInterstitialPageStateGuard state_guard2(interstitial2); 1984 TestInterstitialPageStateGuard state_guard2(interstitial2);
1985 interstitial2->Show(); 1985 interstitial2->Show();
1986 interstitial2->TestDidNavigate(1, url2); 1986 interstitial2->TestDidNavigate(url2);
1987 1987
1988 // Showing interstitial2 should have caused interstitial1 to go away. 1988 // Showing interstitial2 should have caused interstitial1 to go away.
1989 EXPECT_EQ(TestInterstitialPage::CANCELED, state1); 1989 EXPECT_EQ(TestInterstitialPage::CANCELED, state1);
1990 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2); 1990 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2);
1991 1991
1992 RunAllPendingInMessageLoop(); 1992 RunAllPendingInMessageLoop();
1993 EXPECT_TRUE(deleted1); 1993 EXPECT_TRUE(deleted1);
1994 ASSERT_FALSE(deleted2); 1994 ASSERT_FALSE(deleted2);
1995 1995
1996 // Let's make sure interstitial2 is working as intended. 1996 // Let's make sure interstitial2 is working as intended.
(...skipping 21 matching lines...) Expand all
2018 2018
2019 // Show an interstitial. 2019 // Show an interstitial.
2020 TestInterstitialPage::InterstitialState state1 = 2020 TestInterstitialPage::InterstitialState state1 =
2021 TestInterstitialPage::INVALID; 2021 TestInterstitialPage::INVALID;
2022 bool deleted1 = false; 2022 bool deleted1 = false;
2023 GURL url1("http://interstitial1"); 2023 GURL url1("http://interstitial1");
2024 TestInterstitialPage* interstitial1 = 2024 TestInterstitialPage* interstitial1 =
2025 new TestInterstitialPage(contents(), true, url1, &state1, &deleted1); 2025 new TestInterstitialPage(contents(), true, url1, &state1, &deleted1);
2026 TestInterstitialPageStateGuard state_guard1(interstitial1); 2026 TestInterstitialPageStateGuard state_guard1(interstitial1);
2027 interstitial1->Show(); 2027 interstitial1->Show();
2028 interstitial1->TestDidNavigate(1, url1); 2028 interstitial1->TestDidNavigate(url1);
2029 2029
2030 // Take action. The interstitial won't be hidden until the navigation is 2030 // Take action. The interstitial won't be hidden until the navigation is
2031 // committed. 2031 // committed.
2032 interstitial1->Proceed(); 2032 interstitial1->Proceed();
2033 EXPECT_EQ(TestInterstitialPage::OKED, state1); 2033 EXPECT_EQ(TestInterstitialPage::OKED, state1);
2034 2034
2035 // Now show another interstitial (simulating the navigation causing another 2035 // Now show another interstitial (simulating the navigation causing another
2036 // interstitial). 2036 // interstitial).
2037 TestInterstitialPage::InterstitialState state2 = 2037 TestInterstitialPage::InterstitialState state2 =
2038 TestInterstitialPage::INVALID; 2038 TestInterstitialPage::INVALID;
2039 bool deleted2 = false; 2039 bool deleted2 = false;
2040 GURL url2("http://interstitial2"); 2040 GURL url2("http://interstitial2");
2041 TestInterstitialPage* interstitial2 = 2041 TestInterstitialPage* interstitial2 =
2042 new TestInterstitialPage(contents(), true, url2, &state2, &deleted2); 2042 new TestInterstitialPage(contents(), true, url2, &state2, &deleted2);
2043 TestInterstitialPageStateGuard state_guard2(interstitial2); 2043 TestInterstitialPageStateGuard state_guard2(interstitial2);
2044 interstitial2->Show(); 2044 interstitial2->Show();
2045 interstitial2->TestDidNavigate(1, url2); 2045 interstitial2->TestDidNavigate(url2);
2046 2046
2047 // Showing interstitial2 should have caused interstitial1 to go away. 2047 // Showing interstitial2 should have caused interstitial1 to go away.
2048 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2); 2048 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2);
2049 RunAllPendingInMessageLoop(); 2049 RunAllPendingInMessageLoop();
2050 EXPECT_TRUE(deleted1); 2050 EXPECT_TRUE(deleted1);
2051 ASSERT_FALSE(deleted2); 2051 ASSERT_FALSE(deleted2);
2052 2052
2053 // Let's make sure interstitial2 is working as intended. 2053 // Let's make sure interstitial2 is working as intended.
2054 interstitial2->Proceed(); 2054 interstitial2->Proceed();
2055 GURL landing_url("http://www.thepage.com"); 2055 GURL landing_url("http://www.thepage.com");
(...skipping 26 matching lines...) Expand all
2082 // Let's simulate a navigation initiated from the browser before the 2082 // Let's simulate a navigation initiated from the browser before the
2083 // interstitial finishes loading. 2083 // interstitial finishes loading.
2084 const GURL url("http://www.google.com"); 2084 const GURL url("http://www.google.com");
2085 controller().LoadURL( 2085 controller().LoadURL(
2086 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 2086 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
2087 EXPECT_FALSE(interstitial->is_showing()); 2087 EXPECT_FALSE(interstitial->is_showing());
2088 RunAllPendingInMessageLoop(); 2088 RunAllPendingInMessageLoop();
2089 ASSERT_FALSE(deleted); 2089 ASSERT_FALSE(deleted);
2090 2090
2091 // Now let's make the interstitial navigation commit. 2091 // Now let's make the interstitial navigation commit.
2092 interstitial->TestDidNavigate(1, interstitial_url); 2092 interstitial->TestDidNavigate(interstitial_url);
2093 2093
2094 // After it loaded the interstitial should be gone. 2094 // After it loaded the interstitial should be gone.
2095 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 2095 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
2096 2096
2097 RunAllPendingInMessageLoop(); 2097 RunAllPendingInMessageLoop();
2098 EXPECT_TRUE(deleted); 2098 EXPECT_TRUE(deleted);
2099 } 2099 }
2100 2100
2101 // Test that a new request to show an interstitial while an interstitial is 2101 // Test that a new request to show an interstitial while an interstitial is
2102 // pending does not cause problems. htp://crbug/29655 and htp://crbug/9442. 2102 // pending does not cause problems. htp://crbug/29655 and htp://crbug/9442.
(...skipping 24 matching lines...) Expand all
2127 // The first interstitial should have been closed and deleted. 2127 // The first interstitial should have been closed and deleted.
2128 EXPECT_EQ(TestInterstitialPage::CANCELED, state1); 2128 EXPECT_EQ(TestInterstitialPage::CANCELED, state1);
2129 // The 2nd one should still be OK. 2129 // The 2nd one should still be OK.
2130 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2); 2130 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2);
2131 2131
2132 RunAllPendingInMessageLoop(); 2132 RunAllPendingInMessageLoop();
2133 EXPECT_TRUE(deleted1); 2133 EXPECT_TRUE(deleted1);
2134 ASSERT_FALSE(deleted2); 2134 ASSERT_FALSE(deleted2);
2135 2135
2136 // Make the interstitial navigation commit it should be showing. 2136 // Make the interstitial navigation commit it should be showing.
2137 interstitial2->TestDidNavigate(1, interstitial_url); 2137 interstitial2->TestDidNavigate(interstitial_url);
2138 EXPECT_EQ(interstitial2, contents()->GetInterstitialPage()); 2138 EXPECT_EQ(interstitial2, contents()->GetInterstitialPage());
2139 } 2139 }
2140 2140
2141 // Test showing an interstitial and have its renderer crash. 2141 // Test showing an interstitial and have its renderer crash.
2142 TEST_F(WebContentsImplTest, InterstitialCrasher) { 2142 TEST_F(WebContentsImplTest, InterstitialCrasher) {
2143 // Show an interstitial. 2143 // Show an interstitial.
2144 TestInterstitialPage::InterstitialState state = 2144 TestInterstitialPage::InterstitialState state =
2145 TestInterstitialPage::INVALID; 2145 TestInterstitialPage::INVALID;
2146 bool deleted = false; 2146 bool deleted = false;
2147 GURL url("http://interstitial"); 2147 GURL url("http://interstitial");
2148 TestInterstitialPage* interstitial = 2148 TestInterstitialPage* interstitial =
2149 new TestInterstitialPage(contents(), true, url, &state, &deleted); 2149 new TestInterstitialPage(contents(), true, url, &state, &deleted);
2150 TestInterstitialPageStateGuard state_guard(interstitial); 2150 TestInterstitialPageStateGuard state_guard(interstitial);
2151 interstitial->Show(); 2151 interstitial->Show();
2152 // Simulate a renderer crash before the interstitial is shown. 2152 // Simulate a renderer crash before the interstitial is shown.
2153 interstitial->TestRenderViewTerminated( 2153 interstitial->TestRenderViewTerminated(
2154 base::TERMINATION_STATUS_PROCESS_CRASHED, -1); 2154 base::TERMINATION_STATUS_PROCESS_CRASHED, -1);
2155 // The interstitial should have been dismissed. 2155 // The interstitial should have been dismissed.
2156 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 2156 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
2157 RunAllPendingInMessageLoop(); 2157 RunAllPendingInMessageLoop();
2158 EXPECT_TRUE(deleted); 2158 EXPECT_TRUE(deleted);
2159 2159
2160 // Now try again but this time crash the intersitial after it was shown. 2160 // Now try again but this time crash the intersitial after it was shown.
2161 interstitial = 2161 interstitial =
2162 new TestInterstitialPage(contents(), true, url, &state, &deleted); 2162 new TestInterstitialPage(contents(), true, url, &state, &deleted);
2163 interstitial->Show(); 2163 interstitial->Show();
2164 interstitial->TestDidNavigate(1, url); 2164 interstitial->TestDidNavigate(url);
2165 // Simulate a renderer crash. 2165 // Simulate a renderer crash.
2166 interstitial->TestRenderViewTerminated( 2166 interstitial->TestRenderViewTerminated(
2167 base::TERMINATION_STATUS_PROCESS_CRASHED, -1); 2167 base::TERMINATION_STATUS_PROCESS_CRASHED, -1);
2168 // The interstitial should have been dismissed. 2168 // The interstitial should have been dismissed.
2169 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 2169 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
2170 RunAllPendingInMessageLoop(); 2170 RunAllPendingInMessageLoop();
2171 EXPECT_TRUE(deleted); 2171 EXPECT_TRUE(deleted);
2172 } 2172 }
2173 2173
2174 // Tests that showing an interstitial as a result of a browser initiated 2174 // Tests that showing an interstitial as a result of a browser initiated
2175 // navigation while an interstitial is showing does not remove the pending 2175 // navigation while an interstitial is showing does not remove the pending
2176 // entry (see http://crbug.com/9791). 2176 // entry (see http://crbug.com/9791).
2177 TEST_F(WebContentsImplTest, NewInterstitialDoesNotCancelPendingEntry) { 2177 TEST_F(WebContentsImplTest, NewInterstitialDoesNotCancelPendingEntry) {
2178 const char kUrl[] = "http://www.badguys.com/"; 2178 const char kUrl[] = "http://www.badguys.com/";
2179 const GURL kGURL(kUrl); 2179 const GURL kGURL(kUrl);
2180 2180
2181 // Start a navigation to a page 2181 // Start a navigation to a page
2182 contents()->GetController().LoadURL( 2182 contents()->GetController().LoadURL(
2183 kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 2183 kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
2184 2184
2185 // Simulate that navigation triggering an interstitial. 2185 // Simulate that navigation triggering an interstitial.
2186 TestInterstitialPage::InterstitialState state = 2186 TestInterstitialPage::InterstitialState state =
2187 TestInterstitialPage::INVALID; 2187 TestInterstitialPage::INVALID;
2188 bool deleted = false; 2188 bool deleted = false;
2189 TestInterstitialPage* interstitial = 2189 TestInterstitialPage* interstitial =
2190 new TestInterstitialPage(contents(), true, kGURL, &state, &deleted); 2190 new TestInterstitialPage(contents(), true, kGURL, &state, &deleted);
2191 TestInterstitialPageStateGuard state_guard(interstitial); 2191 TestInterstitialPageStateGuard state_guard(interstitial);
2192 interstitial->Show(); 2192 interstitial->Show();
2193 interstitial->TestDidNavigate(1, kGURL); 2193 interstitial->TestDidNavigate(kGURL);
2194 2194
2195 // Initiate a new navigation from the browser that also triggers an 2195 // Initiate a new navigation from the browser that also triggers an
2196 // interstitial. 2196 // interstitial.
2197 contents()->GetController().LoadURL( 2197 contents()->GetController().LoadURL(
2198 kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 2198 kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
2199 TestInterstitialPage::InterstitialState state2 = 2199 TestInterstitialPage::InterstitialState state2 =
2200 TestInterstitialPage::INVALID; 2200 TestInterstitialPage::INVALID;
2201 bool deleted2 = false; 2201 bool deleted2 = false;
2202 TestInterstitialPage* interstitial2 = 2202 TestInterstitialPage* interstitial2 =
2203 new TestInterstitialPage(contents(), true, kGURL, &state2, &deleted2); 2203 new TestInterstitialPage(contents(), true, kGURL, &state2, &deleted2);
2204 TestInterstitialPageStateGuard state_guard2(interstitial2); 2204 TestInterstitialPageStateGuard state_guard2(interstitial2);
2205 interstitial2->Show(); 2205 interstitial2->Show();
2206 interstitial2->TestDidNavigate(1, kGURL); 2206 interstitial2->TestDidNavigate(kGURL);
2207 2207
2208 // Make sure we still have an entry. 2208 // Make sure we still have an entry.
2209 NavigationEntry* entry = contents()->GetController().GetPendingEntry(); 2209 NavigationEntry* entry = contents()->GetController().GetPendingEntry();
2210 ASSERT_TRUE(entry); 2210 ASSERT_TRUE(entry);
2211 EXPECT_EQ(kUrl, entry->GetURL().spec()); 2211 EXPECT_EQ(kUrl, entry->GetURL().spec());
2212 2212
2213 // And that the first interstitial is gone, but not the second. 2213 // And that the first interstitial is gone, but not the second.
2214 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 2214 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
2215 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2); 2215 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2);
2216 RunAllPendingInMessageLoop(); 2216 RunAllPendingInMessageLoop();
(...skipping 15 matching lines...) Expand all
2232 contents()->GetMainFrame(), 1, kGURL, ui::PAGE_TRANSITION_TYPED); 2232 contents()->GetMainFrame(), 1, kGURL, ui::PAGE_TRANSITION_TYPED);
2233 2233
2234 // Simulate showing an interstitial while the page is showing. 2234 // Simulate showing an interstitial while the page is showing.
2235 TestInterstitialPage::InterstitialState state = 2235 TestInterstitialPage::InterstitialState state =
2236 TestInterstitialPage::INVALID; 2236 TestInterstitialPage::INVALID;
2237 bool deleted = false; 2237 bool deleted = false;
2238 TestInterstitialPage* interstitial = 2238 TestInterstitialPage* interstitial =
2239 new TestInterstitialPage(contents(), true, kGURL, &state, &deleted); 2239 new TestInterstitialPage(contents(), true, kGURL, &state, &deleted);
2240 TestInterstitialPageStateGuard state_guard(interstitial); 2240 TestInterstitialPageStateGuard state_guard(interstitial);
2241 interstitial->Show(); 2241 interstitial->Show();
2242 interstitial->TestDidNavigate(1, kGURL); 2242 interstitial->TestDidNavigate(kGURL);
2243 2243
2244 // While the interstitial is showing, let's simulate the hidden page 2244 // While the interstitial is showing, let's simulate the hidden page
2245 // attempting to show a JS message. 2245 // attempting to show a JS message.
2246 IPC::Message* dummy_message = new IPC::Message; 2246 IPC::Message* dummy_message = new IPC::Message;
2247 contents()->RunJavaScriptMessage(contents()->GetMainFrame(), 2247 contents()->RunJavaScriptMessage(contents()->GetMainFrame(),
2248 base::ASCIIToUTF16("This is an informative message"), 2248 base::ASCIIToUTF16("This is an informative message"),
2249 base::ASCIIToUTF16("OK"), 2249 base::ASCIIToUTF16("OK"),
2250 kGURL, JAVASCRIPT_MESSAGE_TYPE_ALERT, dummy_message); 2250 kGURL, JAVASCRIPT_MESSAGE_TYPE_ALERT, dummy_message);
2251 EXPECT_TRUE(contents()->last_dialog_suppressed_); 2251 EXPECT_TRUE(contents()->last_dialog_suppressed_);
2252 } 2252 }
(...skipping 12 matching lines...) Expand all
2265 2265
2266 // Show an interstitial. 2266 // Show an interstitial.
2267 TestInterstitialPage::InterstitialState state = 2267 TestInterstitialPage::InterstitialState state =
2268 TestInterstitialPage::INVALID; 2268 TestInterstitialPage::INVALID;
2269 bool deleted = false; 2269 bool deleted = false;
2270 GURL url2("http://interstitial"); 2270 GURL url2("http://interstitial");
2271 TestInterstitialPage* interstitial = 2271 TestInterstitialPage* interstitial =
2272 new TestInterstitialPage(contents(), true, url2, &state, &deleted); 2272 new TestInterstitialPage(contents(), true, url2, &state, &deleted);
2273 TestInterstitialPageStateGuard state_guard(interstitial); 2273 TestInterstitialPageStateGuard state_guard(interstitial);
2274 interstitial->Show(); 2274 interstitial->Show();
2275 interstitial->TestDidNavigate(1, url2); 2275 interstitial->TestDidNavigate(url2);
2276 EXPECT_TRUE(interstitial->is_showing()); 2276 EXPECT_TRUE(interstitial->is_showing());
2277 EXPECT_EQ(2, controller().GetEntryCount()); 2277 EXPECT_EQ(2, controller().GetEntryCount());
2278 2278
2279 // Create another NavigationController. 2279 // Create another NavigationController.
2280 GURL url3("http://foo2"); 2280 GURL url3("http://foo2");
2281 scoped_ptr<TestWebContents> other_contents( 2281 scoped_ptr<TestWebContents> other_contents(
2282 static_cast<TestWebContents*>(CreateTestWebContents())); 2282 static_cast<TestWebContents*>(CreateTestWebContents()));
2283 NavigationControllerImpl& other_controller = other_contents->GetController(); 2283 NavigationControllerImpl& other_controller = other_contents->GetController();
2284 other_contents->NavigateAndCommit(url3); 2284 other_contents->NavigateAndCommit(url3);
2285 other_contents->ExpectSetHistoryLengthAndPrune( 2285 other_contents->ExpectSetHistoryLengthAndPrune(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2317 // Show an interstitial. 2317 // Show an interstitial.
2318 TestInterstitialPage::InterstitialState state = 2318 TestInterstitialPage::InterstitialState state =
2319 TestInterstitialPage::INVALID; 2319 TestInterstitialPage::INVALID;
2320 bool deleted = false; 2320 bool deleted = false;
2321 GURL url3("http://interstitial"); 2321 GURL url3("http://interstitial");
2322 TestInterstitialPage* interstitial = 2322 TestInterstitialPage* interstitial =
2323 new TestInterstitialPage(other_contents.get(), true, url3, &state, 2323 new TestInterstitialPage(other_contents.get(), true, url3, &state,
2324 &deleted); 2324 &deleted);
2325 TestInterstitialPageStateGuard state_guard(interstitial); 2325 TestInterstitialPageStateGuard state_guard(interstitial);
2326 interstitial->Show(); 2326 interstitial->Show();
2327 interstitial->TestDidNavigate(1, url3); 2327 interstitial->TestDidNavigate(url3);
2328 EXPECT_TRUE(interstitial->is_showing()); 2328 EXPECT_TRUE(interstitial->is_showing());
2329 EXPECT_EQ(2, other_controller.GetEntryCount()); 2329 EXPECT_EQ(2, other_controller.GetEntryCount());
2330 2330
2331 // Ensure that we do not allow calling CopyStateFromAndPrune when an 2331 // Ensure that we do not allow calling CopyStateFromAndPrune when an
2332 // interstitial is showing in the target. 2332 // interstitial is showing in the target.
2333 EXPECT_FALSE(other_controller.CanPruneAllButLastCommitted()); 2333 EXPECT_FALSE(other_controller.CanPruneAllButLastCommitted());
2334 } 2334 }
2335 2335
2336 // Regression test for http://crbug.com/168611 - the URLs passed by the 2336 // Regression test for http://crbug.com/168611 - the URLs passed by the
2337 // DidFinishLoad and DidFailLoadWithError IPCs should get filtered. 2337 // DidFinishLoad and DidFailLoadWithError IPCs should get filtered.
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
2788 2788
2789 // Destroy the remote player. No power save blockers should remain. 2789 // Destroy the remote player. No power save blockers should remain.
2790 rfh->OnMessageReceived( 2790 rfh->OnMessageReceived(
2791 FrameHostMsg_MediaPausedNotification(0, kPlayerRemoteId)); 2791 FrameHostMsg_MediaPausedNotification(0, kPlayerRemoteId));
2792 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); 2792 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing());
2793 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); 2793 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing());
2794 } 2794 }
2795 #endif 2795 #endif
2796 2796
2797 } // namespace content 2797 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager_unittest.cc ('k') | content/common/frame_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698