Chromium Code Reviews| 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..6618cb0b42eb259cdb851755111ae0efaee037aa 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) { |
| 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, WindowCreateVsSiteInstance) { |
|
alexmos
2017/04/11 20:42:40
nit: WindowCreate -> WindowsCreate in the name (to
Łukasz Anforowicz
2017/04/11 23:10:37
Done.
|
| + 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 assertion are important - one observed failure mode was |
|
alexmos
2017/04/11 20:42:40
nit: s/assertion/assertions/
Łukasz Anforowicz
2017/04/11 23:10:37
Ooops. Done.
|
| + // 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 |