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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/extensions/extension_apitest.h" 10 #include "chrome/browser/extensions/extension_apitest.h"
11 #include "chrome/browser/extensions/extension_service.h" 11 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/browser/sessions/session_tab_helper.h" 14 #include "chrome/browser/sessions/session_tab_helper.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model.h"
17 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/extensions/extension_process_policy.h" 18 #include "chrome/common/extensions/extension_process_policy.h"
19 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
20 #include "chrome/test/base/ui_test_utils.h" 20 #include "chrome/test/base/ui_test_utils.h"
21 #include "content/public/browser/notification_service.h" 21 #include "content/public/browser/notification_service.h"
22 #include "content/public/browser/render_frame_host.h" 22 #include "content/public/browser/render_frame_host.h"
23 #include "content/public/browser/render_process_host.h" 23 #include "content/public/browser/render_process_host.h"
24 #include "content/public/browser/render_view_host.h" 24 #include "content/public/browser/render_view_host.h"
25 #include "content/public/browser/site_instance.h" 25 #include "content/public/browser/site_instance.h"
26 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
27 #include "content/public/test/browser_test_utils.h" 27 #include "content/public/test/browser_test_utils.h"
28 #include "content/public/test/test_navigation_observer.h" 28 #include "content/public/test/test_navigation_observer.h"
29 #include "content/public/test/test_utils.h"
29 #include "extensions/browser/extension_host.h" 30 #include "extensions/browser/extension_host.h"
30 #include "extensions/browser/process_manager.h" 31 #include "extensions/browser/process_manager.h"
31 #include "extensions/browser/process_map.h" 32 #include "extensions/browser/process_map.h"
32 #include "extensions/common/switches.h" 33 #include "extensions/common/switches.h"
33 #include "net/dns/mock_host_resolver.h" 34 #include "net/dns/mock_host_resolver.h"
34 #include "net/test/embedded_test_server/embedded_test_server.h" 35 #include "net/test/embedded_test_server/embedded_test_server.h"
35 36
36 using content::NavigationController; 37 using content::NavigationController;
37 using content::WebContents; 38 using content::WebContents;
38 39
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 EXPECT_NE(hosted1_host, extension1_host); 219 EXPECT_NE(hosted1_host, extension1_host);
219 220
220 // Web pages only share with each other. 221 // Web pages only share with each other.
221 EXPECT_EQ(web1_host, web2_host); 222 EXPECT_EQ(web1_host, web2_host);
222 EXPECT_NE(web1_host, extension1_host); 223 EXPECT_NE(web1_host, extension1_host);
223 224
224 // Extensions only share with each other. 225 // Extensions only share with each other.
225 EXPECT_EQ(extension1_host, extension2_host); 226 EXPECT_EQ(extension1_host, extension2_host);
226 } 227 }
227 228
229 // Test that unrelated browsing contexts cannot find each other's windows,
230 // even when they end up using the same renderer process (e.g. because of
231 // hitting a process limit). See also https://crbug.com/718489.
232 IN_PROC_BROWSER_TEST_F(ProcessManagementTest, ProcessReuseVsBrowsingInstance) {
233 // Set max renderers to 1 to force reusing a renderer process between two
234 // unrelated tabs.
235 content::RenderProcessHost::SetMaxRendererProcessCount(1);
236
237 // Navigate 2 tabs to a web page (regular web pages can share renderers
238 // among themselves without any restrictions, unlike extensions, apps, etc.).
239 ASSERT_TRUE(embedded_test_server()->Start());
240 GURL url1(embedded_test_server()->GetURL("/title1.html"));
241 GURL url2(embedded_test_server()->GetURL("/title2.html"));
242 ui_test_utils::NavigateToURL(browser(), url1);
243 ui_test_utils::NavigateToURLWithDisposition(
244 browser(), url2, WindowOpenDisposition::NEW_FOREGROUND_TAB,
245 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
246 content::RenderFrameHost* tab1 =
247 browser()->tab_strip_model()->GetWebContentsAt(0)->GetMainFrame();
248 content::RenderFrameHost* tab2 =
249 browser()->tab_strip_model()->GetWebContentsAt(1)->GetMainFrame();
250
251 // Sanity-check test setup: 2 frames share a renderer process, but are not in
252 // a related browsing instance.
253 if (!content::AreAllSitesIsolatedForTesting())
254 EXPECT_EQ(tab1->GetProcess(), tab2->GetProcess());
255 EXPECT_FALSE(
256 tab1->GetSiteInstance()->IsRelatedSiteInstance(tab2->GetSiteInstance()));
257
258 // Name the 2 frames.
259 EXPECT_TRUE(content::ExecuteScript(tab1, "window.name = 'tab1';"));
260 EXPECT_TRUE(content::ExecuteScript(tab2, "window.name = 'tab2';"));
261
262 // Verify that |tab1| cannot find named frames belonging to |tab2| (i.e. that
263 // window.open will end up creating a new tab rather than returning the old
264 // |tab2| tab).
265 content::WebContentsAddedObserver new_contents_observer;
266 std::string location_of_opened_window;
267 EXPECT_TRUE(ExecuteScriptAndExtractString(
268 tab1,
269 "var w = window.open('', 'tab2');\n"
270 "window.domAutomationController.send(w.location.href);",
271 &location_of_opened_window));
272 EXPECT_EQ(url::kAboutBlankURL, location_of_opened_window);
273 new_contents_observer.GetWebContents();
274 EXPECT_EQ(3, browser()->tab_strip_model()->count());
275 }
276
228 // See 277 // See
229 #if defined(OS_WIN) 278 #if defined(OS_WIN)
230 #define MAYBE_ExtensionProcessBalancing DISABLED_ExtensionProcessBalancing 279 #define MAYBE_ExtensionProcessBalancing DISABLED_ExtensionProcessBalancing
231 #else 280 #else
232 #define MAYBE_ExtensionProcessBalancing ExtensionProcessBalancing 281 #define MAYBE_ExtensionProcessBalancing ExtensionProcessBalancing
233 #endif 282 #endif
234 // Test to verify that the policy of maximum share of extension processes is 283 // Test to verify that the policy of maximum share of extension processes is
235 // properly enforced. 284 // properly enforced.
236 IN_PROC_BROWSER_TEST_F(ProcessManagementTest, MAYBE_ExtensionProcessBalancing) { 285 IN_PROC_BROWSER_TEST_F(ProcessManagementTest, MAYBE_ExtensionProcessBalancing) {
237 // Set max renderers to 6 so we can expect 2 extension processes to be 286 // Set max renderers to 6 so we can expect 2 extension processes to be
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 // the process is the same for all SiteInstances. This allows us to verify 490 // the process is the same for all SiteInstances. This allows us to verify
442 // that the site-to-process map for the extension hasn't been overwritten by 491 // that the site-to-process map for the extension hasn't been overwritten by
443 // the process of the |blocked_url|. 492 // the process of the |blocked_url|.
444 scoped_refptr<content::SiteInstance> new_site_instance = 493 scoped_refptr<content::SiteInstance> new_site_instance =
445 content::SiteInstance::CreateForURL(web_contents->GetBrowserContext(), 494 content::SiteInstance::CreateForURL(web_contents->GetBrowserContext(),
446 extension->GetResourceURL("")); 495 extension->GetResourceURL(""));
447 EXPECT_TRUE(new_site_instance->HasProcess()); 496 EXPECT_TRUE(new_site_instance->HasProcess());
448 EXPECT_EQ(new_site_instance->GetProcess(), 497 EXPECT_EQ(new_site_instance->GetProcess(),
449 web_contents->GetSiteInstance()->GetProcess()); 498 web_contents->GetSiteInstance()->GetProcess());
450 } 499 }
OLDNEW
« 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