[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
avi | a2f4804a | 2015-12-24 23:11:13 | [diff] [blame] | 5 | #include <stddef.h> |
| 6 | |
Lei Zhang | fe5b8693 | 2019-02-01 17:26:59 | [diff] [blame] | 7 | #include "base/strings/stringprintf.h" |
[email protected] | 112158af | 2013-06-07 23:46:18 | [diff] [blame] | 8 | #include "base/strings/utf_string_conversions.h" |
avi | a2f4804a | 2015-12-24 23:11:13 | [diff] [blame] | 9 | #include "build/build_config.h" |
nasko | d1aaa76 | 2017-03-18 02:14:45 | [diff] [blame] | 10 | #include "chrome/browser/chrome_notification_types.h" |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 11 | #include "chrome/browser/extensions/extension_apitest.h" |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 12 | #include "chrome/browser/extensions/extension_service.h" |
| 13 | #include "chrome/browser/profiles/profile.h" |
| 14 | #include "chrome/browser/profiles/profile_manager.h" |
nasko | d1aaa76 | 2017-03-18 02:14:45 | [diff] [blame] | 15 | #include "chrome/browser/sessions/session_tab_helper.h" |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 16 | #include "chrome/browser/ui/browser.h" |
[email protected] | ee49695 | 2013-01-10 23:17:33 | [diff] [blame] | 17 | #include "chrome/browser/ui/tabs/tab_strip_model.h" |
lukasza | 2a130dc | 2016-10-06 00:50:43 | [diff] [blame] | 18 | #include "chrome/common/chrome_switches.h" |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 19 | #include "chrome/common/url_constants.h" |
| 20 | #include "chrome/test/base/ui_test_utils.h" |
nasko | d1aaa76 | 2017-03-18 02:14:45 | [diff] [blame] | 21 | #include "content/public/browser/notification_service.h" |
lukasza | 1d02573 | 2016-09-28 21:36:08 | [diff] [blame] | 22 | #include "content/public/browser/render_frame_host.h" |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 23 | #include "content/public/browser/render_process_host.h" |
[email protected] | 9c1662b | 2012-03-06 15:44:33 | [diff] [blame] | 24 | #include "content/public/browser/render_view_host.h" |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 25 | #include "content/public/browser/site_instance.h" |
| 26 | #include "content/public/browser/web_contents.h" |
Alex Moshchuk | ca17137 | 2017-11-28 16:11:31 | [diff] [blame] | 27 | #include "content/public/common/content_switches.h" |
lukasza | 1d02573 | 2016-09-28 21:36:08 | [diff] [blame] | 28 | #include "content/public/test/browser_test_utils.h" |
| 29 | #include "content/public/test/test_navigation_observer.h" |
Lukasz Anforowicz | 1df5d87d | 2018-03-02 01:30:47 | [diff] [blame] | 30 | #include "content/public/test/test_utils.h" |
[email protected] | 22401dc | 2014-03-21 01:38:57 | [diff] [blame] | 31 | #include "extensions/browser/extension_host.h" |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 32 | #include "extensions/browser/process_manager.h" |
lukasza | 2a130dc | 2016-10-06 00:50:43 | [diff] [blame] | 33 | #include "extensions/browser/process_map.h" |
Devlin Cronin | f1afce25 | 2017-08-19 01:21:48 | [diff] [blame] | 34 | #include "extensions/common/manifest_handlers/web_accessible_resources_info.h" |
[email protected] | c8d0299 | 2013-07-31 22:16:51 | [diff] [blame] | 35 | #include "extensions/common/switches.h" |
[email protected] | f2cb3cf | 2013-03-21 01:40:53 | [diff] [blame] | 36 | #include "net/dns/mock_host_resolver.h" |
[email protected] | c1dffe8 | 2013-06-26 20:59:05 | [diff] [blame] | 37 | #include "net/test/embedded_test_server/embedded_test_server.h" |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 38 | |
| 39 | using content::NavigationController; |
| 40 | using content::WebContents; |
| 41 | |
Devlin Cronin | f1afce25 | 2017-08-19 01:21:48 | [diff] [blame] | 42 | namespace extensions { |
| 43 | |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 44 | namespace { |
| 45 | |
Nick Carter | bf6264a5 | 2018-04-06 02:39:33 | [diff] [blame] | 46 | bool IsExtensionProcessSharingAllowed() { |
| 47 | // TODO(nick): Currently, process sharing is allowed even in |
| 48 | // --site-per-process. Lock this down. https://crbug.com/766267 |
| 49 | return true; |
| 50 | } |
| 51 | |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 52 | class ProcessManagementTest : public ExtensionBrowserTest { |
| 53 | private: |
| 54 | // This is needed for testing isolated apps, which are still experimental. |
avi | 3ef9ec9e | 2014-12-22 22:50:17 | [diff] [blame] | 55 | void SetUpCommandLine(base::CommandLine* command_line) override { |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 56 | ExtensionBrowserTest::SetUpCommandLine(command_line); |
[email protected] | c8d0299 | 2013-07-31 22:16:51 | [diff] [blame] | 57 | command_line->AppendSwitch( |
| 58 | extensions::switches::kEnableExperimentalExtensionApis); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 59 | } |
jam | bb11ed74 | 2017-05-01 17:27:59 | [diff] [blame] | 60 | |
| 61 | void SetUpOnMainThread() override { |
| 62 | ExtensionBrowserTest::SetUpOnMainThread(); |
| 63 | host_resolver()->AddRule("*", "127.0.0.1"); |
| 64 | } |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 65 | }; |
| 66 | |
lukasza | 2a130dc | 2016-10-06 00:50:43 | [diff] [blame] | 67 | class ChromeWebStoreProcessTest : public ExtensionBrowserTest { |
| 68 | public: |
| 69 | const GURL& gallery_url() { return gallery_url_; } |
| 70 | |
lukasza | 2a130dc | 2016-10-06 00:50:43 | [diff] [blame] | 71 | // Overrides location of Chrome Web Store gallery to a test controlled URL. |
| 72 | void SetUpCommandLine(base::CommandLine* command_line) override { |
| 73 | ExtensionBrowserTest::SetUpCommandLine(command_line); |
| 74 | |
| 75 | ASSERT_TRUE(embedded_test_server()->Start()); |
| 76 | gallery_url_ = |
| 77 | embedded_test_server()->GetURL("chrome.webstore.test.com", "/"); |
Devlin Cronin | f1afce25 | 2017-08-19 01:21:48 | [diff] [blame] | 78 | command_line->AppendSwitchASCII(::switches::kAppsGalleryURL, |
lukasza | 2a130dc | 2016-10-06 00:50:43 | [diff] [blame] | 79 | gallery_url_.spec()); |
| 80 | } |
| 81 | |
Alex Moshchuk | ca17137 | 2017-11-28 16:11:31 | [diff] [blame] | 82 | private: |
lukasza | 2a130dc | 2016-10-06 00:50:43 | [diff] [blame] | 83 | void SetUpOnMainThread() override { |
| 84 | host_resolver()->AddRule("*", "127.0.0.1"); |
| 85 | } |
| 86 | |
| 87 | GURL gallery_url_; |
| 88 | }; |
| 89 | |
Alex Moshchuk | ca17137 | 2017-11-28 16:11:31 | [diff] [blame] | 90 | class ChromeWebStoreInIsolatedOriginTest : public ChromeWebStoreProcessTest { |
| 91 | public: |
| 92 | ChromeWebStoreInIsolatedOriginTest() {} |
| 93 | |
| 94 | void SetUpCommandLine(base::CommandLine* command_line) override { |
| 95 | ChromeWebStoreProcessTest::SetUpCommandLine(command_line); |
| 96 | |
| 97 | // Mark the Chrome Web Store URL as an isolated origin. |
| 98 | command_line->AppendSwitchASCII(::switches::kIsolateOrigins, |
| 99 | gallery_url().spec()); |
| 100 | } |
| 101 | |
| 102 | private: |
| 103 | DISALLOW_COPY_AND_ASSIGN(ChromeWebStoreInIsolatedOriginTest); |
| 104 | }; |
| 105 | |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 106 | } // namespace |
| 107 | |
[email protected] | bb4162a | 2013-02-03 01:35:12 | [diff] [blame] | 108 | |
[email protected] | 1c6a3f2 | 2013-03-19 09:52:30 | [diff] [blame] | 109 | // TODO(nasko): crbug.com/173137 |
| 110 | #if defined(OS_WIN) |
[email protected] | bb4162a | 2013-02-03 01:35:12 | [diff] [blame] | 111 | #define MAYBE_ProcessOverflow DISABLED_ProcessOverflow |
| 112 | #else |
| 113 | #define MAYBE_ProcessOverflow ProcessOverflow |
| 114 | #endif |
| 115 | |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 116 | // Ensure that an isolated app never shares a process with WebUIs, non-isolated |
| 117 | // extensions, and normal webpages. None of these should ever comingle |
| 118 | // RenderProcessHosts even if we hit the process limit. |
[email protected] | bb4162a | 2013-02-03 01:35:12 | [diff] [blame] | 119 | IN_PROC_BROWSER_TEST_F(ProcessManagementTest, MAYBE_ProcessOverflow) { |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 120 | // Set max renderers to 1 to force running out of processes. |
| 121 | content::RenderProcessHost::SetMaxRendererProcessCount(1); |
| 122 | |
svaldez | a01f7d9 | 2015-11-18 17:47:56 | [diff] [blame] | 123 | ASSERT_TRUE(embedded_test_server()->Start()); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 124 | |
| 125 | ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app1"))); |
| 126 | ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app2"))); |
| 127 | ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("hosted_app"))); |
| 128 | ASSERT_TRUE( |
| 129 | LoadExtension(test_data_dir_.AppendASCII("api_test/app_process"))); |
| 130 | |
| 131 | // The app under test acts on URLs whose host is "localhost", |
| 132 | // so the URLs we navigate to must have host "localhost". |
[email protected] | c1dffe8 | 2013-06-26 20:59:05 | [diff] [blame] | 133 | GURL base_url = embedded_test_server()->GetURL( |
| 134 | "/extensions/"); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 135 | GURL::Replacements replace_host; |
mgiuca | 77752c3 | 2015-02-05 07:31:18 | [diff] [blame] | 136 | replace_host.SetHostStr("localhost"); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 137 | base_url = base_url.ReplaceComponents(replace_host); |
| 138 | |
| 139 | // Load an extension before adding tabs. |
[email protected] | 1c321ee5 | 2012-05-21 03:02:34 | [diff] [blame] | 140 | const extensions::Extension* extension1 = LoadExtension( |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 141 | test_data_dir_.AppendASCII("api_test/browser_action/basics")); |
| 142 | ASSERT_TRUE(extension1); |
| 143 | GURL extension1_url = extension1->url(); |
| 144 | |
| 145 | // Create multiple tabs for each type of renderer that might exist. |
thestig | 53986dc | 2014-12-16 06:09:18 | [diff] [blame] | 146 | ui_test_utils::NavigateToURL( |
| 147 | browser(), base_url.Resolve("isolated_apps/app1/main.html")); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 148 | ui_test_utils::NavigateToURLWithDisposition( |
| 149 | browser(), GURL(chrome::kChromeUINewTabURL), |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 150 | WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 151 | ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 152 | ui_test_utils::NavigateToURLWithDisposition( |
| 153 | browser(), base_url.Resolve("hosted_app/main.html"), |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 154 | WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 155 | ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 156 | ui_test_utils::NavigateToURLWithDisposition( |
| 157 | browser(), base_url.Resolve("test_file.html"), |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 158 | WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 159 | ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 160 | |
| 161 | ui_test_utils::NavigateToURLWithDisposition( |
| 162 | browser(), base_url.Resolve("isolated_apps/app2/main.html"), |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 163 | WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 164 | ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 165 | ui_test_utils::NavigateToURLWithDisposition( |
| 166 | browser(), GURL(chrome::kChromeUINewTabURL), |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 167 | WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 168 | ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 169 | ui_test_utils::NavigateToURLWithDisposition( |
| 170 | browser(), base_url.Resolve("api_test/app_process/path1/empty.html"), |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 171 | WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 172 | ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 173 | ui_test_utils::NavigateToURLWithDisposition( |
| 174 | browser(), base_url.Resolve("test_file_with_body.html"), |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 175 | WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 176 | ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 177 | |
| 178 | // Load another copy of isolated app 1. |
| 179 | ui_test_utils::NavigateToURLWithDisposition( |
| 180 | browser(), base_url.Resolve("isolated_apps/app1/main.html"), |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 181 | WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 182 | ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 183 | |
| 184 | // Load another extension. |
[email protected] | 1c321ee5 | 2012-05-21 03:02:34 | [diff] [blame] | 185 | const extensions::Extension* extension2 = LoadExtension( |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 186 | test_data_dir_.AppendASCII("api_test/browser_action/close_background")); |
| 187 | ASSERT_TRUE(extension2); |
| 188 | GURL extension2_url = extension2->url(); |
| 189 | |
| 190 | // Get tab processes. |
[email protected] | ee49695 | 2013-01-10 23:17:33 | [diff] [blame] | 191 | ASSERT_EQ(9, browser()->tab_strip_model()->count()); |
Lukasz Anforowicz | 3f0b84ca | 2017-09-28 13:02:37 | [diff] [blame] | 192 | content::RenderProcessHost* isolated1_host = browser() |
| 193 | ->tab_strip_model() |
| 194 | ->GetWebContentsAt(0) |
| 195 | ->GetMainFrame() |
| 196 | ->GetProcess(); |
| 197 | content::RenderProcessHost* ntp1_host = browser() |
| 198 | ->tab_strip_model() |
| 199 | ->GetWebContentsAt(1) |
| 200 | ->GetMainFrame() |
| 201 | ->GetProcess(); |
| 202 | content::RenderProcessHost* hosted1_host = browser() |
| 203 | ->tab_strip_model() |
| 204 | ->GetWebContentsAt(2) |
| 205 | ->GetMainFrame() |
| 206 | ->GetProcess(); |
| 207 | content::RenderProcessHost* web1_host = browser() |
| 208 | ->tab_strip_model() |
| 209 | ->GetWebContentsAt(3) |
| 210 | ->GetMainFrame() |
| 211 | ->GetProcess(); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 212 | |
Lukasz Anforowicz | 3f0b84ca | 2017-09-28 13:02:37 | [diff] [blame] | 213 | content::RenderProcessHost* isolated2_host = browser() |
| 214 | ->tab_strip_model() |
| 215 | ->GetWebContentsAt(4) |
| 216 | ->GetMainFrame() |
| 217 | ->GetProcess(); |
| 218 | content::RenderProcessHost* ntp2_host = browser() |
| 219 | ->tab_strip_model() |
| 220 | ->GetWebContentsAt(5) |
| 221 | ->GetMainFrame() |
| 222 | ->GetProcess(); |
| 223 | content::RenderProcessHost* hosted2_host = browser() |
| 224 | ->tab_strip_model() |
| 225 | ->GetWebContentsAt(6) |
| 226 | ->GetMainFrame() |
| 227 | ->GetProcess(); |
| 228 | content::RenderProcessHost* web2_host = browser() |
| 229 | ->tab_strip_model() |
| 230 | ->GetWebContentsAt(7) |
| 231 | ->GetMainFrame() |
| 232 | ->GetProcess(); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 233 | |
Lukasz Anforowicz | 3f0b84ca | 2017-09-28 13:02:37 | [diff] [blame] | 234 | content::RenderProcessHost* second_isolated1_host = browser() |
| 235 | ->tab_strip_model() |
| 236 | ->GetWebContentsAt(8) |
| 237 | ->GetMainFrame() |
| 238 | ->GetProcess(); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 239 | |
| 240 | // Get extension processes. |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 241 | extensions::ProcessManager* process_manager = |
reillyg | 0ea3fa90 | 2014-10-28 15:30:23 | [diff] [blame] | 242 | extensions::ProcessManager::Get(browser()->profile()); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 243 | content::RenderProcessHost* extension1_host = |
| 244 | process_manager->GetSiteInstanceForURL(extension1_url)->GetProcess(); |
| 245 | content::RenderProcessHost* extension2_host = |
| 246 | process_manager->GetSiteInstanceForURL(extension2_url)->GetProcess(); |
| 247 | |
| 248 | // An isolated app only shares with other instances of itself, not other |
| 249 | // isolated apps or anything else. |
| 250 | EXPECT_EQ(isolated1_host, second_isolated1_host); |
| 251 | EXPECT_NE(isolated1_host, isolated2_host); |
| 252 | EXPECT_NE(isolated1_host, ntp1_host); |
| 253 | EXPECT_NE(isolated1_host, hosted1_host); |
| 254 | EXPECT_NE(isolated1_host, web1_host); |
| 255 | EXPECT_NE(isolated1_host, extension1_host); |
| 256 | EXPECT_NE(isolated2_host, ntp1_host); |
| 257 | EXPECT_NE(isolated2_host, hosted1_host); |
| 258 | EXPECT_NE(isolated2_host, web1_host); |
| 259 | EXPECT_NE(isolated2_host, extension1_host); |
| 260 | |
| 261 | // Everything else is clannish. WebUI only shares with other WebUI. |
| 262 | EXPECT_EQ(ntp1_host, ntp2_host); |
| 263 | EXPECT_NE(ntp1_host, hosted1_host); |
| 264 | EXPECT_NE(ntp1_host, web1_host); |
| 265 | EXPECT_NE(ntp1_host, extension1_host); |
| 266 | |
| 267 | // Hosted apps only share with each other. |
[email protected] | 41fb79a5 | 2012-06-29 16:34:33 | [diff] [blame] | 268 | // Note that hosted2_host's app has the background permission and will use |
| 269 | // process-per-site mode, but it should still share with hosted1_host's app. |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 270 | EXPECT_EQ(hosted1_host, hosted2_host); |
| 271 | EXPECT_NE(hosted1_host, web1_host); |
| 272 | EXPECT_NE(hosted1_host, extension1_host); |
| 273 | |
| 274 | // Web pages only share with each other. |
| 275 | EXPECT_EQ(web1_host, web2_host); |
| 276 | EXPECT_NE(web1_host, extension1_host); |
| 277 | |
Nick Carter | bf6264a5 | 2018-04-06 02:39:33 | [diff] [blame] | 278 | if (IsExtensionProcessSharingAllowed()) { |
Lukasz Anforowicz | 1df5d87d | 2018-03-02 01:30:47 | [diff] [blame] | 279 | // Extensions only share with each other ... |
| 280 | EXPECT_EQ(extension1_host, extension2_host); |
| 281 | } else { |
Nick Carter | bf6264a5 | 2018-04-06 02:39:33 | [diff] [blame] | 282 | // Unless extensions are not allowed to share, even with each other. |
Lukasz Anforowicz | 1df5d87d | 2018-03-02 01:30:47 | [diff] [blame] | 283 | EXPECT_NE(extension1_host, extension2_host); |
| 284 | } |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 285 | } |
| 286 | |
[email protected] | 58b6c699 | 2013-06-11 17:29:50 | [diff] [blame] | 287 | // See |
| 288 | #if defined(OS_WIN) |
| 289 | #define MAYBE_ExtensionProcessBalancing DISABLED_ExtensionProcessBalancing |
| 290 | #else |
| 291 | #define MAYBE_ExtensionProcessBalancing ExtensionProcessBalancing |
| 292 | #endif |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 293 | // Test to verify that the policy of maximum share of extension processes is |
| 294 | // properly enforced. |
[email protected] | 58b6c699 | 2013-06-11 17:29:50 | [diff] [blame] | 295 | IN_PROC_BROWSER_TEST_F(ProcessManagementTest, MAYBE_ExtensionProcessBalancing) { |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 296 | // Set max renderers to 6 so we can expect 2 extension processes to be |
| 297 | // allocated. |
| 298 | content::RenderProcessHost::SetMaxRendererProcessCount(6); |
| 299 | |
svaldez | a01f7d9 | 2015-11-18 17:47:56 | [diff] [blame] | 300 | ASSERT_TRUE(embedded_test_server()->Start()); |
[email protected] | c3f757f3 | 2012-03-30 22:34:58 | [diff] [blame] | 301 | |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 302 | // The app under test acts on URLs whose host is "localhost", |
| 303 | // so the URLs we navigate to must have host "localhost". |
[email protected] | c1dffe8 | 2013-06-26 20:59:05 | [diff] [blame] | 304 | GURL base_url = embedded_test_server()->GetURL( |
| 305 | "/extensions/"); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 306 | GURL::Replacements replace_host; |
mgiuca | 77752c3 | 2015-02-05 07:31:18 | [diff] [blame] | 307 | replace_host.SetHostStr("localhost"); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 308 | base_url = base_url.ReplaceComponents(replace_host); |
| 309 | |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 310 | ASSERT_TRUE(LoadExtension( |
| 311 | test_data_dir_.AppendASCII("api_test/browser_action/none"))); |
| 312 | ASSERT_TRUE(LoadExtension( |
| 313 | test_data_dir_.AppendASCII("api_test/browser_action/basics"))); |
| 314 | ASSERT_TRUE(LoadExtension( |
| 315 | test_data_dir_.AppendASCII("api_test/browser_action/remove_popup"))); |
| 316 | ASSERT_TRUE(LoadExtension( |
| 317 | test_data_dir_.AppendASCII("api_test/browser_action/add_popup"))); |
| 318 | ASSERT_TRUE(LoadExtension( |
| 319 | test_data_dir_.AppendASCII("api_test/browser_action/no_icon"))); |
| 320 | ASSERT_TRUE(LoadExtension( |
| 321 | test_data_dir_.AppendASCII("isolated_apps/app1"))); |
| 322 | ASSERT_TRUE(LoadExtension( |
| 323 | test_data_dir_.AppendASCII("api_test/management/test"))); |
| 324 | |
Lukasz Anforowicz | 1df5d87d | 2018-03-02 01:30:47 | [diff] [blame] | 325 | // TODO(lukasza): It might be worth it to navigate to actual |
| 326 | // chrome-extension:// URIs below (not to HTTP URIs) to make sure the 1/3rd |
| 327 | // of process limit also applies to normal tabs (not just to background pages |
| 328 | // and scripts). |
danakj | fb16d7b6 | 2018-10-25 21:51:04 | [diff] [blame] | 329 | content::RenderProcessHost* first_renderer = ui_test_utils::NavigateToURL( |
thestig | 53986dc | 2014-12-16 06:09:18 | [diff] [blame] | 330 | browser(), base_url.Resolve("isolated_apps/app1/main.html")); |
danakj | fb16d7b6 | 2018-10-25 21:51:04 | [diff] [blame] | 331 | content::RenderProcessHostWatcher first_renderer_watcher( |
| 332 | first_renderer, |
| 333 | content::RenderProcessHostWatcher::WATCH_FOR_HOST_DESTRUCTION); |
| 334 | |
| 335 | content::RenderProcessHost* second_renderer = ui_test_utils::NavigateToURL( |
thestig | 53986dc | 2014-12-16 06:09:18 | [diff] [blame] | 336 | browser(), base_url.Resolve("api_test/management/test/basics.html")); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 337 | |
| 338 | std::set<int> process_ids; |
[email protected] | 2fc15ae | 2012-05-06 00:01:37 | [diff] [blame] | 339 | Profile* profile = browser()->profile(); |
reillyg | 0ea3fa90 | 2014-10-28 15:30:23 | [diff] [blame] | 340 | extensions::ProcessManager* epm = extensions::ProcessManager::Get(profile); |
rdevlin.cronin | 6ae04a01 | 2015-04-03 20:19:40 | [diff] [blame] | 341 | for (extensions::ExtensionHost* host : epm->background_hosts()) |
| 342 | process_ids.insert(host->render_process_host()->GetID()); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 343 | |
Lukasz Anforowicz | 1df5d87d | 2018-03-02 01:30:47 | [diff] [blame] | 344 | // We've loaded 5 extensions with background pages |
| 345 | // (api_test/browser_action/*), 1 extension without background page |
Nick Carter | bf6264a5 | 2018-04-06 02:39:33 | [diff] [blame] | 346 | // (api_test/management), and one isolated app. With extension process |
| 347 | // sharing, we expect only 2 unique processes hosting the background |
| 348 | // pages/scripts of these extensions (which extension gets assigned to which |
| 349 | // process is randomized). If extension process sharing is disabled, there is |
| 350 | // no process limit, and each of the 5 background pages/scripts will be hosted |
| 351 | // in a separate process. |
| 352 | if (IsExtensionProcessSharingAllowed()) |
Lukasz Anforowicz | 1df5d87d | 2018-03-02 01:30:47 | [diff] [blame] | 353 | EXPECT_EQ(2u, process_ids.size()); |
| 354 | else |
| 355 | EXPECT_EQ(5u, process_ids.size()); |
[email protected] | 06bdd2b | 2012-11-30 18:47:13 | [diff] [blame] | 356 | |
danakj | fb16d7b6 | 2018-10-25 21:51:04 | [diff] [blame] | 357 | if (first_renderer != second_renderer) { |
| 358 | // Wait for the first renderer to be torn down before verifying the number |
| 359 | // of processes, else we race with the teardown here (specifically the |
Yuzu Saijo | c0636d2 | 2019-07-12 05:42:10 | [diff] [blame] | 360 | // UnfreezableFrameMsg_SwapOut -> FrameHostMsg_SwapOut_ACK round trip). |
danakj | fb16d7b6 | 2018-10-25 21:51:04 | [diff] [blame] | 361 | first_renderer_watcher.Wait(); |
| 362 | } |
| 363 | |
Lukasz Anforowicz | 1df5d87d | 2018-03-02 01:30:47 | [diff] [blame] | 364 | // ProcessMap will always have exactly 5 entries - one for each of the |
| 365 | // extensions with a background page (api_test/browser_action/*). There won't |
| 366 | // be any additional entries, since 1) the isolated app will be associated |
| 367 | // with a separate content::BrowserContext and 2) the navigation to |
| 368 | // api_test/management/test/basics.html navigates to a file: URI (not to a |
| 369 | // chrome-extension: URI). |
| 370 | extensions::ProcessMap* process_map = extensions::ProcessMap::Get(profile); |
| 371 | EXPECT_EQ(5u, process_map->size()); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 372 | } |
lukasza | 1d02573 | 2016-09-28 21:36:08 | [diff] [blame] | 373 | |
| 374 | IN_PROC_BROWSER_TEST_F(ProcessManagementTest, |
| 375 | NavigateExtensionTabToWebViaPost) { |
lukasza | 1d02573 | 2016-09-28 21:36:08 | [diff] [blame] | 376 | ASSERT_TRUE(embedded_test_server()->Start()); |
| 377 | |
| 378 | // Load an extension. |
| 379 | const extensions::Extension* extension = LoadExtension( |
| 380 | test_data_dir_.AppendASCII("api_test/browser_action/popup_with_form")); |
| 381 | ASSERT_TRUE(extension); |
| 382 | |
| 383 | // Navigate a tab to an extension page. |
| 384 | GURL extension_url = extension->GetResourceURL("popup.html"); |
| 385 | ui_test_utils::NavigateToURL(browser(), extension_url); |
| 386 | WebContents* web_contents = |
| 387 | browser()->tab_strip_model()->GetActiveWebContents(); |
| 388 | EXPECT_EQ(extension_url, web_contents->GetLastCommittedURL()); |
| 389 | content::RenderProcessHost* old_process_host = |
| 390 | web_contents->GetMainFrame()->GetProcess(); |
| 391 | |
| 392 | // Note that the |setTimeout| call below is needed to make sure |
| 393 | // ExecuteScriptAndExtractBool returns *after* a scheduled navigation has |
| 394 | // already started. |
| 395 | GURL web_url(embedded_test_server()->GetURL("foo.com", "/title1.html")); |
| 396 | std::string navigation_starting_script = |
| 397 | "var form = document.getElementById('form');\n" |
| 398 | "form.action = '" + web_url.spec() + "';\n" |
| 399 | "form.submit();\n" |
| 400 | "setTimeout(\n" |
| 401 | " function() { window.domAutomationController.send(true); },\n" |
| 402 | " 0);\n"; |
| 403 | |
| 404 | // Try to trigger navigation to a webpage from within the tab. |
| 405 | bool ignored_script_result = false; |
| 406 | content::TestNavigationObserver nav_observer(web_contents, 1); |
| 407 | EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 408 | web_contents, navigation_starting_script, &ignored_script_result)); |
| 409 | |
| 410 | // Verify that the navigation succeeded. |
| 411 | nav_observer.Wait(); |
| 412 | EXPECT_EQ(web_url, web_contents->GetLastCommittedURL()); |
| 413 | |
| 414 | // Verify that the navigation transferred the contents to another renderer |
| 415 | // process. |
nasko | abed2a5 | 2017-05-03 05:10:17 | [diff] [blame] | 416 | content::RenderProcessHost* new_process_host = |
| 417 | web_contents->GetMainFrame()->GetProcess(); |
| 418 | EXPECT_NE(old_process_host, new_process_host); |
lukasza | 1d02573 | 2016-09-28 21:36:08 | [diff] [blame] | 419 | } |
lukasza | 2a130dc | 2016-10-06 00:50:43 | [diff] [blame] | 420 | |
| 421 | IN_PROC_BROWSER_TEST_F(ChromeWebStoreProcessTest, |
| 422 | NavigateWebTabToChromeWebStoreViaPost) { |
| 423 | // Navigate a tab to a web page with a form. |
| 424 | GURL web_url = embedded_test_server()->GetURL("foo.com", "/form.html"); |
| 425 | ui_test_utils::NavigateToURL(browser(), web_url); |
| 426 | WebContents* web_contents = |
| 427 | browser()->tab_strip_model()->GetActiveWebContents(); |
| 428 | EXPECT_EQ(web_url, web_contents->GetLastCommittedURL()); |
| 429 | content::RenderProcessHost* old_process_host = |
| 430 | web_contents->GetMainFrame()->GetProcess(); |
| 431 | |
| 432 | // Calculate an URL that is 1) relative to the fake (i.e. test-controlled) |
| 433 | // Chrome Web Store gallery URL and 2) resolves to something that |
| 434 | // embedded_test_server can actually serve (e.g. title1.html test file). |
| 435 | GURL::Replacements replace_path; |
| 436 | replace_path.SetPathStr("/title1.html"); |
| 437 | GURL cws_web_url = gallery_url().ReplaceComponents(replace_path); |
| 438 | |
| 439 | // Note that the |setTimeout| call below is needed to make sure |
| 440 | // ExecuteScriptAndExtractBool returns *after* a scheduled navigation has |
| 441 | // already started. |
| 442 | std::string navigation_starting_script = |
| 443 | "var form = document.getElementById('form');\n" |
| 444 | "form.action = '" + cws_web_url.spec() + "';\n" |
| 445 | "form.submit();\n" |
| 446 | "setTimeout(\n" |
| 447 | " function() { window.domAutomationController.send(true); },\n" |
| 448 | " 0);\n"; |
| 449 | |
| 450 | // Trigger a renderer-initiated POST navigation (via the form) to a Chrome Web |
| 451 | // Store gallery URL (which will commit into a chrome-extension://cws-app-id). |
| 452 | bool ignored_script_result = false; |
| 453 | content::TestNavigationObserver nav_observer(web_contents, 1); |
nasko | 9729c20 | 2016-10-31 19:52:29 | [diff] [blame] | 454 | |
lukasza | 2a130dc | 2016-10-06 00:50:43 | [diff] [blame] | 455 | EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 456 | web_contents, navigation_starting_script, &ignored_script_result)); |
| 457 | |
nasko | abed2a5 | 2017-05-03 05:10:17 | [diff] [blame] | 458 | // The expectation is that the store will be properly put in its own process, |
| 459 | // otherwise the renderer process is going to be terminated. |
lukasza | 2a130dc | 2016-10-06 00:50:43 | [diff] [blame] | 460 | // Verify that the navigation succeeded. |
| 461 | nav_observer.Wait(); |
| 462 | EXPECT_EQ(cws_web_url, web_contents->GetLastCommittedURL()); |
| 463 | |
| 464 | // Verify that we really have the Chrome Web Store app loaded in the Web |
| 465 | // Contents. |
| 466 | content::RenderProcessHost* new_process_host = |
| 467 | web_contents->GetMainFrame()->GetProcess(); |
| 468 | EXPECT_TRUE(extensions::ProcessMap::Get(profile())->Contains( |
| 469 | extensions::kWebStoreAppId, new_process_host->GetID())); |
| 470 | |
| 471 | // Verify that Chrome Web Store is isolated in a separate renderer process. |
nasko | 9729c20 | 2016-10-31 19:52:29 | [diff] [blame] | 472 | EXPECT_NE(old_process_host, new_process_host); |
lukasza | 2a130dc | 2016-10-06 00:50:43 | [diff] [blame] | 473 | } |
nasko | d1aaa76 | 2017-03-18 02:14:45 | [diff] [blame] | 474 | |
Alex Moshchuk | ca17137 | 2017-11-28 16:11:31 | [diff] [blame] | 475 | // Check that navigations to the Chrome Web Store succeed when the Chrome Web |
| 476 | // Store URL's origin is set as an isolated origin via the |
| 477 | // --isolate-origins flag. See https://crbug.com/788837. |
| 478 | IN_PROC_BROWSER_TEST_F(ChromeWebStoreInIsolatedOriginTest, |
| 479 | NavigationLoadsChromeWebStore) { |
| 480 | // Sanity check that a SiteInstance for a Chrome Web Store URL requires a |
| 481 | // dedicated process. |
| 482 | content::BrowserContext* context = browser()->profile(); |
| 483 | scoped_refptr<content::SiteInstance> cws_site_instance = |
| 484 | content::SiteInstance::CreateForURL(context, gallery_url()); |
| 485 | EXPECT_TRUE(cws_site_instance->RequiresDedicatedProcess()); |
| 486 | |
| 487 | // Navigate to Chrome Web Store and check that it's loaded successfully. |
| 488 | ui_test_utils::NavigateToURL(browser(), gallery_url()); |
| 489 | WebContents* web_contents = |
| 490 | browser()->tab_strip_model()->GetActiveWebContents(); |
| 491 | EXPECT_EQ(gallery_url(), web_contents->GetLastCommittedURL()); |
| 492 | |
| 493 | // Verify that the Chrome Web Store hosted app is really loaded. |
| 494 | content::RenderProcessHost* render_process_host = |
| 495 | web_contents->GetMainFrame()->GetProcess(); |
| 496 | EXPECT_TRUE(extensions::ProcessMap::Get(profile())->Contains( |
| 497 | extensions::kWebStoreAppId, render_process_host->GetID())); |
| 498 | } |
| 499 | |
nasko | d1aaa76 | 2017-03-18 02:14:45 | [diff] [blame] | 500 | // This test verifies that blocked navigations to extensions pages do not |
| 501 | // overwrite process-per-site map inside content/. |
jam | bb11ed74 | 2017-05-01 17:27:59 | [diff] [blame] | 502 | IN_PROC_BROWSER_TEST_F(ProcessManagementTest, |
nasko | d1aaa76 | 2017-03-18 02:14:45 | [diff] [blame] | 503 | NavigateToBlockedExtensionPageInNewTab) { |
nasko | d1aaa76 | 2017-03-18 02:14:45 | [diff] [blame] | 504 | ASSERT_TRUE(embedded_test_server()->Start()); |
| 505 | |
| 506 | // Load an extension, which will block a request for a specific page in it. |
| 507 | const extensions::Extension* extension = LoadExtension( |
| 508 | test_data_dir_.AppendASCII("web_request_site_process_registration")); |
| 509 | ASSERT_TRUE(extension); |
| 510 | |
| 511 | WebContents* web_contents = |
| 512 | browser()->tab_strip_model()->GetActiveWebContents(); |
| 513 | GURL blocked_url(extension->GetResourceURL("/blocked.html")); |
| 514 | |
| 515 | // Navigating to the blocked extension URL should be done through a redirect, |
| 516 | // otherwise it will result in an OpenURL IPC from the renderer process, which |
| 517 | // will initiate a navigation through the browser process. |
| 518 | GURL redirect_url( |
| 519 | embedded_test_server()->GetURL("/server-redirect?" + blocked_url.spec())); |
| 520 | |
| 521 | // Navigate the current tab to the test page in the extension, which will |
| 522 | // create the extension process and register the webRequest blocking listener. |
| 523 | ui_test_utils::NavigateToURL(browser(), |
| 524 | extension->GetResourceURL("/test.html")); |
| 525 | |
| 526 | // Open a new tab to about:blank, which will result in a new SiteInstance |
| 527 | // without an explicit site URL set. |
| 528 | ui_test_utils::NavigateToURLWithDisposition( |
| 529 | browser(), GURL(url::kAboutBlankURL), |
| 530 | WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 531 | ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 532 | WebContents* new_web_contents = |
| 533 | browser()->tab_strip_model()->GetActiveWebContents(); |
| 534 | |
| 535 | // Navigate the new tab to an extension URL that will be blocked by |
| 536 | // webRequest. It must be a renderer-initiated navigation. It also uses a |
| 537 | // redirect, otherwise the regular renderer process will send an OpenURL |
| 538 | // IPC to the browser due to the chrome-extension:// URL. |
| 539 | std::string script = |
| 540 | base::StringPrintf("location.href = '%s';", redirect_url.spec().c_str()); |
| 541 | content::TestNavigationObserver observer(new_web_contents); |
| 542 | EXPECT_TRUE(content::ExecuteScript(new_web_contents, script)); |
| 543 | observer.Wait(); |
| 544 | |
| 545 | EXPECT_EQ(observer.last_navigation_url(), blocked_url); |
| 546 | EXPECT_FALSE(observer.last_navigation_succeeded()); |
| 547 | |
| 548 | // Very subtle check for content/ internal functionality :(. |
| 549 | // When a navigation is blocked, it still commits an error page. Since |
| 550 | // extensions use the process-per-site model, each extension URL is registered |
| 551 | // in a map from URL to a process. Creating a brand new SiteInstance for the |
| 552 | // extension URL should always result in a SiteInstance that has a process and |
| 553 | // the process is the same for all SiteInstances. This allows us to verify |
| 554 | // that the site-to-process map for the extension hasn't been overwritten by |
| 555 | // the process of the |blocked_url|. |
| 556 | scoped_refptr<content::SiteInstance> new_site_instance = |
| 557 | content::SiteInstance::CreateForURL(web_contents->GetBrowserContext(), |
| 558 | extension->GetResourceURL("")); |
| 559 | EXPECT_TRUE(new_site_instance->HasProcess()); |
| 560 | EXPECT_EQ(new_site_instance->GetProcess(), |
| 561 | web_contents->GetSiteInstance()->GetProcess()); |
Charlie Reis | e2c2c49 | 2018-06-15 21:34:04 | [diff] [blame] | 562 | |
| 563 | // Ensure that reloading a blocked error page completes. |
| 564 | content::TestNavigationObserver reload_observer(new_web_contents); |
| 565 | new_web_contents->GetController().Reload(content::ReloadType::NORMAL, false); |
| 566 | reload_observer.Wait(); |
| 567 | EXPECT_EQ(reload_observer.last_navigation_url(), blocked_url); |
| 568 | EXPECT_FALSE(reload_observer.last_navigation_succeeded()); |
nasko | d1aaa76 | 2017-03-18 02:14:45 | [diff] [blame] | 569 | } |
Devlin Cronin | f1afce25 | 2017-08-19 01:21:48 | [diff] [blame] | 570 | |
| 571 | // Check that whether we can access the window object of a window.open()'d url |
| 572 | // to an extension is the same regardless of whether the extension is installed. |
| 573 | // https://crbug.com/598265. |
| 574 | IN_PROC_BROWSER_TEST_F( |
| 575 | ProcessManagementTest, |
| 576 | TestForkingBehaviorForUninstalledAndNonAccessibleExtensions) { |
| 577 | ASSERT_TRUE(embedded_test_server()->Start()); |
| 578 | const Extension* extension = |
| 579 | LoadExtension(test_data_dir_.AppendASCII("simple_with_icon")); |
| 580 | ASSERT_TRUE(extension); |
| 581 | ASSERT_FALSE( |
| 582 | WebAccessibleResourcesInfo::HasWebAccessibleResources(extension)); |
| 583 | |
| 584 | const GURL installed_extension = extension->url(); |
| 585 | const GURL nonexistent_extension("chrome-extension://" + |
| 586 | std::string(32, 'a') + "/"); |
| 587 | EXPECT_NE(installed_extension, nonexistent_extension); |
| 588 | |
| 589 | ui_test_utils::NavigateToURL( |
| 590 | browser(), embedded_test_server()->GetURL("example.com", "/empty.html")); |
| 591 | content::WebContents* web_contents = |
| 592 | browser()->tab_strip_model()->GetActiveWebContents(); |
| 593 | auto can_access_window = [this, web_contents](const GURL& url) { |
| 594 | bool can_access = false; |
| 595 | const char kOpenNewWindow[] = "window.newWin = window.open('%s');"; |
| 596 | const char kGetAccess[] = |
| 597 | R"( |
| 598 | { |
| 599 | let canAccess = false; |
| 600 | try { |
| 601 | window.newWin.document; |
| 602 | canAccess = true; |
| 603 | } catch (e) { |
| 604 | canAccess = false; |
| 605 | } |
| 606 | window.newWin.close(); |
| 607 | window.domAutomationController.send(canAccess); |
| 608 | } |
| 609 | )"; |
| 610 | EXPECT_TRUE(content::ExecuteScript( |
| 611 | web_contents, base::StringPrintf(kOpenNewWindow, url.spec().c_str()))); |
| 612 | |
| 613 | // WaitForLoadStop() will return false on a 404, but that can happen if we |
| 614 | // navigate to a blocked or nonexistent extension page. |
| 615 | ignore_result(content::WaitForLoadStop( |
| 616 | browser()->tab_strip_model()->GetActiveWebContents())); |
| 617 | |
| 618 | EXPECT_TRUE(content::ExecuteScriptAndExtractBool(web_contents, kGetAccess, |
| 619 | &can_access)); |
| 620 | |
| 621 | return can_access; |
| 622 | }; |
| 623 | |
| 624 | bool can_access_installed = can_access_window(installed_extension); |
| 625 | bool can_access_nonexistent = can_access_window(nonexistent_extension); |
| 626 | // Behavior for installed and nonexistent extensions should be equivalent. |
| 627 | // We don't care much about what the result is (since if it can access it, |
| 628 | // it's about:blank); only that the result is safe. |
| 629 | EXPECT_EQ(can_access_installed, can_access_nonexistent); |
| 630 | } |
| 631 | |
| 632 | } // namespace extensions |