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

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

Issue 11046002: Browser Plugin: Fixed browser process crash on embedder reload. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Alternative behavior to match Istiaque's previous implementation of NavigateGuest Created 8 years, 2 months 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 d868e8f70820f021158778d0bed192bd9dc87623..9333812558533dc11c61ed8b686d706d432d56e5 100644
--- a/content/browser/browser_plugin/browser_plugin_host_browsertest.cc
+++ b/content/browser/browser_plugin/browser_plugin_host_browsertest.cc
@@ -795,5 +795,83 @@ IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, Renavigate) {
}
}
+// This tests verifies that reloading the embedder does not crash the browser
+// and that the guest is reset.
+IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, ReloadEmbedder) {
+ ASSERT_TRUE(test_server()->Start());
+ GURL test_url(test_server()->GetURL(
+ "files/browser_plugin_embedder.html"));
+ NavigateToURL(shell(), test_url);
+
+ WebContentsImpl* embedder_web_contents = static_cast<WebContentsImpl*>(
+ shell()->web_contents());
+ RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
+ embedder_web_contents->GetRenderViewHost());
+
+ rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16(
+ StringPrintf("SetSrc('%s');", kHTMLForGuest)));
+
+ // Wait to make sure embedder is created/attached to WebContents.
+ TestBrowserPluginHostFactory::GetInstance()->WaitForEmbedderCreation();
+
+ TestBrowserPluginEmbedder* test_embedder =
+ static_cast<TestBrowserPluginEmbedder*>(
+ embedder_web_contents->GetBrowserPluginEmbedder());
+ ASSERT_TRUE(test_embedder);
+ test_embedder->WaitForGuestAdded();
+
+ // Verify that we have exactly one guest.
+ const BrowserPluginEmbedder::ContainerInstanceMap& instance_map =
+ test_embedder->guest_web_contents_for_testing();
+ EXPECT_EQ(1u, instance_map.size());
+
+ WebContentsImpl* test_guest_web_contents = static_cast<WebContentsImpl*>(
+ instance_map.begin()->second);
+ TestBrowserPluginGuest* test_guest = static_cast<TestBrowserPluginGuest*>(
+ test_guest_web_contents->GetBrowserPluginGuest());
+
+ // Wait for the guest to send an UpdateRectMsg, meaning it is ready.
+ test_guest->WaitForUpdateRectMsg();
+
+ // Change the title of the page to 'ready'.
lazyboy 2012/10/02 18:48:33 The word 'ready' is a bit misleading, I was thinki
Fady Samuel 2012/10/02 19:39:46 Done.
+ {
+ const string16 expected_title = ASCIIToUTF16("ready");
+ content::TitleWatcher title_watcher(embedder_web_contents,
+ expected_title);
+
+ rvh->ExecuteJavascriptAndGetValue(string16(),
+ ASCIIToUTF16("MarkAsReady();"));
lazyboy 2012/10/02 18:48:33 SetTitle(str) is probably better than MarkAsReady(
Fady Samuel 2012/10/02 19:39:46 Done.
+
+ string16 actual_title = title_watcher.WaitAndGetTitle();
+ EXPECT_EQ(expected_title, actual_title);
+ }
+
+ // Reload the embedder page, and navigate the guest to verify that the browser
+ // process does not crash.
+ {
+ const string16 expected_title = ASCIIToUTF16("embedder");
+ content::TitleWatcher title_watcher(embedder_web_contents,
+ expected_title);
+
+ embedder_web_contents->GetController().Reload(false);
+ string16 actual_title = title_watcher.WaitAndGetTitle();
+ EXPECT_EQ(expected_title, actual_title);
+
+ embedder_web_contents->GetRenderViewHost()->
+ ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16(
+ StringPrintf("SetSrc('%s');", kHTMLForGuest)));
+
+ WebContentsImpl* test_guest_web_contents = static_cast<WebContentsImpl*>(
+ instance_map.begin()->second);
+ TestBrowserPluginGuest* test_guest = static_cast<TestBrowserPluginGuest*>(
+ test_guest_web_contents->GetBrowserPluginGuest());
+
+ // Wait for the guest to send an UpdateRectMsg, meaning it is ready.
+ test_guest->WaitForUpdateRectMsg();
+
lazyboy 2012/10/02 18:48:33 nit: remove whitespaces.
Fady Samuel 2012/10/02 20:00:07 Done.
+
+ }
+}
+
} // namespace content
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_embedder_helper.cc ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698