summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host
diff options
context:
space:
mode:
authorcreis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-26 15:55:46 +0000
committercreis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-26 15:55:46 +0000
commit007a848b67a4a880598d6c76c0c9d94d56d0d8e0 (patch)
tree0f216a696a3b5fb6c88a6db5cb2cfd2bb6f2608e /chrome/browser/renderer_host
parente959f0b97dba7228c76b7722cf4227fdf6416524 (diff)
downloadchromium_src-007a848b67a4a880598d6c76c0c9d94d56d0d8e0.zip
chromium_src-007a848b67a4a880598d6c76c0c9d94d56d0d8e0.tar.gz
chromium_src-007a848b67a4a880598d6c76c0c9d94d56d0d8e0.tar.bz2
Second attempt to swap processes on rel=noreferrer, target=blank links.
The test timed out on one of the bots last time. This change tries to fix that, and it breaks down the test into multiple tests to isolate the problem in case it isn't fixed. No changes to code outside the test and the test HTML file. Previous review at http://codereview.chromium.org/284015. BUG=24447 TEST=RenderViewHostManagerTest.*SwapProcess* Review URL: http://codereview.chromium.org/328017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30050 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r--chrome/browser/renderer_host/test/render_view_host_manager_browsertest.cc132
1 files changed, 131 insertions, 1 deletions
diff --git a/chrome/browser/renderer_host/test/render_view_host_manager_browsertest.cc b/chrome/browser/renderer_host/test/render_view_host_manager_browsertest.cc
index 4fe70cd..dd6546c 100644
--- a/chrome/browser/renderer_host/test/render_view_host_manager_browsertest.cc
+++ b/chrome/browser/renderer_host/test/render_view_host_manager_browsertest.cc
@@ -3,9 +3,10 @@
// found in the LICENSE file.
#include "chrome/browser/browser.h"
-#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/download/download_manager.h"
#include "chrome/browser/profile.h"
+#include "chrome/browser/renderer_host/site_instance.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_details.h"
@@ -25,6 +26,135 @@ class RenderViewHostManagerTest : public InProcessBrowserTest {
}
};
+// Test for crbug.com/24447. Following a cross-site link with rel=noreferrer
+// and target=_blank should create a new SiteInstance.
+IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
+ SwapProcessWithRelNoreferrerAndTargetBlank) {
+ // Start two servers with different sites.
+ const wchar_t kDocRoot[] = L"chrome/test/data";
+ scoped_refptr<HTTPTestServer> http_server =
+ HTTPTestServer::CreateServer(kDocRoot, NULL);
+ scoped_refptr<HTTPSTestServer> https_server =
+ HTTPSTestServer::CreateGoodServer(kDocRoot);
+
+ // Load a page with links that open in a new window.
+ ui_test_utils::NavigateToURL(browser(), http_server->TestServerPageW(
+ L"files/click-noreferrer-links.html"));
+
+ // Get the original SiteInstance for later comparison.
+ scoped_refptr<SiteInstance> orig_site_instance(
+ browser()->GetSelectedTabContents()->GetSiteInstance());
+ EXPECT_TRUE(orig_site_instance != NULL);
+
+ // Test clicking a rel=noreferrer + target=blank link.
+ bool success = false;
+ EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
+ browser()->GetSelectedTabContents()->render_view_host(), L"",
+ L"window.domAutomationController.send(clickNoRefTargetBlankLink());",
+ &success));
+ EXPECT_TRUE(success);
+ // Wait for the cross-site transition to finish.
+ ui_test_utils::WaitForLoadStop(
+ &(browser()->GetSelectedTabContents()->controller()));
+
+ // Opens in new tab.
+ EXPECT_EQ(2, browser()->tab_count());
+ EXPECT_EQ(1, browser()->selected_index());
+ EXPECT_EQ(L"Title Of Awesomeness",
+ browser()->GetSelectedTabContents()->GetTitle());
+
+ // Should have a new SiteInstance.
+ scoped_refptr<SiteInstance> noref_blank_site_instance(
+ browser()->GetSelectedTabContents()->GetSiteInstance());
+ EXPECT_NE(orig_site_instance, noref_blank_site_instance);
+}
+
+// Test for crbug.com/24447. Following a cross-site link with just
+// target=_blank should not create a new SiteInstance.
+IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
+ DontSwapProcessWithOnlyTargetBlank) {
+ // Start two servers with different sites.
+ const wchar_t kDocRoot[] = L"chrome/test/data";
+ scoped_refptr<HTTPTestServer> http_server =
+ HTTPTestServer::CreateServer(kDocRoot, NULL);
+ scoped_refptr<HTTPSTestServer> https_server =
+ HTTPSTestServer::CreateGoodServer(kDocRoot);
+
+ // Load a page with links that open in a new window.
+ ui_test_utils::NavigateToURL(browser(), http_server->TestServerPageW(
+ L"files/click-noreferrer-links.html"));
+
+ // Get the original SiteInstance for later comparison.
+ scoped_refptr<SiteInstance> orig_site_instance(
+ browser()->GetSelectedTabContents()->GetSiteInstance());
+ EXPECT_TRUE(orig_site_instance != NULL);
+
+ // Test clicking a target=blank link.
+ bool success = false;
+ EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
+ browser()->GetSelectedTabContents()->render_view_host(), L"",
+ L"window.domAutomationController.send(clickTargetBlankLink());",
+ &success));
+ EXPECT_TRUE(success);
+ // Wait for the cross-site transition to finish.
+ ui_test_utils::WaitForLoadStop(
+ &(browser()->GetSelectedTabContents()->controller()));
+
+ // Opens in new tab.
+ EXPECT_EQ(2, browser()->tab_count());
+ EXPECT_EQ(1, browser()->selected_index());
+ EXPECT_EQ(L"Title Of Awesomeness",
+ browser()->GetSelectedTabContents()->GetTitle());
+
+ // Should have the same SiteInstance.
+ scoped_refptr<SiteInstance> blank_site_instance(
+ browser()->GetSelectedTabContents()->GetSiteInstance());
+ EXPECT_EQ(orig_site_instance, blank_site_instance);
+}
+
+// Test for crbug.com/24447. Following a cross-site link with rel=noreferrer
+// and no target=_blank should not create a new SiteInstance.
+IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
+ DontSwapProcessWithOnlyRelNoreferrer) {
+ // Start two servers with different sites.
+ const wchar_t kDocRoot[] = L"chrome/test/data";
+ scoped_refptr<HTTPTestServer> http_server =
+ HTTPTestServer::CreateServer(kDocRoot, NULL);
+ scoped_refptr<HTTPSTestServer> https_server =
+ HTTPSTestServer::CreateGoodServer(kDocRoot);
+
+ // Load a page with links that open in a new window.
+ ui_test_utils::NavigateToURL(browser(), http_server->TestServerPageW(
+ L"files/click-noreferrer-links.html"));
+
+ // Get the original SiteInstance for later comparison.
+ scoped_refptr<SiteInstance> orig_site_instance(
+ browser()->GetSelectedTabContents()->GetSiteInstance());
+ EXPECT_TRUE(orig_site_instance != NULL);
+
+ // Test clicking a rel=noreferrer link.
+ bool success = false;
+ EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
+ browser()->GetSelectedTabContents()->render_view_host(), L"",
+ L"window.domAutomationController.send(clickNoRefLink());",
+ &success));
+ EXPECT_TRUE(success);
+ // Wait for the cross-site transition to finish.
+ ui_test_utils::WaitForLoadStop(
+ &(browser()->GetSelectedTabContents()->controller()));
+
+ // Opens in same tab.
+ EXPECT_EQ(1, browser()->tab_count());
+ EXPECT_EQ(0, browser()->selected_index());
+ EXPECT_EQ(L"Title Of Awesomeness",
+ browser()->GetSelectedTabContents()->GetTitle());
+
+ // Should have the same SiteInstance.
+ scoped_refptr<SiteInstance> noref_site_instance(
+ browser()->GetSelectedTabContents()->GetSiteInstance());
+ EXPECT_EQ(orig_site_instance, noref_site_instance);
+}
+
// Test for crbug.com/14505. This tests that chrome:// urls are still functional
// after download of a file while viewing another chrome://.
IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,