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

Side by Side Diff: chrome/browser/extensions/isolated_app_browsertest.cc

Issue 8515027: Define the public version of the browser side RenderProcessHost interface. This interface is not ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "chrome/browser/automation/automation_util.h" 6 #include "chrome/browser/automation/automation_util.h"
7 #include "chrome/browser/extensions/extension_apitest.h" 7 #include "chrome/browser/extensions/extension_apitest.h"
8 #include "chrome/browser/extensions/extension_host.h" 8 #include "chrome/browser/extensions/extension_host.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
13 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
14 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
15 #include "content/browser/renderer_host/browser_render_process_host.h"
16 #include "content/browser/renderer_host/render_view_host.h" 15 #include "content/browser/renderer_host/render_view_host.h"
17 #include "content/browser/tab_contents/tab_contents.h" 16 #include "content/browser/tab_contents/tab_contents.h"
18 #include "content/common/test_url_constants.h" 17 #include "content/common/test_url_constants.h"
18 #include "content/public/browser/render_process_host.h"
19 #include "net/base/mock_host_resolver.h" 19 #include "net/base/mock_host_resolver.h"
20 20
21 namespace { 21 namespace {
22 22
23 class IsolatedAppTest : public ExtensionBrowserTest { 23 class IsolatedAppTest : public ExtensionBrowserTest {
24 public: 24 public:
25 // Returns whether the given tab's current URL has the given cookie. 25 // Returns whether the given tab's current URL has the given cookie.
26 bool WARN_UNUSED_RESULT HasCookie(TabContents* contents, std::string cookie) { 26 bool WARN_UNUSED_RESULT HasCookie(TabContents* contents, std::string cookie) {
27 int value_size; 27 int value_size;
28 std::string actual_cookie; 28 std::string actual_cookie;
29 automation_util::GetCookies(contents->GetURL(), contents, &value_size, 29 automation_util::GetCookies(contents->GetURL(), contents, &value_size,
30 &actual_cookie); 30 &actual_cookie);
31 return actual_cookie.find(cookie) != std::string::npos; 31 return actual_cookie.find(cookie) != std::string::npos;
32 } 32 }
33 33
34 const Extension* GetInstalledApp(TabContents* contents) { 34 const Extension* GetInstalledApp(TabContents* contents) {
35 const Extension* installed_app = NULL; 35 const Extension* installed_app = NULL;
36 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); 36 Profile* profile = Profile::FromBrowserContext(contents->browser_context());
37 ExtensionService* service = profile->GetExtensionService(); 37 ExtensionService* service = profile->GetExtensionService();
38 if (service) { 38 if (service) {
39 installed_app = service->GetInstalledAppForRenderer( 39 installed_app = service->GetInstalledAppForRenderer(
40 contents->render_view_host()->process()->id()); 40 contents->render_view_host()->process()->GetID());
41 } 41 }
42 return installed_app; 42 return installed_app;
43 } 43 }
44 44
45 private: 45 private:
46 virtual void SetUpCommandLine(CommandLine* command_line) { 46 virtual void SetUpCommandLine(CommandLine* command_line) {
47 ExtensionBrowserTest::SetUpCommandLine(command_line); 47 ExtensionBrowserTest::SetUpCommandLine(command_line);
48 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); 48 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
49 } 49 }
50 }; 50 };
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 EXPECT_TRUE(HasCookie(browser()->GetTabContentsAt(2), "app1=3")); 162 EXPECT_TRUE(HasCookie(browser()->GetTabContentsAt(2), "app1=3"));
163 EXPECT_TRUE(HasCookie(browser()->GetTabContentsAt(2), "app2=4")); 163 EXPECT_TRUE(HasCookie(browser()->GetTabContentsAt(2), "app2=4"));
164 EXPECT_TRUE(HasCookie(browser()->GetTabContentsAt(2), "nonAppFrame=6")); 164 EXPECT_TRUE(HasCookie(browser()->GetTabContentsAt(2), "nonAppFrame=6"));
165 } 165 }
166 166
167 // Ensure that an isolated app never shares a process with WebUIs, non-isolated 167 // Ensure that an isolated app never shares a process with WebUIs, non-isolated
168 // extensions, and normal webpages. None of these should ever comingle 168 // extensions, and normal webpages. None of these should ever comingle
169 // RenderProcessHosts even if we hit the process limit. 169 // RenderProcessHosts even if we hit the process limit.
170 IN_PROC_BROWSER_TEST_F(IsolatedAppTest, ProcessOverflow) { 170 IN_PROC_BROWSER_TEST_F(IsolatedAppTest, ProcessOverflow) {
171 // Set max renderers to 1 to force running out of processes. 171 // Set max renderers to 1 to force running out of processes.
172 RenderProcessHost::SetMaxRendererProcessCountForTest(1); 172 content::RenderProcessHost::SetMaxRendererProcessCountForTest(1);
173 173
174 host_resolver()->AddRule("*", "127.0.0.1"); 174 host_resolver()->AddRule("*", "127.0.0.1");
175 ASSERT_TRUE(test_server()->Start()); 175 ASSERT_TRUE(test_server()->Start());
176 176
177 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app1"))); 177 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app1")));
178 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app2"))); 178 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app2")));
179 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("hosted_app"))); 179 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("hosted_app")));
180 180
181 // The app under test acts on URLs whose host is "localhost", 181 // The app under test acts on URLs whose host is "localhost",
182 // so the URLs we navigate to must have host "localhost". 182 // so the URLs we navigate to must have host "localhost".
(...skipping 15 matching lines...) Expand all
198 browser(), base_url.Resolve("hosted_app/main.html"), 198 browser(), base_url.Resolve("hosted_app/main.html"),
199 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 199 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
200 ui_test_utils::NavigateToURLWithDisposition( 200 ui_test_utils::NavigateToURLWithDisposition(
201 browser(), base_url.Resolve("test_file.html"), 201 browser(), base_url.Resolve("test_file.html"),
202 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 202 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
203 ui_test_utils::NavigateToURLWithDisposition( 203 ui_test_utils::NavigateToURLWithDisposition(
204 browser(), base_url.Resolve("isolated_apps/app2/main.html"), 204 browser(), base_url.Resolve("isolated_apps/app2/main.html"),
205 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 205 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
206 206
207 ASSERT_EQ(5, browser()->tab_count()); 207 ASSERT_EQ(5, browser()->tab_count());
208 RenderProcessHost* isolated1_host = 208 content::RenderProcessHost* isolated1_host =
209 browser()->GetTabContentsAt(0)->GetRenderProcessHost(); 209 browser()->GetTabContentsAt(0)->GetRenderProcessHost();
210 RenderProcessHost* ntp_host = 210 content::RenderProcessHost* ntp_host =
211 browser()->GetTabContentsAt(1)->GetRenderProcessHost(); 211 browser()->GetTabContentsAt(1)->GetRenderProcessHost();
212 RenderProcessHost* normal_extension_host = 212 content::RenderProcessHost* normal_extension_host =
213 browser()->GetTabContentsAt(2)->GetRenderProcessHost(); 213 browser()->GetTabContentsAt(2)->GetRenderProcessHost();
214 RenderProcessHost* web_host = 214 content::RenderProcessHost* web_host =
215 browser()->GetTabContentsAt(3)->GetRenderProcessHost(); 215 browser()->GetTabContentsAt(3)->GetRenderProcessHost();
216 RenderProcessHost* isolated2_host = 216 content::RenderProcessHost* isolated2_host =
217 browser()->GetTabContentsAt(4)->GetRenderProcessHost(); 217 browser()->GetTabContentsAt(4)->GetRenderProcessHost();
218 218
219 // Isolated apps shared with each other, but no one else. They're clannish 219 // Isolated apps shared with each other, but no one else. They're clannish
220 // like that. 220 // like that.
221 ASSERT_EQ(isolated1_host, isolated2_host); 221 ASSERT_EQ(isolated1_host, isolated2_host);
222 ASSERT_NE(isolated1_host, ntp_host); 222 ASSERT_NE(isolated1_host, ntp_host);
223 ASSERT_NE(isolated1_host, normal_extension_host); 223 ASSERT_NE(isolated1_host, normal_extension_host);
224 ASSERT_NE(isolated1_host, web_host); 224 ASSERT_NE(isolated1_host, web_host);
225 225
226 // And cause we're here, make sure everyone else is also clannish. This could 226 // And cause we're here, make sure everyone else is also clannish. This could
227 // technially go in another test, but not worth the extra setup overhead. 227 // technially go in another test, but not worth the extra setup overhead.
228 ASSERT_NE(web_host, ntp_host); 228 ASSERT_NE(web_host, ntp_host);
229 ASSERT_NE(web_host, normal_extension_host); 229 ASSERT_NE(web_host, normal_extension_host);
230 ASSERT_NE(normal_extension_host, ntp_host); 230 ASSERT_NE(normal_extension_host, ntp_host);
231 } 231 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_webrequest_api.cc ('k') | chrome/browser/extensions/user_script_master.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698