| Index: chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc
|
| diff --git a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc
|
| index 6d47d2b608808c7f73ffb7d3ef40b0532e2f5a38..6ff1ad82543f1d621ce808d9d914791a61279a1a 100644
|
| --- a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc
|
| +++ b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc
|
| @@ -17,6 +17,7 @@
|
| #include "chrome/test/base/ui_test_utils.h"
|
| #include "content/public/browser/notification_service.h"
|
| #include "content/public/browser/render_process_host.h"
|
| +#include "content/public/browser/render_process_host_observer.h"
|
| #include "content/public/browser/render_view_host.h"
|
| #include "content/public/browser/render_widget_host_iterator.h"
|
| #include "content/public/browser/web_contents.h"
|
| @@ -28,6 +29,42 @@ using content::WebContents;
|
|
|
| namespace {
|
|
|
| +class RenderProcessHostAliveObserver
|
| + : public content::RenderProcessHostObserver {
|
| + public:
|
| + explicit RenderProcessHostAliveObserver(content::RenderProcessHost* host)
|
| + : host_(host) {
|
| + host_->AddObserver(this);
|
| + }
|
| +
|
| + virtual ~RenderProcessHostAliveObserver() {
|
| + CHECK(!host_);
|
| + }
|
| +
|
| + void WaitUntilProcessDies() {
|
| + if (!host_)
|
| + return;
|
| + base::RunLoop run_loop;
|
| + quit_closure_ = run_loop.QuitClosure();
|
| + run_loop.Run();
|
| + }
|
| +
|
| + private:
|
| + // content::RenderProcessHostObserver:
|
| + virtual void RenderProcessHostDestroyed(
|
| + content::RenderProcessHost* host) OVERRIDE {
|
| + CHECK_EQ(host_, host);
|
| + host_ = NULL;
|
| + if (!quit_closure_.is_null())
|
| + quit_closure_.Run();
|
| + }
|
| +
|
| + content::RenderProcessHost* host_;
|
| + base::Closure quit_closure_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(RenderProcessHostAliveObserver);
|
| +};
|
| +
|
| int RenderProcessHostCount() {
|
| content::RenderProcessHost::iterator hosts =
|
| content::RenderProcessHost::AllHostsIterator();
|
| @@ -111,9 +148,18 @@ class ChromeRenderProcessHostTest : public InProcessBrowserTest {
|
| content::RenderProcessHost* rph2 = NULL;
|
| content::RenderProcessHost* rph3 = NULL;
|
|
|
| - // Change the first tab to be the omnibox page (TYPE_WEBUI).
|
| + EXPECT_EQ(host_count, RenderProcessHostCount());
|
| + ASSERT_EQ(tab_count, browser()->tab_strip_model()->count());
|
| +
|
| + tab1 = browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1);
|
| + RenderProcessHostAliveObserver process_observer(
|
| + tab1->GetRenderProcessHost());
|
| +
|
| + // Change the first tab to be the omnibox page (TYPE_WEBUI). The navigation
|
| + // should terminate the existing process.
|
| GURL omnibox(chrome::kChromeUIOmniboxURL);
|
| ui_test_utils::NavigateToURL(browser(), omnibox);
|
| + process_observer.WaitUntilProcessDies();
|
| EXPECT_EQ(tab_count, browser()->tab_strip_model()->count());
|
| tab1 = browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1);
|
| rph1 = tab1->GetRenderProcessHost();
|
|
|