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

Unified Diff: chrome/browser/renderer_host/test/render_view_host_manager_browsertest.cc

Issue 328017: Second attempt to swap processes on rel=noreferrer, target=blank links.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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
« no previous file with comments | « no previous file | chrome/renderer/render_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_host/test/render_view_host_manager_browsertest.cc
===================================================================
--- chrome/browser/renderer_host/test/render_view_host_manager_browsertest.cc (revision 29943)
+++ chrome/browser/renderer_host/test/render_view_host_manager_browsertest.cc (working copy)
@@ -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 @@
}
};
+// 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,
« no previous file with comments | « no previous file | chrome/renderer/render_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698