| Index: chrome/browser/chrome_navigation_browsertest.cc
|
| diff --git a/chrome/browser/chrome_navigation_browsertest.cc b/chrome/browser/chrome_navigation_browsertest.cc
|
| index 3254ffa8327dab158750ceb1796c73324794559e..02e24adb20b65a4fbdea1d36e49d4a2a7b7ccbbb 100644
|
| --- a/chrome/browser/chrome_navigation_browsertest.cc
|
| +++ b/chrome/browser/chrome_navigation_browsertest.cc
|
| @@ -189,6 +189,89 @@ IN_PROC_BROWSER_TEST_F(ChromeNavigationBrowserTest, TestViewFrameSource) {
|
| new_web_contents->GetTitle());
|
| }
|
|
|
| +// Verify that ctrl-click results open up in a new renderer process.
|
| +// See also https://crbug.com/23815
|
| +IN_PROC_BROWSER_TEST_F(ChromeNavigationBrowserTest,
|
| + CtrlClickShouldEndUpInNewProcess) {
|
| + // Navigate to anchor_targeting_remote_frame.html.
|
| + 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());
|
| +
|
| + // Ctrl-click the anchor/link in the page.
|
| + content::WebContents* new_contents = nullptr;
|
| + {
|
| + content::WebContentsAddedObserver new_tab_observer;
|
| +#if defined(OS_MACOSX)
|
| + std::string new_tab_click_script =
|
| + "simulateClick(\"test-anchor-no-target\", { metaKey: true });";
|
| +#else
|
| + std::string new_tab_click_script =
|
| + "simulateClick(\"test-anchor-no-target\", { ctrlKey: true });";
|
| +#endif
|
| + EXPECT_TRUE(ExecuteScript(main_contents, new_tab_click_script));
|
| +
|
| + // Wait for a new tab to appear (the whole point of this test).
|
| + new_contents = new_tab_observer.GetWebContents();
|
| + }
|
| +
|
| + // Verify that the new tab has the right contents and is in the right, new
|
| + // place in the tab strip.
|
| + EXPECT_TRUE(WaitForLoadStop(new_contents));
|
| + EXPECT_EQ(2, browser()->tab_strip_model()->count());
|
| + EXPECT_EQ(new_contents, browser()->tab_strip_model()->GetWebContentsAt(1));
|
| + GURL expected_url(embedded_test_server()->GetURL("/title1.html"));
|
| + EXPECT_EQ(expected_url, new_contents->GetLastCommittedURL());
|
| +
|
| + // Verify that the new tab is in a different process from the old contents.
|
| + EXPECT_NE(main_contents->GetMainFrame()->GetProcess(),
|
| + new_contents->GetMainFrame()->GetProcess());
|
| +
|
| + // Verify that |new_contents| truly is in a brand new browsing instance.
|
| + {
|
| + // Double-check that main_contents has expected window.name set.
|
| + // (this is a sanity check of test setup; this is not a product test).
|
| + std::string name_of_main_contents_window;
|
| + ASSERT_TRUE(ExecuteScriptAndExtractString(
|
| + main_contents->GetMainFrame(),
|
| + "window.domAutomationController.send(window.name)",
|
| + &name_of_main_contents_window));
|
| + 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;
|
| + ASSERT_TRUE(ExecuteScriptAndExtractBool(
|
| + new_contents->GetMainFrame(),
|
| + "window.domAutomationController.send(!!window.opener)",
|
| + &window_opener_cast_to_bool));
|
| + EXPECT_FALSE(window_opener_cast_to_bool);
|
| +
|
| + // Verify that the new contents cannot find the old contents via
|
| + // window.open.
|
| + // (i.e. window.open should open a new window, rather than returning a
|
| + // reference to main_contents / old window).
|
| + content::WebContentsAddedObserver window_open_observer;
|
| + std::string location_of_opened_window;
|
| + ASSERT_TRUE(ExecuteScriptAndExtractString(
|
| + new_contents->GetMainFrame(),
|
| + "w = window.open('', 'main_contents');"
|
| + "window.domAutomationController.send(w.location.href);",
|
| + &location_of_opened_window));
|
| + content::WebContents* found_contents =
|
| + window_open_observer.GetWebContents();
|
| + // Expecting "false" -> expecting to be at a non-PAGE_TYPE_NORMAL page.
|
| + EXPECT_FALSE(WaitForLoadStop(found_contents));
|
| + EXPECT_EQ(GURL(), found_contents->GetLastCommittedURL());
|
| + EXPECT_EQ("about:blank", location_of_opened_window);
|
| + }
|
| +}
|
| +
|
| class ChromeNavigationPortMappedBrowserTest : public InProcessBrowserTest {
|
| public:
|
| ChromeNavigationPortMappedBrowserTest() {}
|
|
|