| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/browser_plugin/browser_plugin_browsertest.h" | 5 #include "content/renderer/browser_plugin/browser_plugin_browsertest.h" |
| 6 | 6 |
| 7 #include "base/debug/leak_annotations.h" | 7 #include "base/debug/leak_annotations.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 // for a BrowserPluginMsg_UpdateRect in response. We issue an UpdateRect, and | 195 // for a BrowserPluginMsg_UpdateRect in response. We issue an UpdateRect, and |
| 196 // we observe an UpdateRect_ACK, with the |pending_damage_buffer_| reset, | 196 // we observe an UpdateRect_ACK, with the |pending_damage_buffer_| reset, |
| 197 // indiciating that the BrowserPlugin is not waiting for any more UpdateRects to | 197 // indiciating that the BrowserPlugin is not waiting for any more UpdateRects to |
| 198 // satisfy its resize request. | 198 // satisfy its resize request. |
| 199 TEST_F(BrowserPluginTest, InitialResize) { | 199 TEST_F(BrowserPluginTest, InitialResize) { |
| 200 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 200 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
| 201 // Verify that the information in Attach is correct. | 201 // Verify that the information in Attach is correct. |
| 202 BrowserPluginHostMsg_Attach_Params params; | 202 BrowserPluginHostMsg_Attach_Params params; |
| 203 MockBrowserPlugin* browser_plugin = GetCurrentPluginWithAttachParams(¶ms); | 203 MockBrowserPlugin* browser_plugin = GetCurrentPluginWithAttachParams(¶ms); |
| 204 | 204 |
| 205 EXPECT_EQ(640, params.resize_guest_params.view_rect.width()); | 205 // Since the browser plugin is now created detached, its initial width/ |
| 206 EXPECT_EQ(480, params.resize_guest_params.view_rect.height()); | 206 // height geometry is 0 x 0. |
| 207 EXPECT_EQ(0, params.resize_guest_params.view_rect.width()); |
| 208 EXPECT_EQ(0, params.resize_guest_params.view_rect.height()); |
| 207 ASSERT_TRUE(browser_plugin); | 209 ASSERT_TRUE(browser_plugin); |
| 208 // Now the browser plugin is expecting a UpdateRect resize. | 210 // Now the browser plugin is expecting a UpdateRect resize. |
| 209 int instance_id = browser_plugin->guest_instance_id(); | 211 int instance_id = browser_plugin->guest_instance_id(); |
| 210 EXPECT_TRUE(browser_plugin->pending_damage_buffer_.get()); | 212 EXPECT_FALSE(browser_plugin->pending_damage_buffer_.get()); |
| 211 | 213 |
| 212 // Send the BrowserPlugin an UpdateRect equal to its container size with | 214 // Send the BrowserPlugin an UpdateRect equal to its container size with |
| 213 // the same damage buffer. That should clear |pending_damage_buffer_|. | 215 // the same damage buffer. That should clear |pending_damage_buffer_|. |
| 214 BrowserPluginMsg_UpdateRect_Params update_rect_params; | 216 BrowserPluginMsg_UpdateRect_Params update_rect_params; |
| 215 update_rect_params.damage_buffer_sequence_id = | 217 update_rect_params.damage_buffer_sequence_id = |
| 216 browser_plugin->damage_buffer_sequence_id_; | 218 browser_plugin->damage_buffer_sequence_id_; |
| 217 update_rect_params.view_size = gfx::Size(640, 480); | 219 update_rect_params.view_size = gfx::Size(640, 480); |
| 218 update_rect_params.scale_factor = 1.0f; | 220 update_rect_params.scale_factor = 1.0f; |
| 219 update_rect_params.is_resize_ack = true; | 221 update_rect_params.is_resize_ack = true; |
| 220 update_rect_params.needs_ack = true; | 222 update_rect_params.needs_ack = true; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 "document.getElementById('browserplugin').src"); | 299 "document.getElementById('browserplugin').src"); |
| 298 EXPECT_EQ("bar", src_value); | 300 EXPECT_EQ("bar", src_value); |
| 299 } | 301 } |
| 300 } | 302 } |
| 301 | 303 |
| 302 TEST_F(BrowserPluginTest, ResizeFlowControl) { | 304 TEST_F(BrowserPluginTest, ResizeFlowControl) { |
| 303 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 305 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
| 304 MockBrowserPlugin* browser_plugin = GetCurrentPlugin(); | 306 MockBrowserPlugin* browser_plugin = GetCurrentPlugin(); |
| 305 ASSERT_TRUE(browser_plugin); | 307 ASSERT_TRUE(browser_plugin); |
| 306 int instance_id = browser_plugin->guest_instance_id(); | 308 int instance_id = browser_plugin->guest_instance_id(); |
| 307 EXPECT_TRUE(browser_plugin->pending_damage_buffer_.get()); | 309 EXPECT_FALSE(browser_plugin->pending_damage_buffer_.get()); |
| 308 // Send an UpdateRect to the BrowserPlugin to make it use the pending damage | 310 // Send an UpdateRect to the BrowserPlugin to make it use the pending damage |
| 309 // buffer. | 311 // buffer. |
| 310 { | 312 { |
| 311 // We send a stale UpdateRect to the BrowserPlugin. | 313 // We send a stale UpdateRect to the BrowserPlugin. |
| 312 BrowserPluginMsg_UpdateRect_Params update_rect_params; | 314 BrowserPluginMsg_UpdateRect_Params update_rect_params; |
| 313 update_rect_params.view_size = gfx::Size(640, 480); | 315 update_rect_params.view_size = gfx::Size(640, 480); |
| 314 update_rect_params.scale_factor = 1.0f; | 316 update_rect_params.scale_factor = 1.0f; |
| 315 update_rect_params.is_resize_ack = true; | 317 update_rect_params.is_resize_ack = true; |
| 316 update_rect_params.needs_ack = true; | 318 update_rect_params.needs_ack = true; |
| 317 // By sending |damage_buffer_sequence_id| back to BrowserPlugin on | 319 // By sending |damage_buffer_sequence_id| back to BrowserPlugin on |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 } | 398 } |
| 397 } | 399 } |
| 398 | 400 |
| 399 TEST_F(BrowserPluginTest, RemovePlugin) { | 401 TEST_F(BrowserPluginTest, RemovePlugin) { |
| 400 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 402 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
| 401 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( | 403 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 402 BrowserPluginHostMsg_PluginDestroyed::ID)); | 404 BrowserPluginHostMsg_PluginDestroyed::ID)); |
| 403 ExecuteJavaScript("x = document.getElementById('browserplugin'); " | 405 ExecuteJavaScript("x = document.getElementById('browserplugin'); " |
| 404 "x.parentNode.removeChild(x);"); | 406 "x.parentNode.removeChild(x);"); |
| 405 ProcessPendingMessages(); | 407 ProcessPendingMessages(); |
| 406 EXPECT_TRUE(browser_plugin_manager()->sink().GetUniqueMessageMatching( | 408 // Since BrowserPlugin persis, there will be no plugin destroyed message |
| 409 // until the owning DOM element is destroyed. |
| 410 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 407 BrowserPluginHostMsg_PluginDestroyed::ID)); | 411 BrowserPluginHostMsg_PluginDestroyed::ID)); |
| 408 } | 412 } |
| 409 | 413 |
| 410 // This test verifies that PluginDestroyed messages do not get sent from a | 414 // This test verifies that PluginDestroyed messages do not get sent from a |
| 411 // BrowserPlugin that has never navigated. | 415 // BrowserPlugin that has never navigated. |
| 412 TEST_F(BrowserPluginTest, RemovePluginBeforeNavigation) { | 416 TEST_F(BrowserPluginTest, RemovePluginBeforeNavigation) { |
| 413 std::string html = base::StringPrintf(kHTMLForSourcelessPluginObject, | 417 std::string html = base::StringPrintf(kHTMLForSourcelessPluginObject, |
| 414 kBrowserPluginMimeType); | 418 kBrowserPluginMimeType); |
| 415 LoadHTML(html.c_str()); | 419 LoadHTML(html.c_str()); |
| 416 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( | 420 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 // These value are not populated (as an optimization) if autosize is | 642 // These value are not populated (as an optimization) if autosize is |
| 639 // disabled. | 643 // disabled. |
| 640 EXPECT_EQ(0, auto_size_params.min_size.width()); | 644 EXPECT_EQ(0, auto_size_params.min_size.width()); |
| 641 EXPECT_EQ(0, auto_size_params.min_size.height()); | 645 EXPECT_EQ(0, auto_size_params.min_size.height()); |
| 642 EXPECT_EQ(0, auto_size_params.max_size.width()); | 646 EXPECT_EQ(0, auto_size_params.max_size.width()); |
| 643 EXPECT_EQ(0, auto_size_params.max_size.height()); | 647 EXPECT_EQ(0, auto_size_params.max_size.height()); |
| 644 } | 648 } |
| 645 } | 649 } |
| 646 | 650 |
| 647 } // namespace content | 651 } // namespace content |
| OLD | NEW |