summaryrefslogtreecommitdiffstats
path: root/chrome/test/ui_test_utils.cc
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-29 17:25:30 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-29 17:25:30 +0000
commit9d8a4642dad84e5bc0ca124ed5201a051045a547 (patch)
tree9aac7c292fe34386f4e4720c2066d336bd002429 /chrome/test/ui_test_utils.cc
parent72f5652440c39aae6086a824b2505d23c71b731f (diff)
downloadchromium_src-9d8a4642dad84e5bc0ca124ed5201a051045a547.zip
chromium_src-9d8a4642dad84e5bc0ca124ed5201a051045a547.tar.gz
chromium_src-9d8a4642dad84e5bc0ca124ed5201a051045a547.tar.bz2
The focus would be messed-up when reloading a crashed tab, also causing accelerators to be broken.
This CL also makes sure to keep the focus on the location bar when reloading the NTP. BUG=http://crbug.com/14954 TEST=See bug. Review URL: http://codereview.chromium.org/160206 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21961 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/ui_test_utils.cc')
-rw-r--r--chrome/test/ui_test_utils.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/chrome/test/ui_test_utils.cc b/chrome/test/ui_test_utils.cc
index 8167968..ee9b7d4 100644
--- a/chrome/test/ui_test_utils.cc
+++ b/chrome/test/ui_test_utils.cc
@@ -7,6 +7,7 @@
#include "base/json_reader.h"
#include "base/message_loop.h"
#include "base/path_service.h"
+#include "base/process_util.h"
#include "base/values.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/dom_operation_notification_details.h"
@@ -229,6 +230,30 @@ class AppModalDialogObserver : public NotificationObserver {
DISALLOW_COPY_AND_ASSIGN(AppModalDialogObserver);
};
+class CrashedRenderProcessObserver : public NotificationObserver {
+ public:
+ explicit CrashedRenderProcessObserver(RenderProcessHost* rph) {
+ registrar_.Add(this, NotificationType::RENDERER_PROCESS_CLOSED,
+ Source<RenderProcessHost>(rph));
+ ui_test_utils::RunMessageLoop();
+ }
+
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ if (type == NotificationType::RENDERER_PROCESS_CLOSED) {
+ MessageLoopForUI::current()->Quit();
+ } else {
+ NOTREACHED();
+ }
+ }
+
+ private:
+ NotificationRegistrar registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(CrashedRenderProcessObserver);
+};
+
} // namespace
void RunMessageLoop() {
@@ -370,4 +395,10 @@ AppModalDialog* WaitForAppModalDialog() {
return observer.WaitForAppModalDialog();
}
+void CrashTab(TabContents* tab) {
+ RenderProcessHost* rph = tab->render_view_host()->process();
+ base::KillProcess(rph->process().handle(), 0, false);
+ CrashedRenderProcessObserver crash_observer(rph);
+}
+
} // namespace ui_test_utils