Chromium Code Reviews| 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 053a97f8f27b6b1633afa299971ff8b5ecef802c..abf44c47ba020758dc9e3e0b0632cc075e199d17 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()); |
| @@ -1106,4 +1113,42 @@ IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, FocusPreservation) { |
| } |
| } |
| +// 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;")); |
|
lazyboy
2012/11/07 07:39:09
Also how about adding tests that doesn't specify a
Fady Samuel
2012/11/07 20:21:12
Added a couple of subtests.
|
| + string16 actual_title = title_watcher.WaitAndGetTitle(); |
| + EXPECT_EQ(expected_title, actual_title); |
| +} |
| + |
| } // namespace content |