nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 1 | // Copyright 2015 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 | |
| 5 | #include "chrome/browser/site_details.h" |
| 6 | |
avi | 664c07b | 2015-12-26 02:18:31 | [diff] [blame] | 7 | #include <stddef.h> |
| 8 | #include <stdint.h> |
| 9 | |
limasdf | 3d10254 | 2015-12-09 03:58:45 | [diff] [blame] | 10 | #include <utility> |
| 11 | |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 12 | #include "base/bind_helpers.h" |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 13 | #include "base/files/file_path.h" |
avi | 664c07b | 2015-12-26 02:18:31 | [diff] [blame] | 14 | #include "base/macros.h" |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 15 | #include "base/message_loop/message_loop.h" |
| 16 | #include "base/path_service.h" |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 17 | #include "base/strings/stringprintf.h" |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 18 | #include "base/test/histogram_tester.h" |
nasko | 7d4c2cb | 2015-11-26 01:29:35 | [diff] [blame] | 19 | #include "chrome/browser/browser_process.h" |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 20 | #include "chrome/browser/extensions/extension_browsertest.h" |
| 21 | #include "chrome/browser/extensions/test_extension_dir.h" |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 22 | #include "chrome/browser/metrics/metrics_memory_details.h" |
| 23 | #include "chrome/browser/ui/browser.h" |
| 24 | #include "chrome/browser/ui/tabs/tab_strip_model.h" |
nasko | 82f3b201 | 2015-10-22 01:04:47 | [diff] [blame] | 25 | #include "chrome/common/extensions/extension_process_policy.h" |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 26 | #include "chrome/common/url_constants.h" |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 27 | #include "chrome/test/base/in_process_browser_test.h" |
| 28 | #include "chrome/test/base/ui_test_utils.h" |
nasko | 7d4c2cb | 2015-11-26 01:29:35 | [diff] [blame] | 29 | #include "components/metrics/metrics_service.h" |
| 30 | #include "components/variations/metrics_util.h" |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 31 | #include "content/public/browser/notification_service.h" |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 32 | #include "content/public/browser/render_process_host.h" |
nasko | 7d4c2cb | 2015-11-26 01:29:35 | [diff] [blame] | 33 | #include "content/public/common/content_switches.h" |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 34 | #include "content/public/test/browser_test_utils.h" |
| 35 | #include "content/public/test/test_utils.h" |
alexmos | 9d656a8 | 2015-12-02 02:03:09 | [diff] [blame] | 36 | #include "extensions/common/switches.h" |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 37 | #include "extensions/common/value_builder.h" |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 38 | #include "net/dns/mock_host_resolver.h" |
| 39 | #include "net/test/embedded_test_server/embedded_test_server.h" |
| 40 | #include "testing/gmock/include/gmock/gmock.h" |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 41 | #include "testing/gtest/include/gtest/gtest.h" |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 42 | |
| 43 | using base::Bucket; |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 44 | using content::WebContents; |
| 45 | using extensions::DictionaryBuilder; |
| 46 | using extensions::Extension; |
| 47 | using extensions::ListBuilder; |
| 48 | using extensions::TestExtensionDir; |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 49 | using testing::ElementsAre; |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 50 | using testing::PrintToString; |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 51 | |
| 52 | namespace { |
| 53 | |
| 54 | class TestMemoryDetails : public MetricsMemoryDetails { |
| 55 | public: |
| 56 | TestMemoryDetails() |
| 57 | : MetricsMemoryDetails(base::Bind(&base::DoNothing), nullptr) {} |
| 58 | |
| 59 | void StartFetchAndWait() { |
| 60 | uma_.reset(new base::HistogramTester()); |
ellyjones | cd6e449d | 2016-04-13 19:31:15 | [diff] [blame] | 61 | StartFetch(); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 62 | content::RunMessageLoop(); |
| 63 | } |
| 64 | |
| 65 | // Returns a HistogramTester which observed the most recent call to |
| 66 | // StartFetchAndWait(). |
| 67 | base::HistogramTester* uma() { return uma_.get(); } |
| 68 | |
nasko | aab1a44 | 2015-11-19 02:10:36 | [diff] [blame] | 69 | int GetOutOfProcessIframeCount() { |
| 70 | std::vector<Bucket> buckets = |
| 71 | uma_->GetAllSamples("SiteIsolation.OutOfProcessIframes"); |
| 72 | CHECK_EQ(1U, buckets.size()); |
| 73 | return buckets[0].min; |
| 74 | } |
| 75 | |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 76 | size_t CountPageTitles() { |
| 77 | size_t count = 0; |
| 78 | for (const ProcessMemoryInformation& process : ChromeBrowser()->processes) { |
| 79 | if (process.process_type == content::PROCESS_TYPE_RENDERER) { |
| 80 | count += process.titles.size(); |
| 81 | } |
| 82 | } |
| 83 | return count; |
| 84 | } |
| 85 | |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 86 | private: |
| 87 | ~TestMemoryDetails() override {} |
| 88 | |
| 89 | void OnDetailsAvailable() override { |
| 90 | MetricsMemoryDetails::OnDetailsAvailable(); |
| 91 | // Exit the loop initiated by StartFetchAndWait(). |
ki.stfu | c4f8e24 | 2015-10-09 20:40:20 | [diff] [blame] | 92 | base::MessageLoop::current()->QuitWhenIdle(); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 93 | } |
| 94 | |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 95 | std::unique_ptr<base::HistogramTester> uma_; |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 96 | |
| 97 | DISALLOW_COPY_AND_ASSIGN(TestMemoryDetails); |
| 98 | }; |
| 99 | |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 100 | IsolationScenarioType GetCurrentPolicy() { |
| 101 | if (content::AreAllSitesIsolatedForTesting()) |
| 102 | return ISOLATE_ALL_SITES; |
| 103 | if (extensions::IsIsolateExtensionsEnabled()) |
| 104 | return ISOLATE_EXTENSIONS; |
| 105 | return ISOLATE_NOTHING; |
| 106 | } |
| 107 | |
| 108 | // This matcher takes three other matchers as arguments, and applies one of them |
| 109 | // depending on the current site isolation mode. The first applies if no site |
| 110 | // isolation mode is active; the second applies under --isolate-extensions mode; |
| 111 | // and the third applies under --site-per-process mode. |
| 112 | MATCHER_P3(DependingOnPolicy, |
| 113 | isolate_nothing, |
| 114 | isolate_extensions, |
| 115 | isolate_all_sites, |
| 116 | GetCurrentPolicy() == ISOLATE_NOTHING |
| 117 | ? std::string("(with oopifs disabled) ") + |
| 118 | PrintToString(isolate_nothing) |
| 119 | : GetCurrentPolicy() == ISOLATE_EXTENSIONS |
| 120 | ? std::string("(under --isolate-extensions) ") + |
| 121 | PrintToString(isolate_extensions) |
| 122 | : std::string("(under --site-per-process) ") + |
| 123 | PrintToString(isolate_all_sites)) { |
| 124 | switch (GetCurrentPolicy()) { |
| 125 | case ISOLATE_NOTHING: |
| 126 | return ExplainMatchResult(isolate_nothing, arg, result_listener); |
| 127 | case ISOLATE_EXTENSIONS: |
| 128 | return ExplainMatchResult(isolate_extensions, arg, result_listener); |
| 129 | case ISOLATE_ALL_SITES: |
| 130 | return ExplainMatchResult(isolate_all_sites, arg, result_listener); |
| 131 | default: |
| 132 | return false; |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | // Matcher for base::Bucket objects that allows bucket_min to be a matcher. |
| 137 | MATCHER_P2(Sample, |
| 138 | bucket_min, |
| 139 | count, |
| 140 | std::string("is a Bucket whose count is ") + PrintToString(count) + |
| 141 | std::string(" and whose value is ") + |
| 142 | PrintToString(bucket_min)) { |
| 143 | return ExplainMatchResult(count, arg.count, result_listener) && |
| 144 | ExplainMatchResult(bucket_min, arg.min, result_listener); |
| 145 | } |
| 146 | |
| 147 | // Allow matchers to be pretty-printed when passed to PrintToString() for the |
| 148 | // cases we care about. |
| 149 | template <typename P1, typename P2, typename P3> |
| 150 | void PrintTo(const DependingOnPolicyMatcherP3<P1, P2, P3>& matcher, |
| 151 | std::ostream* os) { |
| 152 | testing::Matcher<int> matcherCast = matcher; |
| 153 | matcherCast.DescribeTo(os); |
| 154 | } |
| 155 | |
| 156 | template <typename P1, typename P2> |
| 157 | void PrintTo(const SampleMatcherP2<P1, P2>& matcher, std::ostream* os) { |
| 158 | testing::Matcher<Bucket> matcherCast = matcher; |
| 159 | matcherCast.DescribeTo(os); |
| 160 | } |
| 161 | |
| 162 | // Matches a container of histogram samples, for the common case where the |
| 163 | // histogram received just one sample. |
| 164 | #define HasOneSample(x) ElementsAre(Sample(x, 1)) |
| 165 | |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 166 | } // namespace |
| 167 | |
nick | eac6998 | 2016-02-11 22:18:53 | [diff] [blame] | 168 | class SiteDetailsBrowserTest : public ExtensionBrowserTest { |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 169 | public: |
| 170 | SiteDetailsBrowserTest() {} |
| 171 | ~SiteDetailsBrowserTest() override {} |
| 172 | |
| 173 | void SetUpOnMainThread() override { |
| 174 | host_resolver()->AddRule("*", "127.0.0.1"); |
| 175 | |
| 176 | // Add content/test/data so we can use cross_site_iframe_factory.html |
| 177 | base::FilePath test_data_dir; |
| 178 | ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir)); |
| 179 | embedded_test_server()->ServeFilesFromDirectory( |
| 180 | test_data_dir.AppendASCII("content/test/data/")); |
svaldez | a01f7d9 | 2015-11-18 17:47:56 | [diff] [blame] | 181 | ASSERT_TRUE(embedded_test_server()->Start()); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 182 | } |
| 183 | |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 184 | // Create and install an extension that has a couple of web-accessible |
| 185 | // resources and, optionally, a background process. |
| 186 | const Extension* CreateExtension(const std::string& name, |
| 187 | bool has_background_process) { |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 188 | std::unique_ptr<TestExtensionDir> dir(new TestExtensionDir); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 189 | |
| 190 | DictionaryBuilder manifest; |
| 191 | manifest.Set("name", name) |
| 192 | .Set("version", "1.0") |
| 193 | .Set("manifest_version", 2) |
dcheng | 794d2bd | 2016-02-27 03:51:32 | [diff] [blame] | 194 | .Set("web_accessible_resources", ListBuilder() |
| 195 | .Append("blank_iframe.html") |
| 196 | .Append("http_iframe.html") |
| 197 | .Append("two_http_iframes.html") |
| 198 | .Build()); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 199 | |
| 200 | if (has_background_process) { |
limasdf | 3d10254 | 2015-12-09 03:58:45 | [diff] [blame] | 201 | manifest.Set( |
| 202 | "background", |
dcheng | 794d2bd | 2016-02-27 03:51:32 | [diff] [blame] | 203 | DictionaryBuilder() |
| 204 | .Set("scripts", ListBuilder().Append("script.js").Build()) |
| 205 | .Build()); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 206 | dir->WriteFile(FILE_PATH_LITERAL("script.js"), |
| 207 | "console.log('" + name + " running');"); |
| 208 | } |
| 209 | |
| 210 | dir->WriteFile(FILE_PATH_LITERAL("blank_iframe.html"), |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 211 | base::StringPrintf("<html><body>%s, blank iframe:" |
| 212 | " <iframe width=80 height=80></iframe>" |
| 213 | "</body></html>", |
| 214 | name.c_str())); |
| 215 | std::string iframe_url = |
| 216 | embedded_test_server() |
| 217 | ->GetURL("w.com", "/cross_site_iframe_factory.html?w") |
| 218 | .spec(); |
| 219 | std::string iframe_url2 = |
| 220 | embedded_test_server() |
| 221 | ->GetURL("x.com", "/cross_site_iframe_factory.html?x") |
| 222 | .spec(); |
| 223 | dir->WriteFile( |
| 224 | FILE_PATH_LITERAL("http_iframe.html"), |
| 225 | base::StringPrintf("<html><body>%s, http:// iframe:" |
| 226 | " <iframe width=80 height=80 src='%s'></iframe>" |
| 227 | "</body></html>", |
| 228 | name.c_str(), iframe_url.c_str())); |
| 229 | dir->WriteFile(FILE_PATH_LITERAL("two_http_iframes.html"), |
| 230 | base::StringPrintf( |
| 231 | "<html><body>%s, two http:// iframes:" |
| 232 | " <iframe width=80 height=80 src='%s'></iframe>" |
| 233 | " <iframe width=80 height=80 src='%s'></iframe>" |
| 234 | "</body></html>", |
| 235 | name.c_str(), iframe_url.c_str(), iframe_url2.c_str())); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 236 | dir->WriteManifest(manifest.ToJSON()); |
| 237 | |
| 238 | const Extension* extension = LoadExtension(dir->unpacked_path()); |
| 239 | EXPECT_TRUE(extension); |
| 240 | temp_dirs_.push_back(dir.release()); |
| 241 | return extension; |
| 242 | } |
| 243 | |
lazyboy | 730669d | 2016-06-10 18:07:57 | [diff] [blame] | 244 | // Creates a V2 platform app that loads a web iframe in the app's sandbox |
| 245 | // page. |
| 246 | // TODO(lazyboy): Deprecate this behavior in https://crbug.com/615585. |
| 247 | void CreateAppWithSandboxPage(const std::string& name) { |
| 248 | std::unique_ptr<TestExtensionDir> dir(new TestExtensionDir); |
| 249 | |
| 250 | DictionaryBuilder manifest; |
| 251 | manifest.Set("name", name) |
| 252 | .Set("version", "1.0") |
| 253 | .Set("manifest_version", 2) |
| 254 | .Set("sandbox", |
| 255 | DictionaryBuilder() |
| 256 | .Set("pages", ListBuilder().Append("sandbox.html").Build()) |
| 257 | .Build()) |
| 258 | .Set("app", |
| 259 | DictionaryBuilder() |
| 260 | .Set("background", |
| 261 | DictionaryBuilder() |
| 262 | .Set("scripts", |
| 263 | ListBuilder().Append("background.js").Build()) |
| 264 | .Build()) |
| 265 | .Build()); |
| 266 | |
| 267 | dir->WriteFile(FILE_PATH_LITERAL("background.js"), |
| 268 | "var sandboxFrame = document.createElement('iframe');" |
| 269 | "sandboxFrame.src = 'sandbox.html';" |
| 270 | "document.body.appendChild(sandboxFrame);"); |
| 271 | |
| 272 | std::string iframe_url = |
| 273 | embedded_test_server()->GetURL("/title1.html").spec(); |
| 274 | dir->WriteFile( |
| 275 | FILE_PATH_LITERAL("sandbox.html"), |
| 276 | base::StringPrintf("<html><body>%s, web iframe:" |
| 277 | " <iframe width=80 height=80 src=%s></iframe>" |
| 278 | "</body></html>", |
| 279 | name.c_str(), iframe_url.c_str())); |
| 280 | dir->WriteManifest(manifest.ToJSON()); |
| 281 | |
| 282 | const Extension* extension = LoadExtension(dir->unpacked_path()); |
| 283 | EXPECT_TRUE(extension); |
| 284 | temp_dirs_.push_back(dir.release()); |
| 285 | } |
| 286 | |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 287 | const Extension* CreateHostedApp(const std::string& name, |
| 288 | const GURL& app_url) { |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 289 | std::unique_ptr<TestExtensionDir> dir(new TestExtensionDir); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 290 | |
| 291 | DictionaryBuilder manifest; |
| 292 | manifest.Set("name", name) |
| 293 | .Set("version", "1.0") |
| 294 | .Set("manifest_version", 2) |
dcheng | 794d2bd | 2016-02-27 03:51:32 | [diff] [blame] | 295 | .Set( |
| 296 | "app", |
| 297 | DictionaryBuilder() |
| 298 | .Set("urls", ListBuilder().Append(app_url.spec()).Build()) |
| 299 | .Set("launch", |
| 300 | DictionaryBuilder().Set("web_url", app_url.spec()).Build()) |
| 301 | .Build()); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 302 | dir->WriteManifest(manifest.ToJSON()); |
| 303 | |
| 304 | const Extension* extension = LoadExtension(dir->unpacked_path()); |
| 305 | EXPECT_TRUE(extension); |
| 306 | temp_dirs_.push_back(dir.release()); |
| 307 | return extension; |
| 308 | } |
| 309 | |
| 310 | int GetRenderProcessCount() { |
| 311 | int count = 0; |
| 312 | for (content::RenderProcessHost::iterator it( |
| 313 | content::RenderProcessHost::AllHostsIterator()); |
| 314 | !it.IsAtEnd(); it.Advance()) { |
| 315 | count++; |
| 316 | } |
| 317 | return count; |
| 318 | } |
| 319 | |
nasko | 7d4c2cb | 2015-11-26 01:29:35 | [diff] [blame] | 320 | // Checks whether the test run is part of a field trial with |trial_name|. |
| 321 | bool IsInTrial(const std::string& trial_name) { |
| 322 | uint32_t trial = metrics::HashName(trial_name); |
| 323 | |
| 324 | std::vector<variations::ActiveGroupId> synthetic_trials; |
| 325 | g_browser_process->metrics_service() |
| 326 | ->GetCurrentSyntheticFieldTrialsForTesting(&synthetic_trials); |
| 327 | |
| 328 | for (const auto& entry : synthetic_trials) { |
| 329 | if (trial == entry.name) |
| 330 | return true; |
| 331 | } |
| 332 | |
| 333 | return false; |
| 334 | } |
| 335 | |
| 336 | // Similar to IsInTrial but checks that the correct group is present as well. |
| 337 | bool IsInTrialGroup(const std::string& trial_name, |
| 338 | const std::string& group_name) { |
| 339 | uint32_t trial = metrics::HashName(trial_name); |
| 340 | uint32_t group = metrics::HashName(group_name); |
| 341 | |
| 342 | std::vector<variations::ActiveGroupId> synthetic_trials; |
| 343 | g_browser_process->metrics_service() |
| 344 | ->GetCurrentSyntheticFieldTrialsForTesting(&synthetic_trials); |
| 345 | |
| 346 | for (const auto& entry : synthetic_trials) { |
| 347 | if (trial == entry.name && group == entry.group) |
| 348 | return true; |
| 349 | } |
| 350 | |
| 351 | return false; |
| 352 | } |
| 353 | |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 354 | private: |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 355 | ScopedVector<TestExtensionDir> temp_dirs_; |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 356 | DISALLOW_COPY_AND_ASSIGN(SiteDetailsBrowserTest); |
| 357 | }; |
| 358 | |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 359 | |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 360 | // Test the accuracy of SiteDetails process estimation, in the presence of |
| 361 | // multiple iframes, navigation, multiple BrowsingInstances, and multiple tabs |
| 362 | // in the same BrowsingInstance. |
nick | eac6998 | 2016-02-11 22:18:53 | [diff] [blame] | 363 | IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, ManyIframes) { |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 364 | // Page with 14 nested oopifs across 9 sites (a.com through i.com). |
| 365 | // None of these are https. |
| 366 | GURL abcdefghi_url = embedded_test_server()->GetURL( |
| 367 | "a.com", |
| 368 | "/cross_site_iframe_factory.html?a(b(a(b,c,d,e,f,g,h)),c,d,e,i(f))"); |
| 369 | ui_test_utils::NavigateToURL(browser(), abcdefghi_url); |
| 370 | |
| 371 | // Get the metrics. |
| 372 | scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); |
| 373 | details->StartFetchAndWait(); |
| 374 | |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 375 | EXPECT_EQ(1U, details->CountPageTitles()); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 376 | EXPECT_THAT( |
| 377 | details->uma()->GetAllSamples("SiteIsolation.BrowsingInstanceCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 378 | HasOneSample(1)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 379 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 380 | "SiteIsolation.CurrentRendererProcessCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 381 | HasOneSample(GetRenderProcessCount())); |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 382 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 383 | "SiteIsolation.IsolateNothingProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 384 | HasOneSample(1)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 385 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 386 | "SiteIsolation.IsolateAllSitesProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 387 | HasOneSample(9)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 388 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 389 | "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 390 | HasOneSample(9)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 391 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 392 | "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 393 | HasOneSample(9)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 394 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 395 | "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 396 | HasOneSample(1)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 397 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 398 | "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 399 | HasOneSample(1)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 400 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 401 | "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 402 | HasOneSample(1)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 403 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 404 | "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 405 | HasOneSample(1)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 406 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 407 | "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 408 | HasOneSample(1)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 409 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 410 | "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 411 | HasOneSample(1)); |
| 412 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 9)); |
nasko | aab1a44 | 2015-11-19 02:10:36 | [diff] [blame] | 413 | EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 414 | DependingOnPolicy(0, 0, 14)); |
nick | de8b027 | 2016-02-11 04:29:25 | [diff] [blame] | 415 | EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), |
| 416 | HasOneSample(DependingOnPolicy(0, 0, 114))); |
| 417 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 418 | "SiteIsolation.ProxyCountPerBrowsingInstance"), |
| 419 | HasOneSample(DependingOnPolicy(0, 0, 114))); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 420 | |
| 421 | // Navigate to a different, disjoint set of 7 sites. |
| 422 | GURL pqrstuv_url = embedded_test_server()->GetURL( |
| 423 | "p.com", |
| 424 | "/cross_site_iframe_factory.html?p(q(r),r(s),s(t),t(q),u(u),v(p))"); |
| 425 | ui_test_utils::NavigateToURL(browser(), pqrstuv_url); |
| 426 | |
| 427 | details = new TestMemoryDetails(); |
| 428 | details->StartFetchAndWait(); |
| 429 | |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 430 | EXPECT_EQ(1U, details->CountPageTitles()); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 431 | EXPECT_THAT( |
| 432 | details->uma()->GetAllSamples("SiteIsolation.BrowsingInstanceCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 433 | HasOneSample(1)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 434 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 435 | "SiteIsolation.CurrentRendererProcessCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 436 | HasOneSample(GetRenderProcessCount())); |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 437 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 438 | "SiteIsolation.IsolateNothingProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 439 | HasOneSample(1)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 440 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 441 | "SiteIsolation.IsolateAllSitesProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 442 | HasOneSample(7)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 443 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 444 | "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 445 | HasOneSample(7)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 446 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 447 | "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 448 | HasOneSample(7)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 449 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 450 | "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 451 | HasOneSample(1)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 452 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 453 | "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 454 | HasOneSample(1)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 455 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 456 | "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 457 | HasOneSample(1)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 458 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 459 | "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 460 | HasOneSample(1)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 461 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 462 | "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 463 | HasOneSample(1)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 464 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 465 | "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 466 | HasOneSample(1)); |
| 467 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 7)); |
nasko | aab1a44 | 2015-11-19 02:10:36 | [diff] [blame] | 468 | EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 469 | DependingOnPolicy(0, 0, 11)); |
nick | de8b027 | 2016-02-11 04:29:25 | [diff] [blame] | 470 | EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), |
| 471 | HasOneSample(DependingOnPolicy(0, 0, 68))); |
| 472 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 473 | "SiteIsolation.ProxyCountPerBrowsingInstance"), |
| 474 | HasOneSample(DependingOnPolicy(0, 0, 68))); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 475 | |
| 476 | // Open a second tab (different BrowsingInstance) with 4 sites (a through d). |
| 477 | GURL abcd_url = embedded_test_server()->GetURL( |
| 478 | "a.com", "/cross_site_iframe_factory.html?a(b(c(d())))"); |
| 479 | AddTabAtIndex(1, abcd_url, ui::PAGE_TRANSITION_TYPED); |
| 480 | |
| 481 | details = new TestMemoryDetails(); |
| 482 | details->StartFetchAndWait(); |
| 483 | |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 484 | EXPECT_EQ(2U, details->CountPageTitles()); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 485 | EXPECT_THAT( |
| 486 | details->uma()->GetAllSamples("SiteIsolation.BrowsingInstanceCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 487 | HasOneSample(2)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 488 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 489 | "SiteIsolation.CurrentRendererProcessCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 490 | HasOneSample(GetRenderProcessCount())); |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 491 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 492 | "SiteIsolation.IsolateNothingProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 493 | HasOneSample(2)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 494 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 495 | "SiteIsolation.IsolateAllSitesProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 496 | HasOneSample(11)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 497 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 498 | "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 499 | HasOneSample(11)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 500 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 501 | "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 502 | HasOneSample(11)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 503 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 504 | "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 505 | HasOneSample(2)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 506 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 507 | "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 508 | HasOneSample(1)); // TODO(nick): This should be 2. |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 509 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 510 | "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 511 | HasOneSample(2)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 512 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 513 | "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 514 | HasOneSample(2)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 515 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 516 | "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 517 | HasOneSample(1)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 518 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 519 | "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 520 | HasOneSample(2)); |
| 521 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(2, 2, 11)); |
nasko | aab1a44 | 2015-11-19 02:10:36 | [diff] [blame] | 522 | EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 523 | DependingOnPolicy(0, 0, 14)); |
nick | de8b027 | 2016-02-11 04:29:25 | [diff] [blame] | 524 | EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), |
| 525 | HasOneSample(DependingOnPolicy(0, 0, 81))); |
| 526 | EXPECT_THAT( |
| 527 | details->uma()->GetAllSamples( |
| 528 | "SiteIsolation.ProxyCountPerBrowsingInstance"), |
| 529 | DependingOnPolicy(ElementsAre(Bucket(0, 2)), ElementsAre(Bucket(0, 2)), |
| 530 | ElementsAre(Bucket(12, 1), Bucket(68, 1)))); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 531 | |
| 532 | // Open a third tab (different BrowsingInstance) with the same 4 sites. |
| 533 | AddTabAtIndex(2, abcd_url, ui::PAGE_TRANSITION_TYPED); |
| 534 | |
| 535 | details = new TestMemoryDetails(); |
| 536 | details->StartFetchAndWait(); |
| 537 | |
| 538 | EXPECT_THAT( |
| 539 | details->uma()->GetAllSamples("SiteIsolation.BrowsingInstanceCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 540 | HasOneSample(3)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 541 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 542 | "SiteIsolation.CurrentRendererProcessCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 543 | HasOneSample(GetRenderProcessCount())); |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 544 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 545 | "SiteIsolation.IsolateNothingProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 546 | HasOneSample(3)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 547 | // Could be 11 if subframe processes were reused across BrowsingInstances. |
| 548 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 549 | "SiteIsolation.IsolateAllSitesProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 550 | HasOneSample(15)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 551 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 552 | "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 553 | HasOneSample(11)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 554 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 555 | "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 556 | HasOneSample(15)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 557 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 558 | "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 559 | HasOneSample(3)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 560 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 561 | "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 562 | HasOneSample(1)); // TODO(nick): This should be 3. |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 563 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 564 | "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 565 | HasOneSample(3)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 566 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 567 | "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 568 | HasOneSample(3)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 569 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 570 | "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 571 | HasOneSample(1)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 572 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 573 | "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 574 | HasOneSample(3)); |
| 575 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 3, 15)); |
nasko | aab1a44 | 2015-11-19 02:10:36 | [diff] [blame] | 576 | EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 577 | DependingOnPolicy(0, 0, 17)); |
nick | de8b027 | 2016-02-11 04:29:25 | [diff] [blame] | 578 | EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), |
| 579 | HasOneSample(DependingOnPolicy(0, 0, 96))); |
| 580 | EXPECT_THAT( |
| 581 | details->uma()->GetAllSamples( |
| 582 | "SiteIsolation.ProxyCountPerBrowsingInstance"), |
| 583 | DependingOnPolicy(ElementsAre(Bucket(0, 3)), ElementsAre(Bucket(0, 3)), |
| 584 | ElementsAre(Bucket(12, 2), Bucket(68, 1)))); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 585 | |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 586 | // From the third tab, window.open() a fourth tab in the same |
| 587 | // BrowsingInstance, to a page using the same four sites "a-d" as third tab, |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 588 | // plus an additional site "e". The estimated process counts should increase |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 589 | // by one (not five) from the previous scenario, as the new tab can reuse the |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 590 | // four processes already in the BrowsingInstance. |
| 591 | GURL dcbae_url = embedded_test_server()->GetURL( |
| 592 | "a.com", "/cross_site_iframe_factory.html?d(c(b(a(e))))"); |
| 593 | ui_test_utils::UrlLoadObserver load_complete( |
| 594 | dcbae_url, content::NotificationService::AllSources()); |
| 595 | ASSERT_EQ(3, browser()->tab_strip_model()->count()); |
| 596 | ASSERT_TRUE(content::ExecuteScript( |
| 597 | browser()->tab_strip_model()->GetActiveWebContents(), |
| 598 | "window.open('" + dcbae_url.spec() + "');")); |
| 599 | ASSERT_EQ(4, browser()->tab_strip_model()->count()); |
| 600 | load_complete.Wait(); |
| 601 | |
| 602 | details = new TestMemoryDetails(); |
| 603 | details->StartFetchAndWait(); |
| 604 | |
| 605 | EXPECT_THAT( |
| 606 | details->uma()->GetAllSamples("SiteIsolation.BrowsingInstanceCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 607 | HasOneSample(3)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 608 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 609 | "SiteIsolation.CurrentRendererProcessCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 610 | HasOneSample(GetRenderProcessCount())); |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 611 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 612 | "SiteIsolation.IsolateNothingProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 613 | HasOneSample(3)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 614 | // Could be 11 if subframe processes were reused across BrowsingInstances. |
| 615 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 616 | "SiteIsolation.IsolateAllSitesProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 617 | HasOneSample(16)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 618 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 619 | "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 620 | HasOneSample(12)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 621 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 622 | "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 623 | HasOneSample(16)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 624 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 625 | "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 626 | HasOneSample(3)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 627 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 628 | "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 629 | HasOneSample(1)); // TODO(nick): This should be 3. |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 630 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 631 | "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 632 | HasOneSample(3)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 633 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 634 | "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 635 | HasOneSample(3)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 636 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 637 | "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 638 | HasOneSample(1)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 639 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 640 | "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 641 | HasOneSample(3)); |
| 642 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 3, 16)); |
nasko | aab1a44 | 2015-11-19 02:10:36 | [diff] [blame] | 643 | EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 644 | DependingOnPolicy(0, 0, 21)); |
nick | de8b027 | 2016-02-11 04:29:25 | [diff] [blame] | 645 | EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), |
| 646 | HasOneSample(DependingOnPolicy(0, 0, 114))); |
| 647 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 648 | "SiteIsolation.ProxyCountPerBrowsingInstance"), |
| 649 | DependingOnPolicy( |
| 650 | ElementsAre(Bucket(0, 3)), ElementsAre(Bucket(0, 3)), |
| 651 | ElementsAre(Bucket(12, 1), Bucket(29, 1), Bucket(68, 1)))); |
nasko | 7d4c2cb | 2015-11-26 01:29:35 | [diff] [blame] | 652 | |
| 653 | // This test doesn't navigate to any extensions URLs, so it should not be |
| 654 | // in any of the field trial groups. |
| 655 | EXPECT_FALSE(IsInTrial("SiteIsolationExtensionsActive")); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 656 | } |
| 657 | |
nick | eac6998 | 2016-02-11 22:18:53 | [diff] [blame] | 658 | IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, IsolateExtensions) { |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 659 | // We start on "about:blank", which should be credited with a process in this |
| 660 | // case. |
| 661 | scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); |
| 662 | details->StartFetchAndWait(); |
| 663 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 664 | "SiteIsolation.CurrentRendererProcessCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 665 | HasOneSample(GetRenderProcessCount())); |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 666 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 667 | "SiteIsolation.IsolateNothingProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 668 | HasOneSample(1)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 669 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 670 | "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 671 | HasOneSample(1)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 672 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 673 | "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 674 | HasOneSample(1)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 675 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 676 | "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 677 | HasOneSample(1)); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 678 | EXPECT_THAT(GetRenderProcessCount(), 1); |
nasko | aab1a44 | 2015-11-19 02:10:36 | [diff] [blame] | 679 | EXPECT_EQ(0, details->GetOutOfProcessIframeCount()); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 680 | |
| 681 | // Install one script-injecting extension with background page, and an |
| 682 | // extension with web accessible resources. |
| 683 | const Extension* extension1 = CreateExtension("Extension One", true); |
| 684 | const Extension* extension2 = CreateExtension("Extension Two", false); |
| 685 | |
| 686 | // Open two a.com tabs (with cross site http iframes). IsolateExtensions mode |
| 687 | // should have no effect so far, since there are no frames straddling the |
| 688 | // extension/web boundary. |
| 689 | GURL tab1_url = embedded_test_server()->GetURL( |
| 690 | "a.com", "/cross_site_iframe_factory.html?a(b,c)"); |
| 691 | ui_test_utils::NavigateToURL(browser(), tab1_url); |
| 692 | WebContents* tab1 = browser()->tab_strip_model()->GetWebContentsAt(0); |
| 693 | GURL tab2_url = embedded_test_server()->GetURL( |
| 694 | "a.com", "/cross_site_iframe_factory.html?a(d,e)"); |
| 695 | AddTabAtIndex(1, tab2_url, ui::PAGE_TRANSITION_TYPED); |
| 696 | WebContents* tab2 = browser()->tab_strip_model()->GetWebContentsAt(1); |
| 697 | |
| 698 | details = new TestMemoryDetails(); |
| 699 | details->StartFetchAndWait(); |
| 700 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 701 | "SiteIsolation.CurrentRendererProcessCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 702 | HasOneSample(GetRenderProcessCount())); |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 703 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 704 | "SiteIsolation.IsolateNothingProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 705 | HasOneSample(3)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 706 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 707 | "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 708 | HasOneSample(3)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 709 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 710 | "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 711 | HasOneSample(2)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 712 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 713 | "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 714 | HasOneSample(3)); |
| 715 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 3, 7)); |
nasko | aab1a44 | 2015-11-19 02:10:36 | [diff] [blame] | 716 | EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 717 | DependingOnPolicy(0, 0, 4)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 718 | |
| 719 | // Test that "one process per extension" applies even when web content has an |
| 720 | // extension iframe. |
| 721 | |
| 722 | // Tab1 navigates its first iframe to a resource of extension1. This shouldn't |
| 723 | // result in a new extension process (it should share with extension1's |
| 724 | // background page). |
| 725 | content::NavigateIframeToURL( |
| 726 | tab1, "child-0", extension1->GetResourceURL("/blank_iframe.html")); |
| 727 | details = new TestMemoryDetails(); |
| 728 | details->StartFetchAndWait(); |
| 729 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 730 | "SiteIsolation.CurrentRendererProcessCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 731 | HasOneSample(GetRenderProcessCount())); |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 732 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 733 | "SiteIsolation.IsolateNothingProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 734 | HasOneSample(3)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 735 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 736 | "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 737 | HasOneSample(3)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 738 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 739 | "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 740 | HasOneSample(2)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 741 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 742 | "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 743 | HasOneSample(3)); |
| 744 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 3, 6)); |
nasko | aab1a44 | 2015-11-19 02:10:36 | [diff] [blame] | 745 | EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 746 | DependingOnPolicy(0, 1, 4)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 747 | |
| 748 | // Tab2 navigates its first iframe to a resource of extension1. This also |
| 749 | // shouldn't result in a new extension process (it should share with the |
| 750 | // background page and the other iframe). |
| 751 | content::NavigateIframeToURL( |
| 752 | tab2, "child-0", extension1->GetResourceURL("/blank_iframe.html")); |
| 753 | details = new TestMemoryDetails(); |
| 754 | details->StartFetchAndWait(); |
| 755 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 756 | "SiteIsolation.CurrentRendererProcessCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 757 | HasOneSample(GetRenderProcessCount())); |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 758 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 759 | "SiteIsolation.IsolateNothingProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 760 | HasOneSample(3)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 761 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 762 | "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 763 | HasOneSample(3)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 764 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 765 | "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 766 | HasOneSample(2)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 767 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 768 | "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 769 | HasOneSample(3)); |
| 770 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 3, 5)); |
nasko | aab1a44 | 2015-11-19 02:10:36 | [diff] [blame] | 771 | EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 772 | DependingOnPolicy(0, 2, 4)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 773 | |
| 774 | // Tab1 navigates its second iframe to a resource of extension2. This SHOULD |
| 775 | // result in a new process since extension2 had no existing process. |
| 776 | content::NavigateIframeToURL( |
| 777 | tab1, "child-1", extension2->GetResourceURL("/blank_iframe.html")); |
| 778 | details = new TestMemoryDetails(); |
| 779 | details->StartFetchAndWait(); |
| 780 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 781 | "SiteIsolation.CurrentRendererProcessCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 782 | HasOneSample(GetRenderProcessCount())); |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 783 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 784 | "SiteIsolation.IsolateNothingProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 785 | HasOneSample(3)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 786 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 787 | "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 788 | HasOneSample(4)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 789 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 790 | "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 791 | HasOneSample(3)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 792 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 793 | "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 794 | HasOneSample(4)); |
| 795 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 4, 5)); |
nasko | aab1a44 | 2015-11-19 02:10:36 | [diff] [blame] | 796 | EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 797 | DependingOnPolicy(0, 3, 4)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 798 | |
| 799 | // Tab2 navigates its second iframe to a resource of extension2. This should |
| 800 | // share the existing extension2 process. |
| 801 | content::NavigateIframeToURL( |
| 802 | tab2, "child-1", extension2->GetResourceURL("/blank_iframe.html")); |
| 803 | details = new TestMemoryDetails(); |
| 804 | details->StartFetchAndWait(); |
| 805 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 806 | "SiteIsolation.CurrentRendererProcessCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 807 | HasOneSample(GetRenderProcessCount())); |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 808 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 809 | "SiteIsolation.IsolateNothingProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 810 | HasOneSample(3)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 811 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 812 | "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 813 | HasOneSample(4)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 814 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 815 | "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 816 | HasOneSample(3)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 817 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 818 | "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 819 | HasOneSample(4)); |
| 820 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 4, 4)); |
nasko | aab1a44 | 2015-11-19 02:10:36 | [diff] [blame] | 821 | EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 822 | DependingOnPolicy(0, 4, 4)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 823 | |
| 824 | // Install extension3 (identical config to extension2) |
| 825 | const Extension* extension3 = CreateExtension("Extension Three", false); |
| 826 | |
| 827 | // Navigate Tab2 to a top-level page from extension3. There are four processes |
| 828 | // now: one for tab1's main frame, and one for each of the extensions: |
| 829 | // extension1 has a process because it has a background page; extension2 is |
| 830 | // used as an iframe in tab1, and extension3 is the top-level frame in tab2. |
| 831 | ui_test_utils::NavigateToURL(browser(), |
| 832 | extension3->GetResourceURL("blank_iframe.html")); |
| 833 | details = new TestMemoryDetails(); |
| 834 | details->StartFetchAndWait(); |
| 835 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 836 | "SiteIsolation.CurrentRendererProcessCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 837 | HasOneSample(GetRenderProcessCount())); |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 838 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 839 | "SiteIsolation.IsolateNothingProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 840 | HasOneSample(3)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 841 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 842 | "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 843 | HasOneSample(4)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 844 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 845 | "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 846 | HasOneSample(4)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 847 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 848 | "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 849 | HasOneSample(4)); |
| 850 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 4, 4)); |
nasko | aab1a44 | 2015-11-19 02:10:36 | [diff] [blame] | 851 | EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 852 | DependingOnPolicy(0, 2, 2)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 853 | |
| 854 | // Navigate tab2 to a different extension3 page containing a web iframe. The |
| 855 | // iframe should get its own process. The lower bound number indicates that, |
| 856 | // in theory, the iframe could share a process with tab1's main frame. |
| 857 | ui_test_utils::NavigateToURL(browser(), |
| 858 | extension3->GetResourceURL("http_iframe.html")); |
| 859 | details = new TestMemoryDetails(); |
| 860 | details->StartFetchAndWait(); |
| 861 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 862 | "SiteIsolation.CurrentRendererProcessCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 863 | HasOneSample(GetRenderProcessCount())); |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 864 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 865 | "SiteIsolation.IsolateNothingProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 866 | HasOneSample(3)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 867 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 868 | "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 869 | HasOneSample(5)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 870 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 871 | "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 872 | HasOneSample(4)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 873 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 874 | "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 875 | HasOneSample(5)); |
| 876 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 5, 5)); |
nasko | aab1a44 | 2015-11-19 02:10:36 | [diff] [blame] | 877 | EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 878 | DependingOnPolicy(0, 3, 3)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 879 | |
| 880 | // Navigate tab1 to an extension3 page with an extension3 iframe. There should |
| 881 | // be three processes estimated by IsolateExtensions: one for extension3, one |
| 882 | // for extension1's background page, and one for the web iframe in tab2. |
| 883 | browser()->tab_strip_model()->ActivateTabAt(0, true); |
| 884 | ui_test_utils::NavigateToURL(browser(), |
| 885 | extension3->GetResourceURL("blank_iframe.html")); |
| 886 | details = new TestMemoryDetails(); |
| 887 | details->StartFetchAndWait(); |
| 888 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 889 | "SiteIsolation.CurrentRendererProcessCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 890 | HasOneSample(GetRenderProcessCount())); |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 891 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 892 | "SiteIsolation.IsolateNothingProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 893 | HasOneSample(2)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 894 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 895 | "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 896 | HasOneSample(3)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 897 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 898 | "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 899 | HasOneSample(3)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 900 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 901 | "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 902 | HasOneSample(3)); |
| 903 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(2, 3, 3)); |
nasko | aab1a44 | 2015-11-19 02:10:36 | [diff] [blame] | 904 | EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 905 | DependingOnPolicy(0, 1, 1)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 906 | |
| 907 | // Now navigate tab1 to an extension3 page with a web iframe. This could share |
| 908 | // a process with tab2's iframe (the LowerBound number), or it could get its |
| 909 | // own process (the Estimate number). |
| 910 | ui_test_utils::NavigateToURL(browser(), |
| 911 | extension3->GetResourceURL("http_iframe.html")); |
| 912 | details = new TestMemoryDetails(); |
| 913 | details->StartFetchAndWait(); |
| 914 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 915 | "SiteIsolation.CurrentRendererProcessCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 916 | HasOneSample(GetRenderProcessCount())); |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 917 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 918 | "SiteIsolation.IsolateNothingProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 919 | HasOneSample(2)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 920 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 921 | "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 922 | HasOneSample(4)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 923 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 924 | "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 925 | HasOneSample(3)); |
nick | 37dfd9de | 2015-09-14 19:54:03 | [diff] [blame] | 926 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 927 | "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 928 | HasOneSample(4)); |
| 929 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(2, 4, 4)); |
nasko | aab1a44 | 2015-11-19 02:10:36 | [diff] [blame] | 930 | EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 931 | DependingOnPolicy(0, 2, 2)); |
nasko | 7d4c2cb | 2015-11-26 01:29:35 | [diff] [blame] | 932 | |
| 933 | EXPECT_TRUE(IsInTrial("SiteIsolationExtensionsActive")); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 934 | } |
| 935 | |
lazyboy | 730669d | 2016-06-10 18:07:57 | [diff] [blame] | 936 | // Due to http://crbug.com/612711, we are not isolating iframes from platform |
lazyboy | b8ac1f17 | 2016-06-11 00:24:06 | [diff] [blame^] | 937 | // apps with --isolate-extenions. |
lazyboy | 730669d | 2016-06-10 18:07:57 | [diff] [blame] | 938 | IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, PlatformAppsNotIsolated) { |
lazyboy | b8ac1f17 | 2016-06-11 00:24:06 | [diff] [blame^] | 939 | // --site-per-process will still isolate iframes from platform apps, so skip |
| 940 | // the test in that case. |
| 941 | if (content::AreAllSitesIsolatedForTesting()) |
| 942 | return; |
lazyboy | 730669d | 2016-06-10 18:07:57 | [diff] [blame] | 943 | CreateAppWithSandboxPage("Extension One"); |
| 944 | scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); |
| 945 | details->StartFetchAndWait(); |
| 946 | EXPECT_EQ(0, details->GetOutOfProcessIframeCount()); |
| 947 | } |
| 948 | |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 949 | // Exercises accounting in the case where an extension has two different-site |
| 950 | // web iframes. |
nick | eac6998 | 2016-02-11 22:18:53 | [diff] [blame] | 951 | IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, ExtensionWithTwoWebIframes) { |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 952 | scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); |
| 953 | details->StartFetchAndWait(); |
| 954 | |
| 955 | // Install one script-injecting extension with background page, and an |
| 956 | // extension with web accessible resources. |
| 957 | const Extension* extension = CreateExtension("Test Extension", false); |
| 958 | |
| 959 | ui_test_utils::NavigateToURL( |
| 960 | browser(), extension->GetResourceURL("/two_http_iframes.html")); |
| 961 | |
| 962 | details = new TestMemoryDetails(); |
| 963 | details->StartFetchAndWait(); |
| 964 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 965 | "SiteIsolation.CurrentRendererProcessCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 966 | HasOneSample(GetRenderProcessCount())); |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 967 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 968 | "SiteIsolation.IsolateNothingProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 969 | HasOneSample(1)); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 970 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 971 | "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 972 | HasOneSample(2)); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 973 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 974 | "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 975 | HasOneSample(2)); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 976 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 977 | "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 978 | HasOneSample(2)); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 979 | // TODO(nick): https://crbug.com/512560 Make the number below agree with the |
| 980 | // estimates above, which assume consolidation of subframe processes. |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 981 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 3, 3)); |
nasko | aab1a44 | 2015-11-19 02:10:36 | [diff] [blame] | 982 | EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 983 | DependingOnPolicy(0, 2, 2)); |
nasko | 7d4c2cb | 2015-11-26 01:29:35 | [diff] [blame] | 984 | |
| 985 | EXPECT_TRUE(IsInTrial("SiteIsolationExtensionsActive")); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 986 | } |
| 987 | |
nick | cc0d914 | 2015-10-14 16:27:10 | [diff] [blame] | 988 | // Verifies that --isolate-extensions doesn't isolate hosted apps. |
nick | eac6998 | 2016-02-11 22:18:53 | [diff] [blame] | 989 | IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, IsolateExtensionsHostedApps) { |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 990 | GURL app_with_web_iframe_url = embedded_test_server()->GetURL( |
| 991 | "app.org", "/cross_site_iframe_factory.html?app.org(b.com)"); |
| 992 | GURL app_in_web_iframe_url = embedded_test_server()->GetURL( |
| 993 | "b.com", "/cross_site_iframe_factory.html?b.com(app.org)"); |
| 994 | |
| 995 | // No hosted app is installed: app.org just behaves like a normal domain. |
| 996 | ui_test_utils::NavigateToURL(browser(), app_with_web_iframe_url); |
| 997 | scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); |
| 998 | details->StartFetchAndWait(); |
| 999 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1000 | "SiteIsolation.CurrentRendererProcessCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1001 | HasOneSample(GetRenderProcessCount())); |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 1002 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1003 | "SiteIsolation.IsolateNothingProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1004 | HasOneSample(1)); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 1005 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1006 | "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1007 | HasOneSample(1)); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 1008 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1009 | "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1010 | HasOneSample(1)); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 1011 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1012 | "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1013 | HasOneSample(1)); |
| 1014 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); |
nick | cc0d914 | 2015-10-14 16:27:10 | [diff] [blame] | 1015 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1016 | "SiteIsolation.IsolateAllSitesProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1017 | HasOneSample(2)); |
nick | cc0d914 | 2015-10-14 16:27:10 | [diff] [blame] | 1018 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1019 | "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1020 | HasOneSample(2)); |
nick | cc0d914 | 2015-10-14 16:27:10 | [diff] [blame] | 1021 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1022 | "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1023 | HasOneSample(2)); |
| 1024 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); |
nasko | aab1a44 | 2015-11-19 02:10:36 | [diff] [blame] | 1025 | EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1026 | DependingOnPolicy(0, 0, 1)); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 1027 | |
| 1028 | ui_test_utils::NavigateToURL(browser(), app_in_web_iframe_url); |
| 1029 | details = new TestMemoryDetails(); |
| 1030 | details->StartFetchAndWait(); |
| 1031 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1032 | "SiteIsolation.CurrentRendererProcessCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1033 | HasOneSample(GetRenderProcessCount())); |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 1034 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1035 | "SiteIsolation.IsolateNothingProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1036 | HasOneSample(1)); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 1037 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1038 | "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1039 | HasOneSample(1)); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 1040 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1041 | "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1042 | HasOneSample(1)); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 1043 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1044 | "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1045 | HasOneSample(1)); |
| 1046 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); |
nick | cc0d914 | 2015-10-14 16:27:10 | [diff] [blame] | 1047 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1048 | "SiteIsolation.IsolateAllSitesProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1049 | HasOneSample(2)); |
nick | cc0d914 | 2015-10-14 16:27:10 | [diff] [blame] | 1050 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1051 | "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1052 | HasOneSample(2)); |
nick | cc0d914 | 2015-10-14 16:27:10 | [diff] [blame] | 1053 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1054 | "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1055 | HasOneSample(2)); |
| 1056 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); |
nasko | aab1a44 | 2015-11-19 02:10:36 | [diff] [blame] | 1057 | EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1058 | DependingOnPolicy(0, 0, 1)); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 1059 | |
| 1060 | // Now install app.org as a hosted app. |
| 1061 | CreateHostedApp("App", GURL("http://app.org")); |
| 1062 | |
nick | cc0d914 | 2015-10-14 16:27:10 | [diff] [blame] | 1063 | // Reload the same two pages, and verify that the hosted app still is not |
| 1064 | // isolated by --isolate-extensions, but is isolated by --site-per-process. |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 1065 | ui_test_utils::NavigateToURL(browser(), app_with_web_iframe_url); |
| 1066 | details = new TestMemoryDetails(); |
| 1067 | details->StartFetchAndWait(); |
| 1068 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1069 | "SiteIsolation.CurrentRendererProcessCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1070 | HasOneSample(GetRenderProcessCount())); |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 1071 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1072 | "SiteIsolation.IsolateNothingProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1073 | HasOneSample(1)); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 1074 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1075 | "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1076 | HasOneSample(1)); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 1077 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1078 | "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1079 | HasOneSample(1)); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 1080 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1081 | "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1082 | HasOneSample(1)); |
| 1083 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); |
nick | cc0d914 | 2015-10-14 16:27:10 | [diff] [blame] | 1084 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1085 | "SiteIsolation.IsolateAllSitesProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1086 | HasOneSample(2)); |
nick | cc0d914 | 2015-10-14 16:27:10 | [diff] [blame] | 1087 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1088 | "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1089 | HasOneSample(2)); |
nick | cc0d914 | 2015-10-14 16:27:10 | [diff] [blame] | 1090 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1091 | "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1092 | HasOneSample(2)); |
| 1093 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); |
nasko | aab1a44 | 2015-11-19 02:10:36 | [diff] [blame] | 1094 | EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1095 | DependingOnPolicy(0, 0, 1)); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 1096 | |
| 1097 | ui_test_utils::NavigateToURL(browser(), app_in_web_iframe_url); |
| 1098 | details = new TestMemoryDetails(); |
| 1099 | details->StartFetchAndWait(); |
| 1100 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1101 | "SiteIsolation.CurrentRendererProcessCount"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1102 | HasOneSample(GetRenderProcessCount())); |
nick | b2545f7 | 2015-10-30 20:05:15 | [diff] [blame] | 1103 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1104 | "SiteIsolation.IsolateNothingProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1105 | HasOneSample(1)); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 1106 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1107 | "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1108 | HasOneSample(1)); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 1109 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1110 | "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1111 | HasOneSample(1)); |
nick | 3a8aa1f | 2015-09-24 17:00:13 | [diff] [blame] | 1112 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1113 | "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1114 | HasOneSample(1)); |
| 1115 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); |
nick | cc0d914 | 2015-10-14 16:27:10 | [diff] [blame] | 1116 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1117 | "SiteIsolation.IsolateAllSitesProcessCountEstimate"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1118 | HasOneSample(2)); |
nick | cc0d914 | 2015-10-14 16:27:10 | [diff] [blame] | 1119 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1120 | "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1121 | HasOneSample(2)); |
nick | cc0d914 | 2015-10-14 16:27:10 | [diff] [blame] | 1122 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1123 | "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1124 | HasOneSample(2)); |
| 1125 | EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); |
nasko | aab1a44 | 2015-11-19 02:10:36 | [diff] [blame] | 1126 | EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1127 | DependingOnPolicy(0, 0, 1)); |
nasko | 7d4c2cb | 2015-11-26 01:29:35 | [diff] [blame] | 1128 | |
| 1129 | // Since hosted apps are excluded from isolation, this test should not be |
| 1130 | // in any of the field trial groups. |
| 1131 | EXPECT_FALSE(IsInTrial("SiteIsolationExtensionsActive")); |
| 1132 | } |
| 1133 | |
| 1134 | // Verifies that the client is put in the appropriate field trial group. |
nick | eac6998 | 2016-02-11 22:18:53 | [diff] [blame] | 1135 | IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, VerifyFieldTrialGroup) { |
nasko | 7d4c2cb | 2015-11-26 01:29:35 | [diff] [blame] | 1136 | const Extension* extension = CreateExtension("Extension", false); |
| 1137 | GURL tab1_url = embedded_test_server()->GetURL( |
| 1138 | "a.com", "/cross_site_iframe_factory.html?a(b,c)"); |
| 1139 | ui_test_utils::NavigateToURL(browser(), tab1_url); |
| 1140 | WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0); |
| 1141 | |
| 1142 | // Tab navigates its second iframe to a page of the extension. |
| 1143 | content::NavigateIframeToURL(tab, "child-1", |
| 1144 | extension->GetResourceURL("/blank_iframe.html")); |
| 1145 | |
| 1146 | std::string group; |
| 1147 | if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1148 | switches::kSitePerProcess)) { |
| 1149 | group = "SitePerProcessFlag"; |
| 1150 | } else if (extensions::IsIsolateExtensionsEnabled()) { |
| 1151 | if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
alexmos | 9d656a8 | 2015-12-02 02:03:09 | [diff] [blame] | 1152 | extensions::switches::kIsolateExtensions)) { |
nasko | 7d4c2cb | 2015-11-26 01:29:35 | [diff] [blame] | 1153 | group = "IsolateExtensionsFlag"; |
| 1154 | } else { |
| 1155 | group = "FieldTrial"; |
| 1156 | } |
| 1157 | } else { |
nick | 1b39cd7 | 2016-02-11 23:08:21 | [diff] [blame] | 1158 | if (base::FieldTrialList::FindFullName("SiteIsolationExtensions").empty()) |
| 1159 | group = "Default"; |
| 1160 | else |
| 1161 | group = "Control"; |
nasko | 7d4c2cb | 2015-11-26 01:29:35 | [diff] [blame] | 1162 | } |
| 1163 | |
| 1164 | EXPECT_TRUE(IsInTrialGroup("SiteIsolationExtensionsActive", group)); |
nick | 8c3895b7 | 2015-08-13 00:04:02 | [diff] [blame] | 1165 | } |
nasko | 5027371 | 2015-12-03 16:03:50 | [diff] [blame] | 1166 | |
| 1167 | // Verifies that the UMA counter for SiteInstances in a BrowsingInstance is |
| 1168 | // correct when using tabs with web pages. |
nick | eac6998 | 2016-02-11 22:18:53 | [diff] [blame] | 1169 | IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, |
nasko | 5027371 | 2015-12-03 16:03:50 | [diff] [blame] | 1170 | VerifySiteInstanceCountInBrowsingInstance) { |
| 1171 | // Page with 14 nested oopifs across 9 sites (a.com through i.com). |
| 1172 | GURL abcdefghi_url = embedded_test_server()->GetURL( |
| 1173 | "a.com", |
| 1174 | "/cross_site_iframe_factory.html?a(b(a(b,c,d,e,f,g,h)),c,d,e,i(f))"); |
| 1175 | ui_test_utils::NavigateToURL(browser(), abcdefghi_url); |
| 1176 | |
| 1177 | // Get the metrics. |
| 1178 | scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); |
| 1179 | details->StartFetchAndWait(); |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1180 | |
| 1181 | // Since there are no extensions involved, the results in the default case |
| 1182 | // and extensions::IsIsolateExtensionsEnabled() are the same. |
| 1183 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1184 | "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
| 1185 | HasOneSample(DependingOnPolicy(1, 1, 9))); |
nick | de8b027 | 2016-02-11 04:29:25 | [diff] [blame] | 1186 | EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), |
| 1187 | HasOneSample(DependingOnPolicy(0, 0, 114))); |
| 1188 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1189 | "SiteIsolation.ProxyCountPerBrowsingInstance"), |
| 1190 | HasOneSample(DependingOnPolicy(0, 0, 114))); |
nasko | 5027371 | 2015-12-03 16:03:50 | [diff] [blame] | 1191 | |
| 1192 | // Open another tab through window.open(), which will be in the same |
| 1193 | // BrowsingInstance. |
| 1194 | GURL dcbae_url = embedded_test_server()->GetURL( |
| 1195 | "a.com", "/cross_site_iframe_factory.html?d(c(b(j(k))))"); |
| 1196 | ui_test_utils::UrlLoadObserver load_complete( |
| 1197 | dcbae_url, content::NotificationService::AllSources()); |
| 1198 | ASSERT_EQ(1, browser()->tab_strip_model()->count()); |
| 1199 | ASSERT_TRUE(content::ExecuteScript( |
| 1200 | browser()->tab_strip_model()->GetActiveWebContents(), |
| 1201 | "window.open('" + dcbae_url.spec() + "');")); |
| 1202 | ASSERT_EQ(2, browser()->tab_strip_model()->count()); |
| 1203 | load_complete.Wait(); |
| 1204 | |
| 1205 | details = new TestMemoryDetails(); |
| 1206 | details->StartFetchAndWait(); |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1207 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1208 | "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
| 1209 | HasOneSample(DependingOnPolicy(1, 1, 11))); |
nick | de8b027 | 2016-02-11 04:29:25 | [diff] [blame] | 1210 | EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), |
| 1211 | HasOneSample(DependingOnPolicy(0, 0, 160))); |
| 1212 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1213 | "SiteIsolation.ProxyCountPerBrowsingInstance"), |
| 1214 | HasOneSample(DependingOnPolicy(0, 0, 160))); |
nasko | 5027371 | 2015-12-03 16:03:50 | [diff] [blame] | 1215 | |
| 1216 | // Open a tab, which will be in a different BrowsingInstance. |
| 1217 | GURL abcd_url = embedded_test_server()->GetURL( |
| 1218 | "a.com", "/cross_site_iframe_factory.html?a(b(c(d())))"); |
| 1219 | AddTabAtIndex(1, abcd_url, ui::PAGE_TRANSITION_TYPED); |
| 1220 | |
| 1221 | details = new TestMemoryDetails(); |
| 1222 | details->StartFetchAndWait(); |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1223 | EXPECT_THAT( |
| 1224 | details->uma()->GetAllSamples( |
| 1225 | "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
| 1226 | DependingOnPolicy(ElementsAre(Sample(1, 2)), ElementsAre(Sample(1, 2)), |
| 1227 | ElementsAre(Sample(4, 1), Sample(11, 1)))); |
nick | de8b027 | 2016-02-11 04:29:25 | [diff] [blame] | 1228 | EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), |
| 1229 | HasOneSample(DependingOnPolicy(0, 0, 160))); |
| 1230 | EXPECT_THAT( |
| 1231 | details->uma()->GetAllSamples( |
| 1232 | "SiteIsolation.ProxyCountPerBrowsingInstance"), |
| 1233 | DependingOnPolicy(ElementsAre(Sample(0, 2)), ElementsAre(Sample(0, 2)), |
| 1234 | ElementsAre(Sample(12, 1), Sample(160, 1)))); |
nasko | 5027371 | 2015-12-03 16:03:50 | [diff] [blame] | 1235 | } |
| 1236 | |
| 1237 | // Verifies that the UMA counter for SiteInstances in a BrowsingInstance is |
| 1238 | // correct when extensions and web pages are mixed together. |
nick | eac6998 | 2016-02-11 22:18:53 | [diff] [blame] | 1239 | IN_PROC_BROWSER_TEST_F( |
nasko | 5027371 | 2015-12-03 16:03:50 | [diff] [blame] | 1240 | SiteDetailsBrowserTest, |
| 1241 | VerifySiteInstanceCountInBrowsingInstanceWithExtensions) { |
| 1242 | // Open two a.com tabs (with cross site http iframes). IsolateExtensions mode |
| 1243 | // should have no effect so far, since there are no frames straddling the |
| 1244 | // extension/web boundary. |
| 1245 | GURL tab_url = embedded_test_server()->GetURL( |
| 1246 | "a.com", "/cross_site_iframe_factory.html?a(b,c,d(e))"); |
| 1247 | ui_test_utils::NavigateToURL(browser(), tab_url); |
| 1248 | WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0); |
| 1249 | scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); |
| 1250 | details->StartFetchAndWait(); |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1251 | |
| 1252 | // Since there are no extensions loaded yet, the results in the default case |
| 1253 | // and extensions::IsIsolateExtensionsEnabled() are the same. |
| 1254 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1255 | "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
| 1256 | HasOneSample(DependingOnPolicy(1, 1, 5))); |
nasko | 5027371 | 2015-12-03 16:03:50 | [diff] [blame] | 1257 | |
| 1258 | // Load an extension without a background page, which will avoid creating a |
| 1259 | // BrowsingInstance for it. |
| 1260 | const Extension* extension1 = CreateExtension("Extension One", false); |
| 1261 | |
| 1262 | // Navigate the tab's first iframe to a resource of the extension. The |
nasko | e8e623d | 2015-12-04 21:00:30 | [diff] [blame] | 1263 | // extension iframe will be put in the same BrowsingInstance as it is part |
| 1264 | // of the frame tree. |
nasko | 5027371 | 2015-12-03 16:03:50 | [diff] [blame] | 1265 | content::NavigateIframeToURL( |
| 1266 | tab, "child-0", extension1->GetResourceURL("/blank_iframe.html")); |
| 1267 | details = new TestMemoryDetails(); |
| 1268 | details->StartFetchAndWait(); |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1269 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1270 | "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
| 1271 | HasOneSample(DependingOnPolicy(1, 2, 5))); |
nasko | 5027371 | 2015-12-03 16:03:50 | [diff] [blame] | 1272 | |
| 1273 | // Now load an extension with a background page. This will result in a |
| 1274 | // BrowsingInstance for the background page. |
nick | 455cb63 | 2016-05-25 19:06:07 | [diff] [blame] | 1275 | const Extension* extension2 = CreateExtension("Extension Two", true); |
nasko | 5027371 | 2015-12-03 16:03:50 | [diff] [blame] | 1276 | details = new TestMemoryDetails(); |
| 1277 | details->StartFetchAndWait(); |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1278 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1279 | "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
| 1280 | DependingOnPolicy(ElementsAre(Bucket(1, 2)), |
| 1281 | ElementsAre(Bucket(1, 1), Bucket(2, 1)), |
| 1282 | ElementsAre(Bucket(1, 1), Bucket(5, 1)))); |
nasko | 5027371 | 2015-12-03 16:03:50 | [diff] [blame] | 1283 | |
nasko | e8e623d | 2015-12-04 21:00:30 | [diff] [blame] | 1284 | // Navigate the second iframe of the tab to the second extension. It should |
| 1285 | // stay in the same BrowsingInstance as the page. |
nasko | 5027371 | 2015-12-03 16:03:50 | [diff] [blame] | 1286 | content::NavigateIframeToURL( |
| 1287 | tab, "child-1", extension2->GetResourceURL("/blank_iframe.html")); |
| 1288 | details = new TestMemoryDetails(); |
| 1289 | details->StartFetchAndWait(); |
nick | 6c28ecc9 | 2016-02-09 21:30:12 | [diff] [blame] | 1290 | EXPECT_THAT(details->uma()->GetAllSamples( |
| 1291 | "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
| 1292 | DependingOnPolicy(ElementsAre(Bucket(1, 2)), |
| 1293 | ElementsAre(Bucket(1, 1), Bucket(3, 1)), |
| 1294 | ElementsAre(Bucket(1, 1), Bucket(5, 1)))); |
nasko | 5027371 | 2015-12-03 16:03:50 | [diff] [blame] | 1295 | } |