summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host/render_widget_host_unittest.cc
diff options
context:
space:
mode:
authorcreis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-02 18:34:14 +0000
committercreis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-02 18:34:14 +0000
commitbd06e0146a5ad4ae79671e1d4e778627da985fd2 (patch)
tree013455dc156a2272cc9397be9d3324b7b9602f0f /chrome/browser/renderer_host/render_widget_host_unittest.cc
parent04742b4d831aa185e69fd37dea019fcecea94e16 (diff)
downloadchromium_src-bd06e0146a5ad4ae79671e1d4e778627da985fd2.zip
chromium_src-bd06e0146a5ad4ae79671e1d4e778627da985fd2.tar.gz
chromium_src-bd06e0146a5ad4ae79671e1d4e778627da985fd2.tar.bz2
Fixes reloading after a background tab crashes.
Needed to clear RenderWidgetHost::in_flight_size_ if the renderer crashed. BUG=25097 TEST=RenderWidgetHostTest.ResizeThenCrash Review URL: http://codereview.chromium.org/348025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30722 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host/render_widget_host_unittest.cc')
-rw-r--r--chrome/browser/renderer_host/render_widget_host_unittest.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/chrome/browser/renderer_host/render_widget_host_unittest.cc b/chrome/browser/renderer_host/render_widget_host_unittest.cc
index 95c3624..7dd5039 100644
--- a/chrome/browser/renderer_host/render_widget_host_unittest.cc
+++ b/chrome/browser/renderer_host/render_widget_host_unittest.cc
@@ -217,6 +217,7 @@ TEST_F(RenderWidgetHostTest, Resize) {
view_->set_bounds(gfx::Rect());
host_->WasResized();
EXPECT_FALSE(host_->resize_ack_pending_);
+ EXPECT_EQ(gfx::Size(), host_->in_flight_size_);
EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
// Setting the bounds to a "real" rect should send out the notification.
@@ -225,6 +226,7 @@ TEST_F(RenderWidgetHostTest, Resize) {
view_->set_bounds(original_size);
host_->WasResized();
EXPECT_TRUE(host_->resize_ack_pending_);
+ EXPECT_EQ(original_size.size(), host_->in_flight_size_);
EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
// Send out a paint that's not a resize ack. This should not clean the
@@ -233,6 +235,7 @@ TEST_F(RenderWidgetHostTest, Resize) {
process_->InitPaintRectParams(&params);
host_->OnMsgPaintRect(params);
EXPECT_TRUE(host_->resize_ack_pending_);
+ EXPECT_EQ(original_size.size(), host_->in_flight_size_);
// Sending out a new notification should NOT send out a new IPC message since
// a resize ACK is pending.
@@ -241,6 +244,7 @@ TEST_F(RenderWidgetHostTest, Resize) {
view_->set_bounds(second_size);
host_->WasResized();
EXPECT_TRUE(host_->resize_ack_pending_);
+ EXPECT_EQ(original_size.size(), host_->in_flight_size_);
EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
// Send a paint that's a resize ack, but for the original_size we sent. Since
@@ -251,6 +255,7 @@ TEST_F(RenderWidgetHostTest, Resize) {
params.view_size = original_size.size();
host_->OnMsgPaintRect(params);
EXPECT_TRUE(host_->resize_ack_pending_);
+ EXPECT_EQ(second_size.size(), host_->in_flight_size_);
ASSERT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
// Send the resize ack for the latest size.
@@ -258,6 +263,7 @@ TEST_F(RenderWidgetHostTest, Resize) {
params.view_size = second_size.size();
host_->OnMsgPaintRect(params);
EXPECT_FALSE(host_->resize_ack_pending_);
+ EXPECT_EQ(gfx::Size(), host_->in_flight_size_);
ASSERT_FALSE(process_->sink().GetFirstMessageMatching(ViewMsg_Resize::ID));
// Now clearing the bounds should send out a notification but we shouldn't
@@ -267,6 +273,7 @@ TEST_F(RenderWidgetHostTest, Resize) {
view_->set_bounds(gfx::Rect());
host_->WasResized();
EXPECT_FALSE(host_->resize_ack_pending_);
+ EXPECT_EQ(gfx::Size(), host_->in_flight_size_);
EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
// Send a rect that has no area but has either width or height set.
@@ -274,21 +281,45 @@ TEST_F(RenderWidgetHostTest, Resize) {
view_->set_bounds(gfx::Rect(0, 0, 0, 30));
host_->WasResized();
EXPECT_FALSE(host_->resize_ack_pending_);
+ EXPECT_EQ(gfx::Size(0, 30), host_->in_flight_size_);
EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
// Set the same size again. It should not be sent again.
process_->sink().ClearMessages();
host_->WasResized();
EXPECT_FALSE(host_->resize_ack_pending_);
+ EXPECT_EQ(gfx::Size(0, 30), host_->in_flight_size_);
EXPECT_FALSE(process_->sink().GetFirstMessageMatching(ViewMsg_Resize::ID));
// A different size should be sent again, however.
view_->set_bounds(gfx::Rect(0, 0, 0, 31));
host_->WasResized();
EXPECT_FALSE(host_->resize_ack_pending_);
+ EXPECT_EQ(gfx::Size(0, 31), host_->in_flight_size_);
EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
}
+// Test for crbug.com/25097. If a renderer crashes between a resize and the
+// corresponding paint message, we must be sure to clear the resize ack logic.
+TEST_F(RenderWidgetHostTest, ResizeThenCrash) {
+ // Setting the bounds to a "real" rect should send out the notification.
+ gfx::Rect original_size(0, 0, 100, 100);
+ view_->set_bounds(original_size);
+ host_->WasResized();
+ EXPECT_TRUE(host_->resize_ack_pending_);
+ EXPECT_EQ(original_size.size(), host_->in_flight_size_);
+ EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
+
+ // Simulate a renderer crash before the paint message. Ensure all the resize
+ // ack logic is cleared.
+ host_->RendererExited();
+ EXPECT_FALSE(host_->resize_ack_pending_);
+ EXPECT_EQ(gfx::Size(), host_->in_flight_size_);
+
+ // Reset the view so we can exit the test cleanly.
+ view_.reset(new TestView(host_.get()));
+}
+
// Tests setting custom background
TEST_F(RenderWidgetHostTest, Background) {
#if defined(OS_WIN) || defined(OS_LINUX)