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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 117 } |
118 | 118 |
119 // This test verifies that an initial resize occurs when we instantiate the | 119 // This test verifies that an initial resize occurs when we instantiate the |
120 // browser plugin. This test also verifies that the browser plugin is waiting | 120 // browser plugin. This test also verifies that the browser plugin is waiting |
121 // for a BrowserPluginMsg_UpdateRect in response. We issue an UpdateRect, and | 121 // for a BrowserPluginMsg_UpdateRect in response. We issue an UpdateRect, and |
122 // we observe an UpdateRect_ACK, with the |pending_damage_buffer_| reset, | 122 // we observe an UpdateRect_ACK, with the |pending_damage_buffer_| reset, |
123 // indiciating that the BrowserPlugin is not waiting for any more UpdateRects to | 123 // indiciating that the BrowserPlugin is not waiting for any more UpdateRects to |
124 // satisfy its resize request. | 124 // satisfy its resize request. |
125 TEST_F(BrowserPluginTest, InitialResize) { | 125 TEST_F(BrowserPluginTest, InitialResize) { |
126 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 126 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
127 // Verify that the information based on ResizeGuest is correct, and | 127 // Verify that the information in CreateGuest is correct. |
128 // use its TransportDIB::Id to paint. | |
129 int instance_id = 0; | 128 int instance_id = 0; |
130 { | 129 { |
131 const IPC::Message* msg = | 130 const IPC::Message* msg = |
132 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 131 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
133 BrowserPluginHostMsg_ResizeGuest::ID); | 132 BrowserPluginHostMsg_CreateGuest::ID); |
134 ASSERT_TRUE(msg); | 133 ASSERT_TRUE(msg); |
135 BrowserPluginHostMsg_ResizeGuest_Params params; | 134 int instance_id = 0; |
136 BrowserPluginHostMsg_ResizeGuest::Read(msg, &instance_id, ¶ms); | 135 BrowserPluginHostMsg_CreateGuest_Params params; |
137 EXPECT_EQ(640, params.view_size.width()); | 136 BrowserPluginHostMsg_CreateGuest::Read(msg, &instance_id, ¶ms); |
138 EXPECT_EQ(480, params.view_size.height()); | 137 EXPECT_EQ(640, params.resize_guest_params.view_size.width()); |
| 138 EXPECT_EQ(480, params.resize_guest_params.view_size.height()); |
139 } | 139 } |
140 | 140 |
141 MockBrowserPlugin* browser_plugin = | 141 MockBrowserPlugin* browser_plugin = |
142 static_cast<MockBrowserPlugin*>( | 142 static_cast<MockBrowserPlugin*>( |
143 browser_plugin_manager()->GetBrowserPlugin(instance_id)); | 143 browser_plugin_manager()->GetBrowserPlugin(instance_id)); |
144 ASSERT_TRUE(browser_plugin); | 144 ASSERT_TRUE(browser_plugin); |
145 // Now the browser plugin is expecting a UpdateRect resize. | 145 // Now the browser plugin is expecting a UpdateRect resize. |
146 EXPECT_TRUE(browser_plugin->pending_damage_buffer_.get()); | 146 EXPECT_TRUE(browser_plugin->pending_damage_buffer_.get()); |
147 | 147 |
148 // Send the BrowserPlugin an UpdateRect equal to its container size with | 148 // Send the BrowserPlugin an UpdateRect equal to its container size with |
(...skipping 10 matching lines...) Expand all Loading... |
159 EXPECT_FALSE(browser_plugin->pending_damage_buffer_.get()); | 159 EXPECT_FALSE(browser_plugin->pending_damage_buffer_.get()); |
160 } | 160 } |
161 | 161 |
162 // Verify that the src attribute on the browser plugin works as expected. | 162 // Verify that the src attribute on the browser plugin works as expected. |
163 TEST_F(BrowserPluginTest, SrcAttribute) { | 163 TEST_F(BrowserPluginTest, SrcAttribute) { |
164 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 164 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
165 // Verify that we're reporting the correct URL to navigate to based on the | 165 // Verify that we're reporting the correct URL to navigate to based on the |
166 // src attribute. | 166 // src attribute. |
167 { | 167 { |
168 // Ensure we get a CreateGuest on the initial navigation. | 168 // Ensure we get a CreateGuest on the initial navigation. |
169 const IPC::Message* create_msg = | |
170 browser_plugin_manager()->sink().GetUniqueMessageMatching( | |
171 BrowserPluginHostMsg_CreateGuest::ID); | |
172 ASSERT_TRUE(create_msg); | |
173 | |
174 const IPC::Message* msg = | 169 const IPC::Message* msg = |
175 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 170 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
176 BrowserPluginHostMsg_NavigateGuest::ID); | 171 BrowserPluginHostMsg_CreateGuest::ID); |
177 ASSERT_TRUE(msg); | 172 ASSERT_TRUE(msg); |
178 | 173 |
179 int instance_id = 0; | 174 int instance_id = 0; |
180 std::string src; | 175 BrowserPluginHostMsg_CreateGuest_Params params; |
181 BrowserPluginHostMsg_NavigateGuest::Read(msg, &instance_id, &src); | 176 BrowserPluginHostMsg_CreateGuest::Read(msg, &instance_id, ¶ms); |
182 EXPECT_EQ("foo", src); | 177 EXPECT_EQ("foo", params.src); |
183 } | 178 } |
184 | 179 |
185 browser_plugin_manager()->sink().ClearMessages(); | 180 browser_plugin_manager()->sink().ClearMessages(); |
186 // Navigate to bar and observe the associated | 181 // Navigate to bar and observe the associated |
187 // BrowserPluginHostMsg_NavigateGuest message. | 182 // BrowserPluginHostMsg_NavigateGuest message. |
188 // Verify that the src attribute is updated as well. | 183 // Verify that the src attribute is updated as well. |
189 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); | 184 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); |
190 { | 185 { |
191 // Verify that we do not get a CreateGuest on subsequent navigations. | 186 // Verify that we do not get a CreateGuest on subsequent navigations. |
192 const IPC::Message* create_msg = | 187 const IPC::Message* create_msg = |
193 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 188 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
194 BrowserPluginHostMsg_CreateGuest::ID); | 189 BrowserPluginHostMsg_CreateGuest::ID); |
195 ASSERT_FALSE(create_msg); | 190 ASSERT_FALSE(create_msg); |
196 | 191 |
197 const IPC::Message* msg = | 192 const IPC::Message* msg = |
198 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 193 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
199 BrowserPluginHostMsg_NavigateGuest::ID); | 194 BrowserPluginHostMsg_NavigateGuest::ID); |
200 ASSERT_TRUE(msg); | 195 ASSERT_TRUE(msg); |
201 | 196 |
202 int instance_id = 0; | 197 int instance_id = 0; |
203 std::string src; | 198 std::string src; |
204 BrowserPluginHostMsg_NavigateGuest::Read(msg, &instance_id, &src); | 199 BrowserPluginHostMsg_NavigateGuest::Read(msg, &instance_id, &src); |
205 EXPECT_EQ("bar", src); | 200 EXPECT_EQ("bar", src); |
206 std::string src_value = | 201 std::string src_value = |
207 ExecuteScriptAndReturnString( | 202 ExecuteScriptAndReturnString( |
208 "document.getElementById('browserplugin').src"); | 203 "document.getElementById('browserplugin').src"); |
209 EXPECT_EQ("bar", src_value); | 204 EXPECT_EQ("bar", src_value); |
210 } | 205 } |
211 } | 206 } |
212 | 207 |
213 TEST_F(BrowserPluginTest, ResizeFlowControl) { | 208 TEST_F(BrowserPluginTest, ResizeFlowControl) { |
214 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 209 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
215 int instance_id = 0; | 210 int instance_id = 0; |
216 { | 211 { |
217 // Ensure we get a NavigateGuest on the initial navigation and grab the | 212 // Ensure we get a CreateGuest on the initial navigation and grab the |
218 // BrowserPlugin's instance_id from there. | 213 // BrowserPlugin's instance_id from there. |
219 std::string src; | 214 const IPC::Message* msg = |
220 const IPC::Message* nav_msg = | 215 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
221 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 216 BrowserPluginHostMsg_CreateGuest::ID); |
222 BrowserPluginHostMsg_NavigateGuest::ID); | 217 ASSERT_TRUE(msg); |
223 ASSERT_TRUE(nav_msg); | 218 BrowserPluginHostMsg_CreateGuest_Params params; |
224 BrowserPluginHostMsg_NavigateGuest::Read(nav_msg, &instance_id, &src); | 219 BrowserPluginHostMsg_CreateGuest::Read(msg, &instance_id, ¶ms); |
225 } | 220 } |
226 MockBrowserPlugin* browser_plugin = | 221 MockBrowserPlugin* browser_plugin = |
227 static_cast<MockBrowserPlugin*>( | 222 static_cast<MockBrowserPlugin*>( |
228 browser_plugin_manager()->GetBrowserPlugin(instance_id)); | 223 browser_plugin_manager()->GetBrowserPlugin(instance_id)); |
229 ASSERT_TRUE(browser_plugin); | 224 ASSERT_TRUE(browser_plugin); |
230 EXPECT_TRUE(browser_plugin->pending_damage_buffer_.get()); | 225 EXPECT_TRUE(browser_plugin->pending_damage_buffer_.get()); |
231 // Send an UpdateRect to the BrowserPlugin to make it use the pending damage | 226 // Send an UpdateRect to the BrowserPlugin to make it use the pending damage |
232 // buffer. | 227 // buffer. |
233 { | 228 { |
234 // We send a stale UpdateRect to the BrowserPlugin. | 229 // We send a stale UpdateRect to the BrowserPlugin. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 browser_plugin->OnMessageReceived(msg); | 297 browser_plugin->OnMessageReceived(msg); |
303 // The BrowserPlugin has finally received an UpdateRect that satisifes | 298 // The BrowserPlugin has finally received an UpdateRect that satisifes |
304 // its current size, and so it is happy. | 299 // its current size, and so it is happy. |
305 EXPECT_FALSE(browser_plugin->pending_damage_buffer_.get()); | 300 EXPECT_FALSE(browser_plugin->pending_damage_buffer_.get()); |
306 } | 301 } |
307 } | 302 } |
308 | 303 |
309 TEST_F(BrowserPluginTest, GuestCrash) { | 304 TEST_F(BrowserPluginTest, GuestCrash) { |
310 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 305 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
311 | 306 |
312 // Grab the BrowserPlugin's instance ID from its resize message. | 307 // Grab the BrowserPlugin's instance ID from its CreateGuest message. |
313 int instance_id = 0; | 308 int instance_id = 0; |
314 { | 309 { |
315 const IPC::Message* msg = | 310 const IPC::Message* msg = |
316 browser_plugin_manager()->sink().GetFirstMessageMatching( | 311 browser_plugin_manager()->sink().GetFirstMessageMatching( |
317 BrowserPluginHostMsg_ResizeGuest::ID); | 312 BrowserPluginHostMsg_CreateGuest::ID); |
318 ASSERT_TRUE(msg); | 313 ASSERT_TRUE(msg); |
319 BrowserPluginHostMsg_ResizeGuest_Params params; | 314 BrowserPluginHostMsg_CreateGuest_Params params; |
320 BrowserPluginHostMsg_ResizeGuest::Read(msg, &instance_id, ¶ms); | 315 BrowserPluginHostMsg_CreateGuest::Read(msg, &instance_id, ¶ms); |
321 } | 316 } |
322 MockBrowserPlugin* browser_plugin = | 317 MockBrowserPlugin* browser_plugin = |
323 static_cast<MockBrowserPlugin*>( | 318 static_cast<MockBrowserPlugin*>( |
324 browser_plugin_manager()->GetBrowserPlugin(instance_id)); | 319 browser_plugin_manager()->GetBrowserPlugin(instance_id)); |
325 ASSERT_TRUE(browser_plugin); | 320 ASSERT_TRUE(browser_plugin); |
326 | 321 |
327 WebKit::WebCursorInfo cursor_info; | 322 WebKit::WebCursorInfo cursor_info; |
328 // Send an event and verify that the event is deported. | 323 // Send an event and verify that the event is deported. |
329 browser_plugin->handleInputEvent(WebKit::WebMouseEvent(), | 324 browser_plugin->handleInputEvent(WebKit::WebMouseEvent(), |
330 cursor_info); | 325 cursor_info); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 const char* kGetSrc = | 391 const char* kGetSrc = |
397 "document.getElementById('browserplugin').src"; | 392 "document.getElementById('browserplugin').src"; |
398 const char* kGoogleURL = "http://www.google.com/"; | 393 const char* kGoogleURL = "http://www.google.com/"; |
399 const char* kGoogleNewsURL = "http://news.google.com/"; | 394 const char* kGoogleNewsURL = "http://news.google.com/"; |
400 | 395 |
401 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 396 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
402 ExecuteJavaScript(kAddEventListener); | 397 ExecuteJavaScript(kAddEventListener); |
403 // Grab the BrowserPlugin's instance ID from its resize message. | 398 // Grab the BrowserPlugin's instance ID from its resize message. |
404 const IPC::Message* msg = | 399 const IPC::Message* msg = |
405 browser_plugin_manager()->sink().GetFirstMessageMatching( | 400 browser_plugin_manager()->sink().GetFirstMessageMatching( |
406 BrowserPluginHostMsg_ResizeGuest::ID); | 401 BrowserPluginHostMsg_CreateGuest::ID); |
407 ASSERT_TRUE(msg); | 402 ASSERT_TRUE(msg); |
408 int instance_id = 0; | 403 int instance_id = 0; |
409 BrowserPluginHostMsg_ResizeGuest_Params params; | 404 BrowserPluginHostMsg_CreateGuest_Params params; |
410 BrowserPluginHostMsg_ResizeGuest::Read(msg, &instance_id, ¶ms); | 405 BrowserPluginHostMsg_CreateGuest::Read(msg, &instance_id, ¶ms); |
411 | 406 |
412 MockBrowserPlugin* browser_plugin = | 407 MockBrowserPlugin* browser_plugin = |
413 static_cast<MockBrowserPlugin*>( | 408 static_cast<MockBrowserPlugin*>( |
414 browser_plugin_manager()->GetBrowserPlugin(instance_id)); | 409 browser_plugin_manager()->GetBrowserPlugin(instance_id)); |
415 ASSERT_TRUE(browser_plugin); | 410 ASSERT_TRUE(browser_plugin); |
416 | 411 |
417 { | 412 { |
418 BrowserPluginMsg_LoadCommit_Params navigate_params; | 413 BrowserPluginMsg_LoadCommit_Params navigate_params; |
419 navigate_params.is_top_level = true; | 414 navigate_params.is_top_level = true; |
420 navigate_params.url = GURL(kGoogleURL); | 415 navigate_params.url = GURL(kGoogleURL); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 "document.getElementById('browserplugin').src")); | 520 "document.getElementById('browserplugin').src")); |
526 } | 521 } |
527 | 522 |
528 // Verify that the BrowserPlugin accepts changes to its src attribue after | 523 // Verify that the BrowserPlugin accepts changes to its src attribue after |
529 // setting the partition to a valid value. | 524 // setting the partition to a valid value. |
530 ExecuteJavaScript( | 525 ExecuteJavaScript( |
531 "document.getElementById('browserplugin').partition = 'persist:foo'"); | 526 "document.getElementById('browserplugin').partition = 'persist:foo'"); |
532 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); | 527 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); |
533 EXPECT_EQ("bar", ExecuteScriptAndReturnString( | 528 EXPECT_EQ("bar", ExecuteScriptAndReturnString( |
534 "document.getElementById('browserplugin').src")); | 529 "document.getElementById('browserplugin').src")); |
| 530 ProcessPendingMessages(); |
535 // Verify that the BrowserPlugin does not 'deadlock': it can recover from | 531 // Verify that the BrowserPlugin does not 'deadlock': it can recover from |
536 // the partition ID error state. | 532 // the partition ID error state. |
537 { | 533 { |
538 ExecuteJavaScript( | 534 ExecuteJavaScript( |
539 "try {" | 535 "try {" |
540 " document.getElementById('browserplugin').partition = 'persist:1337';" | 536 " document.getElementById('browserplugin').partition = 'persist:1337';" |
541 " document.title = 'success';" | 537 " document.title = 'success';" |
542 "} catch (e) { document.title = e.message; }"); | 538 "} catch (e) { document.title = e.message; }"); |
543 std::string title = ExecuteScriptAndReturnString("document.title"); | 539 std::string title = ExecuteScriptAndReturnString("document.title"); |
544 EXPECT_STREQ( | 540 EXPECT_STREQ( |
(...skipping 16 matching lines...) Expand all Loading... |
561 "document.getElementById('browserplugin').partition = 'storage'"); | 557 "document.getElementById('browserplugin').partition = 'storage'"); |
562 std::string partition_value = ExecuteScriptAndReturnString( | 558 std::string partition_value = ExecuteScriptAndReturnString( |
563 "document.getElementById('browserplugin').partition"); | 559 "document.getElementById('browserplugin').partition"); |
564 EXPECT_STREQ("storage", partition_value.c_str()); | 560 EXPECT_STREQ("storage", partition_value.c_str()); |
565 | 561 |
566 std::string src_value = ExecuteScriptAndReturnString( | 562 std::string src_value = ExecuteScriptAndReturnString( |
567 "document.getElementById('browserplugin').src"); | 563 "document.getElementById('browserplugin').src"); |
568 EXPECT_STREQ("", src_value.c_str()); | 564 EXPECT_STREQ("", src_value.c_str()); |
569 | 565 |
570 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); | 566 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); |
| 567 ProcessPendingMessages(); |
571 { | 568 { |
572 const IPC::Message* create_msg = | 569 const IPC::Message* create_msg = |
573 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 570 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
574 BrowserPluginHostMsg_CreateGuest::ID); | 571 BrowserPluginHostMsg_CreateGuest::ID); |
575 ASSERT_TRUE(create_msg); | 572 ASSERT_TRUE(create_msg); |
576 | 573 |
577 int create_instance_id = 0; | 574 int create_instance_id = 0; |
578 BrowserPluginHostMsg_CreateGuest_Params params; | 575 BrowserPluginHostMsg_CreateGuest_Params params; |
579 BrowserPluginHostMsg_CreateGuest::Read( | 576 BrowserPluginHostMsg_CreateGuest::Read( |
580 create_msg, | 577 create_msg, |
581 &create_instance_id, | 578 &create_instance_id, |
582 ¶ms); | 579 ¶ms); |
583 EXPECT_STREQ("storage", params.storage_partition_id.c_str()); | 580 EXPECT_STREQ("storage", params.storage_partition_id.c_str()); |
584 EXPECT_FALSE(params.persist_storage); | 581 EXPECT_FALSE(params.persist_storage); |
585 | 582 EXPECT_STREQ("bar", params.src.c_str()); |
586 const IPC::Message* msg = | |
587 browser_plugin_manager()->sink().GetUniqueMessageMatching( | |
588 BrowserPluginHostMsg_NavigateGuest::ID); | |
589 ASSERT_TRUE(msg); | |
590 | |
591 int instance_id = 0; | |
592 std::string src; | |
593 BrowserPluginHostMsg_NavigateGuest::Read(msg, &instance_id, &src); | |
594 EXPECT_STREQ("bar", src.c_str()); | |
595 EXPECT_EQ(create_instance_id, instance_id); | |
596 } | 583 } |
597 | 584 |
598 // Setting the partition should throw an exception and the value should not | 585 // Setting the partition should throw an exception and the value should not |
599 // change. | 586 // change. |
600 ExecuteJavaScript( | 587 ExecuteJavaScript( |
601 "try {" | 588 "try {" |
602 " document.getElementById('browserplugin').partition = 'someid';" | 589 " document.getElementById('browserplugin').partition = 'someid';" |
603 " document.title = 'success';" | 590 " document.title = 'success';" |
604 "} catch (e) { document.title = e.message; }"); | 591 "} catch (e) { document.title = e.message; }"); |
605 | 592 |
(...skipping 19 matching lines...) Expand all Loading... |
625 "}" | 612 "}" |
626 "document.getElementById('browserplugin')." | 613 "document.getElementById('browserplugin')." |
627 " addEventListener('-internal-loadcommit', nav);"; | 614 " addEventListener('-internal-loadcommit', nav);"; |
628 const char* kGoogleURL = "http://www.google.com/"; | 615 const char* kGoogleURL = "http://www.google.com/"; |
629 const char* kGoogleNewsURL = "http://news.google.com/"; | 616 const char* kGoogleNewsURL = "http://news.google.com/"; |
630 const char* kGetProcessID = | 617 const char* kGetProcessID = |
631 "document.getElementById('browserplugin').getProcessId()"; | 618 "document.getElementById('browserplugin').getProcessId()"; |
632 | 619 |
633 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 620 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
634 ExecuteJavaScript(kAddEventListener); | 621 ExecuteJavaScript(kAddEventListener); |
635 // Grab the BrowserPlugin's instance ID from its resize message. | 622 // Grab the BrowserPlugin's instance ID from its CreateGuest message. |
636 const IPC::Message* msg = | 623 const IPC::Message* msg = |
637 browser_plugin_manager()->sink().GetFirstMessageMatching( | 624 browser_plugin_manager()->sink().GetFirstMessageMatching( |
638 BrowserPluginHostMsg_ResizeGuest::ID); | 625 BrowserPluginHostMsg_CreateGuest::ID); |
639 ASSERT_TRUE(msg); | 626 ASSERT_TRUE(msg); |
640 int instance_id = 0; | 627 int instance_id = 0; |
641 BrowserPluginHostMsg_ResizeGuest_Params params; | 628 BrowserPluginHostMsg_CreateGuest_Params params; |
642 BrowserPluginHostMsg_ResizeGuest::Read(msg, &instance_id, ¶ms); | 629 BrowserPluginHostMsg_CreateGuest::Read(msg, &instance_id, ¶ms); |
643 | 630 |
644 MockBrowserPlugin* browser_plugin = | 631 MockBrowserPlugin* browser_plugin = |
645 static_cast<MockBrowserPlugin*>( | 632 static_cast<MockBrowserPlugin*>( |
646 browser_plugin_manager()->GetBrowserPlugin(instance_id)); | 633 browser_plugin_manager()->GetBrowserPlugin(instance_id)); |
647 ASSERT_TRUE(browser_plugin); | 634 ASSERT_TRUE(browser_plugin); |
648 | 635 |
649 { | 636 { |
650 BrowserPluginMsg_LoadCommit_Params navigate_params; | 637 BrowserPluginMsg_LoadCommit_Params navigate_params; |
651 navigate_params.url = GURL(kGoogleURL); | 638 navigate_params.url = GURL(kGoogleURL); |
652 navigate_params.process_id = 1337; | 639 navigate_params.process_id = 1337; |
(...skipping 29 matching lines...) Expand all Loading... |
682 "document.getElementById('browserplugin')." | 669 "document.getElementById('browserplugin')." |
683 " addEventListener('-internal-loadcommit', nava);" | 670 " addEventListener('-internal-loadcommit', nava);" |
684 "document.getElementById('browserplugin')." | 671 "document.getElementById('browserplugin')." |
685 " addEventListener('-internal-loadcommit', navb);"; | 672 " addEventListener('-internal-loadcommit', navb);"; |
686 const char* kGoogleURL = "http://www.google.com/"; | 673 const char* kGoogleURL = "http://www.google.com/"; |
687 const char* kGetProcessID = | 674 const char* kGetProcessID = |
688 "document.getElementById('browserplugin').getProcessId()"; | 675 "document.getElementById('browserplugin').getProcessId()"; |
689 | 676 |
690 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 677 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
691 ExecuteJavaScript(kAddEventListener); | 678 ExecuteJavaScript(kAddEventListener); |
692 // Grab the BrowserPlugin's instance ID from its resize message. | 679 // Grab the BrowserPlugin's instance ID from its CreateGuest message. |
693 const IPC::Message* msg = | 680 const IPC::Message* msg = |
694 browser_plugin_manager()->sink().GetFirstMessageMatching( | 681 browser_plugin_manager()->sink().GetFirstMessageMatching( |
695 BrowserPluginHostMsg_ResizeGuest::ID); | 682 BrowserPluginHostMsg_CreateGuest::ID); |
696 ASSERT_TRUE(msg); | 683 ASSERT_TRUE(msg); |
697 int instance_id = 0; | 684 int instance_id = 0; |
698 BrowserPluginHostMsg_ResizeGuest_Params params; | 685 BrowserPluginHostMsg_CreateGuest_Params params; |
699 BrowserPluginHostMsg_ResizeGuest::Read(msg, &instance_id, ¶ms); | 686 BrowserPluginHostMsg_CreateGuest::Read(msg, &instance_id, ¶ms); |
700 | 687 |
701 MockBrowserPlugin* browser_plugin = | 688 MockBrowserPlugin* browser_plugin = |
702 static_cast<MockBrowserPlugin*>( | 689 static_cast<MockBrowserPlugin*>( |
703 browser_plugin_manager()->GetBrowserPlugin(instance_id)); | 690 browser_plugin_manager()->GetBrowserPlugin(instance_id)); |
704 ASSERT_TRUE(browser_plugin); | 691 ASSERT_TRUE(browser_plugin); |
705 | 692 |
706 { | 693 { |
707 BrowserPluginMsg_LoadCommit_Params navigate_params; | 694 BrowserPluginMsg_LoadCommit_Params navigate_params; |
708 navigate_params.url = GURL(kGoogleURL); | 695 navigate_params.url = GURL(kGoogleURL); |
709 navigate_params.process_id = 1337; | 696 navigate_params.process_id = 1337; |
710 BrowserPluginMsg_LoadCommit msg(0, instance_id, navigate_params); | 697 BrowserPluginMsg_LoadCommit msg(0, instance_id, navigate_params); |
711 browser_plugin->OnMessageReceived(msg); | 698 browser_plugin->OnMessageReceived(msg); |
712 EXPECT_EQ(2, ExecuteScriptAndReturnInt("count")); | 699 EXPECT_EQ(2, ExecuteScriptAndReturnInt("count")); |
713 EXPECT_EQ(1337, ExecuteScriptAndReturnInt(kGetProcessID)); | 700 EXPECT_EQ(1337, ExecuteScriptAndReturnInt(kGetProcessID)); |
714 } | 701 } |
715 } | 702 } |
716 | 703 |
717 TEST_F(BrowserPluginTest, RemoveBrowserPluginOnExit) { | 704 TEST_F(BrowserPluginTest, RemoveBrowserPluginOnExit) { |
718 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 705 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
719 | 706 |
720 // Grab the BrowserPlugin's instance ID from its resize message. | 707 // Grab the BrowserPlugin's instance ID from its CreateGuest message. |
721 int instance_id = 0; | 708 int instance_id = 0; |
722 { | 709 { |
723 const IPC::Message* msg = | 710 const IPC::Message* msg = |
724 browser_plugin_manager()->sink().GetFirstMessageMatching( | 711 browser_plugin_manager()->sink().GetFirstMessageMatching( |
725 BrowserPluginHostMsg_ResizeGuest::ID); | 712 BrowserPluginHostMsg_CreateGuest::ID); |
726 ASSERT_TRUE(msg); | 713 ASSERT_TRUE(msg); |
727 BrowserPluginHostMsg_ResizeGuest_Params params; | 714 BrowserPluginHostMsg_CreateGuest_Params params; |
728 BrowserPluginHostMsg_ResizeGuest::Read(msg, &instance_id, ¶ms); | 715 BrowserPluginHostMsg_CreateGuest::Read(msg, &instance_id, ¶ms); |
729 } | 716 } |
730 | 717 |
731 MockBrowserPlugin* browser_plugin = | 718 MockBrowserPlugin* browser_plugin = |
732 static_cast<MockBrowserPlugin*>( | 719 static_cast<MockBrowserPlugin*>( |
733 browser_plugin_manager()->GetBrowserPlugin(instance_id)); | 720 browser_plugin_manager()->GetBrowserPlugin(instance_id)); |
734 ASSERT_TRUE(browser_plugin); | 721 ASSERT_TRUE(browser_plugin); |
735 | 722 |
736 const char* kAddEventListener = | 723 const char* kAddEventListener = |
737 "function exitListener(e) {" | 724 "function exitListener(e) {" |
738 " if (JSON.parse(e.detail).reason == 'killed') {" | 725 " if (JSON.parse(e.detail).reason == 'killed') {" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 &resize_params); | 824 &resize_params); |
838 EXPECT_FALSE(auto_size_params.enable); | 825 EXPECT_FALSE(auto_size_params.enable); |
839 EXPECT_EQ(42, auto_size_params.min_size.width()); | 826 EXPECT_EQ(42, auto_size_params.min_size.width()); |
840 EXPECT_EQ(43, auto_size_params.min_size.height()); | 827 EXPECT_EQ(43, auto_size_params.min_size.height()); |
841 EXPECT_EQ(1337, auto_size_params.max_size.width()); | 828 EXPECT_EQ(1337, auto_size_params.max_size.width()); |
842 EXPECT_EQ(1338, auto_size_params.max_size.height()); | 829 EXPECT_EQ(1338, auto_size_params.max_size.height()); |
843 } | 830 } |
844 } | 831 } |
845 | 832 |
846 } // namespace content | 833 } // namespace content |
OLD | NEW |