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

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

Issue 2400523002: Isolating Chrome Web Store app in the transfer (i.e. non-OpenURL) path. (Closed)
Patch Set: Addressed CR feedback from lazyboy@ (removed one more unneeded #include). Created 4 years, 2 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
« no previous file with comments | « chrome/browser/extensions/chrome_content_browser_client_extensions_part.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/extensions/extension_apitest.h" 9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/profiles/profile_manager.h" 12 #include "chrome/browser/profiles/profile_manager.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" 14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
15 #include "chrome/common/chrome_switches.h"
15 #include "chrome/common/extensions/extension_process_policy.h" 16 #include "chrome/common/extensions/extension_process_policy.h"
16 #include "chrome/common/url_constants.h" 17 #include "chrome/common/url_constants.h"
17 #include "chrome/test/base/ui_test_utils.h" 18 #include "chrome/test/base/ui_test_utils.h"
18 #include "content/public/browser/render_frame_host.h" 19 #include "content/public/browser/render_frame_host.h"
19 #include "content/public/browser/render_process_host.h" 20 #include "content/public/browser/render_process_host.h"
20 #include "content/public/browser/render_view_host.h" 21 #include "content/public/browser/render_view_host.h"
21 #include "content/public/browser/site_instance.h" 22 #include "content/public/browser/site_instance.h"
22 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
23 #include "content/public/test/browser_test_utils.h" 24 #include "content/public/test/browser_test_utils.h"
24 #include "content/public/test/test_navigation_observer.h" 25 #include "content/public/test/test_navigation_observer.h"
25 #include "extensions/browser/extension_host.h" 26 #include "extensions/browser/extension_host.h"
26 #include "extensions/browser/process_manager.h" 27 #include "extensions/browser/process_manager.h"
28 #include "extensions/browser/process_map.h"
27 #include "extensions/common/switches.h" 29 #include "extensions/common/switches.h"
28 #include "net/dns/mock_host_resolver.h" 30 #include "net/dns/mock_host_resolver.h"
29 #include "net/test/embedded_test_server/embedded_test_server.h" 31 #include "net/test/embedded_test_server/embedded_test_server.h"
30 32
31 using content::NavigationController; 33 using content::NavigationController;
32 using content::WebContents; 34 using content::WebContents;
33 35
34 namespace { 36 namespace {
35 37
36 class ProcessManagementTest : public ExtensionBrowserTest { 38 class ProcessManagementTest : public ExtensionBrowserTest {
37 private: 39 private:
38 // This is needed for testing isolated apps, which are still experimental. 40 // This is needed for testing isolated apps, which are still experimental.
39 void SetUpCommandLine(base::CommandLine* command_line) override { 41 void SetUpCommandLine(base::CommandLine* command_line) override {
40 ExtensionBrowserTest::SetUpCommandLine(command_line); 42 ExtensionBrowserTest::SetUpCommandLine(command_line);
41 command_line->AppendSwitch( 43 command_line->AppendSwitch(
42 extensions::switches::kEnableExperimentalExtensionApis); 44 extensions::switches::kEnableExperimentalExtensionApis);
43 } 45 }
44 }; 46 };
45 47
48 class ChromeWebStoreProcessTest : public ExtensionBrowserTest {
49 public:
50 const GURL& gallery_url() { return gallery_url_; }
51
52 private:
53 // Overrides location of Chrome Web Store gallery to a test controlled URL.
54 void SetUpCommandLine(base::CommandLine* command_line) override {
55 ExtensionBrowserTest::SetUpCommandLine(command_line);
56
57 ASSERT_TRUE(embedded_test_server()->Start());
58 gallery_url_ =
59 embedded_test_server()->GetURL("chrome.webstore.test.com", "/");
60 command_line->AppendSwitchASCII(switches::kAppsGalleryURL,
61 gallery_url_.spec());
62 }
63
64 void SetUpOnMainThread() override {
65 host_resolver()->AddRule("*", "127.0.0.1");
66 }
67
68 GURL gallery_url_;
69 };
70
46 } // namespace 71 } // namespace
47 72
48 73
49 // TODO(nasko): crbug.com/173137 74 // TODO(nasko): crbug.com/173137
50 #if defined(OS_WIN) 75 #if defined(OS_WIN)
51 #define MAYBE_ProcessOverflow DISABLED_ProcessOverflow 76 #define MAYBE_ProcessOverflow DISABLED_ProcessOverflow
52 #else 77 #else
53 #define MAYBE_ProcessOverflow ProcessOverflow 78 #define MAYBE_ProcessOverflow ProcessOverflow
54 #endif 79 #endif
55 80
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 EXPECT_EQ(web_url, web_contents->GetLastCommittedURL()); 320 EXPECT_EQ(web_url, web_contents->GetLastCommittedURL());
296 321
297 // Verify that the navigation transferred the contents to another renderer 322 // Verify that the navigation transferred the contents to another renderer
298 // process. 323 // process.
299 if (extensions::IsIsolateExtensionsEnabled()) { 324 if (extensions::IsIsolateExtensionsEnabled()) {
300 content::RenderProcessHost* new_process_host = 325 content::RenderProcessHost* new_process_host =
301 web_contents->GetMainFrame()->GetProcess(); 326 web_contents->GetMainFrame()->GetProcess();
302 EXPECT_NE(old_process_host, new_process_host); 327 EXPECT_NE(old_process_host, new_process_host);
303 } 328 }
304 } 329 }
330
331 IN_PROC_BROWSER_TEST_F(ChromeWebStoreProcessTest,
332 NavigateWebTabToChromeWebStoreViaPost) {
333 // Navigate a tab to a web page with a form.
334 GURL web_url = embedded_test_server()->GetURL("foo.com", "/form.html");
335 ui_test_utils::NavigateToURL(browser(), web_url);
336 WebContents* web_contents =
337 browser()->tab_strip_model()->GetActiveWebContents();
338 EXPECT_EQ(web_url, web_contents->GetLastCommittedURL());
339 content::RenderProcessHost* old_process_host =
340 web_contents->GetMainFrame()->GetProcess();
341
342 // Calculate an URL that is 1) relative to the fake (i.e. test-controlled)
343 // Chrome Web Store gallery URL and 2) resolves to something that
344 // embedded_test_server can actually serve (e.g. title1.html test file).
345 GURL::Replacements replace_path;
346 replace_path.SetPathStr("/title1.html");
347 GURL cws_web_url = gallery_url().ReplaceComponents(replace_path);
348
349 // Note that the |setTimeout| call below is needed to make sure
350 // ExecuteScriptAndExtractBool returns *after* a scheduled navigation has
351 // already started.
352 std::string navigation_starting_script =
353 "var form = document.getElementById('form');\n"
354 "form.action = '" + cws_web_url.spec() + "';\n"
355 "form.submit();\n"
356 "setTimeout(\n"
357 " function() { window.domAutomationController.send(true); },\n"
358 " 0);\n";
359
360 // Trigger a renderer-initiated POST navigation (via the form) to a Chrome Web
361 // Store gallery URL (which will commit into a chrome-extension://cws-app-id).
362 bool ignored_script_result = false;
363 content::TestNavigationObserver nav_observer(web_contents, 1);
364 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
365 web_contents, navigation_starting_script, &ignored_script_result));
366
367 // Verify that the navigation succeeded.
368 nav_observer.Wait();
369 EXPECT_EQ(cws_web_url, web_contents->GetLastCommittedURL());
370
371 // Verify that we really have the Chrome Web Store app loaded in the Web
372 // Contents.
373 content::RenderProcessHost* new_process_host =
374 web_contents->GetMainFrame()->GetProcess();
375 EXPECT_TRUE(extensions::ProcessMap::Get(profile())->Contains(
376 extensions::kWebStoreAppId, new_process_host->GetID()));
377
378 // Verify that Chrome Web Store is isolated in a separate renderer process.
379 if (extensions::IsIsolateExtensionsEnabled())
380 EXPECT_NE(old_process_host, new_process_host);
381 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/chrome_content_browser_client_extensions_part.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698