summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
authorcreis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-12 15:37:15 +0000
committercreis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-12 15:37:15 +0000
commit992db4c20a063a1009ae28c2cfb5b220701ea301 (patch)
tree570549ba54be36ea4b81ef446791e1d2e546e6f9 /chrome/browser/tab_contents
parent08c5fe5d62ec33cd7215bcdcd532d83866076580 (diff)
downloadchromium_src-992db4c20a063a1009ae28c2cfb5b220701ea301.zip
chromium_src-992db4c20a063a1009ae28c2cfb5b220701ea301.tar.gz
chromium_src-992db4c20a063a1009ae28c2cfb5b220701ea301.tar.bz2
Support window.opener after a process swap.
Changes: 1. Swap out RVHs instead of closing them, so we can return to the same Frame object if we later come back. 2. Filter out messages from swapped out RVHs, in case any are in-flight. 3. Remove the workaround for navigating away from an app. 4. Update tests to reflect the new sequence of events. BUG=65953 TEST=AppApiTest.AppProcess TEST=ResourceDispatcherTest.CrossSiteImmediateLoadOnunloadCookie Review URL: http://codereview.chromium.org/6319001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85134 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r--chrome/browser/tab_contents/background_contents.cc1
-rw-r--r--chrome/browser/tab_contents/background_contents.h3
-rw-r--r--chrome/browser/tab_contents/web_contents_unittest.cc37
3 files changed, 37 insertions, 4 deletions
diff --git a/chrome/browser/tab_contents/background_contents.cc b/chrome/browser/tab_contents/background_contents.cc
index e5f98b8..2d0dd69 100644
--- a/chrome/browser/tab_contents/background_contents.cc
+++ b/chrome/browser/tab_contents/background_contents.cc
@@ -103,6 +103,7 @@ void BackgroundContents::DidNavigate(
}
void BackgroundContents::RunJavaScriptMessage(
+ const RenderViewHost* rvh,
const std::wstring& message,
const std::wstring& default_prompt,
const GURL& frame_url,
diff --git a/chrome/browser/tab_contents/background_contents.h b/chrome/browser/tab_contents/background_contents.h
index f4e8874..9cd4f81 100644
--- a/chrome/browser/tab_contents/background_contents.h
+++ b/chrome/browser/tab_contents/background_contents.h
@@ -67,7 +67,8 @@ class BackgroundContents : public RenderViewHostDelegate,
virtual void DidNavigate(RenderViewHost* render_view_host,
const ViewHostMsg_FrameNavigate_Params& params);
virtual WebPreferences GetWebkitPrefs();
- virtual void RunJavaScriptMessage(const std::wstring& message,
+ virtual void RunJavaScriptMessage(const RenderViewHost* rvh,
+ const std::wstring& message,
const std::wstring& default_prompt,
const GURL& frame_url,
const int flags,
diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc
index 76f0ef0..411e693 100644
--- a/chrome/browser/tab_contents/web_contents_unittest.cc
+++ b/chrome/browser/tab_contents/web_contents_unittest.cc
@@ -300,6 +300,11 @@ TEST_F(TabContentsTest, CrossSiteBoundaries) {
int pending_rvh_delete_count = 0;
pending_rvh->set_delete_counter(&pending_rvh_delete_count);
+ // Navigations should be suspended in pending_rvh until ShouldCloseACK.
+ EXPECT_TRUE(pending_rvh->are_navigations_suspended());
+ orig_rvh->SendShouldCloseACK(true);
+ EXPECT_FALSE(pending_rvh->are_navigations_suspended());
+
// DidNavigate from the pending page
ViewHostMsg_FrameNavigate_Params params2;
InitNavigateParams(&params2, 1, url2, PageTransition::TYPED);
@@ -310,20 +315,36 @@ TEST_F(TabContentsTest, CrossSiteBoundaries) {
EXPECT_EQ(pending_rvh, contents()->render_view_host());
EXPECT_NE(instance1, instance2);
EXPECT_TRUE(contents()->pending_rvh() == NULL);
- EXPECT_EQ(orig_rvh_delete_count, 1);
+ // We keep the original RVH around, swapped out.
+ EXPECT_TRUE(contents()->render_manager()->IsSwappedOut(orig_rvh));
+ EXPECT_EQ(orig_rvh_delete_count, 0);
// Going back should switch SiteInstances again. The first SiteInstance is
// stored in the NavigationEntry, so it should be the same as at the start.
+ // We should use the same RVH as before, swapping it back in.
controller().GoBack();
TestRenderViewHost* goback_rvh = contents()->pending_rvh();
+ EXPECT_EQ(orig_rvh, goback_rvh);
EXPECT_TRUE(contents()->cross_navigation_pending());
+ // Navigations should be suspended in goback_rvh until ShouldCloseACK.
+ EXPECT_TRUE(goback_rvh->are_navigations_suspended());
+ pending_rvh->SendShouldCloseACK(true);
+ EXPECT_FALSE(goback_rvh->are_navigations_suspended());
+
// DidNavigate from the back action
contents()->TestDidNavigate(goback_rvh, params1);
EXPECT_FALSE(contents()->cross_navigation_pending());
EXPECT_EQ(goback_rvh, contents()->render_view_host());
- EXPECT_EQ(pending_rvh_delete_count, 1);
EXPECT_EQ(instance1, contents()->GetSiteInstance());
+ // The pending RVH should now be swapped out, not deleted.
+ EXPECT_TRUE(contents()->render_manager()->IsSwappedOut(pending_rvh));
+ EXPECT_EQ(pending_rvh_delete_count, 0);
+
+ // Close tab and ensure RVHs are deleted.
+ DeleteContents();
+ EXPECT_EQ(orig_rvh_delete_count, 1);
+ EXPECT_EQ(pending_rvh_delete_count, 1);
}
// Test that navigating across a site boundary after a crash creates a new
@@ -355,6 +376,7 @@ TEST_F(TabContentsTest, CrossSiteBoundariesAfterCrash) {
EXPECT_FALSE(contents()->cross_navigation_pending());
EXPECT_TRUE(contents()->pending_rvh() == NULL);
EXPECT_NE(orig_rvh, new_rvh);
+ EXPECT_FALSE(contents()->render_manager()->IsSwappedOut(orig_rvh));
EXPECT_EQ(orig_rvh_delete_count, 1);
// DidNavigate from the new page
@@ -367,6 +389,10 @@ TEST_F(TabContentsTest, CrossSiteBoundariesAfterCrash) {
EXPECT_EQ(new_rvh, rvh());
EXPECT_NE(instance1, instance2);
EXPECT_TRUE(contents()->pending_rvh() == NULL);
+
+ // Close tab and ensure RVHs are deleted.
+ DeleteContents();
+ EXPECT_EQ(orig_rvh_delete_count, 1);
}
// Test that opening a new tab in the same SiteInstance and then navigating
@@ -395,6 +421,7 @@ TEST_F(TabContentsTest, NavigateTwoTabsCrossSite) {
// Navigate first tab to a new site
const GURL url2a("http://www.yahoo.com");
controller().LoadURL(url2a, GURL(), PageTransition::TYPED);
+ orig_rvh->SendShouldCloseACK(true);
TestRenderViewHost* pending_rvh_a = contents()->pending_rvh();
ViewHostMsg_FrameNavigate_Params params2a;
InitNavigateParams(&params2a, 1, url2a, PageTransition::TYPED);
@@ -405,6 +432,9 @@ TEST_F(TabContentsTest, NavigateTwoTabsCrossSite) {
// Navigate second tab to the same site as the first tab
const GURL url2b("http://mail.yahoo.com");
contents2.controller().LoadURL(url2b, GURL(), PageTransition::TYPED);
+ TestRenderViewHost* rvh2 =
+ static_cast<TestRenderViewHost*>(contents2.render_view_host());
+ rvh2->SendShouldCloseACK(true);
TestRenderViewHost* pending_rvh_b = contents2.pending_rvh();
EXPECT_TRUE(pending_rvh_b != NULL);
EXPECT_TRUE(contents2.cross_navigation_pending());
@@ -1602,7 +1632,8 @@ TEST_F(TabContentsTest, NoJSMessageOnInterstitials) {
// attempting to show a JS message.
IPC::Message* dummy_message = new IPC::Message;
bool did_suppress_message = false;
- contents()->RunJavaScriptMessage(L"This is an informative message", L"OK",
+ contents()->RunJavaScriptMessage(contents()->render_view_host(),
+ L"This is an informative message", L"OK",
kGURL, ui::MessageBoxFlags::kIsJavascriptAlert, dummy_message,
&did_suppress_message);
EXPECT_TRUE(did_suppress_message);