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 417d916e58fef857d1b339e0f8709cd935dda2f6..cffa9720499b6f73f88f624cabb181213aca1d71 100644 |
--- a/content/browser/browser_plugin/browser_plugin_host_browsertest.cc |
+++ b/content/browser/browser_plugin/browser_plugin_host_browsertest.cc |
@@ -494,6 +494,70 @@ IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, EmbedderVisibilityChanged) { |
test_guest()->WaitUntilHidden(); |
} |
+// Verifies that setting the src attribute prior to DOM attachment works, i.e. |
+// that the BrowserPlugin is created without having a renderer. |
+IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, PluginCreatedWithoutRenderer) { |
+ const char kEmbedderURL[] = "/browser_plugin_embedder_late_attach.html"; |
+ const char kGuestTitle[] = "late attach"; |
+ StartBrowserPluginTest( |
+ kEmbedderURL, GetHTMLForGuestWithTitle(kGuestTitle), true, std::string()); |
+ |
+ // Attach the browser plugin to the dom. We don't pass this to |
+ // StartBrowserPluginTest since we want it to execute after the src parameter |
+ // is set. |
+ ExecuteSyncJSFunction(shell()->web_contents()->GetRenderViewHost(), |
+ "attachPlugin();"); |
+ |
+ // Verify attachment with src attribute intact. |
+ EXPECT_FALSE( |
+ IsAttributeNull(shell()->web_contents()->GetRenderViewHost(), "src")); |
+ |
+ // Verify page loaded properly by checking title. |
+ const string16 expected_title = ASCIIToUTF16(kGuestTitle); |
+ EXPECT_EQ(expected_title, test_guest()->web_contents()->GetTitle()); |
+} |
+ |
+// Verifies that browser-plugin state survives setting "display = none", i.e. |
+// that the BrowserPlugin object is persisted. |
+IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, PluginPersists) { |
+ const char kEmbedderURL[] = "/browser_plugin_embedder.html"; |
+ StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, std::string()); |
+ |
+ const char kGuestTitle[] = "persisted"; |
+ const char kGuestTitleModified[] = "still persisted"; |
+ |
+ // Verify title is seen. |
+ const string16 expected_title = ASCIIToUTF16(kGuestTitle); |
+ { |
+ content::TitleWatcher title_watcher(test_guest()->web_contents(), |
+ expected_title); |
+ ExecuteSyncJSFunction( |
+ test_embedder()->web_contents()->GetRenderViewHost(), |
+ base::StringPrintf("SetSrc('%s');", |
+ GetHTMLForGuestWithTitle(kGuestTitle).c_str())); |
+ string16 actual_title = title_watcher.WaitAndGetTitle(); |
+ EXPECT_EQ(expected_title, actual_title); |
+ } |
+ |
+ // Set display none, verify title not seen. |
+ ExecuteSyncJSFunction( |
+ shell()->web_contents()->GetRenderViewHost(), |
+ "document.getElementById('plugin').style.display = 'none'"); |
+ |
+ ExecuteSyncJSFunction( |
+ test_guest()->web_contents()->GetRenderViewHost(), |
+ base::StringPrintf("document.title = '%s'", kGuestTitleModified)); |
+ |
+ // Clear display none. |
+ ExecuteSyncJSFunction( |
+ shell()->web_contents()->GetRenderViewHost(), |
+ "document.getElementById('plugin').style.display = 'block'"); |
+ |
+ // The guest title should have survived the display:none. |
+ const string16 expected_title_modified = ASCIIToUTF16(kGuestTitleModified); |
+ EXPECT_EQ(test_guest()->web_contents()->GetTitle(), expected_title_modified); |
+} |
+ |
// Verifies that installing/uninstalling touch-event handlers in the guest |
// plugin correctly updates the touch-event handling state in the embedder. |
IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, AcceptTouchEvents) { |