| 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/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // This test verifies that an initial resize occurs when we instantiate the | 120 // This test verifies that an initial resize occurs when we instantiate the |
| 121 // browser plugin. This test also verifies that the browser plugin is waiting | 121 // browser plugin. This test also verifies that the browser plugin is waiting |
| 122 // for a BrowserPluginMsg_UpdateRect in response. We issue an UpdateRect, and | 122 // for a BrowserPluginMsg_UpdateRect in response. We issue an UpdateRect, and |
| 123 // we observe an UpdateRect_ACK, with the |pending_damage_buffer_| reset, | 123 // we observe an UpdateRect_ACK, with the |pending_damage_buffer_| reset, |
| 124 // indiciating that the BrowserPlugin is not waiting for any more UpdateRects to | 124 // indiciating that the BrowserPlugin is not waiting for any more UpdateRects to |
| 125 // satisfy its resize request. | 125 // satisfy its resize request. |
| 126 TEST_F(BrowserPluginTest, InitialResize) { | 126 TEST_F(BrowserPluginTest, InitialResize) { |
| 127 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 127 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
| 128 // Verify that the information based on ResizeGuest is correct, and | 128 // Verify that the information based on ResizeGuest is correct, and |
| 129 // use its TransportDIB::Id to paint. | 129 // use its TransportDIB::Id to paint. |
| 130 const IPC::Message* msg = | 130 int instance_id = 0; |
| 131 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 131 { |
| 132 BrowserPluginHostMsg_ResizeGuest::ID); | 132 const IPC::Message* msg = |
| 133 ASSERT_TRUE(msg); | 133 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 134 int instance_id = -1; | 134 BrowserPluginHostMsg_ResizeGuest::ID); |
| 135 BrowserPluginHostMsg_ResizeGuest_Params params; | 135 ASSERT_TRUE(msg); |
| 136 BrowserPluginHostMsg_ResizeGuest::Read(msg, &instance_id, ¶ms); | 136 BrowserPluginHostMsg_ResizeGuest_Params params; |
| 137 EXPECT_EQ(640, params.view_size.width()); | 137 BrowserPluginHostMsg_ResizeGuest::Read(msg, &instance_id, ¶ms); |
| 138 EXPECT_EQ(480, params.view_size.height()); | 138 EXPECT_EQ(640, params.view_size.width()); |
| 139 EXPECT_EQ(480, params.view_size.height()); |
| 140 } |
| 139 | 141 |
| 140 MockBrowserPlugin* browser_plugin = | 142 MockBrowserPlugin* browser_plugin = |
| 141 static_cast<MockBrowserPlugin*>( | 143 static_cast<MockBrowserPlugin*>( |
| 142 browser_plugin_manager()->GetBrowserPlugin(instance_id)); | 144 browser_plugin_manager()->GetBrowserPlugin(instance_id)); |
| 143 ASSERT_TRUE(browser_plugin); | 145 ASSERT_TRUE(browser_plugin); |
| 144 // Now the browser plugin is expecting a UpdateRect resize. | 146 // Now the browser plugin is expecting a UpdateRect resize. |
| 145 EXPECT_TRUE(browser_plugin->pending_damage_buffer_); | 147 EXPECT_TRUE(browser_plugin->pending_damage_buffer_); |
| 146 | 148 |
| 147 // Send the BrowserPlugin an UpdateRect equal to its container size with | 149 // Send the BrowserPlugin an UpdateRect equal to its container size with |
| 148 // the same damage buffer. That should clear |pending_damage_buffer_|. | 150 // the same damage buffer. That should clear |pending_damage_buffer_|. |
| 149 BrowserPluginMsg_UpdateRect_Params update_rect_params; | 151 BrowserPluginMsg_UpdateRect_Params update_rect_params; |
| 150 update_rect_params.damage_buffer_identifier = | 152 update_rect_params.damage_buffer_identifier = |
| 151 #if defined(OS_MACOSX) | 153 #if defined(OS_MACOSX) |
| 152 browser_plugin->pending_damage_buffer_->id(); | 154 browser_plugin->pending_damage_buffer_->id(); |
| 153 #else | 155 #else |
| 154 browser_plugin->pending_damage_buffer_->handle(); | 156 browser_plugin->pending_damage_buffer_->handle(); |
| 155 #endif | 157 #endif |
| 156 update_rect_params.view_size = gfx::Size(640, 480); | 158 update_rect_params.view_size = gfx::Size(640, 480); |
| 157 update_rect_params.scale_factor = 1.0f; | 159 update_rect_params.scale_factor = 1.0f; |
| 158 update_rect_params.is_resize_ack = true; | 160 update_rect_params.is_resize_ack = true; |
| 159 browser_plugin->UpdateRect(0, update_rect_params); | 161 BrowserPluginMsg_UpdateRect msg(0, instance_id, 0, update_rect_params); |
| 162 browser_plugin->OnMessageReceived(msg); |
| 160 EXPECT_FALSE(browser_plugin->pending_damage_buffer_); | 163 EXPECT_FALSE(browser_plugin->pending_damage_buffer_); |
| 161 } | 164 } |
| 162 | 165 |
| 163 // Verify that the src attribute on the browser plugin works as expected. | 166 // Verify that the src attribute on the browser plugin works as expected. |
| 164 TEST_F(BrowserPluginTest, SrcAttribute) { | 167 TEST_F(BrowserPluginTest, SrcAttribute) { |
| 165 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 168 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
| 166 // Verify that we're reporting the correct URL to navigate to based on the | 169 // Verify that we're reporting the correct URL to navigate to based on the |
| 167 // src attribute. | 170 // src attribute. |
| 168 { | 171 { |
| 169 // Ensure we get a CreateGuest on the initial navigation. | 172 // Ensure we get a CreateGuest on the initial navigation. |
| 170 const IPC::Message* create_msg = | 173 const IPC::Message* create_msg = |
| 171 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 174 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 172 BrowserPluginHostMsg_CreateGuest::ID); | 175 BrowserPluginHostMsg_CreateGuest::ID); |
| 173 ASSERT_TRUE(create_msg); | 176 ASSERT_TRUE(create_msg); |
| 174 | 177 |
| 175 const IPC::Message* msg = | 178 const IPC::Message* msg = |
| 176 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 179 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 177 BrowserPluginHostMsg_NavigateGuest::ID); | 180 BrowserPluginHostMsg_NavigateGuest::ID); |
| 178 ASSERT_TRUE(msg); | 181 ASSERT_TRUE(msg); |
| 179 | 182 |
| 180 int instance_id = -1; | 183 int instance_id = 0; |
| 181 std::string src; | 184 std::string src; |
| 182 BrowserPluginHostMsg_NavigateGuest::Read(msg, &instance_id, &src); | 185 BrowserPluginHostMsg_NavigateGuest::Read(msg, &instance_id, &src); |
| 183 EXPECT_EQ("foo", src); | 186 EXPECT_EQ("foo", src); |
| 184 } | 187 } |
| 185 | 188 |
| 186 browser_plugin_manager()->sink().ClearMessages(); | 189 browser_plugin_manager()->sink().ClearMessages(); |
| 187 // Navigate to bar and observe the associated | 190 // Navigate to bar and observe the associated |
| 188 // BrowserPluginHostMsg_NavigateGuest message. | 191 // BrowserPluginHostMsg_NavigateGuest message. |
| 189 // Verify that the src attribute is updated as well. | 192 // Verify that the src attribute is updated as well. |
| 190 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); | 193 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); |
| 191 { | 194 { |
| 192 // Verify that we do not get a CreateGuest on subsequent navigations. | 195 // Verify that we do not get a CreateGuest on subsequent navigations. |
| 193 const IPC::Message* create_msg = | 196 const IPC::Message* create_msg = |
| 194 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 197 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 195 BrowserPluginHostMsg_CreateGuest::ID); | 198 BrowserPluginHostMsg_CreateGuest::ID); |
| 196 ASSERT_FALSE(create_msg); | 199 ASSERT_FALSE(create_msg); |
| 197 | 200 |
| 198 const IPC::Message* msg = | 201 const IPC::Message* msg = |
| 199 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 202 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 200 BrowserPluginHostMsg_NavigateGuest::ID); | 203 BrowserPluginHostMsg_NavigateGuest::ID); |
| 201 ASSERT_TRUE(msg); | 204 ASSERT_TRUE(msg); |
| 202 | 205 |
| 203 int instance_id = -1; | 206 int instance_id = 0; |
| 204 std::string src; | 207 std::string src; |
| 205 BrowserPluginHostMsg_NavigateGuest::Read(msg, &instance_id, &src); | 208 BrowserPluginHostMsg_NavigateGuest::Read(msg, &instance_id, &src); |
| 206 EXPECT_EQ("bar", src); | 209 EXPECT_EQ("bar", src); |
| 207 std::string src_value = | 210 std::string src_value = |
| 208 ExecuteScriptAndReturnString( | 211 ExecuteScriptAndReturnString( |
| 209 "document.getElementById('browserplugin').src"); | 212 "document.getElementById('browserplugin').src"); |
| 210 EXPECT_EQ("bar", src_value); | 213 EXPECT_EQ("bar", src_value); |
| 211 } | 214 } |
| 212 } | 215 } |
| 213 | 216 |
| 214 TEST_F(BrowserPluginTest, ResizeFlowControl) { | 217 TEST_F(BrowserPluginTest, ResizeFlowControl) { |
| 215 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 218 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
| 216 int instance_id = -1; | 219 int instance_id = 0; |
| 217 { | 220 { |
| 218 // Ensure we get a NavigateGuest on the initial navigation and grab the | 221 // Ensure we get a NavigateGuest on the initial navigation and grab the |
| 219 // BrowserPlugin's instance_id from there. | 222 // BrowserPlugin's instance_id from there. |
| 220 std::string src; | 223 std::string src; |
| 221 const IPC::Message* nav_msg = | 224 const IPC::Message* nav_msg = |
| 222 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 225 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 223 BrowserPluginHostMsg_NavigateGuest::ID); | 226 BrowserPluginHostMsg_NavigateGuest::ID); |
| 224 ASSERT_TRUE(nav_msg); | 227 ASSERT_TRUE(nav_msg); |
| 225 BrowserPluginHostMsg_NavigateGuest::Read(nav_msg, &instance_id, &src); | 228 BrowserPluginHostMsg_NavigateGuest::Read(nav_msg, &instance_id, &src); |
| 226 } | 229 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 239 update_rect_params.is_resize_ack = true; | 242 update_rect_params.is_resize_ack = true; |
| 240 // By sending the damage buffer handle back to BrowserPlugin on UpdateRect, | 243 // By sending the damage buffer handle back to BrowserPlugin on UpdateRect, |
| 241 // then the BrowserPlugin knows that the browser process has received and | 244 // then the BrowserPlugin knows that the browser process has received and |
| 242 // has begun to use the pending_damage_buffer. | 245 // has begun to use the pending_damage_buffer. |
| 243 update_rect_params.damage_buffer_identifier = | 246 update_rect_params.damage_buffer_identifier = |
| 244 #if defined(OS_MACOSX) | 247 #if defined(OS_MACOSX) |
| 245 browser_plugin->pending_damage_buffer_->id(); | 248 browser_plugin->pending_damage_buffer_->id(); |
| 246 #else | 249 #else |
| 247 browser_plugin->pending_damage_buffer_->handle(); | 250 browser_plugin->pending_damage_buffer_->handle(); |
| 248 #endif | 251 #endif |
| 249 browser_plugin->UpdateRect(0, update_rect_params); | 252 BrowserPluginMsg_UpdateRect msg(0, instance_id, 0, update_rect_params); |
| 253 browser_plugin->OnMessageReceived(msg); |
| 250 EXPECT_EQ(NULL, browser_plugin->pending_damage_buffer_); | 254 EXPECT_EQ(NULL, browser_plugin->pending_damage_buffer_); |
| 251 } | 255 } |
| 252 | 256 |
| 253 browser_plugin_manager()->sink().ClearMessages(); | 257 browser_plugin_manager()->sink().ClearMessages(); |
| 254 | 258 |
| 255 // Resize the browser plugin three times. | 259 // Resize the browser plugin three times. |
| 256 ExecuteJavaScript("document.getElementById('browserplugin').width = '641px'"); | 260 ExecuteJavaScript("document.getElementById('browserplugin').width = '641px'"); |
| 257 ProcessPendingMessages(); | 261 ProcessPendingMessages(); |
| 258 ExecuteJavaScript("document.getElementById('browserplugin').width = '642px'"); | 262 ExecuteJavaScript("document.getElementById('browserplugin').width = '642px'"); |
| 259 ProcessPendingMessages(); | 263 ProcessPendingMessages(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 281 BrowserPluginMsg_UpdateRect_Params update_rect_params; | 285 BrowserPluginMsg_UpdateRect_Params update_rect_params; |
| 282 update_rect_params.view_size = gfx::Size(641, 480); | 286 update_rect_params.view_size = gfx::Size(641, 480); |
| 283 update_rect_params.scale_factor = 1.0f; | 287 update_rect_params.scale_factor = 1.0f; |
| 284 update_rect_params.is_resize_ack = true; | 288 update_rect_params.is_resize_ack = true; |
| 285 update_rect_params.damage_buffer_identifier = | 289 update_rect_params.damage_buffer_identifier = |
| 286 #if defined(OS_MACOSX) | 290 #if defined(OS_MACOSX) |
| 287 browser_plugin->pending_damage_buffer_->id(); | 291 browser_plugin->pending_damage_buffer_->id(); |
| 288 #else | 292 #else |
| 289 browser_plugin->pending_damage_buffer_->handle(); | 293 browser_plugin->pending_damage_buffer_->handle(); |
| 290 #endif | 294 #endif |
| 291 browser_plugin->UpdateRect(0, update_rect_params); | 295 BrowserPluginMsg_UpdateRect msg(0, instance_id, 0, update_rect_params); |
| 296 browser_plugin->OnMessageReceived(msg); |
| 292 // This tells us that the BrowserPlugin is still expecting another | 297 // This tells us that the BrowserPlugin is still expecting another |
| 293 // UpdateRect with the most recent size. | 298 // UpdateRect with the most recent size. |
| 294 EXPECT_TRUE(browser_plugin->pending_damage_buffer_); | 299 EXPECT_TRUE(browser_plugin->pending_damage_buffer_); |
| 295 } | 300 } |
| 296 // Send the BrowserPlugin another UpdateRect, but this time with a size | 301 // Send the BrowserPlugin another UpdateRect, but this time with a size |
| 297 // that matches the size of the container. | 302 // that matches the size of the container. |
| 298 { | 303 { |
| 299 BrowserPluginMsg_UpdateRect_Params update_rect_params; | 304 BrowserPluginMsg_UpdateRect_Params update_rect_params; |
| 300 update_rect_params.view_size = gfx::Size(643, 480); | 305 update_rect_params.view_size = gfx::Size(643, 480); |
| 301 update_rect_params.scale_factor = 1.0f; | 306 update_rect_params.scale_factor = 1.0f; |
| 302 update_rect_params.is_resize_ack = true; | 307 update_rect_params.is_resize_ack = true; |
| 303 update_rect_params.damage_buffer_identifier = | 308 update_rect_params.damage_buffer_identifier = |
| 304 #if defined(OS_MACOSX) | 309 #if defined(OS_MACOSX) |
| 305 browser_plugin->pending_damage_buffer_->id(); | 310 browser_plugin->pending_damage_buffer_->id(); |
| 306 #else | 311 #else |
| 307 browser_plugin->pending_damage_buffer_->handle(); | 312 browser_plugin->pending_damage_buffer_->handle(); |
| 308 #endif | 313 #endif |
| 309 browser_plugin->UpdateRect(0, update_rect_params); | 314 BrowserPluginMsg_UpdateRect msg(0, instance_id, 0, update_rect_params); |
| 315 browser_plugin->OnMessageReceived(msg); |
| 310 // The BrowserPlugin has finally received an UpdateRect that satisifes | 316 // The BrowserPlugin has finally received an UpdateRect that satisifes |
| 311 // its current size, and so it is happy. | 317 // its current size, and so it is happy. |
| 312 EXPECT_FALSE(browser_plugin->pending_damage_buffer_); | 318 EXPECT_FALSE(browser_plugin->pending_damage_buffer_); |
| 313 } | 319 } |
| 314 } | 320 } |
| 315 | 321 |
| 316 TEST_F(BrowserPluginTest, GuestCrash) { | 322 TEST_F(BrowserPluginTest, GuestCrash) { |
| 317 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 323 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
| 318 | 324 |
| 319 // Grab the BrowserPlugin's instance ID from its resize message. | 325 // Grab the BrowserPlugin's instance ID from its resize message. |
| 320 const IPC::Message* msg = | 326 int instance_id = 0; |
| 321 browser_plugin_manager()->sink().GetFirstMessageMatching( | 327 { |
| 322 BrowserPluginHostMsg_ResizeGuest::ID); | 328 const IPC::Message* msg = |
| 323 ASSERT_TRUE(msg); | 329 browser_plugin_manager()->sink().GetFirstMessageMatching( |
| 324 int instance_id = -1; | 330 BrowserPluginHostMsg_ResizeGuest::ID); |
| 325 BrowserPluginHostMsg_ResizeGuest_Params params; | 331 ASSERT_TRUE(msg); |
| 326 BrowserPluginHostMsg_ResizeGuest::Read(msg, &instance_id, ¶ms); | 332 BrowserPluginHostMsg_ResizeGuest_Params params; |
| 327 | 333 BrowserPluginHostMsg_ResizeGuest::Read(msg, &instance_id, ¶ms); |
| 334 } |
| 328 MockBrowserPlugin* browser_plugin = | 335 MockBrowserPlugin* browser_plugin = |
| 329 static_cast<MockBrowserPlugin*>( | 336 static_cast<MockBrowserPlugin*>( |
| 330 browser_plugin_manager()->GetBrowserPlugin(instance_id)); | 337 browser_plugin_manager()->GetBrowserPlugin(instance_id)); |
| 331 ASSERT_TRUE(browser_plugin); | 338 ASSERT_TRUE(browser_plugin); |
| 332 | 339 |
| 333 WebKit::WebCursorInfo cursor_info; | 340 WebKit::WebCursorInfo cursor_info; |
| 334 // Send an event and verify that the event is deported. | 341 // Send an event and verify that the event is deported. |
| 335 browser_plugin->handleInputEvent(WebKit::WebMouseEvent(), | 342 browser_plugin->handleInputEvent(WebKit::WebMouseEvent(), |
| 336 cursor_info); | 343 cursor_info); |
| 337 EXPECT_TRUE(browser_plugin_manager()->sink().GetUniqueMessageMatching( | 344 EXPECT_TRUE(browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 338 BrowserPluginHostMsg_HandleInputEvent::ID)); | 345 BrowserPluginHostMsg_HandleInputEvent::ID)); |
| 339 browser_plugin_manager()->sink().ClearMessages(); | 346 browser_plugin_manager()->sink().ClearMessages(); |
| 340 | 347 |
| 341 const char* kAddEventListener = | 348 const char* kAddEventListener = |
| 342 "var msg;" | 349 "var msg;" |
| 343 "function exitListener(e) {" | 350 "function exitListener(e) {" |
| 344 " msg = JSON.parse(e.detail).reason;" | 351 " msg = JSON.parse(e.detail).reason;" |
| 345 "}" | 352 "}" |
| 346 "document.getElementById('browserplugin')." | 353 "document.getElementById('browserplugin')." |
| 347 " addEventListener('-internal-exit', exitListener);"; | 354 " addEventListener('-internal-exit', exitListener);"; |
| 348 | 355 |
| 349 ExecuteJavaScript(kAddEventListener); | 356 ExecuteJavaScript(kAddEventListener); |
| 350 | 357 |
| 351 // Pretend that the guest has terminated normally. | 358 // Pretend that the guest has terminated normally. |
| 352 browser_plugin->GuestGone(0, base::TERMINATION_STATUS_NORMAL_TERMINATION); | 359 { |
| 360 BrowserPluginMsg_GuestGone msg( |
| 361 0, 0, 0, base::TERMINATION_STATUS_NORMAL_TERMINATION); |
| 362 browser_plugin->OnMessageReceived(msg); |
| 363 } |
| 353 | 364 |
| 354 // Verify that our event listener has fired. | 365 // Verify that our event listener has fired. |
| 355 EXPECT_EQ("normal", ExecuteScriptAndReturnString("msg")); | 366 EXPECT_EQ("normal", ExecuteScriptAndReturnString("msg")); |
| 356 | 367 |
| 357 // Pretend that the guest has crashed. | 368 // Pretend that the guest has crashed. |
| 358 browser_plugin->GuestGone(0, base::TERMINATION_STATUS_PROCESS_CRASHED); | 369 { |
| 370 BrowserPluginMsg_GuestGone msg( |
| 371 0, 0, 0, base::TERMINATION_STATUS_PROCESS_CRASHED); |
| 372 browser_plugin->OnMessageReceived(msg); |
| 373 } |
| 359 | 374 |
| 360 // Verify that our event listener has fired. | 375 // Verify that our event listener has fired. |
| 361 EXPECT_EQ("crashed", ExecuteScriptAndReturnString("msg")); | 376 EXPECT_EQ("crashed", ExecuteScriptAndReturnString("msg")); |
| 362 | 377 |
| 363 // Send an event and verify that events are no longer deported. | 378 // Send an event and verify that events are no longer deported. |
| 364 browser_plugin->handleInputEvent(WebKit::WebMouseEvent(), | 379 browser_plugin->handleInputEvent(WebKit::WebMouseEvent(), |
| 365 cursor_info); | 380 cursor_info); |
| 366 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( | 381 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 367 BrowserPluginHostMsg_HandleInputEvent::ID)); | 382 BrowserPluginHostMsg_HandleInputEvent::ID)); |
| 368 } | 383 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 396 const char* kGoogleURL = "http://www.google.com/"; | 411 const char* kGoogleURL = "http://www.google.com/"; |
| 397 const char* kGoogleNewsURL = "http://news.google.com/"; | 412 const char* kGoogleNewsURL = "http://news.google.com/"; |
| 398 | 413 |
| 399 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 414 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
| 400 ExecuteJavaScript(kAddEventListener); | 415 ExecuteJavaScript(kAddEventListener); |
| 401 // Grab the BrowserPlugin's instance ID from its resize message. | 416 // Grab the BrowserPlugin's instance ID from its resize message. |
| 402 const IPC::Message* msg = | 417 const IPC::Message* msg = |
| 403 browser_plugin_manager()->sink().GetFirstMessageMatching( | 418 browser_plugin_manager()->sink().GetFirstMessageMatching( |
| 404 BrowserPluginHostMsg_ResizeGuest::ID); | 419 BrowserPluginHostMsg_ResizeGuest::ID); |
| 405 ASSERT_TRUE(msg); | 420 ASSERT_TRUE(msg); |
| 406 int instance_id = -1; | 421 int instance_id = 0; |
| 407 BrowserPluginHostMsg_ResizeGuest_Params params; | 422 BrowserPluginHostMsg_ResizeGuest_Params params; |
| 408 BrowserPluginHostMsg_ResizeGuest::Read(msg, &instance_id, ¶ms); | 423 BrowserPluginHostMsg_ResizeGuest::Read(msg, &instance_id, ¶ms); |
| 409 | 424 |
| 410 MockBrowserPlugin* browser_plugin = | 425 MockBrowserPlugin* browser_plugin = |
| 411 static_cast<MockBrowserPlugin*>( | 426 static_cast<MockBrowserPlugin*>( |
| 412 browser_plugin_manager()->GetBrowserPlugin(instance_id)); | 427 browser_plugin_manager()->GetBrowserPlugin(instance_id)); |
| 413 ASSERT_TRUE(browser_plugin); | 428 ASSERT_TRUE(browser_plugin); |
| 414 | 429 |
| 415 { | 430 { |
| 416 BrowserPluginMsg_LoadCommit_Params navigate_params; | 431 BrowserPluginMsg_LoadCommit_Params navigate_params; |
| 417 navigate_params.is_top_level = true; | 432 navigate_params.is_top_level = true; |
| 418 navigate_params.url = GURL(kGoogleURL); | 433 navigate_params.url = GURL(kGoogleURL); |
| 419 navigate_params.process_id = 1337; | 434 navigate_params.process_id = 1337; |
| 420 browser_plugin->LoadCommit(navigate_params); | 435 BrowserPluginMsg_LoadCommit msg(0, instance_id, navigate_params); |
| 436 browser_plugin->OnMessageReceived(msg); |
| 421 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); | 437 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); |
| 422 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString(kGetSrc)); | 438 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString(kGetSrc)); |
| 423 EXPECT_EQ(1337, ExecuteScriptAndReturnInt(kGetProcessID)); | 439 EXPECT_EQ(1337, ExecuteScriptAndReturnInt(kGetProcessID)); |
| 424 } | 440 } |
| 425 ExecuteJavaScript(kRemoveEventListener); | 441 ExecuteJavaScript(kRemoveEventListener); |
| 426 { | 442 { |
| 427 BrowserPluginMsg_LoadCommit_Params navigate_params; | 443 BrowserPluginMsg_LoadCommit_Params navigate_params; |
| 428 navigate_params.is_top_level = false; | 444 navigate_params.is_top_level = false; |
| 429 navigate_params.url = GURL(kGoogleNewsURL); | 445 navigate_params.url = GURL(kGoogleNewsURL); |
| 430 navigate_params.process_id = 42; | 446 navigate_params.process_id = 42; |
| 431 browser_plugin->LoadCommit(navigate_params); | 447 BrowserPluginMsg_LoadCommit msg(0, instance_id, navigate_params); |
| 448 browser_plugin->OnMessageReceived(msg); |
| 432 // The URL variable should not change because we've removed the event | 449 // The URL variable should not change because we've removed the event |
| 433 // listener. | 450 // listener. |
| 434 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); | 451 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); |
| 435 // The src attribute should not change if this is a top-level navigation. | 452 // The src attribute should not change if this is a top-level navigation. |
| 436 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString(kGetSrc)); | 453 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString(kGetSrc)); |
| 437 EXPECT_EQ(42, ExecuteScriptAndReturnInt(kGetProcessID)); | 454 EXPECT_EQ(42, ExecuteScriptAndReturnInt(kGetProcessID)); |
| 438 } | 455 } |
| 439 } | 456 } |
| 440 | 457 |
| 441 TEST_F(BrowserPluginTest, StopMethod) { | 458 TEST_F(BrowserPluginTest, StopMethod) { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 "document.getElementById('browserplugin').src"); | 580 "document.getElementById('browserplugin').src"); |
| 564 EXPECT_STREQ("", src_value.c_str()); | 581 EXPECT_STREQ("", src_value.c_str()); |
| 565 | 582 |
| 566 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); | 583 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); |
| 567 { | 584 { |
| 568 const IPC::Message* create_msg = | 585 const IPC::Message* create_msg = |
| 569 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 586 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 570 BrowserPluginHostMsg_CreateGuest::ID); | 587 BrowserPluginHostMsg_CreateGuest::ID); |
| 571 ASSERT_TRUE(create_msg); | 588 ASSERT_TRUE(create_msg); |
| 572 | 589 |
| 573 int create_instance_id = -1; | 590 int create_instance_id = 0; |
| 574 BrowserPluginHostMsg_CreateGuest_Params params; | 591 BrowserPluginHostMsg_CreateGuest_Params params; |
| 575 BrowserPluginHostMsg_CreateGuest::Read( | 592 BrowserPluginHostMsg_CreateGuest::Read( |
| 576 create_msg, | 593 create_msg, |
| 577 &create_instance_id, | 594 &create_instance_id, |
| 578 ¶ms); | 595 ¶ms); |
| 579 EXPECT_STREQ("storage", params.storage_partition_id.c_str()); | 596 EXPECT_STREQ("storage", params.storage_partition_id.c_str()); |
| 580 EXPECT_FALSE(params.persist_storage); | 597 EXPECT_FALSE(params.persist_storage); |
| 581 | 598 |
| 582 const IPC::Message* msg = | 599 const IPC::Message* msg = |
| 583 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 600 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 584 BrowserPluginHostMsg_NavigateGuest::ID); | 601 BrowserPluginHostMsg_NavigateGuest::ID); |
| 585 ASSERT_TRUE(msg); | 602 ASSERT_TRUE(msg); |
| 586 | 603 |
| 587 int instance_id = -1; | 604 int instance_id = 0; |
| 588 std::string src; | 605 std::string src; |
| 589 BrowserPluginHostMsg_NavigateGuest::Read(msg, &instance_id, &src); | 606 BrowserPluginHostMsg_NavigateGuest::Read(msg, &instance_id, &src); |
| 590 EXPECT_STREQ("bar", src.c_str()); | 607 EXPECT_STREQ("bar", src.c_str()); |
| 591 EXPECT_EQ(create_instance_id, instance_id); | 608 EXPECT_EQ(create_instance_id, instance_id); |
| 592 } | 609 } |
| 593 | 610 |
| 594 // Setting the partition should throw an exception and the value should not | 611 // Setting the partition should throw an exception and the value should not |
| 595 // change. | 612 // change. |
| 596 ExecuteJavaScript( | 613 ExecuteJavaScript( |
| 597 "try {" | 614 "try {" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 626 const char* kGetProcessID = | 643 const char* kGetProcessID = |
| 627 "document.getElementById('browserplugin').getProcessId()"; | 644 "document.getElementById('browserplugin').getProcessId()"; |
| 628 | 645 |
| 629 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 646 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
| 630 ExecuteJavaScript(kAddEventListener); | 647 ExecuteJavaScript(kAddEventListener); |
| 631 // Grab the BrowserPlugin's instance ID from its resize message. | 648 // Grab the BrowserPlugin's instance ID from its resize message. |
| 632 const IPC::Message* msg = | 649 const IPC::Message* msg = |
| 633 browser_plugin_manager()->sink().GetFirstMessageMatching( | 650 browser_plugin_manager()->sink().GetFirstMessageMatching( |
| 634 BrowserPluginHostMsg_ResizeGuest::ID); | 651 BrowserPluginHostMsg_ResizeGuest::ID); |
| 635 ASSERT_TRUE(msg); | 652 ASSERT_TRUE(msg); |
| 636 int instance_id = -1; | 653 int instance_id = 0; |
| 637 BrowserPluginHostMsg_ResizeGuest_Params params; | 654 BrowserPluginHostMsg_ResizeGuest_Params params; |
| 638 BrowserPluginHostMsg_ResizeGuest::Read(msg, &instance_id, ¶ms); | 655 BrowserPluginHostMsg_ResizeGuest::Read(msg, &instance_id, ¶ms); |
| 639 | 656 |
| 640 MockBrowserPlugin* browser_plugin = | 657 MockBrowserPlugin* browser_plugin = |
| 641 static_cast<MockBrowserPlugin*>( | 658 static_cast<MockBrowserPlugin*>( |
| 642 browser_plugin_manager()->GetBrowserPlugin(instance_id)); | 659 browser_plugin_manager()->GetBrowserPlugin(instance_id)); |
| 643 ASSERT_TRUE(browser_plugin); | 660 ASSERT_TRUE(browser_plugin); |
| 644 | 661 |
| 645 { | 662 { |
| 646 BrowserPluginMsg_LoadCommit_Params navigate_params; | 663 BrowserPluginMsg_LoadCommit_Params navigate_params; |
| 647 navigate_params.url = GURL(kGoogleURL); | 664 navigate_params.url = GURL(kGoogleURL); |
| 648 navigate_params.process_id = 1337; | 665 navigate_params.process_id = 1337; |
| 649 browser_plugin->LoadCommit(navigate_params); | 666 BrowserPluginMsg_LoadCommit msg(0, instance_id, navigate_params); |
| 667 browser_plugin->OnMessageReceived(msg); |
| 650 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); | 668 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); |
| 651 EXPECT_EQ(1337, ExecuteScriptAndReturnInt(kGetProcessID)); | 669 EXPECT_EQ(1337, ExecuteScriptAndReturnInt(kGetProcessID)); |
| 652 } | 670 } |
| 653 { | 671 { |
| 654 BrowserPluginMsg_LoadCommit_Params navigate_params; | 672 BrowserPluginMsg_LoadCommit_Params navigate_params; |
| 655 navigate_params.url = GURL(kGoogleNewsURL); | 673 navigate_params.url = GURL(kGoogleNewsURL); |
| 656 navigate_params.process_id = 42; | 674 navigate_params.process_id = 42; |
| 657 browser_plugin->LoadCommit(navigate_params); | 675 BrowserPluginMsg_LoadCommit msg(0, instance_id, navigate_params); |
| 676 browser_plugin->OnMessageReceived(msg); |
| 658 // The URL variable should not change because we've removed the event | 677 // The URL variable should not change because we've removed the event |
| 659 // listener. | 678 // listener. |
| 660 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); | 679 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); |
| 661 EXPECT_EQ(42, ExecuteScriptAndReturnInt(kGetProcessID)); | 680 EXPECT_EQ(42, ExecuteScriptAndReturnInt(kGetProcessID)); |
| 662 } | 681 } |
| 663 } | 682 } |
| 664 | 683 |
| 665 // This test verifies that multiple event listeners fire that are registered | 684 // This test verifies that multiple event listeners fire that are registered |
| 666 // on a single event type. | 685 // on a single event type. |
| 667 TEST_F(BrowserPluginTest, MultipleEventListeners) { | 686 TEST_F(BrowserPluginTest, MultipleEventListeners) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 681 const char* kGetProcessID = | 700 const char* kGetProcessID = |
| 682 "document.getElementById('browserplugin').getProcessId()"; | 701 "document.getElementById('browserplugin').getProcessId()"; |
| 683 | 702 |
| 684 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 703 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
| 685 ExecuteJavaScript(kAddEventListener); | 704 ExecuteJavaScript(kAddEventListener); |
| 686 // Grab the BrowserPlugin's instance ID from its resize message. | 705 // Grab the BrowserPlugin's instance ID from its resize message. |
| 687 const IPC::Message* msg = | 706 const IPC::Message* msg = |
| 688 browser_plugin_manager()->sink().GetFirstMessageMatching( | 707 browser_plugin_manager()->sink().GetFirstMessageMatching( |
| 689 BrowserPluginHostMsg_ResizeGuest::ID); | 708 BrowserPluginHostMsg_ResizeGuest::ID); |
| 690 ASSERT_TRUE(msg); | 709 ASSERT_TRUE(msg); |
| 691 int instance_id = -1; | 710 int instance_id = 0; |
| 692 BrowserPluginHostMsg_ResizeGuest_Params params; | 711 BrowserPluginHostMsg_ResizeGuest_Params params; |
| 693 BrowserPluginHostMsg_ResizeGuest::Read(msg, &instance_id, ¶ms); | 712 BrowserPluginHostMsg_ResizeGuest::Read(msg, &instance_id, ¶ms); |
| 694 | 713 |
| 695 MockBrowserPlugin* browser_plugin = | 714 MockBrowserPlugin* browser_plugin = |
| 696 static_cast<MockBrowserPlugin*>( | 715 static_cast<MockBrowserPlugin*>( |
| 697 browser_plugin_manager()->GetBrowserPlugin(instance_id)); | 716 browser_plugin_manager()->GetBrowserPlugin(instance_id)); |
| 698 ASSERT_TRUE(browser_plugin); | 717 ASSERT_TRUE(browser_plugin); |
| 699 | 718 |
| 700 { | 719 { |
| 701 BrowserPluginMsg_LoadCommit_Params navigate_params; | 720 BrowserPluginMsg_LoadCommit_Params navigate_params; |
| 702 navigate_params.url = GURL(kGoogleURL); | 721 navigate_params.url = GURL(kGoogleURL); |
| 703 navigate_params.process_id = 1337; | 722 navigate_params.process_id = 1337; |
| 704 browser_plugin->LoadCommit(navigate_params); | 723 BrowserPluginMsg_LoadCommit msg(0, instance_id, navigate_params); |
| 724 browser_plugin->OnMessageReceived(msg); |
| 705 EXPECT_EQ(2, ExecuteScriptAndReturnInt("count")); | 725 EXPECT_EQ(2, ExecuteScriptAndReturnInt("count")); |
| 706 EXPECT_EQ(1337, ExecuteScriptAndReturnInt(kGetProcessID)); | 726 EXPECT_EQ(1337, ExecuteScriptAndReturnInt(kGetProcessID)); |
| 707 } | 727 } |
| 708 } | 728 } |
| 709 | 729 |
| 710 TEST_F(BrowserPluginTest, RemoveBrowserPluginOnExit) { | 730 TEST_F(BrowserPluginTest, RemoveBrowserPluginOnExit) { |
| 711 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 731 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
| 712 | 732 |
| 713 // Grab the BrowserPlugin's instance ID from its resize message. | 733 // Grab the BrowserPlugin's instance ID from its resize message. |
| 714 const IPC::Message* msg = | 734 int instance_id = 0; |
| 715 browser_plugin_manager()->sink().GetFirstMessageMatching( | 735 { |
| 716 BrowserPluginHostMsg_ResizeGuest::ID); | 736 const IPC::Message* msg = |
| 717 ASSERT_TRUE(msg); | 737 browser_plugin_manager()->sink().GetFirstMessageMatching( |
| 718 int instance_id = -1; | 738 BrowserPluginHostMsg_ResizeGuest::ID); |
| 719 BrowserPluginHostMsg_ResizeGuest_Params params; | 739 ASSERT_TRUE(msg); |
| 720 BrowserPluginHostMsg_ResizeGuest::Read(msg, &instance_id, ¶ms); | 740 BrowserPluginHostMsg_ResizeGuest_Params params; |
| 741 BrowserPluginHostMsg_ResizeGuest::Read(msg, &instance_id, ¶ms); |
| 742 } |
| 721 | 743 |
| 722 MockBrowserPlugin* browser_plugin = | 744 MockBrowserPlugin* browser_plugin = |
| 723 static_cast<MockBrowserPlugin*>( | 745 static_cast<MockBrowserPlugin*>( |
| 724 browser_plugin_manager()->GetBrowserPlugin(instance_id)); | 746 browser_plugin_manager()->GetBrowserPlugin(instance_id)); |
| 725 ASSERT_TRUE(browser_plugin); | 747 ASSERT_TRUE(browser_plugin); |
| 726 | 748 |
| 727 const char* kAddEventListener = | 749 const char* kAddEventListener = |
| 728 "function exitListener(e) {" | 750 "function exitListener(e) {" |
| 729 " if (JSON.parse(e.detail).reason == 'killed') {" | 751 " if (JSON.parse(e.detail).reason == 'killed') {" |
| 730 " var bp = document.getElementById('browserplugin');" | 752 " var bp = document.getElementById('browserplugin');" |
| 731 " bp.parentNode.removeChild(bp);" | 753 " bp.parentNode.removeChild(bp);" |
| 732 " }" | 754 " }" |
| 733 "}" | 755 "}" |
| 734 "document.getElementById('browserplugin')." | 756 "document.getElementById('browserplugin')." |
| 735 " addEventListener('-internal-exit', exitListener);"; | 757 " addEventListener('-internal-exit', exitListener);"; |
| 736 | 758 |
| 737 ExecuteJavaScript(kAddEventListener); | 759 ExecuteJavaScript(kAddEventListener); |
| 738 | 760 |
| 739 // Pretend that the guest has crashed. | 761 // Pretend that the guest has crashed. |
| 740 browser_plugin->GuestGone(0, base::TERMINATION_STATUS_PROCESS_WAS_KILLED); | 762 BrowserPluginMsg_GuestGone msg( |
| 763 0, instance_id, 0, base::TERMINATION_STATUS_PROCESS_WAS_KILLED); |
| 764 browser_plugin->OnMessageReceived(msg); |
| 741 | 765 |
| 742 ProcessPendingMessages(); | 766 ProcessPendingMessages(); |
| 743 | 767 |
| 744 EXPECT_EQ(NULL, browser_plugin_manager()->GetBrowserPlugin(instance_id)); | 768 EXPECT_EQ(NULL, browser_plugin_manager()->GetBrowserPlugin(instance_id)); |
| 745 } | 769 } |
| 746 | 770 |
| 747 TEST_F(BrowserPluginTest, AutoSizeAttributes) { | 771 TEST_F(BrowserPluginTest, AutoSizeAttributes) { |
| 748 std::string html = StringPrintf(kHTMLForSourcelessPluginObject, | 772 std::string html = StringPrintf(kHTMLForSourcelessPluginObject, |
| 749 content::kBrowserPluginMimeType); | 773 content::kBrowserPluginMimeType); |
| 750 LoadHTML(html.c_str()); | 774 LoadHTML(html.c_str()); |
| 751 const char* kSetAutoSizeParametersAndNavigate = | 775 const char* kSetAutoSizeParametersAndNavigate = |
| 752 "var browserplugin = document.getElementById('browserplugin');" | 776 "var browserplugin = document.getElementById('browserplugin');" |
| 753 "browserplugin.autoSize = true;" | 777 "browserplugin.autoSize = true;" |
| 754 "browserplugin.minWidth = 42;" | 778 "browserplugin.minWidth = 42;" |
| 755 "browserplugin.minHeight = 43;" | 779 "browserplugin.minHeight = 43;" |
| 756 "browserplugin.maxWidth = 1337;" | 780 "browserplugin.maxWidth = 1337;" |
| 757 "browserplugin.maxHeight = 1338;" | 781 "browserplugin.maxHeight = 1338;" |
| 758 "browserplugin.src = 'foobar';"; | 782 "browserplugin.src = 'foobar';"; |
| 759 const char* kDisableAutoSize = | 783 const char* kDisableAutoSize = |
| 760 "document.getElementById('browserplugin').autoSize = false;"; | 784 "document.getElementById('browserplugin').autoSize = false;"; |
| 761 | 785 |
| 762 int instance_id = -1; | 786 int instance_id = 0; |
| 763 // Set some autosize parameters before navigating then navigate. | 787 // Set some autosize parameters before navigating then navigate. |
| 764 // Verify that the BrowserPluginHostMsg_CreateGuest message contains | 788 // Verify that the BrowserPluginHostMsg_CreateGuest message contains |
| 765 // the correct autosize parameters. | 789 // the correct autosize parameters. |
| 766 ExecuteJavaScript(kSetAutoSizeParametersAndNavigate); | 790 ExecuteJavaScript(kSetAutoSizeParametersAndNavigate); |
| 767 ProcessPendingMessages(); | 791 ProcessPendingMessages(); |
| 768 { | 792 { |
| 769 const IPC::Message* create_msg = | 793 const IPC::Message* create_msg = |
| 770 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 794 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 771 BrowserPluginHostMsg_CreateGuest::ID); | 795 BrowserPluginHostMsg_CreateGuest::ID); |
| 772 ASSERT_TRUE(create_msg); | 796 ASSERT_TRUE(create_msg); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 803 BrowserPluginMsg_UpdateRect_Params update_rect_params; | 827 BrowserPluginMsg_UpdateRect_Params update_rect_params; |
| 804 update_rect_params.damage_buffer_identifier = | 828 update_rect_params.damage_buffer_identifier = |
| 805 #if defined(OS_MACOSX) | 829 #if defined(OS_MACOSX) |
| 806 browser_plugin->pending_damage_buffer_->id(); | 830 browser_plugin->pending_damage_buffer_->id(); |
| 807 #else | 831 #else |
| 808 browser_plugin->pending_damage_buffer_->handle(); | 832 browser_plugin->pending_damage_buffer_->handle(); |
| 809 #endif | 833 #endif |
| 810 update_rect_params.view_size = gfx::Size(1337, 1338); | 834 update_rect_params.view_size = gfx::Size(1337, 1338); |
| 811 update_rect_params.scale_factor = 1.0f; | 835 update_rect_params.scale_factor = 1.0f; |
| 812 update_rect_params.is_resize_ack = true; | 836 update_rect_params.is_resize_ack = true; |
| 813 browser_plugin->UpdateRect(0, update_rect_params); | 837 BrowserPluginMsg_UpdateRect msg(0, instance_id, 0, update_rect_params); |
| 838 browser_plugin->OnMessageReceived(msg); |
| 814 | 839 |
| 815 // Verify that the autosize state has been updated. | 840 // Verify that the autosize state has been updated. |
| 816 { | 841 { |
| 817 const IPC::Message* auto_size_msg = | 842 const IPC::Message* auto_size_msg = |
| 818 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 843 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 819 BrowserPluginHostMsg_UpdateRect_ACK::ID); | 844 BrowserPluginHostMsg_UpdateRect_ACK::ID); |
| 820 ASSERT_TRUE(auto_size_msg); | 845 ASSERT_TRUE(auto_size_msg); |
| 821 | 846 |
| 822 int instance_id = -1; | 847 int instance_id = 0; |
| 823 int message_id = 0; | 848 int message_id = 0; |
| 824 BrowserPluginHostMsg_AutoSize_Params auto_size_params; | 849 BrowserPluginHostMsg_AutoSize_Params auto_size_params; |
| 825 BrowserPluginHostMsg_ResizeGuest_Params resize_params; | 850 BrowserPluginHostMsg_ResizeGuest_Params resize_params; |
| 826 BrowserPluginHostMsg_UpdateRect_ACK::Read(auto_size_msg, | 851 BrowserPluginHostMsg_UpdateRect_ACK::Read(auto_size_msg, |
| 827 &instance_id, | 852 &instance_id, |
| 828 &message_id, | 853 &message_id, |
| 829 &auto_size_params, | 854 &auto_size_params, |
| 830 &resize_params); | 855 &resize_params); |
| 831 EXPECT_FALSE(auto_size_params.enable); | 856 EXPECT_FALSE(auto_size_params.enable); |
| 832 EXPECT_EQ(42, auto_size_params.min_size.width()); | 857 EXPECT_EQ(42, auto_size_params.min_size.width()); |
| 833 EXPECT_EQ(43, auto_size_params.min_size.height()); | 858 EXPECT_EQ(43, auto_size_params.min_size.height()); |
| 834 EXPECT_EQ(1337, auto_size_params.max_size.width()); | 859 EXPECT_EQ(1337, auto_size_params.max_size.width()); |
| 835 EXPECT_EQ(1338, auto_size_params.max_size.height()); | 860 EXPECT_EQ(1338, auto_size_params.max_size.height()); |
| 836 } | 861 } |
| 837 } | 862 } |
| 838 | 863 |
| 839 } // namespace content | 864 } // namespace content |
| OLD | NEW |