summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcreis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-25 23:51:43 +0000
committercreis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-25 23:51:43 +0000
commit02fa53076a7290eaa3e0222ca8783964818a12c1 (patch)
tree95986c5243f55be51dcd4f4ff2d654be1c5a00b0
parentcb48eafcefa0031b3203cecb6dba35b0a1a62ee4 (diff)
downloadchromium_src-02fa53076a7290eaa3e0222ca8783964818a12c1.zip
chromium_src-02fa53076a7290eaa3e0222ca8783964818a12c1.tar.gz
chromium_src-02fa53076a7290eaa3e0222ca8783964818a12c1.tar.bz2
Merge 253006 "Clear any open dialogs when the renderer process g..."
> Clear any open dialogs when the renderer process goes away. > > BUG=343625 > TEST=See bug for repro steps. > R=darin@chromium.org > > Review URL: https://codereview.chromium.org/177123002 TBR=creis@chromium.org Review URL: https://codereview.chromium.org/177843012 git-svn-id: svn://svn.chromium.org/chrome/branches/1750/src@253294 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/browser_browsertest.cc32
-rw-r--r--content/browser/web_contents/web_contents_impl.cc4
2 files changed, 36 insertions, 0 deletions
diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc
index acaa74b..a8d6981 100644
--- a/chrome/browser/ui/browser_browsertest.cc
+++ b/chrome/browser/ui/browser_browsertest.cc
@@ -494,6 +494,38 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, CrossProcessNavCancelsDialogs) {
EXPECT_FALSE(contents->GetRenderProcessHost()->IgnoreInputEvents());
}
+// Make sure that dialogs are closed after a renderer process dies, and that
+// subsequent navigations work. See http://crbug/com/343265.
+IN_PROC_BROWSER_TEST_F(BrowserTest, SadTabCancelsDialogs) {
+ ASSERT_TRUE(test_server()->Start());
+ host_resolver()->AddRule("www.example.com", "127.0.0.1");
+ GURL beforeunload_url(test_server()->GetURL("files/beforeunload.html"));
+ ui_test_utils::NavigateToURL(browser(), beforeunload_url);
+
+ // Start a navigation to trigger the beforeunload dialog.
+ WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
+ contents->GetRenderViewHost()->ExecuteJavascriptInWebFrame(
+ base::string16(),
+ ASCIIToUTF16("window.location.href = 'data:text/html,foo'"));
+ AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
+ EXPECT_TRUE(alert->IsValid());
+ AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance();
+ EXPECT_TRUE(dialog_queue->HasActiveDialog());
+
+ // Crash the renderer process and ensure the dialog is gone.
+ content::RenderProcessHost* child_process = contents->GetRenderProcessHost();
+ content::WindowedNotificationObserver crash_observer(
+ content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
+ content::Source<content::RenderProcessHost>(child_process));
+ base::KillProcess(child_process->GetHandle(), 0, false);
+ crash_observer.Wait();
+ EXPECT_FALSE(dialog_queue->HasActiveDialog());
+
+ // Make sure subsequent navigations work.
+ GURL url2("http://www.example.com/files/empty.html");
+ ui_test_utils::NavigateToURL(browser(), url2);
+}
+
// Test for crbug.com/22004. Reloading a page with a before unload handler and
// then canceling the dialog should not leave the throbber spinning.
IN_PROC_BROWSER_TEST_F(BrowserTest, ReloadThenCancelBeforeUnload) {
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index c5765d5..6b6cf00 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -2895,6 +2895,10 @@ void WebContentsImpl::RenderViewTerminated(RenderViewHost* rvh,
return;
}
+ // Cancel any visible dialogs so they are not left dangling over the sad tab.
+ if (dialog_manager_)
+ dialog_manager_->CancelActiveAndPendingDialogs(this);
+
ClearPowerSaveBlockers(rvh);
SetIsLoading(rvh, false, NULL);
NotifyDisconnected();