OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/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/renderer_host/render_view_host_impl.h" | 10 #include "content/browser/renderer_host/render_view_host_impl.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 | 147 |
148 int command_received_count() const { | 148 int command_received_count() const { |
149 return command_received_count_; | 149 return command_received_count_; |
150 } | 150 } |
151 | 151 |
152 void TestDomOperationResponse(const std::string& json_string) { | 152 void TestDomOperationResponse(const std::string& json_string) { |
153 if (enabled()) | 153 if (enabled()) |
154 CommandReceived(); | 154 CommandReceived(); |
155 } | 155 } |
156 | 156 |
157 void TestDidNavigate(int page_id, const GURL& url) { | 157 void TestDidNavigate(const GURL& url) { |
158 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 158 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
159 InitNavigateParams(¶ms, page_id, url, PAGE_TRANSITION_TYPED); | 159 InitNavigateParams(¶ms, url, PAGE_TRANSITION_TYPED); |
160 DidNavigate(GetRenderViewHostForTesting(), params); | 160 DidNavigate(GetRenderViewHostForTesting(), params); |
161 } | 161 } |
162 | 162 |
163 void TestRenderViewTerminated(base::TerminationStatus status, | 163 void TestRenderViewTerminated(base::TerminationStatus status, |
164 int error_code) { | 164 int error_code) { |
165 RenderViewTerminated(GetRenderViewHostForTesting(), status, error_code); | 165 RenderViewTerminated(GetRenderViewHostForTesting(), status, error_code); |
166 } | 166 } |
167 | 167 |
168 bool is_showing() const { | 168 bool is_showing() const { |
169 return static_cast<TestRenderWidgetHostView*>( | 169 return static_cast<TestRenderWidgetHostView*>( |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 DISALLOW_COPY_AND_ASSIGN(FakeValidationMessageDelegate); | 335 DISALLOW_COPY_AND_ASSIGN(FakeValidationMessageDelegate); |
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(¶ms, GURL(url::kAboutBlankURL), PAGE_TRANSITION_TYPED); |
346 ¶ms, 0, GURL(url::kAboutBlankURL), PAGE_TRANSITION_TYPED); | |
347 | 346 |
348 LoadCommittedDetails details; | 347 LoadCommittedDetails details; |
349 cont.RendererDidNavigate(contents()->GetMainFrame(), params, &details); | 348 cont.RendererDidNavigate(contents()->GetMainFrame(), 0, params, &details); |
350 | 349 |
351 contents()->UpdateTitle(contents()->GetMainFrame(), 0, | 350 contents()->UpdateTitle(contents()->GetMainFrame(), 0, |
352 base::ASCIIToUTF16(" Lots O' Whitespace\n"), | 351 base::ASCIIToUTF16(" Lots O' Whitespace\n"), |
353 base::i18n::LEFT_TO_RIGHT); | 352 base::i18n::LEFT_TO_RIGHT); |
354 EXPECT_EQ(base::ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle()); | 353 EXPECT_EQ(base::ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle()); |
355 } | 354 } |
356 | 355 |
357 TEST_F(WebContentsImplTest, DontUseTitleFromPendingEntry) { | 356 TEST_F(WebContentsImplTest, DontUseTitleFromPendingEntry) { |
358 const GURL kGURL("chrome://blah"); | 357 const GURL kGURL("chrome://blah"); |
359 controller().LoadURL( | 358 controller().LoadURL( |
(...skipping 24 matching lines...) Expand all Loading... | |
384 process()->sink().ClearMessages(); | 383 process()->sink().ClearMessages(); |
385 | 384 |
386 cont.LoadURL( | 385 cont.LoadURL( |
387 kGURL, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 386 kGURL, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
388 rvh()->GetDelegate()->RenderViewCreated(rvh()); | 387 rvh()->GetDelegate()->RenderViewCreated(rvh()); |
389 // Did we get the expected message? | 388 // Did we get the expected message? |
390 EXPECT_TRUE(process()->sink().GetFirstMessageMatching( | 389 EXPECT_TRUE(process()->sink().GetFirstMessageMatching( |
391 ViewMsg_EnableViewSourceMode::ID)); | 390 ViewMsg_EnableViewSourceMode::ID)); |
392 | 391 |
393 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 392 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
394 InitNavigateParams(¶ms, 0, kGURL, PAGE_TRANSITION_TYPED); | 393 InitNavigateParams(¶ms, kGURL, PAGE_TRANSITION_TYPED); |
395 LoadCommittedDetails details; | 394 LoadCommittedDetails details; |
396 cont.RendererDidNavigate(contents()->GetMainFrame(), params, &details); | 395 cont.RendererDidNavigate(contents()->GetMainFrame(), 0, params, &details); |
397 // Also check title and url. | 396 // Also check title and url. |
398 EXPECT_EQ(base::ASCIIToUTF16(kUrl), contents()->GetTitle()); | 397 EXPECT_EQ(base::ASCIIToUTF16(kUrl), contents()->GetTitle()); |
399 } | 398 } |
400 | 399 |
401 // Test to ensure UpdateMaxPageID is working properly. | 400 // Test to ensure UpdateMaxPageID is working properly. |
402 TEST_F(WebContentsImplTest, UpdateMaxPageID) { | 401 TEST_F(WebContentsImplTest, UpdateMaxPageID) { |
403 SiteInstance* instance1 = contents()->GetSiteInstance(); | 402 SiteInstance* instance1 = contents()->GetSiteInstance(); |
404 scoped_refptr<SiteInstance> instance2(SiteInstance::Create(NULL)); | 403 scoped_refptr<SiteInstance> instance2(SiteInstance::Create(NULL)); |
405 | 404 |
406 // Starts at -1. | 405 // Starts at -1. |
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1455 GURL url2("http://interstitial"); | 1454 GURL url2("http://interstitial"); |
1456 TestInterstitialPage* interstitial = | 1455 TestInterstitialPage* interstitial = |
1457 new TestInterstitialPage(contents(), true, url2, &state, &deleted); | 1456 new TestInterstitialPage(contents(), true, url2, &state, &deleted); |
1458 TestInterstitialPageStateGuard state_guard(interstitial); | 1457 TestInterstitialPageStateGuard state_guard(interstitial); |
1459 interstitial->Show(); | 1458 interstitial->Show(); |
1460 // The interstitial should not show until its navigation has committed. | 1459 // The interstitial should not show until its navigation has committed. |
1461 EXPECT_FALSE(interstitial->is_showing()); | 1460 EXPECT_FALSE(interstitial->is_showing()); |
1462 EXPECT_FALSE(contents()->ShowingInterstitialPage()); | 1461 EXPECT_FALSE(contents()->ShowingInterstitialPage()); |
1463 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); | 1462 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); |
1464 // Let's commit the interstitial navigation. | 1463 // Let's commit the interstitial navigation. |
1465 interstitial->TestDidNavigate(1, url2); | 1464 interstitial->TestDidNavigate(url2); |
Charlie Reis
2014/09/11 22:55:39
All of these tests used to pass a page ID to TestD
Avi (use Gerrit)
2014/09/11 23:10:10
In a previous patchset, I commented TestDidNavigat
Charlie Reis
2014/09/11 23:15:28
Ah, that makes sense. Interstitials don't maintai
| |
1466 EXPECT_TRUE(interstitial->is_showing()); | 1465 EXPECT_TRUE(interstitial->is_showing()); |
1467 EXPECT_TRUE(contents()->ShowingInterstitialPage()); | 1466 EXPECT_TRUE(contents()->ShowingInterstitialPage()); |
1468 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); | 1467 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); |
1469 NavigationEntry* entry = controller().GetVisibleEntry(); | 1468 NavigationEntry* entry = controller().GetVisibleEntry(); |
1470 ASSERT_TRUE(entry != NULL); | 1469 ASSERT_TRUE(entry != NULL); |
1471 EXPECT_TRUE(entry->GetURL() == url2); | 1470 EXPECT_TRUE(entry->GetURL() == url2); |
1472 | 1471 |
1473 // Now don't proceed. | 1472 // Now don't proceed. |
1474 interstitial->DontProceed(); | 1473 interstitial->DontProceed(); |
1475 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 1474 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
(...skipping 26 matching lines...) Expand all Loading... | |
1502 GURL url2("http://interstitial"); | 1501 GURL url2("http://interstitial"); |
1503 TestInterstitialPage* interstitial = | 1502 TestInterstitialPage* interstitial = |
1504 new TestInterstitialPage(contents(), true, url2, &state, &deleted); | 1503 new TestInterstitialPage(contents(), true, url2, &state, &deleted); |
1505 TestInterstitialPageStateGuard state_guard(interstitial); | 1504 TestInterstitialPageStateGuard state_guard(interstitial); |
1506 interstitial->Show(); | 1505 interstitial->Show(); |
1507 // The interstitial should not show until its navigation has committed. | 1506 // The interstitial should not show until its navigation has committed. |
1508 EXPECT_FALSE(interstitial->is_showing()); | 1507 EXPECT_FALSE(interstitial->is_showing()); |
1509 EXPECT_FALSE(contents()->ShowingInterstitialPage()); | 1508 EXPECT_FALSE(contents()->ShowingInterstitialPage()); |
1510 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); | 1509 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); |
1511 // Let's commit the interstitial navigation. | 1510 // Let's commit the interstitial navigation. |
1512 interstitial->TestDidNavigate(1, url2); | 1511 interstitial->TestDidNavigate(url2); |
1513 EXPECT_TRUE(interstitial->is_showing()); | 1512 EXPECT_TRUE(interstitial->is_showing()); |
1514 EXPECT_TRUE(contents()->ShowingInterstitialPage()); | 1513 EXPECT_TRUE(contents()->ShowingInterstitialPage()); |
1515 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); | 1514 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); |
1516 NavigationEntry* entry = controller().GetVisibleEntry(); | 1515 NavigationEntry* entry = controller().GetVisibleEntry(); |
1517 ASSERT_TRUE(entry != NULL); | 1516 ASSERT_TRUE(entry != NULL); |
1518 EXPECT_TRUE(entry->GetURL() == url2); | 1517 EXPECT_TRUE(entry->GetURL() == url2); |
1519 | 1518 |
1520 // Now don't proceed. | 1519 // Now don't proceed. |
1521 interstitial->DontProceed(); | 1520 interstitial->DontProceed(); |
1522 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 1521 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
(...skipping 24 matching lines...) Expand all Loading... | |
1547 GURL url2("http://interstitial"); | 1546 GURL url2("http://interstitial"); |
1548 TestInterstitialPage* interstitial = | 1547 TestInterstitialPage* interstitial = |
1549 new TestInterstitialPage(contents(), false, url2, &state, &deleted); | 1548 new TestInterstitialPage(contents(), false, url2, &state, &deleted); |
1550 TestInterstitialPageStateGuard state_guard(interstitial); | 1549 TestInterstitialPageStateGuard state_guard(interstitial); |
1551 interstitial->Show(); | 1550 interstitial->Show(); |
1552 // The interstitial should not show until its navigation has committed. | 1551 // The interstitial should not show until its navigation has committed. |
1553 EXPECT_FALSE(interstitial->is_showing()); | 1552 EXPECT_FALSE(interstitial->is_showing()); |
1554 EXPECT_FALSE(contents()->ShowingInterstitialPage()); | 1553 EXPECT_FALSE(contents()->ShowingInterstitialPage()); |
1555 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); | 1554 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); |
1556 // Let's commit the interstitial navigation. | 1555 // Let's commit the interstitial navigation. |
1557 interstitial->TestDidNavigate(1, url2); | 1556 interstitial->TestDidNavigate(url2); |
1558 EXPECT_TRUE(interstitial->is_showing()); | 1557 EXPECT_TRUE(interstitial->is_showing()); |
1559 EXPECT_TRUE(contents()->ShowingInterstitialPage()); | 1558 EXPECT_TRUE(contents()->ShowingInterstitialPage()); |
1560 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); | 1559 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); |
1561 NavigationEntry* entry = controller().GetVisibleEntry(); | 1560 NavigationEntry* entry = controller().GetVisibleEntry(); |
1562 ASSERT_TRUE(entry != NULL); | 1561 ASSERT_TRUE(entry != NULL); |
1563 // The URL specified to the interstitial should have been ignored. | 1562 // The URL specified to the interstitial should have been ignored. |
1564 EXPECT_TRUE(entry->GetURL() == url1); | 1563 EXPECT_TRUE(entry->GetURL() == url1); |
1565 | 1564 |
1566 // Now don't proceed. | 1565 // Now don't proceed. |
1567 interstitial->DontProceed(); | 1566 interstitial->DontProceed(); |
(...skipping 30 matching lines...) Expand all Loading... | |
1598 GURL url2("http://interstitial"); | 1597 GURL url2("http://interstitial"); |
1599 TestInterstitialPage* interstitial = | 1598 TestInterstitialPage* interstitial = |
1600 new TestInterstitialPage(contents(), true, url2, &state, &deleted); | 1599 new TestInterstitialPage(contents(), true, url2, &state, &deleted); |
1601 TestInterstitialPageStateGuard state_guard(interstitial); | 1600 TestInterstitialPageStateGuard state_guard(interstitial); |
1602 interstitial->Show(); | 1601 interstitial->Show(); |
1603 // The interstitial should not show until its navigation has committed. | 1602 // The interstitial should not show until its navigation has committed. |
1604 EXPECT_FALSE(interstitial->is_showing()); | 1603 EXPECT_FALSE(interstitial->is_showing()); |
1605 EXPECT_FALSE(contents()->ShowingInterstitialPage()); | 1604 EXPECT_FALSE(contents()->ShowingInterstitialPage()); |
1606 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); | 1605 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); |
1607 // Let's commit the interstitial navigation. | 1606 // Let's commit the interstitial navigation. |
1608 interstitial->TestDidNavigate(1, url2); | 1607 interstitial->TestDidNavigate(url2); |
1609 EXPECT_TRUE(interstitial->is_showing()); | 1608 EXPECT_TRUE(interstitial->is_showing()); |
1610 EXPECT_TRUE(contents()->ShowingInterstitialPage()); | 1609 EXPECT_TRUE(contents()->ShowingInterstitialPage()); |
1611 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); | 1610 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); |
1612 NavigationEntry* entry = controller().GetVisibleEntry(); | 1611 NavigationEntry* entry = controller().GetVisibleEntry(); |
1613 ASSERT_TRUE(entry != NULL); | 1612 ASSERT_TRUE(entry != NULL); |
1614 EXPECT_TRUE(entry->GetURL() == url2); | 1613 EXPECT_TRUE(entry->GetURL() == url2); |
1615 | 1614 |
1616 // Then proceed. | 1615 // Then proceed. |
1617 interstitial->Proceed(); | 1616 interstitial->Proceed(); |
1618 // The interstitial should show until the new navigation commits. | 1617 // The interstitial should show until the new navigation commits. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1656 GURL url2("http://interstitial"); | 1655 GURL url2("http://interstitial"); |
1657 TestInterstitialPage* interstitial = | 1656 TestInterstitialPage* interstitial = |
1658 new TestInterstitialPage(contents(), true, url2, &state, &deleted); | 1657 new TestInterstitialPage(contents(), true, url2, &state, &deleted); |
1659 TestInterstitialPageStateGuard state_guard(interstitial); | 1658 TestInterstitialPageStateGuard state_guard(interstitial); |
1660 interstitial->Show(); | 1659 interstitial->Show(); |
1661 // The interstitial should not show until its navigation has committed. | 1660 // The interstitial should not show until its navigation has committed. |
1662 EXPECT_FALSE(interstitial->is_showing()); | 1661 EXPECT_FALSE(interstitial->is_showing()); |
1663 EXPECT_FALSE(contents()->ShowingInterstitialPage()); | 1662 EXPECT_FALSE(contents()->ShowingInterstitialPage()); |
1664 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); | 1663 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); |
1665 // Let's commit the interstitial navigation. | 1664 // Let's commit the interstitial navigation. |
1666 interstitial->TestDidNavigate(1, url2); | 1665 interstitial->TestDidNavigate(url2); |
1667 EXPECT_TRUE(interstitial->is_showing()); | 1666 EXPECT_TRUE(interstitial->is_showing()); |
1668 EXPECT_TRUE(contents()->ShowingInterstitialPage()); | 1667 EXPECT_TRUE(contents()->ShowingInterstitialPage()); |
1669 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); | 1668 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); |
1670 NavigationEntry* entry = controller().GetVisibleEntry(); | 1669 NavigationEntry* entry = controller().GetVisibleEntry(); |
1671 ASSERT_TRUE(entry != NULL); | 1670 ASSERT_TRUE(entry != NULL); |
1672 EXPECT_TRUE(entry->GetURL() == url2); | 1671 EXPECT_TRUE(entry->GetURL() == url2); |
1673 | 1672 |
1674 // Then proceed. | 1673 // Then proceed. |
1675 interstitial->Proceed(); | 1674 interstitial->Proceed(); |
1676 // The interstitial should show until the new navigation commits. | 1675 // The interstitial should show until the new navigation commits. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1713 GURL url2("http://interstitial"); | 1712 GURL url2("http://interstitial"); |
1714 TestInterstitialPage* interstitial = | 1713 TestInterstitialPage* interstitial = |
1715 new TestInterstitialPage(contents(), false, url2, &state, &deleted); | 1714 new TestInterstitialPage(contents(), false, url2, &state, &deleted); |
1716 TestInterstitialPageStateGuard state_guard(interstitial); | 1715 TestInterstitialPageStateGuard state_guard(interstitial); |
1717 interstitial->Show(); | 1716 interstitial->Show(); |
1718 // The interstitial should not show until its navigation has committed. | 1717 // The interstitial should not show until its navigation has committed. |
1719 EXPECT_FALSE(interstitial->is_showing()); | 1718 EXPECT_FALSE(interstitial->is_showing()); |
1720 EXPECT_FALSE(contents()->ShowingInterstitialPage()); | 1719 EXPECT_FALSE(contents()->ShowingInterstitialPage()); |
1721 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); | 1720 EXPECT_TRUE(contents()->GetInterstitialPage() == NULL); |
1722 // Let's commit the interstitial navigation. | 1721 // Let's commit the interstitial navigation. |
1723 interstitial->TestDidNavigate(1, url2); | 1722 interstitial->TestDidNavigate(url2); |
1724 EXPECT_TRUE(interstitial->is_showing()); | 1723 EXPECT_TRUE(interstitial->is_showing()); |
1725 EXPECT_TRUE(contents()->ShowingInterstitialPage()); | 1724 EXPECT_TRUE(contents()->ShowingInterstitialPage()); |
1726 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); | 1725 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); |
1727 NavigationEntry* entry = controller().GetVisibleEntry(); | 1726 NavigationEntry* entry = controller().GetVisibleEntry(); |
1728 ASSERT_TRUE(entry != NULL); | 1727 ASSERT_TRUE(entry != NULL); |
1729 // The URL specified to the interstitial should have been ignored. | 1728 // The URL specified to the interstitial should have been ignored. |
1730 EXPECT_TRUE(entry->GetURL() == url1); | 1729 EXPECT_TRUE(entry->GetURL() == url1); |
1731 | 1730 |
1732 // Then proceed. | 1731 // Then proceed. |
1733 interstitial->Proceed(); | 1732 interstitial->Proceed(); |
(...skipping 16 matching lines...) Expand all Loading... | |
1750 TEST_F(WebContentsImplTest, ShowInterstitialThenNavigate) { | 1749 TEST_F(WebContentsImplTest, ShowInterstitialThenNavigate) { |
1751 // Show interstitial. | 1750 // Show interstitial. |
1752 TestInterstitialPage::InterstitialState state = | 1751 TestInterstitialPage::InterstitialState state = |
1753 TestInterstitialPage::INVALID; | 1752 TestInterstitialPage::INVALID; |
1754 bool deleted = false; | 1753 bool deleted = false; |
1755 GURL url("http://interstitial"); | 1754 GURL url("http://interstitial"); |
1756 TestInterstitialPage* interstitial = | 1755 TestInterstitialPage* interstitial = |
1757 new TestInterstitialPage(contents(), true, url, &state, &deleted); | 1756 new TestInterstitialPage(contents(), true, url, &state, &deleted); |
1758 TestInterstitialPageStateGuard state_guard(interstitial); | 1757 TestInterstitialPageStateGuard state_guard(interstitial); |
1759 interstitial->Show(); | 1758 interstitial->Show(); |
1760 interstitial->TestDidNavigate(1, url); | 1759 interstitial->TestDidNavigate(url); |
1761 | 1760 |
1762 // While interstitial showing, navigate to a new URL. | 1761 // While interstitial showing, navigate to a new URL. |
1763 const GURL url2("http://www.yahoo.com"); | 1762 const GURL url2("http://www.yahoo.com"); |
1764 contents()->GetMainFrame()->SendNavigate(1, url2); | 1763 contents()->GetMainFrame()->SendNavigate(1, url2); |
1765 | 1764 |
1766 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 1765 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
1767 | 1766 |
1768 RunAllPendingInMessageLoop(); | 1767 RunAllPendingInMessageLoop(); |
1769 EXPECT_TRUE(deleted); | 1768 EXPECT_TRUE(deleted); |
1770 } | 1769 } |
1771 | 1770 |
1772 // Test navigating to a page that shows an interstitial, then going back. | 1771 // Test navigating to a page that shows an interstitial, then going back. |
1773 TEST_F(WebContentsImplTest, ShowInterstitialThenGoBack) { | 1772 TEST_F(WebContentsImplTest, ShowInterstitialThenGoBack) { |
1774 // Navigate to a page so we have a navigation entry in the controller. | 1773 // Navigate to a page so we have a navigation entry in the controller. |
1775 GURL url1("http://www.google.com"); | 1774 GURL url1("http://www.google.com"); |
1776 contents()->GetMainFrame()->SendNavigate(1, url1); | 1775 contents()->GetMainFrame()->SendNavigate(1, url1); |
1777 EXPECT_EQ(1, controller().GetEntryCount()); | 1776 EXPECT_EQ(1, controller().GetEntryCount()); |
1778 | 1777 |
1779 // Show interstitial. | 1778 // Show interstitial. |
1780 TestInterstitialPage::InterstitialState state = | 1779 TestInterstitialPage::InterstitialState state = |
1781 TestInterstitialPage::INVALID; | 1780 TestInterstitialPage::INVALID; |
1782 bool deleted = false; | 1781 bool deleted = false; |
1783 GURL interstitial_url("http://interstitial"); | 1782 GURL interstitial_url("http://interstitial"); |
1784 TestInterstitialPage* interstitial = | 1783 TestInterstitialPage* interstitial = |
1785 new TestInterstitialPage(contents(), true, interstitial_url, | 1784 new TestInterstitialPage(contents(), true, interstitial_url, |
1786 &state, &deleted); | 1785 &state, &deleted); |
1787 TestInterstitialPageStateGuard state_guard(interstitial); | 1786 TestInterstitialPageStateGuard state_guard(interstitial); |
1788 interstitial->Show(); | 1787 interstitial->Show(); |
1789 interstitial->TestDidNavigate(2, interstitial_url); | 1788 interstitial->TestDidNavigate(interstitial_url); |
1790 | 1789 |
1791 // While the interstitial is showing, go back. | 1790 // While the interstitial is showing, go back. |
1792 controller().GoBack(); | 1791 controller().GoBack(); |
1793 contents()->GetMainFrame()->SendNavigate(1, url1); | 1792 contents()->GetMainFrame()->SendNavigate(1, url1); |
1794 | 1793 |
1795 // Make sure we are back to the original page and that the interstitial is | 1794 // Make sure we are back to the original page and that the interstitial is |
1796 // gone. | 1795 // gone. |
1797 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 1796 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
1798 NavigationEntry* entry = controller().GetVisibleEntry(); | 1797 NavigationEntry* entry = controller().GetVisibleEntry(); |
1799 ASSERT_TRUE(entry); | 1798 ASSERT_TRUE(entry); |
(...skipping 14 matching lines...) Expand all Loading... | |
1814 // Show interstitial. | 1813 // Show interstitial. |
1815 TestInterstitialPage::InterstitialState state = | 1814 TestInterstitialPage::InterstitialState state = |
1816 TestInterstitialPage::INVALID; | 1815 TestInterstitialPage::INVALID; |
1817 bool deleted = false; | 1816 bool deleted = false; |
1818 GURL interstitial_url("http://interstitial"); | 1817 GURL interstitial_url("http://interstitial"); |
1819 TestInterstitialPage* interstitial = | 1818 TestInterstitialPage* interstitial = |
1820 new TestInterstitialPage(contents(), true, interstitial_url, | 1819 new TestInterstitialPage(contents(), true, interstitial_url, |
1821 &state, &deleted); | 1820 &state, &deleted); |
1822 TestInterstitialPageStateGuard state_guard(interstitial); | 1821 TestInterstitialPageStateGuard state_guard(interstitial); |
1823 interstitial->Show(); | 1822 interstitial->Show(); |
1824 interstitial->TestDidNavigate(2, interstitial_url); | 1823 interstitial->TestDidNavigate(interstitial_url); |
1825 | 1824 |
1826 // Crash the renderer | 1825 // Crash the renderer |
1827 test_rvh()->OnMessageReceived( | 1826 test_rvh()->OnMessageReceived( |
1828 ViewHostMsg_RenderProcessGone( | 1827 ViewHostMsg_RenderProcessGone( |
1829 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); | 1828 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); |
1830 | 1829 |
1831 // While the interstitial is showing, go back. | 1830 // While the interstitial is showing, go back. |
1832 controller().GoBack(); | 1831 controller().GoBack(); |
1833 contents()->GetMainFrame()->SendNavigate(1, url1); | 1832 contents()->GetMainFrame()->SendNavigate(1, url1); |
1834 | 1833 |
(...skipping 25 matching lines...) Expand all Loading... | |
1860 new TestInterstitialPage(contents(), true, interstitial_url, | 1859 new TestInterstitialPage(contents(), true, interstitial_url, |
1861 &state, &deleted); | 1860 &state, &deleted); |
1862 TestInterstitialPageStateGuard state_guard(interstitial); | 1861 TestInterstitialPageStateGuard state_guard(interstitial); |
1863 interstitial->Show(); | 1862 interstitial->Show(); |
1864 | 1863 |
1865 // Crash the renderer | 1864 // Crash the renderer |
1866 test_rvh()->OnMessageReceived( | 1865 test_rvh()->OnMessageReceived( |
1867 ViewHostMsg_RenderProcessGone( | 1866 ViewHostMsg_RenderProcessGone( |
1868 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); | 1867 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); |
1869 | 1868 |
1870 interstitial->TestDidNavigate(2, interstitial_url); | 1869 interstitial->TestDidNavigate(interstitial_url); |
1871 } | 1870 } |
1872 | 1871 |
1873 // Test navigating to a page that shows an interstitial, then close the | 1872 // Test navigating to a page that shows an interstitial, then close the |
1874 // contents. | 1873 // contents. |
1875 TEST_F(WebContentsImplTest, ShowInterstitialThenCloseTab) { | 1874 TEST_F(WebContentsImplTest, ShowInterstitialThenCloseTab) { |
1876 // Show interstitial. | 1875 // Show interstitial. |
1877 TestInterstitialPage::InterstitialState state = | 1876 TestInterstitialPage::InterstitialState state = |
1878 TestInterstitialPage::INVALID; | 1877 TestInterstitialPage::INVALID; |
1879 bool deleted = false; | 1878 bool deleted = false; |
1880 GURL url("http://interstitial"); | 1879 GURL url("http://interstitial"); |
1881 TestInterstitialPage* interstitial = | 1880 TestInterstitialPage* interstitial = |
1882 new TestInterstitialPage(contents(), true, url, &state, &deleted); | 1881 new TestInterstitialPage(contents(), true, url, &state, &deleted); |
1883 TestInterstitialPageStateGuard state_guard(interstitial); | 1882 TestInterstitialPageStateGuard state_guard(interstitial); |
1884 interstitial->Show(); | 1883 interstitial->Show(); |
1885 interstitial->TestDidNavigate(1, url); | 1884 interstitial->TestDidNavigate(url); |
1886 | 1885 |
1887 // Now close the contents. | 1886 // Now close the contents. |
1888 DeleteContents(); | 1887 DeleteContents(); |
1889 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 1888 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
1890 | 1889 |
1891 RunAllPendingInMessageLoop(); | 1890 RunAllPendingInMessageLoop(); |
1892 EXPECT_TRUE(deleted); | 1891 EXPECT_TRUE(deleted); |
1893 } | 1892 } |
1894 | 1893 |
1895 // Test navigating to a page that shows an interstitial, then close the | 1894 // Test navigating to a page that shows an interstitial, then close the |
1896 // contents. | 1895 // contents. |
1897 TEST_F(WebContentsImplTest, ShowInterstitialThenCloseAndShutdown) { | 1896 TEST_F(WebContentsImplTest, ShowInterstitialThenCloseAndShutdown) { |
1898 // Show interstitial. | 1897 // Show interstitial. |
1899 TestInterstitialPage::InterstitialState state = | 1898 TestInterstitialPage::InterstitialState state = |
1900 TestInterstitialPage::INVALID; | 1899 TestInterstitialPage::INVALID; |
1901 bool deleted = false; | 1900 bool deleted = false; |
1902 GURL url("http://interstitial"); | 1901 GURL url("http://interstitial"); |
1903 TestInterstitialPage* interstitial = | 1902 TestInterstitialPage* interstitial = |
1904 new TestInterstitialPage(contents(), true, url, &state, &deleted); | 1903 new TestInterstitialPage(contents(), true, url, &state, &deleted); |
1905 TestInterstitialPageStateGuard state_guard(interstitial); | 1904 TestInterstitialPageStateGuard state_guard(interstitial); |
1906 interstitial->Show(); | 1905 interstitial->Show(); |
1907 interstitial->TestDidNavigate(1, url); | 1906 interstitial->TestDidNavigate(url); |
1908 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 1907 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
1909 interstitial->GetRenderViewHostForTesting()); | 1908 interstitial->GetRenderViewHostForTesting()); |
1910 | 1909 |
1911 // Now close the contents. | 1910 // Now close the contents. |
1912 DeleteContents(); | 1911 DeleteContents(); |
1913 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 1912 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
1914 | 1913 |
1915 // Before the interstitial has a chance to process its shutdown task, | 1914 // Before the interstitial has a chance to process its shutdown task, |
1916 // simulate quitting the browser. This goes through all processes and | 1915 // simulate quitting the browser. This goes through all processes and |
1917 // tells them to destruct. | 1916 // tells them to destruct. |
(...skipping 14 matching lines...) Expand all Loading... | |
1932 | 1931 |
1933 // Show an interstitial. | 1932 // Show an interstitial. |
1934 TestInterstitialPage::InterstitialState state = | 1933 TestInterstitialPage::InterstitialState state = |
1935 TestInterstitialPage::INVALID; | 1934 TestInterstitialPage::INVALID; |
1936 bool deleted = false; | 1935 bool deleted = false; |
1937 GURL url2("http://interstitial"); | 1936 GURL url2("http://interstitial"); |
1938 TestInterstitialPage* interstitial = | 1937 TestInterstitialPage* interstitial = |
1939 new TestInterstitialPage(contents(), true, url2, &state, &deleted); | 1938 new TestInterstitialPage(contents(), true, url2, &state, &deleted); |
1940 TestInterstitialPageStateGuard state_guard(interstitial); | 1939 TestInterstitialPageStateGuard state_guard(interstitial); |
1941 interstitial->Show(); | 1940 interstitial->Show(); |
1942 interstitial->TestDidNavigate(1, url2); | 1941 interstitial->TestDidNavigate(url2); |
1943 | 1942 |
1944 // Run a command. | 1943 // Run a command. |
1945 EXPECT_EQ(0, interstitial->command_received_count()); | 1944 EXPECT_EQ(0, interstitial->command_received_count()); |
1946 interstitial->TestDomOperationResponse("toto"); | 1945 interstitial->TestDomOperationResponse("toto"); |
1947 EXPECT_EQ(1, interstitial->command_received_count()); | 1946 EXPECT_EQ(1, interstitial->command_received_count()); |
1948 | 1947 |
1949 // Then proceed. | 1948 // Then proceed. |
1950 interstitial->Proceed(); | 1949 interstitial->Proceed(); |
1951 RunAllPendingInMessageLoop(); | 1950 RunAllPendingInMessageLoop(); |
1952 ASSERT_FALSE(deleted); | 1951 ASSERT_FALSE(deleted); |
(...skipping 14 matching lines...) Expand all Loading... | |
1967 | 1966 |
1968 // Show an interstitial. | 1967 // Show an interstitial. |
1969 TestInterstitialPage::InterstitialState state1 = | 1968 TestInterstitialPage::InterstitialState state1 = |
1970 TestInterstitialPage::INVALID; | 1969 TestInterstitialPage::INVALID; |
1971 bool deleted1 = false; | 1970 bool deleted1 = false; |
1972 GURL url1("http://interstitial1"); | 1971 GURL url1("http://interstitial1"); |
1973 TestInterstitialPage* interstitial1 = | 1972 TestInterstitialPage* interstitial1 = |
1974 new TestInterstitialPage(contents(), true, url1, &state1, &deleted1); | 1973 new TestInterstitialPage(contents(), true, url1, &state1, &deleted1); |
1975 TestInterstitialPageStateGuard state_guard1(interstitial1); | 1974 TestInterstitialPageStateGuard state_guard1(interstitial1); |
1976 interstitial1->Show(); | 1975 interstitial1->Show(); |
1977 interstitial1->TestDidNavigate(1, url1); | 1976 interstitial1->TestDidNavigate(url1); |
1978 | 1977 |
1979 // Now show another interstitial. | 1978 // Now show another interstitial. |
1980 TestInterstitialPage::InterstitialState state2 = | 1979 TestInterstitialPage::InterstitialState state2 = |
1981 TestInterstitialPage::INVALID; | 1980 TestInterstitialPage::INVALID; |
1982 bool deleted2 = false; | 1981 bool deleted2 = false; |
1983 GURL url2("http://interstitial2"); | 1982 GURL url2("http://interstitial2"); |
1984 TestInterstitialPage* interstitial2 = | 1983 TestInterstitialPage* interstitial2 = |
1985 new TestInterstitialPage(contents(), true, url2, &state2, &deleted2); | 1984 new TestInterstitialPage(contents(), true, url2, &state2, &deleted2); |
1986 TestInterstitialPageStateGuard state_guard2(interstitial2); | 1985 TestInterstitialPageStateGuard state_guard2(interstitial2); |
1987 interstitial2->Show(); | 1986 interstitial2->Show(); |
1988 interstitial2->TestDidNavigate(1, url2); | 1987 interstitial2->TestDidNavigate(url2); |
1989 | 1988 |
1990 // Showing interstitial2 should have caused interstitial1 to go away. | 1989 // Showing interstitial2 should have caused interstitial1 to go away. |
1991 EXPECT_EQ(TestInterstitialPage::CANCELED, state1); | 1990 EXPECT_EQ(TestInterstitialPage::CANCELED, state1); |
1992 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2); | 1991 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2); |
1993 | 1992 |
1994 RunAllPendingInMessageLoop(); | 1993 RunAllPendingInMessageLoop(); |
1995 EXPECT_TRUE(deleted1); | 1994 EXPECT_TRUE(deleted1); |
1996 ASSERT_FALSE(deleted2); | 1995 ASSERT_FALSE(deleted2); |
1997 | 1996 |
1998 // Let's make sure interstitial2 is working as intended. | 1997 // Let's make sure interstitial2 is working as intended. |
(...skipping 21 matching lines...) Expand all Loading... | |
2020 | 2019 |
2021 // Show an interstitial. | 2020 // Show an interstitial. |
2022 TestInterstitialPage::InterstitialState state1 = | 2021 TestInterstitialPage::InterstitialState state1 = |
2023 TestInterstitialPage::INVALID; | 2022 TestInterstitialPage::INVALID; |
2024 bool deleted1 = false; | 2023 bool deleted1 = false; |
2025 GURL url1("http://interstitial1"); | 2024 GURL url1("http://interstitial1"); |
2026 TestInterstitialPage* interstitial1 = | 2025 TestInterstitialPage* interstitial1 = |
2027 new TestInterstitialPage(contents(), true, url1, &state1, &deleted1); | 2026 new TestInterstitialPage(contents(), true, url1, &state1, &deleted1); |
2028 TestInterstitialPageStateGuard state_guard1(interstitial1); | 2027 TestInterstitialPageStateGuard state_guard1(interstitial1); |
2029 interstitial1->Show(); | 2028 interstitial1->Show(); |
2030 interstitial1->TestDidNavigate(1, url1); | 2029 interstitial1->TestDidNavigate(url1); |
2031 | 2030 |
2032 // Take action. The interstitial won't be hidden until the navigation is | 2031 // Take action. The interstitial won't be hidden until the navigation is |
2033 // committed. | 2032 // committed. |
2034 interstitial1->Proceed(); | 2033 interstitial1->Proceed(); |
2035 EXPECT_EQ(TestInterstitialPage::OKED, state1); | 2034 EXPECT_EQ(TestInterstitialPage::OKED, state1); |
2036 | 2035 |
2037 // Now show another interstitial (simulating the navigation causing another | 2036 // Now show another interstitial (simulating the navigation causing another |
2038 // interstitial). | 2037 // interstitial). |
2039 TestInterstitialPage::InterstitialState state2 = | 2038 TestInterstitialPage::InterstitialState state2 = |
2040 TestInterstitialPage::INVALID; | 2039 TestInterstitialPage::INVALID; |
2041 bool deleted2 = false; | 2040 bool deleted2 = false; |
2042 GURL url2("http://interstitial2"); | 2041 GURL url2("http://interstitial2"); |
2043 TestInterstitialPage* interstitial2 = | 2042 TestInterstitialPage* interstitial2 = |
2044 new TestInterstitialPage(contents(), true, url2, &state2, &deleted2); | 2043 new TestInterstitialPage(contents(), true, url2, &state2, &deleted2); |
2045 TestInterstitialPageStateGuard state_guard2(interstitial2); | 2044 TestInterstitialPageStateGuard state_guard2(interstitial2); |
2046 interstitial2->Show(); | 2045 interstitial2->Show(); |
2047 interstitial2->TestDidNavigate(1, url2); | 2046 interstitial2->TestDidNavigate(url2); |
2048 | 2047 |
2049 // Showing interstitial2 should have caused interstitial1 to go away. | 2048 // Showing interstitial2 should have caused interstitial1 to go away. |
2050 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2); | 2049 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2); |
2051 RunAllPendingInMessageLoop(); | 2050 RunAllPendingInMessageLoop(); |
2052 EXPECT_TRUE(deleted1); | 2051 EXPECT_TRUE(deleted1); |
2053 ASSERT_FALSE(deleted2); | 2052 ASSERT_FALSE(deleted2); |
2054 | 2053 |
2055 // Let's make sure interstitial2 is working as intended. | 2054 // Let's make sure interstitial2 is working as intended. |
2056 interstitial2->Proceed(); | 2055 interstitial2->Proceed(); |
2057 GURL landing_url("http://www.thepage.com"); | 2056 GURL landing_url("http://www.thepage.com"); |
(...skipping 25 matching lines...) Expand all Loading... | |
2083 | 2082 |
2084 // Let's simulate a navigation initiated from the browser before the | 2083 // Let's simulate a navigation initiated from the browser before the |
2085 // interstitial finishes loading. | 2084 // interstitial finishes loading. |
2086 const GURL url("http://www.google.com"); | 2085 const GURL url("http://www.google.com"); |
2087 controller().LoadURL(url, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2086 controller().LoadURL(url, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
2088 EXPECT_FALSE(interstitial->is_showing()); | 2087 EXPECT_FALSE(interstitial->is_showing()); |
2089 RunAllPendingInMessageLoop(); | 2088 RunAllPendingInMessageLoop(); |
2090 ASSERT_FALSE(deleted); | 2089 ASSERT_FALSE(deleted); |
2091 | 2090 |
2092 // Now let's make the interstitial navigation commit. | 2091 // Now let's make the interstitial navigation commit. |
2093 interstitial->TestDidNavigate(1, interstitial_url); | 2092 interstitial->TestDidNavigate(interstitial_url); |
2094 | 2093 |
2095 // After it loaded the interstitial should be gone. | 2094 // After it loaded the interstitial should be gone. |
2096 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 2095 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
2097 | 2096 |
2098 RunAllPendingInMessageLoop(); | 2097 RunAllPendingInMessageLoop(); |
2099 EXPECT_TRUE(deleted); | 2098 EXPECT_TRUE(deleted); |
2100 } | 2099 } |
2101 | 2100 |
2102 // 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 |
2103 // 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 Loading... | |
2128 // The first interstitial should have been closed and deleted. | 2127 // The first interstitial should have been closed and deleted. |
2129 EXPECT_EQ(TestInterstitialPage::CANCELED, state1); | 2128 EXPECT_EQ(TestInterstitialPage::CANCELED, state1); |
2130 // The 2nd one should still be OK. | 2129 // The 2nd one should still be OK. |
2131 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2); | 2130 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2); |
2132 | 2131 |
2133 RunAllPendingInMessageLoop(); | 2132 RunAllPendingInMessageLoop(); |
2134 EXPECT_TRUE(deleted1); | 2133 EXPECT_TRUE(deleted1); |
2135 ASSERT_FALSE(deleted2); | 2134 ASSERT_FALSE(deleted2); |
2136 | 2135 |
2137 // Make the interstitial navigation commit it should be showing. | 2136 // Make the interstitial navigation commit it should be showing. |
2138 interstitial2->TestDidNavigate(1, interstitial_url); | 2137 interstitial2->TestDidNavigate(interstitial_url); |
2139 EXPECT_EQ(interstitial2, contents()->GetInterstitialPage()); | 2138 EXPECT_EQ(interstitial2, contents()->GetInterstitialPage()); |
2140 } | 2139 } |
2141 | 2140 |
2142 // Test showing an interstitial and have its renderer crash. | 2141 // Test showing an interstitial and have its renderer crash. |
2143 TEST_F(WebContentsImplTest, InterstitialCrasher) { | 2142 TEST_F(WebContentsImplTest, InterstitialCrasher) { |
2144 // Show an interstitial. | 2143 // Show an interstitial. |
2145 TestInterstitialPage::InterstitialState state = | 2144 TestInterstitialPage::InterstitialState state = |
2146 TestInterstitialPage::INVALID; | 2145 TestInterstitialPage::INVALID; |
2147 bool deleted = false; | 2146 bool deleted = false; |
2148 GURL url("http://interstitial"); | 2147 GURL url("http://interstitial"); |
2149 TestInterstitialPage* interstitial = | 2148 TestInterstitialPage* interstitial = |
2150 new TestInterstitialPage(contents(), true, url, &state, &deleted); | 2149 new TestInterstitialPage(contents(), true, url, &state, &deleted); |
2151 TestInterstitialPageStateGuard state_guard(interstitial); | 2150 TestInterstitialPageStateGuard state_guard(interstitial); |
2152 interstitial->Show(); | 2151 interstitial->Show(); |
2153 // Simulate a renderer crash before the interstitial is shown. | 2152 // Simulate a renderer crash before the interstitial is shown. |
2154 interstitial->TestRenderViewTerminated( | 2153 interstitial->TestRenderViewTerminated( |
2155 base::TERMINATION_STATUS_PROCESS_CRASHED, -1); | 2154 base::TERMINATION_STATUS_PROCESS_CRASHED, -1); |
2156 // The interstitial should have been dismissed. | 2155 // The interstitial should have been dismissed. |
2157 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 2156 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
2158 RunAllPendingInMessageLoop(); | 2157 RunAllPendingInMessageLoop(); |
2159 EXPECT_TRUE(deleted); | 2158 EXPECT_TRUE(deleted); |
2160 | 2159 |
2161 // 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. |
2162 interstitial = | 2161 interstitial = |
2163 new TestInterstitialPage(contents(), true, url, &state, &deleted); | 2162 new TestInterstitialPage(contents(), true, url, &state, &deleted); |
2164 interstitial->Show(); | 2163 interstitial->Show(); |
2165 interstitial->TestDidNavigate(1, url); | 2164 interstitial->TestDidNavigate(url); |
2166 // Simulate a renderer crash. | 2165 // Simulate a renderer crash. |
2167 interstitial->TestRenderViewTerminated( | 2166 interstitial->TestRenderViewTerminated( |
2168 base::TERMINATION_STATUS_PROCESS_CRASHED, -1); | 2167 base::TERMINATION_STATUS_PROCESS_CRASHED, -1); |
2169 // The interstitial should have been dismissed. | 2168 // The interstitial should have been dismissed. |
2170 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 2169 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
2171 RunAllPendingInMessageLoop(); | 2170 RunAllPendingInMessageLoop(); |
2172 EXPECT_TRUE(deleted); | 2171 EXPECT_TRUE(deleted); |
2173 } | 2172 } |
2174 | 2173 |
2175 // 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 |
2176 // navigation while an interstitial is showing does not remove the pending | 2175 // navigation while an interstitial is showing does not remove the pending |
2177 // entry (see http://crbug.com/9791). | 2176 // entry (see http://crbug.com/9791). |
2178 TEST_F(WebContentsImplTest, NewInterstitialDoesNotCancelPendingEntry) { | 2177 TEST_F(WebContentsImplTest, NewInterstitialDoesNotCancelPendingEntry) { |
2179 const char kUrl[] = "http://www.badguys.com/"; | 2178 const char kUrl[] = "http://www.badguys.com/"; |
2180 const GURL kGURL(kUrl); | 2179 const GURL kGURL(kUrl); |
2181 | 2180 |
2182 // Start a navigation to a page | 2181 // Start a navigation to a page |
2183 contents()->GetController().LoadURL( | 2182 contents()->GetController().LoadURL( |
2184 kGURL, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2183 kGURL, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
2185 | 2184 |
2186 // Simulate that navigation triggering an interstitial. | 2185 // Simulate that navigation triggering an interstitial. |
2187 TestInterstitialPage::InterstitialState state = | 2186 TestInterstitialPage::InterstitialState state = |
2188 TestInterstitialPage::INVALID; | 2187 TestInterstitialPage::INVALID; |
2189 bool deleted = false; | 2188 bool deleted = false; |
2190 TestInterstitialPage* interstitial = | 2189 TestInterstitialPage* interstitial = |
2191 new TestInterstitialPage(contents(), true, kGURL, &state, &deleted); | 2190 new TestInterstitialPage(contents(), true, kGURL, &state, &deleted); |
2192 TestInterstitialPageStateGuard state_guard(interstitial); | 2191 TestInterstitialPageStateGuard state_guard(interstitial); |
2193 interstitial->Show(); | 2192 interstitial->Show(); |
2194 interstitial->TestDidNavigate(1, kGURL); | 2193 interstitial->TestDidNavigate(kGURL); |
2195 | 2194 |
2196 // Initiate a new navigation from the browser that also triggers an | 2195 // Initiate a new navigation from the browser that also triggers an |
2197 // interstitial. | 2196 // interstitial. |
2198 contents()->GetController().LoadURL( | 2197 contents()->GetController().LoadURL( |
2199 kGURL, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 2198 kGURL, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
2200 TestInterstitialPage::InterstitialState state2 = | 2199 TestInterstitialPage::InterstitialState state2 = |
2201 TestInterstitialPage::INVALID; | 2200 TestInterstitialPage::INVALID; |
2202 bool deleted2 = false; | 2201 bool deleted2 = false; |
2203 TestInterstitialPage* interstitial2 = | 2202 TestInterstitialPage* interstitial2 = |
2204 new TestInterstitialPage(contents(), true, kGURL, &state2, &deleted2); | 2203 new TestInterstitialPage(contents(), true, kGURL, &state2, &deleted2); |
2205 TestInterstitialPageStateGuard state_guard2(interstitial2); | 2204 TestInterstitialPageStateGuard state_guard2(interstitial2); |
2206 interstitial2->Show(); | 2205 interstitial2->Show(); |
2207 interstitial2->TestDidNavigate(1, kGURL); | 2206 interstitial2->TestDidNavigate(kGURL); |
2208 | 2207 |
2209 // Make sure we still have an entry. | 2208 // Make sure we still have an entry. |
2210 NavigationEntry* entry = contents()->GetController().GetPendingEntry(); | 2209 NavigationEntry* entry = contents()->GetController().GetPendingEntry(); |
2211 ASSERT_TRUE(entry); | 2210 ASSERT_TRUE(entry); |
2212 EXPECT_EQ(kUrl, entry->GetURL().spec()); | 2211 EXPECT_EQ(kUrl, entry->GetURL().spec()); |
2213 | 2212 |
2214 // And that the first interstitial is gone, but not the second. | 2213 // And that the first interstitial is gone, but not the second. |
2215 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 2214 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
2216 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2); | 2215 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2); |
2217 RunAllPendingInMessageLoop(); | 2216 RunAllPendingInMessageLoop(); |
(...skipping 15 matching lines...) Expand all Loading... | |
2233 contents()->GetMainFrame(), 1, kGURL, PAGE_TRANSITION_TYPED); | 2232 contents()->GetMainFrame(), 1, kGURL, PAGE_TRANSITION_TYPED); |
2234 | 2233 |
2235 // Simulate showing an interstitial while the page is showing. | 2234 // Simulate showing an interstitial while the page is showing. |
2236 TestInterstitialPage::InterstitialState state = | 2235 TestInterstitialPage::InterstitialState state = |
2237 TestInterstitialPage::INVALID; | 2236 TestInterstitialPage::INVALID; |
2238 bool deleted = false; | 2237 bool deleted = false; |
2239 TestInterstitialPage* interstitial = | 2238 TestInterstitialPage* interstitial = |
2240 new TestInterstitialPage(contents(), true, kGURL, &state, &deleted); | 2239 new TestInterstitialPage(contents(), true, kGURL, &state, &deleted); |
2241 TestInterstitialPageStateGuard state_guard(interstitial); | 2240 TestInterstitialPageStateGuard state_guard(interstitial); |
2242 interstitial->Show(); | 2241 interstitial->Show(); |
2243 interstitial->TestDidNavigate(1, kGURL); | 2242 interstitial->TestDidNavigate(kGURL); |
2244 | 2243 |
2245 // While the interstitial is showing, let's simulate the hidden page | 2244 // While the interstitial is showing, let's simulate the hidden page |
2246 // attempting to show a JS message. | 2245 // attempting to show a JS message. |
2247 IPC::Message* dummy_message = new IPC::Message; | 2246 IPC::Message* dummy_message = new IPC::Message; |
2248 contents()->RunJavaScriptMessage(contents()->GetMainFrame(), | 2247 contents()->RunJavaScriptMessage(contents()->GetMainFrame(), |
2249 base::ASCIIToUTF16("This is an informative message"), | 2248 base::ASCIIToUTF16("This is an informative message"), |
2250 base::ASCIIToUTF16("OK"), | 2249 base::ASCIIToUTF16("OK"), |
2251 kGURL, JAVASCRIPT_MESSAGE_TYPE_ALERT, dummy_message); | 2250 kGURL, JAVASCRIPT_MESSAGE_TYPE_ALERT, dummy_message); |
2252 EXPECT_TRUE(contents()->last_dialog_suppressed_); | 2251 EXPECT_TRUE(contents()->last_dialog_suppressed_); |
2253 } | 2252 } |
(...skipping 12 matching lines...) Expand all Loading... | |
2266 | 2265 |
2267 // Show an interstitial. | 2266 // Show an interstitial. |
2268 TestInterstitialPage::InterstitialState state = | 2267 TestInterstitialPage::InterstitialState state = |
2269 TestInterstitialPage::INVALID; | 2268 TestInterstitialPage::INVALID; |
2270 bool deleted = false; | 2269 bool deleted = false; |
2271 GURL url2("http://interstitial"); | 2270 GURL url2("http://interstitial"); |
2272 TestInterstitialPage* interstitial = | 2271 TestInterstitialPage* interstitial = |
2273 new TestInterstitialPage(contents(), true, url2, &state, &deleted); | 2272 new TestInterstitialPage(contents(), true, url2, &state, &deleted); |
2274 TestInterstitialPageStateGuard state_guard(interstitial); | 2273 TestInterstitialPageStateGuard state_guard(interstitial); |
2275 interstitial->Show(); | 2274 interstitial->Show(); |
2276 interstitial->TestDidNavigate(1, url2); | 2275 interstitial->TestDidNavigate(url2); |
2277 EXPECT_TRUE(interstitial->is_showing()); | 2276 EXPECT_TRUE(interstitial->is_showing()); |
2278 EXPECT_EQ(2, controller().GetEntryCount()); | 2277 EXPECT_EQ(2, controller().GetEntryCount()); |
2279 | 2278 |
2280 // Create another NavigationController. | 2279 // Create another NavigationController. |
2281 GURL url3("http://foo2"); | 2280 GURL url3("http://foo2"); |
2282 scoped_ptr<TestWebContents> other_contents( | 2281 scoped_ptr<TestWebContents> other_contents( |
2283 static_cast<TestWebContents*>(CreateTestWebContents())); | 2282 static_cast<TestWebContents*>(CreateTestWebContents())); |
2284 NavigationControllerImpl& other_controller = other_contents->GetController(); | 2283 NavigationControllerImpl& other_controller = other_contents->GetController(); |
2285 other_contents->NavigateAndCommit(url3); | 2284 other_contents->NavigateAndCommit(url3); |
2286 other_contents->ExpectSetHistoryLengthAndPrune( | 2285 other_contents->ExpectSetHistoryLengthAndPrune( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2318 // Show an interstitial. | 2317 // Show an interstitial. |
2319 TestInterstitialPage::InterstitialState state = | 2318 TestInterstitialPage::InterstitialState state = |
2320 TestInterstitialPage::INVALID; | 2319 TestInterstitialPage::INVALID; |
2321 bool deleted = false; | 2320 bool deleted = false; |
2322 GURL url3("http://interstitial"); | 2321 GURL url3("http://interstitial"); |
2323 TestInterstitialPage* interstitial = | 2322 TestInterstitialPage* interstitial = |
2324 new TestInterstitialPage(other_contents.get(), true, url3, &state, | 2323 new TestInterstitialPage(other_contents.get(), true, url3, &state, |
2325 &deleted); | 2324 &deleted); |
2326 TestInterstitialPageStateGuard state_guard(interstitial); | 2325 TestInterstitialPageStateGuard state_guard(interstitial); |
2327 interstitial->Show(); | 2326 interstitial->Show(); |
2328 interstitial->TestDidNavigate(1, url3); | 2327 interstitial->TestDidNavigate(url3); |
2329 EXPECT_TRUE(interstitial->is_showing()); | 2328 EXPECT_TRUE(interstitial->is_showing()); |
2330 EXPECT_EQ(2, other_controller.GetEntryCount()); | 2329 EXPECT_EQ(2, other_controller.GetEntryCount()); |
2331 | 2330 |
2332 // Ensure that we do not allow calling CopyStateFromAndPrune when an | 2331 // Ensure that we do not allow calling CopyStateFromAndPrune when an |
2333 // interstitial is showing in the target. | 2332 // interstitial is showing in the target. |
2334 EXPECT_FALSE(other_controller.CanPruneAllButLastCommitted()); | 2333 EXPECT_FALSE(other_controller.CanPruneAllButLastCommitted()); |
2335 } | 2334 } |
2336 | 2335 |
2337 // 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 |
2338 // DidFinishLoad and DidFailLoadWithError IPCs should get filtered. | 2337 // DidFinishLoad and DidFailLoadWithError IPCs should get filtered. |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2679 contents->CommitPendingNavigation(); | 2678 contents->CommitPendingNavigation(); |
2680 EXPECT_EQ(0u, instance->GetRelatedActiveContentsCount()); | 2679 EXPECT_EQ(0u, instance->GetRelatedActiveContentsCount()); |
2681 EXPECT_EQ(1u, instance_webui->GetRelatedActiveContentsCount()); | 2680 EXPECT_EQ(1u, instance_webui->GetRelatedActiveContentsCount()); |
2682 | 2681 |
2683 contents.reset(); | 2682 contents.reset(); |
2684 EXPECT_EQ(0u, instance->GetRelatedActiveContentsCount()); | 2683 EXPECT_EQ(0u, instance->GetRelatedActiveContentsCount()); |
2685 EXPECT_EQ(0u, instance_webui->GetRelatedActiveContentsCount()); | 2684 EXPECT_EQ(0u, instance_webui->GetRelatedActiveContentsCount()); |
2686 } | 2685 } |
2687 | 2686 |
2688 } // namespace content | 2687 } // namespace content |
OLD | NEW |