Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(621)

Unified Diff: content/browser/renderer_host/render_widget_host_unittest.cc

Issue 938123003: Prevent hang monitor restarts when hidden (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_widget_host_unittest.cc
diff --git a/content/browser/renderer_host/render_widget_host_unittest.cc b/content/browser/renderer_host/render_widget_host_unittest.cc
index ea9d84e52cccbaf196b8c3849cd4229fe65f0c15..7d23c00c4d814f4e409747b8133158a095604f1e 100644
--- a/content/browser/renderer_host/render_widget_host_unittest.cc
+++ b/content/browser/renderer_host/render_widget_host_unittest.cc
@@ -992,6 +992,43 @@ TEST_F(RenderWidgetHostTest, ShorterDelayHangMonitorTimeout) {
EXPECT_TRUE(host_->unresponsive_timer_fired());
}
+// Test that the hang monitor timer is effectively disabled when the widget is
+// hidden.
+TEST_F(RenderWidgetHostTest, HangMonitorTimeoutDisabledWhenHidden) {
+ host_->StartHangMonitorTimeout(TimeDelta::FromMicroseconds(1));
+
+ // Hiding the widget should deactivate the timeout.
+ host_->WasHidden();
+
+ // The timeout should not fire.
+ EXPECT_FALSE(host_->unresponsive_timer_fired());
+ base::MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::MessageLoop::QuitClosure(),
+ TimeDelta::FromMicroseconds(2));
+ base::MessageLoop::current()->Run();
+ EXPECT_FALSE(host_->unresponsive_timer_fired());
+
+ // The timeout should never reactivate while hidden.
+ host_->StartHangMonitorTimeout(TimeDelta::FromMicroseconds(1));
+ base::MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::MessageLoop::QuitClosure(),
+ TimeDelta::FromMicroseconds(2));
+ base::MessageLoop::current()->Run();
+ EXPECT_FALSE(host_->unresponsive_timer_fired());
+
+ // Showing the widget should restore normal timeout behavior.
+ host_->WasShown(ui::LatencyInfo());
+ host_->StartHangMonitorTimeout(TimeDelta::FromMicroseconds(1));
+ base::MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::MessageLoop::QuitClosure(),
+ TimeDelta::FromMicroseconds(2));
+ base::MessageLoop::current()->Run();
+ EXPECT_TRUE(host_->unresponsive_timer_fired());
+}
+
// Test that the hang monitor catches two input events but only one ack.
// This can happen if the second input event causes the renderer to hang.
// This test will catch a regression of crbug.com/111185.

Powered by Google App Engine
This is Rietveld 408576698