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

Unified Diff: chrome/browser/extensions/process_management_browsertest.cc

Issue 2873503002: NOT YET READY: Improve granularity of window namespaces in Blink.
Patch Set: Rebasing... Created 3 years, 6 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/extensions/process_management_browsertest.cc
diff --git a/chrome/browser/extensions/process_management_browsertest.cc b/chrome/browser/extensions/process_management_browsertest.cc
index f0702c845664ff03110221a60a1beca0668908ee..c2691edb3919f4e2579be88d7c6cf3ff9818b6c4 100644
--- a/chrome/browser/extensions/process_management_browsertest.cc
+++ b/chrome/browser/extensions/process_management_browsertest.cc
@@ -26,6 +26,7 @@
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
+#include "content/public/test/test_utils.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/process_manager.h"
#include "extensions/browser/process_map.h"
@@ -225,6 +226,54 @@ IN_PROC_BROWSER_TEST_F(ProcessManagementTest, MAYBE_ProcessOverflow) {
EXPECT_EQ(extension1_host, extension2_host);
}
+// Test that unrelated browsing contexts cannot find each other's windows,
+// even when they end up using the same renderer process (e.g. because of
+// hitting a process limit). See also https://crbug.com/718489.
+IN_PROC_BROWSER_TEST_F(ProcessManagementTest, ProcessReuseVsBrowsingInstance) {
+ // Set max renderers to 1 to force reusing a renderer process between two
+ // unrelated tabs.
+ content::RenderProcessHost::SetMaxRendererProcessCount(1);
+
+ // Navigate 2 tabs to a web page (regular web pages can share renderers
+ // among themselves without any restrictions, unlike extensions, apps, etc.).
+ ASSERT_TRUE(embedded_test_server()->Start());
+ GURL url1(embedded_test_server()->GetURL("/title1.html"));
+ GURL url2(embedded_test_server()->GetURL("/title2.html"));
+ ui_test_utils::NavigateToURL(browser(), url1);
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(), url2, WindowOpenDisposition::NEW_FOREGROUND_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+ content::RenderFrameHost* tab1 =
+ browser()->tab_strip_model()->GetWebContentsAt(0)->GetMainFrame();
+ content::RenderFrameHost* tab2 =
+ browser()->tab_strip_model()->GetWebContentsAt(1)->GetMainFrame();
+
+ // Sanity-check test setup: 2 frames share a renderer process, but are not in
+ // a related browsing instance.
+ if (!content::AreAllSitesIsolatedForTesting())
+ EXPECT_EQ(tab1->GetProcess(), tab2->GetProcess());
+ EXPECT_FALSE(
+ tab1->GetSiteInstance()->IsRelatedSiteInstance(tab2->GetSiteInstance()));
+
+ // Name the 2 frames.
+ EXPECT_TRUE(content::ExecuteScript(tab1, "window.name = 'tab1';"));
+ EXPECT_TRUE(content::ExecuteScript(tab2, "window.name = 'tab2';"));
+
+ // Verify that |tab1| cannot find named frames belonging to |tab2| (i.e. that
+ // window.open will end up creating a new tab rather than returning the old
+ // |tab2| tab).
+ content::WebContentsAddedObserver new_contents_observer;
+ std::string location_of_opened_window;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ tab1,
+ "var w = window.open('', 'tab2');\n"
+ "window.domAutomationController.send(w.location.href);",
+ &location_of_opened_window));
+ EXPECT_EQ(url::kAboutBlankURL, location_of_opened_window);
+ new_contents_observer.GetWebContents();
+ EXPECT_EQ(3, browser()->tab_strip_model()->count());
+}
+
// See
#if defined(OS_WIN)
#define MAYBE_ExtensionProcessBalancing DISABLED_ExtensionProcessBalancing
« no previous file with comments | « chrome/browser/extensions/extension_functional_browsertest.cc ('k') | chrome/renderer/chrome_content_renderer_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698