| Index: content/browser/browser_plugin/browser_plugin_host_browsertest.cc
|
| diff --git a/content/browser/browser_plugin/browser_plugin_host_browsertest.cc b/content/browser/browser_plugin/browser_plugin_host_browsertest.cc
|
| index fca49bb206433a07a735671f55ff626845bcd5e0..cb3a6f4beaf107ad75761282fe1b29ef6bd042d6 100644
|
| --- a/content/browser/browser_plugin/browser_plugin_host_browsertest.cc
|
| +++ b/content/browser/browser_plugin/browser_plugin_host_browsertest.cc
|
| @@ -74,6 +74,13 @@ const char kHTMLForGuestAcceptDrag[] =
|
| " ondrop=\"dropped();\">"
|
| "</textarea>"
|
| "</body></html>";
|
| +const char kHTMLForGuestWithSize[] =
|
| + "data:text/html,"
|
| + "<html>"
|
| + "<body style=\"margin: 0px;\">"
|
| + "<img style=\"width: 100%; height: 400px;\"/>"
|
| + "</body>"
|
| + "</html>";
|
|
|
| std::string GetHTMLForGuestWithTitle(const std::string& title) {
|
| return StringPrintf(kHTMLForGuestWithTitle, title.c_str());
|
| @@ -1136,4 +1143,60 @@ IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, FocusTracksEmbedder) {
|
| test_guest()->WaitForBlur();
|
| }
|
|
|
| +// This test verifies that if a browser plugin is in autosize mode before
|
| +// navigation then the guest starts auto-sized.
|
| +IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, AutoSizeBeforeNavigation) {
|
| + const char* kEmbedderURL = "files/browser_plugin_embedder.html";
|
| + const std::string embedder_code =
|
| + "document.getElementById('plugin').minWidth = 300;"
|
| + "document.getElementById('plugin').minHeight = 200;"
|
| + "document.getElementById('plugin').maxWidth = 600;"
|
| + "document.getElementById('plugin').maxHeight = 400;"
|
| + "document.getElementById('plugin').autoSize = true;";
|
| + StartBrowserPluginTest(
|
| + kEmbedderURL, kHTMLForGuestWithSize, true, embedder_code);
|
| + // Verify that the guest has been auto-sized.
|
| + test_guest()->WaitForViewSize(gfx::Size(300, 400));
|
| +}
|
| +
|
| +// This test verifies that enabling autosize resizes the guest and triggers
|
| +// a 'sizechanged' event.
|
| +IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, AutoSizeAfterNavigation) {
|
| + const char* kEmbedderURL = "files/browser_plugin_embedder.html";
|
| + StartBrowserPluginTest(
|
| + kEmbedderURL, kHTMLForGuestWithSize, true, "");
|
| + RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
|
| + test_embedder()->web_contents()->GetRenderViewHost());
|
| +
|
| + {
|
| + const string16 expected_title = ASCIIToUTF16("AutoSize(300, 400)");
|
| + content::TitleWatcher title_watcher(test_embedder()->web_contents(),
|
| + expected_title);
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
|
| + "document.getElementById('plugin').minWidth = 300;"
|
| + "document.getElementById('plugin').minHeight = 200;"
|
| + "document.getElementById('plugin').maxWidth = 600;"
|
| + "document.getElementById('plugin').maxHeight = 400;"
|
| + "document.getElementById('plugin').autoSize = true;"));
|
| + string16 actual_title = title_watcher.WaitAndGetTitle();
|
| + EXPECT_EQ(expected_title, actual_title);
|
| + }
|
| + {
|
| + // Change the minWidth and verify that it causes relayout.
|
| + const string16 expected_title = ASCIIToUTF16("AutoSize(350, 400)");
|
| + content::TitleWatcher title_watcher(test_embedder()->web_contents(),
|
| + expected_title);
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
|
| + "document.getElementById('plugin').minWidth = 350;"));
|
| + string16 actual_title = title_watcher.WaitAndGetTitle();
|
| + EXPECT_EQ(expected_title, actual_title);
|
| + }
|
| + {
|
| + // Turn off autoSize and verify that the guest resizes to fit the contaienr.
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
|
| + "document.getElementById('plugin').autoSize = false;"));
|
| + test_guest()->WaitForViewSize(gfx::Size(640, 480));
|
| + }
|
| +}
|
| +
|
| } // namespace content
|
|
|