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

Side by Side Diff: content/renderer/browser_plugin/browser_plugin_browsertest.cc

Issue 11361052: Browser Plugin: Implement autosize (Embedder-side code) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/path_service.h" 9 #include "base/path_service.h"
10 #include "content/common/browser_plugin_messages.h" 10 #include "content/common/browser_plugin_messages.h"
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 EXPECT_STREQ("", src_value.c_str()); 446 EXPECT_STREQ("", src_value.c_str());
447 447
448 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); 448 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'");
449 { 449 {
450 const IPC::Message* create_msg = 450 const IPC::Message* create_msg =
451 browser_plugin_manager()->sink().GetUniqueMessageMatching( 451 browser_plugin_manager()->sink().GetUniqueMessageMatching(
452 BrowserPluginHostMsg_CreateGuest::ID); 452 BrowserPluginHostMsg_CreateGuest::ID);
453 ASSERT_TRUE(create_msg); 453 ASSERT_TRUE(create_msg);
454 454
455 int create_instance_id; 455 int create_instance_id;
456 std::string storage_partition; 456 BrowserPluginHostMsg_CreateGuest_Params params;
457 bool persist_storage = true;
458 bool focused = false;
459 bool visible = false;
460 BrowserPluginHostMsg_CreateGuest::Read( 457 BrowserPluginHostMsg_CreateGuest::Read(
461 create_msg, 458 create_msg,
462 &create_instance_id, 459 &create_instance_id,
463 &storage_partition, 460 &params);
464 &persist_storage, 461 EXPECT_STREQ("storage", params.storage_partition_id.c_str());
465 &focused, 462 EXPECT_FALSE(params.persist_storage);
466 &visible);
467 EXPECT_STREQ("storage", storage_partition.c_str());
468 EXPECT_FALSE(persist_storage);
469 463
470 const IPC::Message* msg = 464 const IPC::Message* msg =
471 browser_plugin_manager()->sink().GetUniqueMessageMatching( 465 browser_plugin_manager()->sink().GetUniqueMessageMatching(
472 BrowserPluginHostMsg_NavigateGuest::ID); 466 BrowserPluginHostMsg_NavigateGuest::ID);
473 ASSERT_TRUE(msg); 467 ASSERT_TRUE(msg);
474 468
475 int instance_id; 469 int instance_id;
476 std::string src; 470 std::string src;
477 BrowserPluginHostMsg_ResizeGuest_Params resize_params; 471 BrowserPluginHostMsg_ResizeGuest_Params resize_params;
478 BrowserPluginHostMsg_NavigateGuest::Read( 472 BrowserPluginHostMsg_NavigateGuest::Read(
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 ExecuteJavaScript(kAddEventListener); 627 ExecuteJavaScript(kAddEventListener);
634 628
635 // Pretend that the guest has crashed. 629 // Pretend that the guest has crashed.
636 browser_plugin->GuestGone(0, base::TERMINATION_STATUS_PROCESS_WAS_KILLED); 630 browser_plugin->GuestGone(0, base::TERMINATION_STATUS_PROCESS_WAS_KILLED);
637 631
638 ProcessPendingMessages(); 632 ProcessPendingMessages();
639 633
640 EXPECT_EQ(NULL, browser_plugin_manager()->GetBrowserPlugin(instance_id)); 634 EXPECT_EQ(NULL, browser_plugin_manager()->GetBrowserPlugin(instance_id));
641 } 635 }
642 636
637 TEST_F(BrowserPluginTest, AutoSizeAttributes) {
638 std::string html = StringPrintf(kHTMLForSourcelessPluginObject,
639 content::kBrowserPluginMimeType);
640 LoadHTML(html.c_str());
641 const char* kSetAutoSizeParametersAndNavigate =
642 "var browserplugin = document.getElementById('browserplugin');"
643 "browserplugin.autoSize = true;"
644 "browserplugin.minWidth = 42;"
645 "browserplugin.minHeight = 43;"
646 "browserplugin.maxWidth = 1337;"
647 "browserplugin.maxHeight = 1338;"
648 "browserplugin.src = 'foobar';";
649 const char* kDisableAutoSize =
650 "document.getElementById('browserplugin').autoSize = false;";
651
652 // Set some autosize parameters before navigating then navigate.
653 // Verify that the BrowserPluginHostMsg_CreateGuest message contains
654 // the correct autosize parameters.
655 ExecuteJavaScript(kSetAutoSizeParametersAndNavigate);
656 ProcessPendingMessages();
657 {
658 const IPC::Message* create_msg =
659 browser_plugin_manager()->sink().GetUniqueMessageMatching(
660 BrowserPluginHostMsg_CreateGuest::ID);
661 ASSERT_TRUE(create_msg);
662
663 int create_instance_id;
664 BrowserPluginHostMsg_CreateGuest_Params params;
665 BrowserPluginHostMsg_CreateGuest::Read(
666 create_msg,
667 &create_instance_id,
668 &params);
669 EXPECT_TRUE(params.autosize.enable);
670 EXPECT_EQ(42, params.autosize.minwidth);
671 EXPECT_EQ(43, params.autosize.minheight);
672 EXPECT_EQ(1337, params.autosize.maxwidth);
673 EXPECT_EQ(1338, params.autosize.maxheight);
674 }
675 // Disable autosize and verify that the BrowserPlugin issues a
676 // BrowserPluginHostMsg_SetAutoSize with the change.
677 ExecuteJavaScript(kDisableAutoSize);
678 ProcessPendingMessages();
679 {
680 const IPC::Message* autosize_msg =
681 browser_plugin_manager()->sink().GetUniqueMessageMatching(
682 BrowserPluginHostMsg_SetAutoSize::ID);
683 ASSERT_TRUE(autosize_msg);
684
685 int instance_id;
686 BrowserPluginHostMsg_AutoSize_Params params;
687 BrowserPluginHostMsg_SetAutoSize::Read(
688 autosize_msg,
689 &instance_id,
690 &params);
691 EXPECT_FALSE(params.enable);
692 EXPECT_EQ(42, params.minwidth);
693 EXPECT_EQ(43, params.minheight);
694 EXPECT_EQ(1337, params.maxwidth);
695 EXPECT_EQ(1338, params.maxheight);
696 }
697 }
698
643 } // namespace content 699 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698