| OLD | NEW |
| 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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "chrome/browser/extensions/extension_apitest.h" | 6 #include "chrome/browser/extensions/extension_apitest.h" |
| 7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 12 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
| 13 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
| 14 #include "content/public/browser/render_process_host.h" | 14 #include "content/public/browser/render_process_host.h" |
| 15 #include "content/public/browser/render_view_host.h" | 15 #include "content/public/browser/render_view_host.h" |
| 16 #include "content/public/browser/site_instance.h" | 16 #include "content/public/browser/site_instance.h" |
| 17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 #include "extensions/browser/extension_host.h" | 18 #include "extensions/browser/extension_host.h" |
| 19 #include "extensions/browser/extension_system.h" | |
| 20 #include "extensions/browser/process_manager.h" | 19 #include "extensions/browser/process_manager.h" |
| 21 #include "extensions/common/switches.h" | 20 #include "extensions/common/switches.h" |
| 22 #include "net/dns/mock_host_resolver.h" | 21 #include "net/dns/mock_host_resolver.h" |
| 23 #include "net/test/embedded_test_server/embedded_test_server.h" | 22 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 24 | 23 |
| 25 using content::NavigationController; | 24 using content::NavigationController; |
| 26 using content::WebContents; | 25 using content::WebContents; |
| 27 | 26 |
| 28 namespace { | 27 namespace { |
| 29 | 28 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 content::RenderProcessHost* hosted2_host = | 133 content::RenderProcessHost* hosted2_host = |
| 135 browser()->tab_strip_model()->GetWebContentsAt(6)->GetRenderProcessHost(); | 134 browser()->tab_strip_model()->GetWebContentsAt(6)->GetRenderProcessHost(); |
| 136 content::RenderProcessHost* web2_host = | 135 content::RenderProcessHost* web2_host = |
| 137 browser()->tab_strip_model()->GetWebContentsAt(7)->GetRenderProcessHost(); | 136 browser()->tab_strip_model()->GetWebContentsAt(7)->GetRenderProcessHost(); |
| 138 | 137 |
| 139 content::RenderProcessHost* second_isolated1_host = | 138 content::RenderProcessHost* second_isolated1_host = |
| 140 browser()->tab_strip_model()->GetWebContentsAt(8)->GetRenderProcessHost(); | 139 browser()->tab_strip_model()->GetWebContentsAt(8)->GetRenderProcessHost(); |
| 141 | 140 |
| 142 // Get extension processes. | 141 // Get extension processes. |
| 143 extensions::ProcessManager* process_manager = | 142 extensions::ProcessManager* process_manager = |
| 144 extensions::ExtensionSystem::Get(browser()->profile())-> | 143 extensions::ProcessManager::Get(browser()->profile()); |
| 145 process_manager(); | |
| 146 content::RenderProcessHost* extension1_host = | 144 content::RenderProcessHost* extension1_host = |
| 147 process_manager->GetSiteInstanceForURL(extension1_url)->GetProcess(); | 145 process_manager->GetSiteInstanceForURL(extension1_url)->GetProcess(); |
| 148 content::RenderProcessHost* extension2_host = | 146 content::RenderProcessHost* extension2_host = |
| 149 process_manager->GetSiteInstanceForURL(extension2_url)->GetProcess(); | 147 process_manager->GetSiteInstanceForURL(extension2_url)->GetProcess(); |
| 150 | 148 |
| 151 // An isolated app only shares with other instances of itself, not other | 149 // An isolated app only shares with other instances of itself, not other |
| 152 // isolated apps or anything else. | 150 // isolated apps or anything else. |
| 153 EXPECT_EQ(isolated1_host, second_isolated1_host); | 151 EXPECT_EQ(isolated1_host, second_isolated1_host); |
| 154 EXPECT_NE(isolated1_host, isolated2_host); | 152 EXPECT_NE(isolated1_host, isolated2_host); |
| 155 EXPECT_NE(isolated1_host, ntp1_host); | 153 EXPECT_NE(isolated1_host, ntp1_host); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 ui_test_utils::NavigateToURLWithDisposition( | 223 ui_test_utils::NavigateToURLWithDisposition( |
| 226 browser(), base_url.Resolve("isolated_apps/app1/main.html"), | 224 browser(), base_url.Resolve("isolated_apps/app1/main.html"), |
| 227 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 225 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 228 | 226 |
| 229 ui_test_utils::NavigateToURLWithDisposition( | 227 ui_test_utils::NavigateToURLWithDisposition( |
| 230 browser(), base_url.Resolve("api_test/management/test/basics.html"), | 228 browser(), base_url.Resolve("api_test/management/test/basics.html"), |
| 231 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 229 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 232 | 230 |
| 233 std::set<int> process_ids; | 231 std::set<int> process_ids; |
| 234 Profile* profile = browser()->profile(); | 232 Profile* profile = browser()->profile(); |
| 235 extensions::ProcessManager* epm = extensions::ExtensionSystem::Get(profile)-> | 233 extensions::ProcessManager* epm = extensions::ProcessManager::Get(profile); |
| 236 process_manager(); | |
| 237 for (extensions::ProcessManager::const_iterator iter = | 234 for (extensions::ProcessManager::const_iterator iter = |
| 238 epm->background_hosts().begin(); | 235 epm->background_hosts().begin(); |
| 239 iter != epm->background_hosts().end(); ++iter) { | 236 iter != epm->background_hosts().end(); ++iter) { |
| 240 process_ids.insert((*iter)->render_process_host()->GetID()); | 237 process_ids.insert((*iter)->render_process_host()->GetID()); |
| 241 } | 238 } |
| 242 | 239 |
| 243 // We've loaded 5 extensions with background pages, 1 extension without | 240 // We've loaded 5 extensions with background pages, 1 extension without |
| 244 // background page, and one isolated app. We expect only 2 unique processes | 241 // background page, and one isolated app. We expect only 2 unique processes |
| 245 // hosting those extensions. | 242 // hosting those extensions. |
| 246 extensions::ProcessMap* process_map = extensions::ProcessMap::Get(profile); | 243 extensions::ProcessMap* process_map = extensions::ProcessMap::Get(profile); |
| 247 | 244 |
| 248 EXPECT_GE((size_t) 6, process_map->size()); | 245 EXPECT_GE((size_t) 6, process_map->size()); |
| 249 EXPECT_EQ((size_t) 2, process_ids.size()); | 246 EXPECT_EQ((size_t) 2, process_ids.size()); |
| 250 } | 247 } |
| OLD | NEW |