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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/memory/singleton.h" 5 #include "base/memory/singleton.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "base/test/test_timeouts.h" 7 #include "base/test/test_timeouts.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "content/browser/browser_plugin/browser_plugin_guest.h" 9 #include "content/browser/browser_plugin/browser_plugin_guest.h"
10 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" 10 #include "content/browser/browser_plugin/browser_plugin_host_factory.h"
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 content::TitleWatcher title_watcher(test_guest_web_contents, 788 content::TitleWatcher title_watcher(test_guest_web_contents,
789 expected_title); 789 expected_title);
790 790
791 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("Go(-2);")); 791 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("Go(-2);"));
792 792
793 string16 actual_title = title_watcher.WaitAndGetTitle(); 793 string16 actual_title = title_watcher.WaitAndGetTitle();
794 EXPECT_EQ(expected_title, actual_title); 794 EXPECT_EQ(expected_title, actual_title);
795 } 795 }
796 } 796 }
797 797
798 // This tests verifies that reloading the embedder does not crash the browser
799 // and that the guest is reset.
800 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, ReloadEmbedder) {
801 ASSERT_TRUE(test_server()->Start());
802 GURL test_url(test_server()->GetURL(
803 "files/browser_plugin_embedder.html"));
804 NavigateToURL(shell(), test_url);
805
806 WebContentsImpl* embedder_web_contents = static_cast<WebContentsImpl*>(
807 shell()->web_contents());
808 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
809 embedder_web_contents->GetRenderViewHost());
810
811 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16(
812 StringPrintf("SetSrc('%s');", kHTMLForGuest)));
813
814 // Wait to make sure embedder is created/attached to WebContents.
815 TestBrowserPluginHostFactory::GetInstance()->WaitForEmbedderCreation();
816
817 TestBrowserPluginEmbedder* test_embedder =
818 static_cast<TestBrowserPluginEmbedder*>(
819 embedder_web_contents->GetBrowserPluginEmbedder());
820 ASSERT_TRUE(test_embedder);
821 test_embedder->WaitForGuestAdded();
822
823 // Verify that we have exactly one guest.
824 const BrowserPluginEmbedder::ContainerInstanceMap& instance_map =
825 test_embedder->guest_web_contents_for_testing();
826 EXPECT_EQ(1u, instance_map.size());
827
828 WebContentsImpl* test_guest_web_contents = static_cast<WebContentsImpl*>(
829 instance_map.begin()->second);
830 TestBrowserPluginGuest* test_guest = static_cast<TestBrowserPluginGuest*>(
831 test_guest_web_contents->GetBrowserPluginGuest());
832
833 // Wait for the guest to send an UpdateRectMsg, meaning it is ready.
834 test_guest->WaitForUpdateRectMsg();
835
836 // 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.
837 {
838 const string16 expected_title = ASCIIToUTF16("ready");
839 content::TitleWatcher title_watcher(embedder_web_contents,
840 expected_title);
841
842 rvh->ExecuteJavascriptAndGetValue(string16(),
843 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.
844
845 string16 actual_title = title_watcher.WaitAndGetTitle();
846 EXPECT_EQ(expected_title, actual_title);
847 }
848
849 // Reload the embedder page, and navigate the guest to verify that the browser
850 // process does not crash.
851 {
852 const string16 expected_title = ASCIIToUTF16("embedder");
853 content::TitleWatcher title_watcher(embedder_web_contents,
854 expected_title);
855
856 embedder_web_contents->GetController().Reload(false);
857 string16 actual_title = title_watcher.WaitAndGetTitle();
858 EXPECT_EQ(expected_title, actual_title);
859
860 embedder_web_contents->GetRenderViewHost()->
861 ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16(
862 StringPrintf("SetSrc('%s');", kHTMLForGuest)));
863
864 WebContentsImpl* test_guest_web_contents = static_cast<WebContentsImpl*>(
865 instance_map.begin()->second);
866 TestBrowserPluginGuest* test_guest = static_cast<TestBrowserPluginGuest*>(
867 test_guest_web_contents->GetBrowserPluginGuest());
868
869 // Wait for the guest to send an UpdateRectMsg, meaning it is ready.
870 test_guest->WaitForUpdateRectMsg();
871
lazyboy 2012/10/02 18:48:33 nit: remove whitespaces.
Fady Samuel 2012/10/02 20:00:07 Done.
872
873 }
874 }
875
798 876
799 } // namespace content 877 } // namespace content
OLDNEW
« 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