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

Unified Diff: chrome/browser/chrome_navigation_browsertest.cc

Issue 2680353005: WebContents created via ctrl-click should be in a new process (target=_blank). (Closed)
Patch Set: Rebasing... Created 3 years, 8 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: chrome/browser/chrome_navigation_browsertest.cc
diff --git a/chrome/browser/chrome_navigation_browsertest.cc b/chrome/browser/chrome_navigation_browsertest.cc
index 0753f8fa5c49c6bf82c1f42ac7de33e0f92c77b5..83a0fd3f0aa6017fa2bb8352be4fd58bf23567e6 100644
--- a/chrome/browser/chrome_navigation_browsertest.cc
+++ b/chrome/browser/chrome_navigation_browsertest.cc
@@ -270,36 +270,48 @@ class CtrlClickShouldEndUpInNewProcessTest
return new_contents;
}
+
+ void TestCtrlClick(const char* id_of_anchor_to_click) {
+ // Navigate to the test page.
+ GURL main_url(embedded_test_server()->GetURL(
+ "/frame_tree/anchor_to_same_site_location.html"));
+ ui_test_utils::NavigateToURL(browser(), main_url);
+
+ // Verify that there is only 1 active tab (with the right contents
+ // committed).
+ EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
+ content::WebContents* main_contents =
+ browser()->tab_strip_model()->GetWebContentsAt(0);
+ EXPECT_EQ(main_url, main_contents->GetLastCommittedURL());
+
+ // Test what happens after ctrl-click. SimulateCtrlClick will verify
+ // that |new_contents1| is in a separate process and browsing instance
+ // from |main_contents|.
+ content::WebContents* new_contents1 =
+ SimulateCtrlClick(main_contents, id_of_anchor_to_click);
+
+ // Test that each subsequent ctrl-click also gets a new process.
+ content::WebContents* new_contents2 =
+ SimulateCtrlClick(main_contents, id_of_anchor_to_click);
+ EXPECT_NE(new_contents1->GetMainFrame()->GetProcess(),
+ new_contents2->GetMainFrame()->GetProcess());
+ EXPECT_NE(new_contents1->GetMainFrame()->GetSiteInstance(),
+ new_contents2->GetMainFrame()->GetSiteInstance());
+ EXPECT_FALSE(new_contents1->GetSiteInstance()->IsRelatedSiteInstance(
+ new_contents2->GetSiteInstance()));
+ }
};
IN_PROC_BROWSER_TEST_F(CtrlClickShouldEndUpInNewProcessTest, NoTarget) {
- // Navigate to the test page.
- GURL main_url(embedded_test_server()->GetURL(
- "/frame_tree/anchor_to_same_site_location.html"));
- ui_test_utils::NavigateToURL(browser(), main_url);
- const char* kIdOfAnchorToClick = "test-anchor-no-target";
-
- // Verify that there is only 1 active tab (with the right contents committed).
- EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
- content::WebContents* main_contents =
- browser()->tab_strip_model()->GetWebContentsAt(0);
- EXPECT_EQ(main_url, main_contents->GetLastCommittedURL());
-
- // Test what happens after ctrl-click. SimulateCtrlClick will verify
- // that |new_contents1| is in a separate process and browsing instance
- // from |main_contents|.
- content::WebContents* new_contents1 =
- SimulateCtrlClick(main_contents, kIdOfAnchorToClick);
-
- // Test that each subsequent ctrl-click also gets a new process.
- content::WebContents* new_contents2 =
- SimulateCtrlClick(main_contents, kIdOfAnchorToClick);
- EXPECT_NE(new_contents1->GetMainFrame()->GetProcess(),
- new_contents2->GetMainFrame()->GetProcess());
- EXPECT_NE(new_contents1->GetMainFrame()->GetSiteInstance(),
- new_contents2->GetMainFrame()->GetSiteInstance());
- EXPECT_FALSE(new_contents1->GetSiteInstance()->IsRelatedSiteInstance(
- new_contents2->GetSiteInstance()));
+ TestCtrlClick("test-anchor-no-target");
+}
+
+IN_PROC_BROWSER_TEST_F(CtrlClickShouldEndUpInNewProcessTest, BlankTarget) {
+ TestCtrlClick("test-anchor-with-blank-target");
+}
+
+IN_PROC_BROWSER_TEST_F(CtrlClickShouldEndUpInNewProcessTest, SubframeTarget) {
+ TestCtrlClick("test-anchor-with-subframe-target");
}
class ChromeNavigationPortMappedBrowserTest : public InProcessBrowserTest {

Powered by Google App Engine
This is Rietveld 408576698