| 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/renderer_host/render_view_host_impl.h" | 7 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 8 #include "content/browser/renderer_host/test_render_view_host.h" | 8 #include "content/browser/renderer_host/test_render_view_host.h" |
| 9 #include "content/browser/site_instance_impl.h" | 9 #include "content/browser/site_instance_impl.h" |
| 10 #include "content/browser/web_contents/frame_tree_node.h" | 10 #include "content/browser/web_contents/frame_tree_node.h" |
| (...skipping 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1568 GURL interstitial_url("http://interstitial"); | 1568 GURL interstitial_url("http://interstitial"); |
| 1569 TestInterstitialPage* interstitial = | 1569 TestInterstitialPage* interstitial = |
| 1570 new TestInterstitialPage(contents(), true, interstitial_url, | 1570 new TestInterstitialPage(contents(), true, interstitial_url, |
| 1571 &state, &deleted); | 1571 &state, &deleted); |
| 1572 TestInterstitialPageStateGuard state_guard(interstitial); | 1572 TestInterstitialPageStateGuard state_guard(interstitial); |
| 1573 interstitial->Show(); | 1573 interstitial->Show(); |
| 1574 interstitial->TestDidNavigate(2, interstitial_url); | 1574 interstitial->TestDidNavigate(2, interstitial_url); |
| 1575 | 1575 |
| 1576 // Crash the renderer | 1576 // Crash the renderer |
| 1577 test_rvh()->OnMessageReceived( | 1577 test_rvh()->OnMessageReceived( |
| 1578 ViewHostMsg_RenderViewGone( | 1578 ViewHostMsg_RenderProcessGone( |
| 1579 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); | 1579 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); |
| 1580 | 1580 |
| 1581 // While the interstitial is showing, go back. | 1581 // While the interstitial is showing, go back. |
| 1582 controller().GoBack(); | 1582 controller().GoBack(); |
| 1583 test_rvh()->SendNavigate(1, url1); | 1583 test_rvh()->SendNavigate(1, url1); |
| 1584 | 1584 |
| 1585 // Make sure we are back to the original page and that the interstitial is | 1585 // Make sure we are back to the original page and that the interstitial is |
| 1586 // gone. | 1586 // gone. |
| 1587 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 1587 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
| 1588 NavigationEntry* entry = controller().GetActiveEntry(); | 1588 NavigationEntry* entry = controller().GetActiveEntry(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1607 bool deleted = false; | 1607 bool deleted = false; |
| 1608 GURL interstitial_url("http://interstitial"); | 1608 GURL interstitial_url("http://interstitial"); |
| 1609 TestInterstitialPage* interstitial = | 1609 TestInterstitialPage* interstitial = |
| 1610 new TestInterstitialPage(contents(), true, interstitial_url, | 1610 new TestInterstitialPage(contents(), true, interstitial_url, |
| 1611 &state, &deleted); | 1611 &state, &deleted); |
| 1612 TestInterstitialPageStateGuard state_guard(interstitial); | 1612 TestInterstitialPageStateGuard state_guard(interstitial); |
| 1613 interstitial->Show(); | 1613 interstitial->Show(); |
| 1614 | 1614 |
| 1615 // Crash the renderer | 1615 // Crash the renderer |
| 1616 test_rvh()->OnMessageReceived( | 1616 test_rvh()->OnMessageReceived( |
| 1617 ViewHostMsg_RenderViewGone( | 1617 ViewHostMsg_RenderProcessGone( |
| 1618 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); | 1618 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); |
| 1619 | 1619 |
| 1620 interstitial->TestDidNavigate(2, interstitial_url); | 1620 interstitial->TestDidNavigate(2, interstitial_url); |
| 1621 } | 1621 } |
| 1622 | 1622 |
| 1623 // Test navigating to a page that shows an interstitial, then close the | 1623 // Test navigating to a page that shows an interstitial, then close the |
| 1624 // contents. | 1624 // contents. |
| 1625 TEST_F(WebContentsImplTest, ShowInterstitialThenCloseTab) { | 1625 TEST_F(WebContentsImplTest, ShowInterstitialThenCloseTab) { |
| 1626 // Show interstitial. | 1626 // Show interstitial. |
| 1627 TestInterstitialPage::InterstitialState state = | 1627 TestInterstitialPage::InterstitialState state = |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1659 interstitial->GetRenderViewHostForTesting()); | 1659 interstitial->GetRenderViewHostForTesting()); |
| 1660 | 1660 |
| 1661 // Now close the contents. | 1661 // Now close the contents. |
| 1662 DeleteContents(); | 1662 DeleteContents(); |
| 1663 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 1663 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
| 1664 | 1664 |
| 1665 // Before the interstitial has a chance to process its shutdown task, | 1665 // Before the interstitial has a chance to process its shutdown task, |
| 1666 // simulate quitting the browser. This goes through all processes and | 1666 // simulate quitting the browser. This goes through all processes and |
| 1667 // tells them to destruct. | 1667 // tells them to destruct. |
| 1668 rvh->OnMessageReceived( | 1668 rvh->OnMessageReceived( |
| 1669 ViewHostMsg_RenderViewGone(0, 0, 0)); | 1669 ViewHostMsg_RenderProcessGone(0, 0, 0)); |
| 1670 | 1670 |
| 1671 RunAllPendingInMessageLoop(); | 1671 RunAllPendingInMessageLoop(); |
| 1672 EXPECT_TRUE(deleted); | 1672 EXPECT_TRUE(deleted); |
| 1673 } | 1673 } |
| 1674 | 1674 |
| 1675 // Test that after Proceed is called and an interstitial is still shown, no more | 1675 // Test that after Proceed is called and an interstitial is still shown, no more |
| 1676 // commands get executed. | 1676 // commands get executed. |
| 1677 TEST_F(WebContentsImplTest, ShowInterstitialProceedMultipleCommands) { | 1677 TEST_F(WebContentsImplTest, ShowInterstitialProceedMultipleCommands) { |
| 1678 // Navigate to a page so we have a navigation entry in the controller. | 1678 // Navigate to a page so we have a navigation entry in the controller. |
| 1679 GURL url1("http://www.google.com"); | 1679 GURL url1("http://www.google.com"); |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2199 EXPECT_EQ(0UL, deep_tree->child_at(0)->child_at(0)->child_count()); | 2199 EXPECT_EQ(0UL, deep_tree->child_at(0)->child_at(0)->child_count()); |
| 2200 | 2200 |
| 2201 contents()->OnFrameDetached(16, 265); | 2201 contents()->OnFrameDetached(16, 265); |
| 2202 EXPECT_EQ(4UL, root->child_at(2)->child_count()); | 2202 EXPECT_EQ(4UL, root->child_at(2)->child_count()); |
| 2203 | 2203 |
| 2204 contents()->OnFrameDetached(5, 15); | 2204 contents()->OnFrameDetached(5, 15); |
| 2205 EXPECT_EQ(2UL, root->child_count()); | 2205 EXPECT_EQ(2UL, root->child_count()); |
| 2206 } | 2206 } |
| 2207 | 2207 |
| 2208 } // namespace content | 2208 } // namespace content |
| OLD | NEW |