diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-24 16:39:44 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-24 16:39:44 +0000 |
commit | 1e6d82afa2241e27d0134a2fec2f9d230979bb01 (patch) | |
tree | ed9aac1cd7754531397aa4156bf315bf20ef0f04 | |
parent | 661452b3f486a43f9b102f46aa6d0a097361718b (diff) | |
download | chromium_src-1e6d82afa2241e27d0134a2fec2f9d230979bb01.zip chromium_src-1e6d82afa2241e27d0134a2fec2f9d230979bb01.tar.gz chromium_src-1e6d82afa2241e27d0134a2fec2f9d230979bb01.tar.bz2 |
Fix interstitial crash.
The hidden page's renderer can crash before InterstitialPage::DidNavigate() gets called.
Add an if check for this case.
BUG=http://crbug.com/14942
TEST=see bug for info
Review URL: http://codereview.chromium.org/146070
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19129 0039d316-1c4b-4281-b951-d872f2087c98
-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. |