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

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: 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
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"
16 #include "chrome/common/extensions/api/url_handlers/url_handlers_parser.h"
15 #include "chrome/common/extensions/extension_process_policy.h" 17 #include "chrome/common/extensions/extension_process_policy.h"
16 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
17 #include "chrome/test/base/ui_test_utils.h" 19 #include "chrome/test/base/ui_test_utils.h"
18 #include "content/public/browser/render_frame_host.h" 20 #include "content/public/browser/render_frame_host.h"
19 #include "content/public/browser/render_process_host.h" 21 #include "content/public/browser/render_process_host.h"
20 #include "content/public/browser/render_view_host.h" 22 #include "content/public/browser/render_view_host.h"
21 #include "content/public/browser/site_instance.h" 23 #include "content/public/browser/site_instance.h"
22 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
23 #include "content/public/test/browser_test_utils.h" 25 #include "content/public/test/browser_test_utils.h"
24 #include "content/public/test/test_navigation_observer.h" 26 #include "content/public/test/test_navigation_observer.h"
25 #include "extensions/browser/extension_host.h" 27 #include "extensions/browser/extension_host.h"
28 #include "extensions/browser/extension_registry.h"
26 #include "extensions/browser/process_manager.h" 29 #include "extensions/browser/process_manager.h"
30 #include "extensions/browser/process_map.h"
31 #include "extensions/common/manifest_constants.h"
27 #include "extensions/common/switches.h" 32 #include "extensions/common/switches.h"
33 #include "extensions/common/url_pattern.h"
34 #include "extensions/common/url_pattern_set.h"
28 #include "net/dns/mock_host_resolver.h" 35 #include "net/dns/mock_host_resolver.h"
29 #include "net/test/embedded_test_server/embedded_test_server.h" 36 #include "net/test/embedded_test_server/embedded_test_server.h"
30 37
31 using content::NavigationController; 38 using content::NavigationController;
32 using content::WebContents; 39 using content::WebContents;
33 40
34 namespace { 41 namespace {
35 42
36 class ProcessManagementTest : public ExtensionBrowserTest { 43 class ProcessManagementTest : public ExtensionBrowserTest {
37 private: 44 private:
38 // This is needed for testing isolated apps, which are still experimental. 45 // This is needed for testing isolated apps, which are still experimental.
39 void SetUpCommandLine(base::CommandLine* command_line) override { 46 void SetUpCommandLine(base::CommandLine* command_line) override {
40 ExtensionBrowserTest::SetUpCommandLine(command_line); 47 ExtensionBrowserTest::SetUpCommandLine(command_line);
41 command_line->AppendSwitch( 48 command_line->AppendSwitch(
42 extensions::switches::kEnableExperimentalExtensionApis); 49 extensions::switches::kEnableExperimentalExtensionApis);
43 } 50 }
44 }; 51 };
45 52
53 class ChromeWebStoreProcessTest : public ExtensionBrowserTest {
54 public:
55 const GURL& gallery_url() { return gallery_url_; }
56
57 private:
58 // Overrides location of Chrome Web Store gallery to a test controlled URL.
59 void SetUpCommandLine(base::CommandLine* command_line) override {
60 ExtensionBrowserTest::SetUpCommandLine(command_line);
61
62 ASSERT_TRUE(embedded_test_server()->Start());
63 gallery_url_ =
64 embedded_test_server()->GetURL("chrome.webstore.test.com", "/");
65 command_line->AppendSwitchASCII(switches::kAppsGalleryURL,
66 gallery_url_.spec());
67 }
68
69 void SetUpOnMainThread() override {
70 host_resolver()->AddRule("*", "127.0.0.1");
71 }
72
73 GURL gallery_url_;
74 };
75
46 } // namespace 76 } // namespace
47 77
48 78
49 // TODO(nasko): crbug.com/173137 79 // TODO(nasko): crbug.com/173137
50 #if defined(OS_WIN) 80 #if defined(OS_WIN)
51 #define MAYBE_ProcessOverflow DISABLED_ProcessOverflow 81 #define MAYBE_ProcessOverflow DISABLED_ProcessOverflow
52 #else 82 #else
53 #define MAYBE_ProcessOverflow ProcessOverflow 83 #define MAYBE_ProcessOverflow ProcessOverflow
54 #endif 84 #endif
55 85
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 EXPECT_EQ(web_url, web_contents->GetLastCommittedURL()); 325 EXPECT_EQ(web_url, web_contents->GetLastCommittedURL());
296 326
297 // Verify that the navigation transferred the contents to another renderer 327 // Verify that the navigation transferred the contents to another renderer
298 // process. 328 // process.
299 if (extensions::IsIsolateExtensionsEnabled()) { 329 if (extensions::IsIsolateExtensionsEnabled()) {
300 content::RenderProcessHost* new_process_host = 330 content::RenderProcessHost* new_process_host =
301 web_contents->GetMainFrame()->GetProcess(); 331 web_contents->GetMainFrame()->GetProcess();
302 EXPECT_NE(old_process_host, new_process_host); 332 EXPECT_NE(old_process_host, new_process_host);
303 } 333 }
304 } 334 }
335
336 IN_PROC_BROWSER_TEST_F(ChromeWebStoreProcessTest,
337 NavigateWebTabToChromeWebStoreViaPost) {
338 // Navigate a tab to a web page with a form.
339 GURL web_url = embedded_test_server()->GetURL("foo.com", "/form.html");
340 ui_test_utils::NavigateToURL(browser(), web_url);
341 WebContents* web_contents =
342 browser()->tab_strip_model()->GetActiveWebContents();
343 EXPECT_EQ(web_url, web_contents->GetLastCommittedURL());
344 content::RenderProcessHost* old_process_host =
345 web_contents->GetMainFrame()->GetProcess();
346
347 // Note that the |setTimeout| call below is needed to make sure
348 // ExecuteScriptAndExtractBool returns *after* a scheduled navigation has
349 // already started.
350 GURL cws_web_url(gallery_url().spec() + "title1.html");
351 std::string navigation_starting_script =
352 "var form = document.getElementById('form');\n"
353 "form.action = '" + cws_web_url.spec() + "';\n"
354 "form.submit();\n"
355 "setTimeout(\n"
356 " function() { window.domAutomationController.send(true); },\n"
357 " 0);\n";
358
359 // Trigger a renderer-initiated POST navigation (via the form) to a Chrome Web
360 // Store gallery URL (which will commit into a chrome-extension://cws-app-id).
361 bool ignored_script_result = false;
362 content::TestNavigationObserver nav_observer(web_contents, 1);
363 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
364 web_contents, navigation_starting_script, &ignored_script_result));
365
366 // Verify that the navigation succeeded.
367 nav_observer.Wait();
368 EXPECT_EQ(cws_web_url, web_contents->GetLastCommittedURL());
369
370 // Verify that we really have the Chrome Web Store app loaded in the Web
371 // Contents.
372 content::RenderProcessHost* new_process_host =
373 web_contents->GetMainFrame()->GetProcess();
374 EXPECT_TRUE(extensions::ProcessMap::Get(profile())->Contains(
375 extensions::kWebStoreAppId, new_process_host->GetID()));
376
377 // Verify that Chrome Web Store is isolated in a separate renderer process.
378 if (extensions::IsIsolateExtensionsEnabled())
379 EXPECT_NE(old_process_host, new_process_host);
Łukasz Anforowicz 2016/10/05 22:34:56 The test expectation above would fail before the c
lazyboy 2016/10/05 23:20:02 Acknowledged.
380 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698