 Chromium Code Reviews
 Chromium Code Reviews Issue 2686943002:
  New WebContents created via ctrl-click should be in a new process.  (Closed)
    
  
    Issue 2686943002:
  New WebContents created via ctrl-click should be in a new process.  (Closed) 
  | Index: chrome/browser/extensions/api/tabs/tabs_test.cc | 
| diff --git a/chrome/browser/extensions/api/tabs/tabs_test.cc b/chrome/browser/extensions/api/tabs/tabs_test.cc | 
| index 17bc023eabb4701b925af2eb9df553dd069f7580..1714e1cee7d1d088d18bb947d0a583d932fa68b3 100644 | 
| --- a/chrome/browser/extensions/api/tabs/tabs_test.cc | 
| +++ b/chrome/browser/extensions/api/tabs/tabs_test.cc | 
| @@ -39,6 +39,7 @@ | 
| #include "components/prefs/pref_service.h" | 
| #include "content/public/browser/browser_context.h" | 
| #include "content/public/browser/notification_service.h" | 
| +#include "content/public/browser/render_frame_host.h" | 
| #include "content/public/browser/storage_partition.h" | 
| #include "content/public/common/page_zoom.h" | 
| #include "content/public/common/url_constants.h" | 
| @@ -2116,7 +2117,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsZoomTest, CannotZoomInvalidTab) { | 
| } | 
| // Regression test for crbug.com/660498. | 
| -IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Foo) { | 
| +IN_PROC_BROWSER_TEST_F(ExtensionApiTest, TemporaryAddressSpoof) { | 
| 
Charlie Reis
2017/04/14 22:28:33
Heh, thanks.  Looks like I missed that in review.
 | 
| ASSERT_TRUE(StartEmbeddedTestServer()); | 
| content::WebContents* first_web_contents = | 
| browser()->tab_strip_model()->GetActiveWebContents(); | 
| @@ -2144,4 +2145,38 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Foo) { | 
| EXPECT_EQ(url, second_web_contents->GetVisibleURL()); | 
| } | 
| +// Window created by chrome.windows.create should be in the same SiteInstance | 
| +// as the opener - regression test for hangouts-vs-isolate-extensions-trouble | 
| +// (see also https://crbug.com/597750). | 
| +IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WindowsCreateVsSiteInstance) { | 
| + const extensions::Extension* extension = | 
| + LoadExtension(test_data_dir_.AppendASCII("../simple_with_file")); | 
| + ASSERT_TRUE(extension); | 
| + | 
| + // Navigate a tab to an extension page. | 
| + GURL extension_url = extension->GetResourceURL("file.html"); | 
| + ui_test_utils::NavigateToURL(browser(), extension_url); | 
| + content::WebContents* old_contents = | 
| + browser()->tab_strip_model()->GetActiveWebContents(); | 
| + | 
| + // Execute chrome.windows.create and store the new tab in |new_contents|. | 
| + content::WebContents* new_contents; | 
| + { | 
| + content::WebContentsAddedObserver observer; | 
| + ASSERT_TRUE(content::ExecuteScript(old_contents, | 
| + "window.name = 'test-name';\n" | 
| + "chrome.windows.create({url: '" + | 
| + extension_url.spec() + "'})")); | 
| + new_contents = observer.GetWebContents(); | 
| + } | 
| + | 
| + // Verify that the old and new tab are in the same process and SiteInstance. | 
| + // Note: both test assertions are important - one observed failure mode was | 
| + // having the same process, but different SiteInstance. | 
| + EXPECT_EQ(old_contents->GetMainFrame()->GetProcess(), | 
| + new_contents->GetMainFrame()->GetProcess()); | 
| + EXPECT_EQ(old_contents->GetMainFrame()->GetSiteInstance(), | 
| + new_contents->GetMainFrame()->GetSiteInstance()); | 
| +} | 
| + | 
| } // namespace extensions |