Commit e5fc1632 authored by yurys@chromium.org's avatar yurys@chromium.org

DevTools: don't show the unresponsive dialog for inspected tabs

BUG=66458
TEST=DevToolsManagerTest.NoUnresponsiveDialogInInspectedTab

Review URL: http://codereview.chromium.org/7565008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95798 0039d316-1c4b-4281-b951-d872f2087c98
parent b8f0554c
......@@ -12,6 +12,7 @@
#include "chrome/browser/prerender/prerender_tracker.h"
#include "chrome/browser/printing/background_printing_manager.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "content/browser/debugger/devtools_manager.h"
#include "net/url_request/url_request_context_getter.h"
#include "ui/base/clipboard/clipboard.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -20,7 +21,8 @@ TestingBrowserProcess::TestingBrowserProcess()
: module_ref_count_(0),
app_locale_("en"),
local_state_(NULL),
io_thread_(NULL) {
io_thread_(NULL),
devtools_manager_(NULL) {
}
TestingBrowserProcess::~TestingBrowserProcess() {
......@@ -96,7 +98,7 @@ ThumbnailGenerator* TestingBrowserProcess::GetThumbnailGenerator() {
}
DevToolsManager* TestingBrowserProcess::devtools_manager() {
return NULL;
return devtools_manager_.get();
}
SidebarManager* TestingBrowserProcess::sidebar_manager() {
......@@ -262,6 +264,10 @@ void TestingBrowserProcess::SetIOThread(IOThread* io_thread) {
io_thread_ = io_thread;
}
void TestingBrowserProcess::SetDevToolsManager(DevToolsManager* manager) {
devtools_manager_.reset(manager);
}
ScopedTestingBrowserProcess::ScopedTestingBrowserProcess() {
// TODO(phajdan.jr): Temporary, for http://crbug.com/61062.
// ChromeTestSuite sets up a global TestingBrowserProcess
......
......@@ -125,6 +125,7 @@ class TestingBrowserProcess : public BrowserProcess {
void SetGoogleURLTracker(GoogleURLTracker* google_url_tracker);
void SetProfileManager(ProfileManager* profile_manager);
void SetIOThread(IOThread* io_thread);
void SetDevToolsManager(DevToolsManager*);
private:
NotificationService notification_service_;
......@@ -141,6 +142,7 @@ class TestingBrowserProcess : public BrowserProcess {
scoped_ptr<printing::BackgroundPrintingManager> background_printing_manager_;
scoped_ptr<prerender::PrerenderTracker> prerender_tracker_;
IOThread* io_thread_;
scoped_ptr<DevToolsManager> devtools_manager_;
DISALLOW_COPY_AND_ASSIGN(TestingBrowserProcess);
};
......
......@@ -3,11 +3,16 @@
// found in the LICENSE file.
#include "base/basictypes.h"
#include "base/time.h"
#include "content/browser/debugger/devtools_client_host.h"
#include "content/browser/debugger/devtools_manager.h"
#include "content/browser/renderer_host/test_render_view_host.h"
#include "content/browser/tab_contents/tab_contents_delegate.h"
#include "content/browser/tab_contents/test_tab_contents.h"
#include "testing/gtest/include/gtest/gtest.h"
using base::TimeDelta;
namespace {
class TestDevToolsClientHost : public DevToolsClientHost {
......@@ -59,6 +64,24 @@ class TestDevToolsClientHost : public DevToolsClientHost {
int TestDevToolsClientHost::close_counter = 0;
class TestTabContentsDelegate : public TabContentsDelegate {
public:
TestTabContentsDelegate() : renderer_unresponsive_received_(false) {}
// Notification that the tab is hung.
virtual void RendererUnresponsive(TabContents* source) {
renderer_unresponsive_received_ = true;
}
bool renderer_unresponsive_received() const {
return renderer_unresponsive_received_;
}
private:
bool renderer_unresponsive_received_;
};
} // namespace
class DevToolsManagerTest : public RenderViewHostTestHarness {
......@@ -111,3 +134,38 @@ TEST_F(DevToolsManagerTest, ForwardMessageToClient) {
client_host.Close();
EXPECT_EQ(1, TestDevToolsClientHost::close_counter);
}
TEST_F(DevToolsManagerTest, NoUnresponsiveDialogInInspectedTab) {
TestRenderViewHost* inspected_rvh = rvh();
inspected_rvh->set_render_view_created(true);
EXPECT_FALSE(contents()->delegate());
TestTabContentsDelegate delegate;
contents()->set_delegate(&delegate);
testing_browser_process_.get()->SetDevToolsManager(new DevToolsManager());
DevToolsManager* manager = DevToolsManager::GetInstance();
ASSERT_TRUE(manager);
TestDevToolsClientHost client_host;
manager->RegisterDevToolsClientHostFor(inspected_rvh, &client_host);
// Start with a short timeout.
inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10));
// Wait long enough for first timeout and see if it fired.
MessageLoop::current()->PostDelayedTask(FROM_HERE,
new MessageLoop::QuitTask(), 10);
MessageLoop::current()->Run();
EXPECT_FALSE(delegate.renderer_unresponsive_received());
// Now close devtools and check that the notification is delivered.
client_host.Close();
// Start with a short timeout.
inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10));
// Wait long enough for first timeout and see if it fired.
MessageLoop::current()->PostDelayedTask(FROM_HERE,
new MessageLoop::QuitTask(), 10);
MessageLoop::current()->Run();
EXPECT_TRUE(delegate.renderer_unresponsive_received());
contents()->set_delegate(NULL);
}
......@@ -1758,6 +1758,14 @@ void TabContents::RendererUnresponsive(RenderViewHost* rvh,
if (rvh != render_view_host())
return;
// Ignore renderer unresponsive event if debugger is attached to the tab
// since the event may be a result of the renderer sitting on a breakpoint.
// See http://crbug.com/65458
DevToolsManager* devtools_manager = DevToolsManager::GetInstance();
if (devtools_manager &&
devtools_manager->GetDevToolsClientHostFor(rvh) != NULL)
return;
if (is_during_unload) {
// Hang occurred while firing the beforeunload/unload handler.
// Pretend the handler fired so tab closing continues as if it had.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment