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

Unified Diff: content/browser/browser_plugin/browser_plugin_host_browsertest.cc

Issue 11360106: Browser Plugin: Implement AutoSize (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with ToT 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698