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

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 updating LayoutTest/FlagExpectations to account for test name change. 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
« no previous file with comments | « no previous file | chrome/test/data/frame_tree/anchor_to_same_site_location.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_navigation_browsertest.cc
diff --git a/chrome/browser/chrome_navigation_browsertest.cc b/chrome/browser/chrome_navigation_browsertest.cc
index 4971fa68e0e9f88d1bb7af82a9ac50f3180edd0f..0a1f0bf53bf8c65a0c222b3b7da26568308fa5fa 100644
--- a/chrome/browser/chrome_navigation_browsertest.cc
+++ b/chrome/browser/chrome_navigation_browsertest.cc
@@ -250,7 +250,7 @@ class CtrlClickShouldEndUpInNewProcessTest
EXPECT_EQ("main_contents", name_of_main_contents_window);
// Verify that the new contents doesn't have a window.opener set.
- bool window_opener_cast_to_bool;
+ bool window_opener_cast_to_bool = true;
EXPECT_TRUE(ExecuteScriptAndExtractBool(
new_contents, "window.domAutomationController.send(!!window.opener)",
&window_opener_cast_to_bool));
@@ -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 {
« no previous file with comments | « no previous file | chrome/test/data/frame_tree/anchor_to_same_site_location.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698