diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/tab_contents/interstitial_page.cc | 15 | ||||
-rw-r--r-- | chrome/browser/tab_contents/web_contents_unittest.cc | 27 |
2 files changed, 36 insertions, 6 deletions
diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc index efbc033..3c5a099 100644 --- a/chrome/browser/tab_contents/interstitial_page.cc +++ b/chrome/browser/tab_contents/interstitial_page.cc @@ -393,12 +393,17 @@ void InterstitialPage::DidNavigate( render_view_host_->view()->Show(); tab_->set_interstitial_page(this); - // If the page has focus, focus the interstitial. - if (tab_->render_view_host()->view()->HasFocus()) - Focus(); + RenderWidgetHostView* rwh_view = tab_->render_view_host()->view(); - // Hide the original RVH since we're showing the interstitial instead. - tab_->render_view_host()->view()->Hide(); + // The RenderViewHost may already have crashed before we even get here. + if (rwh_view) { + // If the page has focus, focus the interstitial. + if (rwh_view->HasFocus()) + Focus(); + + // Hide the original RVH since we're showing the interstitial instead. + rwh_view->Hide(); + } // Notify the tab we are not loading so the throbber is stopped. It also // causes a NOTIFY_LOAD_STOP notification, that the AutomationProvider (used diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc index c391fd1..3b1c43e 100644 --- a/chrome/browser/tab_contents/web_contents_unittest.cc +++ b/chrome/browser/tab_contents/web_contents_unittest.cc @@ -938,7 +938,6 @@ TEST_F(TabContentsTest, ShowInterstitialThenGoBack) { // Test navigating to a page that shows an interstitial, has a renderer crash, // and then goes back. -// http://crbug.com/13937: Disabling because it's leaky on win/mac. TEST_F(TabContentsTest, ShowInterstitialCrashRendererThenGoBack) { // Navigate to a page so we have a navigation entry in the controller. GURL url1("http://www.google.com"); @@ -972,6 +971,32 @@ TEST_F(TabContentsTest, ShowInterstitialCrashRendererThenGoBack) { ASSERT_TRUE(entry); EXPECT_EQ(url1.spec(), entry->url().spec()); } + +// Test navigating to a page that shows an interstitial, has the renderer crash, +// and then navigates to the interstitial. +TEST_F(TabContentsTest, ShowInterstitialCrashRendererThenNavigate) { + // Navigate to a page so we have a navigation entry in the controller. + GURL url1("http://www.google.com"); + rvh()->SendNavigate(1, url1); + EXPECT_EQ(1, controller().entry_count()); + + // Show interstitial. + TestInterstitialPage::InterstitialState state = + TestInterstitialPage::UNDECIDED; + bool deleted = false; + GURL interstitial_url("http://interstitial"); + TestInterstitialPage* interstitial = + new TestInterstitialPage(contents(), true, interstitial_url, + &state, &deleted); + TestInterstitialPageStateGuard state_guard(interstitial); + interstitial->Show(); + + // Crash the renderer + rvh()->TestOnMessageReceived(ViewHostMsg_RenderViewGone(0)); + + interstitial->TestDidNavigate(2, interstitial_url); +} + // Test navigating to a page that shows an interstitial, then close the tab. TEST_F(TabContentsTest, ShowInterstitialThenCloseTab) { // Show interstitial. |