OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/site_details.h" | 5 #include "chrome/browser/site_details.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
(...skipping 28 matching lines...) Expand all Loading... |
39 #include "net/test/embedded_test_server/embedded_test_server.h" | 39 #include "net/test/embedded_test_server/embedded_test_server.h" |
40 #include "testing/gmock/include/gmock/gmock.h" | 40 #include "testing/gmock/include/gmock/gmock.h" |
41 #include "testing/gtest/include/gtest/gtest.h" | 41 #include "testing/gtest/include/gtest/gtest.h" |
42 | 42 |
43 using base::Bucket; | 43 using base::Bucket; |
44 using content::WebContents; | 44 using content::WebContents; |
45 using extensions::DictionaryBuilder; | 45 using extensions::DictionaryBuilder; |
46 using extensions::Extension; | 46 using extensions::Extension; |
47 using extensions::ListBuilder; | 47 using extensions::ListBuilder; |
48 using extensions::TestExtensionDir; | 48 using extensions::TestExtensionDir; |
49 using testing::ContainerEq; | |
50 using testing::ElementsAre; | 49 using testing::ElementsAre; |
| 50 using testing::PrintToString; |
51 | 51 |
52 namespace { | 52 namespace { |
53 | 53 |
54 class TestMemoryDetails : public MetricsMemoryDetails { | 54 class TestMemoryDetails : public MetricsMemoryDetails { |
55 public: | 55 public: |
56 TestMemoryDetails() | 56 TestMemoryDetails() |
57 : MetricsMemoryDetails(base::Bind(&base::DoNothing), nullptr) {} | 57 : MetricsMemoryDetails(base::Bind(&base::DoNothing), nullptr) {} |
58 | 58 |
59 void StartFetchAndWait() { | 59 void StartFetchAndWait() { |
60 uma_.reset(new base::HistogramTester()); | 60 uma_.reset(new base::HistogramTester()); |
(...skipping 29 matching lines...) Expand all Loading... |
90 MetricsMemoryDetails::OnDetailsAvailable(); | 90 MetricsMemoryDetails::OnDetailsAvailable(); |
91 // Exit the loop initiated by StartFetchAndWait(). | 91 // Exit the loop initiated by StartFetchAndWait(). |
92 base::MessageLoop::current()->QuitWhenIdle(); | 92 base::MessageLoop::current()->QuitWhenIdle(); |
93 } | 93 } |
94 | 94 |
95 scoped_ptr<base::HistogramTester> uma_; | 95 scoped_ptr<base::HistogramTester> uma_; |
96 | 96 |
97 DISALLOW_COPY_AND_ASSIGN(TestMemoryDetails); | 97 DISALLOW_COPY_AND_ASSIGN(TestMemoryDetails); |
98 }; | 98 }; |
99 | 99 |
| 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 |
100 } // namespace | 166 } // namespace |
101 | 167 |
102 class SiteDetailsBrowserTest : public ExtensionBrowserTest { | 168 class SiteDetailsBrowserTest : public ExtensionBrowserTest, |
| 169 public testing::WithParamInterface<const char*> { |
103 public: | 170 public: |
104 SiteDetailsBrowserTest() {} | 171 SiteDetailsBrowserTest() {} |
105 ~SiteDetailsBrowserTest() override {} | 172 ~SiteDetailsBrowserTest() override {} |
106 | 173 |
| 174 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 175 ExtensionBrowserTest::SetUpCommandLine(command_line); |
| 176 std::string switch_name = GetParam(); |
| 177 if (!switch_name.empty()) { |
| 178 command_line->AppendSwitch(switch_name); |
| 179 } |
| 180 } |
| 181 |
107 void SetUpOnMainThread() override { | 182 void SetUpOnMainThread() override { |
108 host_resolver()->AddRule("*", "127.0.0.1"); | 183 host_resolver()->AddRule("*", "127.0.0.1"); |
109 | 184 |
110 // Add content/test/data so we can use cross_site_iframe_factory.html | 185 // Add content/test/data so we can use cross_site_iframe_factory.html |
111 base::FilePath test_data_dir; | 186 base::FilePath test_data_dir; |
112 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir)); | 187 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir)); |
113 embedded_test_server()->ServeFilesFromDirectory( | 188 embedded_test_server()->ServeFilesFromDirectory( |
114 test_data_dir.AppendASCII("content/test/data/")); | 189 test_data_dir.AppendASCII("content/test/data/")); |
115 ASSERT_TRUE(embedded_test_server()->Start()); | 190 ASSERT_TRUE(embedded_test_server()->Start()); |
116 } | 191 } |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 } | 313 } |
239 | 314 |
240 return false; | 315 return false; |
241 } | 316 } |
242 | 317 |
243 private: | 318 private: |
244 ScopedVector<TestExtensionDir> temp_dirs_; | 319 ScopedVector<TestExtensionDir> temp_dirs_; |
245 DISALLOW_COPY_AND_ASSIGN(SiteDetailsBrowserTest); | 320 DISALLOW_COPY_AND_ASSIGN(SiteDetailsBrowserTest); |
246 }; | 321 }; |
247 | 322 |
248 MATCHER_P(EqualsIfExtensionsIsolated, expected, "") { | |
249 if (content::AreAllSitesIsolatedForTesting()) | |
250 return arg >= expected; | |
251 if (extensions::IsIsolateExtensionsEnabled()) | |
252 return arg == expected; | |
253 return true; | |
254 } | |
255 | |
256 MATCHER_P(EqualsIfSitePerProcess, expected, "") { | |
257 return !content::AreAllSitesIsolatedForTesting() || expected == arg; | |
258 } | |
259 | 323 |
260 // Test the accuracy of SiteDetails process estimation, in the presence of | 324 // Test the accuracy of SiteDetails process estimation, in the presence of |
261 // multiple iframes, navigation, multiple BrowsingInstances, and multiple tabs | 325 // multiple iframes, navigation, multiple BrowsingInstances, and multiple tabs |
262 // in the same BrowsingInstance. | 326 // in the same BrowsingInstance. |
263 IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, ManyIframes) { | 327 IN_PROC_BROWSER_TEST_P(SiteDetailsBrowserTest, ManyIframes) { |
264 // Page with 14 nested oopifs across 9 sites (a.com through i.com). | 328 // Page with 14 nested oopifs across 9 sites (a.com through i.com). |
265 // None of these are https. | 329 // None of these are https. |
266 GURL abcdefghi_url = embedded_test_server()->GetURL( | 330 GURL abcdefghi_url = embedded_test_server()->GetURL( |
267 "a.com", | 331 "a.com", |
268 "/cross_site_iframe_factory.html?a(b(a(b,c,d,e,f,g,h)),c,d,e,i(f))"); | 332 "/cross_site_iframe_factory.html?a(b(a(b,c,d,e,f,g,h)),c,d,e,i(f))"); |
269 ui_test_utils::NavigateToURL(browser(), abcdefghi_url); | 333 ui_test_utils::NavigateToURL(browser(), abcdefghi_url); |
270 | 334 |
271 // Get the metrics. | 335 // Get the metrics. |
272 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); | 336 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); |
273 details->StartFetchAndWait(); | 337 details->StartFetchAndWait(); |
274 | 338 |
275 EXPECT_EQ(1U, details->CountPageTitles()); | 339 EXPECT_EQ(1U, details->CountPageTitles()); |
276 EXPECT_THAT( | 340 EXPECT_THAT( |
277 details->uma()->GetAllSamples("SiteIsolation.BrowsingInstanceCount"), | 341 details->uma()->GetAllSamples("SiteIsolation.BrowsingInstanceCount"), |
278 ElementsAre(Bucket(1, 1))); | 342 HasOneSample(1)); |
279 EXPECT_THAT(details->uma()->GetAllSamples( | 343 EXPECT_THAT(details->uma()->GetAllSamples( |
280 "SiteIsolation.CurrentRendererProcessCount"), | 344 "SiteIsolation.CurrentRendererProcessCount"), |
281 ElementsAre(Bucket(GetRenderProcessCount(), 1))); | 345 HasOneSample(GetRenderProcessCount())); |
282 EXPECT_THAT(details->uma()->GetAllSamples( | 346 EXPECT_THAT(details->uma()->GetAllSamples( |
283 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 347 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
284 ElementsAre(Bucket(1, 1))); | 348 HasOneSample(1)); |
285 EXPECT_THAT(details->uma()->GetAllSamples( | 349 EXPECT_THAT(details->uma()->GetAllSamples( |
286 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), | 350 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), |
287 ElementsAre(Bucket(9, 1))); | 351 HasOneSample(9)); |
288 EXPECT_THAT(details->uma()->GetAllSamples( | 352 EXPECT_THAT(details->uma()->GetAllSamples( |
289 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), | 353 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), |
290 ElementsAre(Bucket(9, 1))); | 354 HasOneSample(9)); |
291 EXPECT_THAT(details->uma()->GetAllSamples( | 355 EXPECT_THAT(details->uma()->GetAllSamples( |
292 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), | 356 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), |
293 ElementsAre(Bucket(9, 1))); | 357 HasOneSample(9)); |
294 EXPECT_THAT(details->uma()->GetAllSamples( | 358 EXPECT_THAT(details->uma()->GetAllSamples( |
295 "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), | 359 "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), |
296 ElementsAre(Bucket(1, 1))); | 360 HasOneSample(1)); |
297 EXPECT_THAT(details->uma()->GetAllSamples( | 361 EXPECT_THAT(details->uma()->GetAllSamples( |
298 "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), | 362 "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), |
299 ElementsAre(Bucket(1, 1))); | 363 HasOneSample(1)); |
300 EXPECT_THAT(details->uma()->GetAllSamples( | 364 EXPECT_THAT(details->uma()->GetAllSamples( |
301 "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), | 365 "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), |
302 ElementsAre(Bucket(1, 1))); | 366 HasOneSample(1)); |
303 EXPECT_THAT(details->uma()->GetAllSamples( | 367 EXPECT_THAT(details->uma()->GetAllSamples( |
304 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 368 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
305 ElementsAre(Bucket(1, 1))); | 369 HasOneSample(1)); |
306 EXPECT_THAT(details->uma()->GetAllSamples( | 370 EXPECT_THAT(details->uma()->GetAllSamples( |
307 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 371 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
308 ElementsAre(Bucket(1, 1))); | 372 HasOneSample(1)); |
309 EXPECT_THAT(details->uma()->GetAllSamples( | 373 EXPECT_THAT(details->uma()->GetAllSamples( |
310 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 374 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
311 ElementsAre(Bucket(1, 1))); | 375 HasOneSample(1)); |
312 EXPECT_THAT(GetRenderProcessCount(), EqualsIfExtensionsIsolated(1)); | 376 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 9)); |
313 EXPECT_THAT(GetRenderProcessCount(), EqualsIfSitePerProcess(9)); | |
314 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 377 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
315 EqualsIfExtensionsIsolated(0)); | 378 DependingOnPolicy(0, 0, 14)); |
316 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | |
317 EqualsIfSitePerProcess(14)); | |
318 | 379 |
319 // Navigate to a different, disjoint set of 7 sites. | 380 // Navigate to a different, disjoint set of 7 sites. |
320 GURL pqrstuv_url = embedded_test_server()->GetURL( | 381 GURL pqrstuv_url = embedded_test_server()->GetURL( |
321 "p.com", | 382 "p.com", |
322 "/cross_site_iframe_factory.html?p(q(r),r(s),s(t),t(q),u(u),v(p))"); | 383 "/cross_site_iframe_factory.html?p(q(r),r(s),s(t),t(q),u(u),v(p))"); |
323 ui_test_utils::NavigateToURL(browser(), pqrstuv_url); | 384 ui_test_utils::NavigateToURL(browser(), pqrstuv_url); |
324 | 385 |
325 details = new TestMemoryDetails(); | 386 details = new TestMemoryDetails(); |
326 details->StartFetchAndWait(); | 387 details->StartFetchAndWait(); |
327 | 388 |
328 EXPECT_EQ(1U, details->CountPageTitles()); | 389 EXPECT_EQ(1U, details->CountPageTitles()); |
329 EXPECT_THAT( | 390 EXPECT_THAT( |
330 details->uma()->GetAllSamples("SiteIsolation.BrowsingInstanceCount"), | 391 details->uma()->GetAllSamples("SiteIsolation.BrowsingInstanceCount"), |
331 ElementsAre(Bucket(1, 1))); | 392 HasOneSample(1)); |
332 EXPECT_THAT(details->uma()->GetAllSamples( | 393 EXPECT_THAT(details->uma()->GetAllSamples( |
333 "SiteIsolation.CurrentRendererProcessCount"), | 394 "SiteIsolation.CurrentRendererProcessCount"), |
334 ElementsAre(Bucket(GetRenderProcessCount(), 1))); | 395 HasOneSample(GetRenderProcessCount())); |
335 EXPECT_THAT(details->uma()->GetAllSamples( | 396 EXPECT_THAT(details->uma()->GetAllSamples( |
336 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 397 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
337 ElementsAre(Bucket(1, 1))); | 398 HasOneSample(1)); |
338 EXPECT_THAT(details->uma()->GetAllSamples( | 399 EXPECT_THAT(details->uma()->GetAllSamples( |
339 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), | 400 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), |
340 ElementsAre(Bucket(7, 1))); | 401 HasOneSample(7)); |
341 EXPECT_THAT(details->uma()->GetAllSamples( | 402 EXPECT_THAT(details->uma()->GetAllSamples( |
342 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), | 403 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), |
343 ElementsAre(Bucket(7, 1))); | 404 HasOneSample(7)); |
344 EXPECT_THAT(details->uma()->GetAllSamples( | 405 EXPECT_THAT(details->uma()->GetAllSamples( |
345 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), | 406 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), |
346 ElementsAre(Bucket(7, 1))); | 407 HasOneSample(7)); |
347 EXPECT_THAT(details->uma()->GetAllSamples( | 408 EXPECT_THAT(details->uma()->GetAllSamples( |
348 "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), | 409 "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), |
349 ElementsAre(Bucket(1, 1))); | 410 HasOneSample(1)); |
350 EXPECT_THAT(details->uma()->GetAllSamples( | 411 EXPECT_THAT(details->uma()->GetAllSamples( |
351 "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), | 412 "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), |
352 ElementsAre(Bucket(1, 1))); | 413 HasOneSample(1)); |
353 EXPECT_THAT(details->uma()->GetAllSamples( | 414 EXPECT_THAT(details->uma()->GetAllSamples( |
354 "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), | 415 "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), |
355 ElementsAre(Bucket(1, 1))); | 416 HasOneSample(1)); |
356 EXPECT_THAT(details->uma()->GetAllSamples( | 417 EXPECT_THAT(details->uma()->GetAllSamples( |
357 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 418 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
358 ElementsAre(Bucket(1, 1))); | 419 HasOneSample(1)); |
359 EXPECT_THAT(details->uma()->GetAllSamples( | 420 EXPECT_THAT(details->uma()->GetAllSamples( |
360 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 421 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
361 ElementsAre(Bucket(1, 1))); | 422 HasOneSample(1)); |
362 EXPECT_THAT(details->uma()->GetAllSamples( | 423 EXPECT_THAT(details->uma()->GetAllSamples( |
363 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 424 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
364 ElementsAre(Bucket(1, 1))); | 425 HasOneSample(1)); |
365 EXPECT_THAT(GetRenderProcessCount(), EqualsIfExtensionsIsolated(1)); | 426 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 7)); |
366 EXPECT_THAT(GetRenderProcessCount(), EqualsIfSitePerProcess(7)); | |
367 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 427 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
368 EqualsIfExtensionsIsolated(0)); | 428 DependingOnPolicy(0, 0, 11)); |
369 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | |
370 EqualsIfSitePerProcess(11)); | |
371 | 429 |
372 // Open a second tab (different BrowsingInstance) with 4 sites (a through d). | 430 // Open a second tab (different BrowsingInstance) with 4 sites (a through d). |
373 GURL abcd_url = embedded_test_server()->GetURL( | 431 GURL abcd_url = embedded_test_server()->GetURL( |
374 "a.com", "/cross_site_iframe_factory.html?a(b(c(d())))"); | 432 "a.com", "/cross_site_iframe_factory.html?a(b(c(d())))"); |
375 AddTabAtIndex(1, abcd_url, ui::PAGE_TRANSITION_TYPED); | 433 AddTabAtIndex(1, abcd_url, ui::PAGE_TRANSITION_TYPED); |
376 | 434 |
377 details = new TestMemoryDetails(); | 435 details = new TestMemoryDetails(); |
378 details->StartFetchAndWait(); | 436 details->StartFetchAndWait(); |
379 | 437 |
380 EXPECT_EQ(2U, details->CountPageTitles()); | 438 EXPECT_EQ(2U, details->CountPageTitles()); |
381 EXPECT_THAT( | 439 EXPECT_THAT( |
382 details->uma()->GetAllSamples("SiteIsolation.BrowsingInstanceCount"), | 440 details->uma()->GetAllSamples("SiteIsolation.BrowsingInstanceCount"), |
383 ElementsAre(Bucket(2, 1))); | 441 HasOneSample(2)); |
384 EXPECT_THAT(details->uma()->GetAllSamples( | 442 EXPECT_THAT(details->uma()->GetAllSamples( |
385 "SiteIsolation.CurrentRendererProcessCount"), | 443 "SiteIsolation.CurrentRendererProcessCount"), |
386 ElementsAre(Bucket(GetRenderProcessCount(), 1))); | 444 HasOneSample(GetRenderProcessCount())); |
387 EXPECT_THAT(details->uma()->GetAllSamples( | 445 EXPECT_THAT(details->uma()->GetAllSamples( |
388 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 446 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
389 ElementsAre(Bucket(2, 1))); | 447 HasOneSample(2)); |
390 EXPECT_THAT(details->uma()->GetAllSamples( | 448 EXPECT_THAT(details->uma()->GetAllSamples( |
391 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), | 449 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), |
392 ElementsAre(Bucket(11, 1))); | 450 HasOneSample(11)); |
393 EXPECT_THAT(details->uma()->GetAllSamples( | 451 EXPECT_THAT(details->uma()->GetAllSamples( |
394 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), | 452 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), |
395 ElementsAre(Bucket(11, 1))); | 453 HasOneSample(11)); |
396 EXPECT_THAT(details->uma()->GetAllSamples( | 454 EXPECT_THAT(details->uma()->GetAllSamples( |
397 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), | 455 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), |
398 ElementsAre(Bucket(11, 1))); | 456 HasOneSample(11)); |
399 EXPECT_THAT(details->uma()->GetAllSamples( | 457 EXPECT_THAT(details->uma()->GetAllSamples( |
400 "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), | 458 "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), |
401 ElementsAre(Bucket(2, 1))); | 459 HasOneSample(2)); |
402 EXPECT_THAT(details->uma()->GetAllSamples( | 460 EXPECT_THAT(details->uma()->GetAllSamples( |
403 "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), | 461 "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), |
404 ElementsAre(Bucket(1, 1))); // TODO(nick): This should be 2. | 462 HasOneSample(1)); // TODO(nick): This should be 2. |
405 EXPECT_THAT(details->uma()->GetAllSamples( | 463 EXPECT_THAT(details->uma()->GetAllSamples( |
406 "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), | 464 "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), |
407 ElementsAre(Bucket(2, 1))); | 465 HasOneSample(2)); |
408 EXPECT_THAT(details->uma()->GetAllSamples( | 466 EXPECT_THAT(details->uma()->GetAllSamples( |
409 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 467 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
410 ElementsAre(Bucket(2, 1))); | 468 HasOneSample(2)); |
411 EXPECT_THAT(details->uma()->GetAllSamples( | 469 EXPECT_THAT(details->uma()->GetAllSamples( |
412 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 470 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
413 ElementsAre(Bucket(1, 1))); | 471 HasOneSample(1)); |
414 EXPECT_THAT(details->uma()->GetAllSamples( | 472 EXPECT_THAT(details->uma()->GetAllSamples( |
415 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 473 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
416 ElementsAre(Bucket(2, 1))); | 474 HasOneSample(2)); |
417 EXPECT_THAT(GetRenderProcessCount(), EqualsIfExtensionsIsolated(2)); | 475 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(2, 2, 11)); |
418 EXPECT_THAT(GetRenderProcessCount(), EqualsIfSitePerProcess(11)); | |
419 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 476 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
420 EqualsIfExtensionsIsolated(0)); | 477 DependingOnPolicy(0, 0, 14)); |
421 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | |
422 EqualsIfSitePerProcess(14)); | |
423 | 478 |
424 // Open a third tab (different BrowsingInstance) with the same 4 sites. | 479 // Open a third tab (different BrowsingInstance) with the same 4 sites. |
425 AddTabAtIndex(2, abcd_url, ui::PAGE_TRANSITION_TYPED); | 480 AddTabAtIndex(2, abcd_url, ui::PAGE_TRANSITION_TYPED); |
426 | 481 |
427 details = new TestMemoryDetails(); | 482 details = new TestMemoryDetails(); |
428 details->StartFetchAndWait(); | 483 details->StartFetchAndWait(); |
429 | 484 |
430 EXPECT_THAT( | 485 EXPECT_THAT( |
431 details->uma()->GetAllSamples("SiteIsolation.BrowsingInstanceCount"), | 486 details->uma()->GetAllSamples("SiteIsolation.BrowsingInstanceCount"), |
432 ElementsAre(Bucket(3, 1))); | 487 HasOneSample(3)); |
433 EXPECT_THAT(details->uma()->GetAllSamples( | 488 EXPECT_THAT(details->uma()->GetAllSamples( |
434 "SiteIsolation.CurrentRendererProcessCount"), | 489 "SiteIsolation.CurrentRendererProcessCount"), |
435 ElementsAre(Bucket(GetRenderProcessCount(), 1))); | 490 HasOneSample(GetRenderProcessCount())); |
436 EXPECT_THAT(details->uma()->GetAllSamples( | 491 EXPECT_THAT(details->uma()->GetAllSamples( |
437 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 492 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
438 ElementsAre(Bucket(3, 1))); | 493 HasOneSample(3)); |
439 // Could be 11 if subframe processes were reused across BrowsingInstances. | 494 // Could be 11 if subframe processes were reused across BrowsingInstances. |
440 EXPECT_THAT(details->uma()->GetAllSamples( | 495 EXPECT_THAT(details->uma()->GetAllSamples( |
441 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), | 496 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), |
442 ElementsAre(Bucket(15, 1))); | 497 HasOneSample(15)); |
443 EXPECT_THAT(details->uma()->GetAllSamples( | 498 EXPECT_THAT(details->uma()->GetAllSamples( |
444 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), | 499 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), |
445 ElementsAre(Bucket(11, 1))); | 500 HasOneSample(11)); |
446 EXPECT_THAT(details->uma()->GetAllSamples( | 501 EXPECT_THAT(details->uma()->GetAllSamples( |
447 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), | 502 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), |
448 ElementsAre(Bucket(15, 1))); | 503 HasOneSample(15)); |
449 EXPECT_THAT(details->uma()->GetAllSamples( | 504 EXPECT_THAT(details->uma()->GetAllSamples( |
450 "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), | 505 "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), |
451 ElementsAre(Bucket(3, 1))); | 506 HasOneSample(3)); |
452 EXPECT_THAT(details->uma()->GetAllSamples( | 507 EXPECT_THAT(details->uma()->GetAllSamples( |
453 "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), | 508 "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), |
454 ElementsAre(Bucket(1, 1))); // TODO(nick): This should be 3. | 509 HasOneSample(1)); // TODO(nick): This should be 3. |
455 EXPECT_THAT(details->uma()->GetAllSamples( | 510 EXPECT_THAT(details->uma()->GetAllSamples( |
456 "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), | 511 "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), |
457 ElementsAre(Bucket(3, 1))); | 512 HasOneSample(3)); |
458 EXPECT_THAT(details->uma()->GetAllSamples( | 513 EXPECT_THAT(details->uma()->GetAllSamples( |
459 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 514 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
460 ElementsAre(Bucket(3, 1))); | 515 HasOneSample(3)); |
461 EXPECT_THAT(details->uma()->GetAllSamples( | 516 EXPECT_THAT(details->uma()->GetAllSamples( |
462 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 517 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
463 ElementsAre(Bucket(1, 1))); | 518 HasOneSample(1)); |
464 EXPECT_THAT(details->uma()->GetAllSamples( | 519 EXPECT_THAT(details->uma()->GetAllSamples( |
465 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 520 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
466 ElementsAre(Bucket(3, 1))); | 521 HasOneSample(3)); |
467 EXPECT_THAT(GetRenderProcessCount(), EqualsIfExtensionsIsolated(3)); | 522 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 3, 15)); |
468 EXPECT_THAT(GetRenderProcessCount(), EqualsIfSitePerProcess(15)); | |
469 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 523 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
470 EqualsIfExtensionsIsolated(0)); | 524 DependingOnPolicy(0, 0, 17)); |
471 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | |
472 EqualsIfSitePerProcess(17)); | |
473 | 525 |
474 // From the third tab, window.open() a fourth tab in the same | 526 // From the third tab, window.open() a fourth tab in the same |
475 // BrowsingInstance, to a page using the same four sites "a-d" as third tab, | 527 // BrowsingInstance, to a page using the same four sites "a-d" as third tab, |
476 // plus an additional site "e". The estimated process counts should increase | 528 // plus an additional site "e". The estimated process counts should increase |
477 // by one (not five) from the previous scenario, as the new tab can reuse the | 529 // by one (not five) from the previous scenario, as the new tab can reuse the |
478 // four processes already in the BrowsingInstance. | 530 // four processes already in the BrowsingInstance. |
479 GURL dcbae_url = embedded_test_server()->GetURL( | 531 GURL dcbae_url = embedded_test_server()->GetURL( |
480 "a.com", "/cross_site_iframe_factory.html?d(c(b(a(e))))"); | 532 "a.com", "/cross_site_iframe_factory.html?d(c(b(a(e))))"); |
481 ui_test_utils::UrlLoadObserver load_complete( | 533 ui_test_utils::UrlLoadObserver load_complete( |
482 dcbae_url, content::NotificationService::AllSources()); | 534 dcbae_url, content::NotificationService::AllSources()); |
483 ASSERT_EQ(3, browser()->tab_strip_model()->count()); | 535 ASSERT_EQ(3, browser()->tab_strip_model()->count()); |
484 ASSERT_TRUE(content::ExecuteScript( | 536 ASSERT_TRUE(content::ExecuteScript( |
485 browser()->tab_strip_model()->GetActiveWebContents(), | 537 browser()->tab_strip_model()->GetActiveWebContents(), |
486 "window.open('" + dcbae_url.spec() + "');")); | 538 "window.open('" + dcbae_url.spec() + "');")); |
487 ASSERT_EQ(4, browser()->tab_strip_model()->count()); | 539 ASSERT_EQ(4, browser()->tab_strip_model()->count()); |
488 load_complete.Wait(); | 540 load_complete.Wait(); |
489 | 541 |
490 details = new TestMemoryDetails(); | 542 details = new TestMemoryDetails(); |
491 details->StartFetchAndWait(); | 543 details->StartFetchAndWait(); |
492 | 544 |
493 EXPECT_THAT( | 545 EXPECT_THAT( |
494 details->uma()->GetAllSamples("SiteIsolation.BrowsingInstanceCount"), | 546 details->uma()->GetAllSamples("SiteIsolation.BrowsingInstanceCount"), |
495 ElementsAre(Bucket(3, 1))); | 547 HasOneSample(3)); |
496 EXPECT_THAT(details->uma()->GetAllSamples( | 548 EXPECT_THAT(details->uma()->GetAllSamples( |
497 "SiteIsolation.CurrentRendererProcessCount"), | 549 "SiteIsolation.CurrentRendererProcessCount"), |
498 ElementsAre(Bucket(GetRenderProcessCount(), 1))); | 550 HasOneSample(GetRenderProcessCount())); |
499 EXPECT_THAT(details->uma()->GetAllSamples( | 551 EXPECT_THAT(details->uma()->GetAllSamples( |
500 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 552 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
501 ElementsAre(Bucket(3, 1))); | 553 HasOneSample(3)); |
502 // Could be 11 if subframe processes were reused across BrowsingInstances. | 554 // Could be 11 if subframe processes were reused across BrowsingInstances. |
503 EXPECT_THAT(details->uma()->GetAllSamples( | 555 EXPECT_THAT(details->uma()->GetAllSamples( |
504 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), | 556 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), |
505 ElementsAre(Bucket(16, 1))); | 557 HasOneSample(16)); |
506 EXPECT_THAT(details->uma()->GetAllSamples( | 558 EXPECT_THAT(details->uma()->GetAllSamples( |
507 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), | 559 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), |
508 ElementsAre(Bucket(12, 1))); | 560 HasOneSample(12)); |
509 EXPECT_THAT(details->uma()->GetAllSamples( | 561 EXPECT_THAT(details->uma()->GetAllSamples( |
510 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), | 562 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), |
511 ElementsAre(Bucket(16, 1))); | 563 HasOneSample(16)); |
512 EXPECT_THAT(details->uma()->GetAllSamples( | 564 EXPECT_THAT(details->uma()->GetAllSamples( |
513 "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), | 565 "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), |
514 ElementsAre(Bucket(3, 1))); | 566 HasOneSample(3)); |
515 EXPECT_THAT(details->uma()->GetAllSamples( | 567 EXPECT_THAT(details->uma()->GetAllSamples( |
516 "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), | 568 "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), |
517 ElementsAre(Bucket(1, 1))); // TODO(nick): This should be 3. | 569 HasOneSample(1)); // TODO(nick): This should be 3. |
518 EXPECT_THAT(details->uma()->GetAllSamples( | 570 EXPECT_THAT(details->uma()->GetAllSamples( |
519 "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), | 571 "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), |
520 ElementsAre(Bucket(3, 1))); | 572 HasOneSample(3)); |
521 EXPECT_THAT(details->uma()->GetAllSamples( | 573 EXPECT_THAT(details->uma()->GetAllSamples( |
522 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 574 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
523 ElementsAre(Bucket(3, 1))); | 575 HasOneSample(3)); |
524 EXPECT_THAT(details->uma()->GetAllSamples( | 576 EXPECT_THAT(details->uma()->GetAllSamples( |
525 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 577 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
526 ElementsAre(Bucket(1, 1))); | 578 HasOneSample(1)); |
527 EXPECT_THAT(details->uma()->GetAllSamples( | 579 EXPECT_THAT(details->uma()->GetAllSamples( |
528 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 580 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
529 ElementsAre(Bucket(3, 1))); | 581 HasOneSample(3)); |
530 EXPECT_THAT(GetRenderProcessCount(), EqualsIfExtensionsIsolated(3)); | 582 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 3, 16)); |
531 EXPECT_THAT(GetRenderProcessCount(), EqualsIfSitePerProcess(16)); | |
532 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 583 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
533 EqualsIfExtensionsIsolated(0)); | 584 DependingOnPolicy(0, 0, 21)); |
534 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | |
535 EqualsIfSitePerProcess(21)); | |
536 | 585 |
537 // This test doesn't navigate to any extensions URLs, so it should not be | 586 // This test doesn't navigate to any extensions URLs, so it should not be |
538 // in any of the field trial groups. | 587 // in any of the field trial groups. |
539 EXPECT_FALSE(IsInTrial("SiteIsolationExtensionsActive")); | 588 EXPECT_FALSE(IsInTrial("SiteIsolationExtensionsActive")); |
540 } | 589 } |
541 | 590 |
542 IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, IsolateExtensions) { | 591 IN_PROC_BROWSER_TEST_P(SiteDetailsBrowserTest, IsolateExtensions) { |
543 // We start on "about:blank", which should be credited with a process in this | 592 // We start on "about:blank", which should be credited with a process in this |
544 // case. | 593 // case. |
545 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); | 594 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); |
546 details->StartFetchAndWait(); | 595 details->StartFetchAndWait(); |
547 EXPECT_THAT(details->uma()->GetAllSamples( | 596 EXPECT_THAT(details->uma()->GetAllSamples( |
548 "SiteIsolation.CurrentRendererProcessCount"), | 597 "SiteIsolation.CurrentRendererProcessCount"), |
549 ElementsAre(Bucket(GetRenderProcessCount(), 1))); | 598 HasOneSample(GetRenderProcessCount())); |
550 EXPECT_THAT(details->uma()->GetAllSamples( | 599 EXPECT_THAT(details->uma()->GetAllSamples( |
551 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 600 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
552 ElementsAre(Bucket(1, 1))); | 601 HasOneSample(1)); |
553 EXPECT_THAT(details->uma()->GetAllSamples( | 602 EXPECT_THAT(details->uma()->GetAllSamples( |
554 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 603 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
555 ElementsAre(Bucket(1, 1))); | 604 HasOneSample(1)); |
556 EXPECT_THAT(details->uma()->GetAllSamples( | 605 EXPECT_THAT(details->uma()->GetAllSamples( |
557 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 606 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
558 ElementsAre(Bucket(1, 1))); | 607 HasOneSample(1)); |
559 EXPECT_THAT(details->uma()->GetAllSamples( | 608 EXPECT_THAT(details->uma()->GetAllSamples( |
560 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 609 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
561 ElementsAre(Bucket(1, 1))); | 610 HasOneSample(1)); |
562 EXPECT_THAT(GetRenderProcessCount(), 1); | 611 EXPECT_THAT(GetRenderProcessCount(), 1); |
563 EXPECT_EQ(0, details->GetOutOfProcessIframeCount()); | 612 EXPECT_EQ(0, details->GetOutOfProcessIframeCount()); |
564 | 613 |
565 // Install one script-injecting extension with background page, and an | 614 // Install one script-injecting extension with background page, and an |
566 // extension with web accessible resources. | 615 // extension with web accessible resources. |
567 const Extension* extension1 = CreateExtension("Extension One", true); | 616 const Extension* extension1 = CreateExtension("Extension One", true); |
568 const Extension* extension2 = CreateExtension("Extension Two", false); | 617 const Extension* extension2 = CreateExtension("Extension Two", false); |
569 | 618 |
570 // Open two a.com tabs (with cross site http iframes). IsolateExtensions mode | 619 // Open two a.com tabs (with cross site http iframes). IsolateExtensions mode |
571 // should have no effect so far, since there are no frames straddling the | 620 // should have no effect so far, since there are no frames straddling the |
572 // extension/web boundary. | 621 // extension/web boundary. |
573 GURL tab1_url = embedded_test_server()->GetURL( | 622 GURL tab1_url = embedded_test_server()->GetURL( |
574 "a.com", "/cross_site_iframe_factory.html?a(b,c)"); | 623 "a.com", "/cross_site_iframe_factory.html?a(b,c)"); |
575 ui_test_utils::NavigateToURL(browser(), tab1_url); | 624 ui_test_utils::NavigateToURL(browser(), tab1_url); |
576 WebContents* tab1 = browser()->tab_strip_model()->GetWebContentsAt(0); | 625 WebContents* tab1 = browser()->tab_strip_model()->GetWebContentsAt(0); |
577 GURL tab2_url = embedded_test_server()->GetURL( | 626 GURL tab2_url = embedded_test_server()->GetURL( |
578 "a.com", "/cross_site_iframe_factory.html?a(d,e)"); | 627 "a.com", "/cross_site_iframe_factory.html?a(d,e)"); |
579 AddTabAtIndex(1, tab2_url, ui::PAGE_TRANSITION_TYPED); | 628 AddTabAtIndex(1, tab2_url, ui::PAGE_TRANSITION_TYPED); |
580 WebContents* tab2 = browser()->tab_strip_model()->GetWebContentsAt(1); | 629 WebContents* tab2 = browser()->tab_strip_model()->GetWebContentsAt(1); |
581 | 630 |
582 details = new TestMemoryDetails(); | 631 details = new TestMemoryDetails(); |
583 details->StartFetchAndWait(); | 632 details->StartFetchAndWait(); |
584 EXPECT_THAT(details->uma()->GetAllSamples( | 633 EXPECT_THAT(details->uma()->GetAllSamples( |
585 "SiteIsolation.CurrentRendererProcessCount"), | 634 "SiteIsolation.CurrentRendererProcessCount"), |
586 ElementsAre(Bucket(GetRenderProcessCount(), 1))); | 635 HasOneSample(GetRenderProcessCount())); |
587 EXPECT_THAT(details->uma()->GetAllSamples( | 636 EXPECT_THAT(details->uma()->GetAllSamples( |
588 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 637 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
589 ElementsAre(Bucket(3, 1))); | 638 HasOneSample(3)); |
590 EXPECT_THAT(details->uma()->GetAllSamples( | 639 EXPECT_THAT(details->uma()->GetAllSamples( |
591 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 640 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
592 ElementsAre(Bucket(3, 1))); | 641 HasOneSample(3)); |
593 EXPECT_THAT(details->uma()->GetAllSamples( | 642 EXPECT_THAT(details->uma()->GetAllSamples( |
594 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 643 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
595 ElementsAre(Bucket(2, 1))); | 644 HasOneSample(2)); |
596 EXPECT_THAT(details->uma()->GetAllSamples( | 645 EXPECT_THAT(details->uma()->GetAllSamples( |
597 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 646 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
598 ElementsAre(Bucket(3, 1))); | 647 HasOneSample(3)); |
599 EXPECT_THAT(GetRenderProcessCount(), EqualsIfExtensionsIsolated(3)); | 648 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 3, 7)); |
600 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 649 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
601 EqualsIfExtensionsIsolated(0)); | 650 DependingOnPolicy(0, 0, 4)); |
602 EXPECT_THAT(details->GetOutOfProcessIframeCount(), EqualsIfSitePerProcess(4)); | |
603 | 651 |
604 // Test that "one process per extension" applies even when web content has an | 652 // Test that "one process per extension" applies even when web content has an |
605 // extension iframe. | 653 // extension iframe. |
606 | 654 |
607 // Tab1 navigates its first iframe to a resource of extension1. This shouldn't | 655 // Tab1 navigates its first iframe to a resource of extension1. This shouldn't |
608 // result in a new extension process (it should share with extension1's | 656 // result in a new extension process (it should share with extension1's |
609 // background page). | 657 // background page). |
610 content::NavigateIframeToURL( | 658 content::NavigateIframeToURL( |
611 tab1, "child-0", extension1->GetResourceURL("/blank_iframe.html")); | 659 tab1, "child-0", extension1->GetResourceURL("/blank_iframe.html")); |
612 details = new TestMemoryDetails(); | 660 details = new TestMemoryDetails(); |
613 details->StartFetchAndWait(); | 661 details->StartFetchAndWait(); |
614 EXPECT_THAT(details->uma()->GetAllSamples( | 662 EXPECT_THAT(details->uma()->GetAllSamples( |
615 "SiteIsolation.CurrentRendererProcessCount"), | 663 "SiteIsolation.CurrentRendererProcessCount"), |
616 ElementsAre(Bucket(GetRenderProcessCount(), 1))); | 664 HasOneSample(GetRenderProcessCount())); |
617 EXPECT_THAT(details->uma()->GetAllSamples( | 665 EXPECT_THAT(details->uma()->GetAllSamples( |
618 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 666 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
619 ElementsAre(Bucket(3, 1))); | 667 HasOneSample(3)); |
620 EXPECT_THAT(details->uma()->GetAllSamples( | 668 EXPECT_THAT(details->uma()->GetAllSamples( |
621 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 669 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
622 ElementsAre(Bucket(3, 1))); | 670 HasOneSample(3)); |
623 EXPECT_THAT(details->uma()->GetAllSamples( | 671 EXPECT_THAT(details->uma()->GetAllSamples( |
624 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 672 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
625 ElementsAre(Bucket(2, 1))); | 673 HasOneSample(2)); |
626 EXPECT_THAT(details->uma()->GetAllSamples( | 674 EXPECT_THAT(details->uma()->GetAllSamples( |
627 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 675 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
628 ElementsAre(Bucket(3, 1))); | 676 HasOneSample(3)); |
629 EXPECT_THAT(GetRenderProcessCount(), EqualsIfExtensionsIsolated(3)); | 677 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 3, 6)); |
630 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 678 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
631 EqualsIfExtensionsIsolated(1)); | 679 DependingOnPolicy(0, 1, 4)); |
632 EXPECT_THAT(details->GetOutOfProcessIframeCount(), EqualsIfSitePerProcess(4)); | |
633 | 680 |
634 // Tab2 navigates its first iframe to a resource of extension1. This also | 681 // Tab2 navigates its first iframe to a resource of extension1. This also |
635 // shouldn't result in a new extension process (it should share with the | 682 // shouldn't result in a new extension process (it should share with the |
636 // background page and the other iframe). | 683 // background page and the other iframe). |
637 content::NavigateIframeToURL( | 684 content::NavigateIframeToURL( |
638 tab2, "child-0", extension1->GetResourceURL("/blank_iframe.html")); | 685 tab2, "child-0", extension1->GetResourceURL("/blank_iframe.html")); |
639 details = new TestMemoryDetails(); | 686 details = new TestMemoryDetails(); |
640 details->StartFetchAndWait(); | 687 details->StartFetchAndWait(); |
641 EXPECT_THAT(details->uma()->GetAllSamples( | 688 EXPECT_THAT(details->uma()->GetAllSamples( |
642 "SiteIsolation.CurrentRendererProcessCount"), | 689 "SiteIsolation.CurrentRendererProcessCount"), |
643 ElementsAre(Bucket(GetRenderProcessCount(), 1))); | 690 HasOneSample(GetRenderProcessCount())); |
644 EXPECT_THAT(details->uma()->GetAllSamples( | 691 EXPECT_THAT(details->uma()->GetAllSamples( |
645 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 692 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
646 ElementsAre(Bucket(3, 1))); | 693 HasOneSample(3)); |
647 EXPECT_THAT(details->uma()->GetAllSamples( | 694 EXPECT_THAT(details->uma()->GetAllSamples( |
648 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 695 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
649 ElementsAre(Bucket(3, 1))); | 696 HasOneSample(3)); |
650 EXPECT_THAT(details->uma()->GetAllSamples( | 697 EXPECT_THAT(details->uma()->GetAllSamples( |
651 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 698 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
652 ElementsAre(Bucket(2, 1))); | 699 HasOneSample(2)); |
653 EXPECT_THAT(details->uma()->GetAllSamples( | 700 EXPECT_THAT(details->uma()->GetAllSamples( |
654 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 701 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
655 ElementsAre(Bucket(3, 1))); | 702 HasOneSample(3)); |
656 EXPECT_THAT(GetRenderProcessCount(), EqualsIfExtensionsIsolated(3)); | 703 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 3, 5)); |
657 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 704 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
658 EqualsIfExtensionsIsolated(2)); | 705 DependingOnPolicy(0, 2, 4)); |
659 EXPECT_THAT(details->GetOutOfProcessIframeCount(), EqualsIfSitePerProcess(4)); | |
660 | 706 |
661 // Tab1 navigates its second iframe to a resource of extension2. This SHOULD | 707 // Tab1 navigates its second iframe to a resource of extension2. This SHOULD |
662 // result in a new process since extension2 had no existing process. | 708 // result in a new process since extension2 had no existing process. |
663 content::NavigateIframeToURL( | 709 content::NavigateIframeToURL( |
664 tab1, "child-1", extension2->GetResourceURL("/blank_iframe.html")); | 710 tab1, "child-1", extension2->GetResourceURL("/blank_iframe.html")); |
665 details = new TestMemoryDetails(); | 711 details = new TestMemoryDetails(); |
666 details->StartFetchAndWait(); | 712 details->StartFetchAndWait(); |
667 EXPECT_THAT(details->uma()->GetAllSamples( | 713 EXPECT_THAT(details->uma()->GetAllSamples( |
668 "SiteIsolation.CurrentRendererProcessCount"), | 714 "SiteIsolation.CurrentRendererProcessCount"), |
669 ElementsAre(Bucket(GetRenderProcessCount(), 1))); | 715 HasOneSample(GetRenderProcessCount())); |
670 EXPECT_THAT(details->uma()->GetAllSamples( | 716 EXPECT_THAT(details->uma()->GetAllSamples( |
671 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 717 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
672 ElementsAre(Bucket(3, 1))); | 718 HasOneSample(3)); |
673 EXPECT_THAT(details->uma()->GetAllSamples( | 719 EXPECT_THAT(details->uma()->GetAllSamples( |
674 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 720 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
675 ElementsAre(Bucket(4, 1))); | 721 HasOneSample(4)); |
676 EXPECT_THAT(details->uma()->GetAllSamples( | 722 EXPECT_THAT(details->uma()->GetAllSamples( |
677 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 723 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
678 ElementsAre(Bucket(3, 1))); | 724 HasOneSample(3)); |
679 EXPECT_THAT(details->uma()->GetAllSamples( | 725 EXPECT_THAT(details->uma()->GetAllSamples( |
680 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 726 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
681 ElementsAre(Bucket(4, 1))); | 727 HasOneSample(4)); |
682 EXPECT_THAT(GetRenderProcessCount(), EqualsIfExtensionsIsolated(4)); | 728 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 4, 5)); |
683 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 729 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
684 EqualsIfExtensionsIsolated(3)); | 730 DependingOnPolicy(0, 3, 4)); |
685 EXPECT_THAT(details->GetOutOfProcessIframeCount(), EqualsIfSitePerProcess(4)); | |
686 | 731 |
687 // Tab2 navigates its second iframe to a resource of extension2. This should | 732 // Tab2 navigates its second iframe to a resource of extension2. This should |
688 // share the existing extension2 process. | 733 // share the existing extension2 process. |
689 content::NavigateIframeToURL( | 734 content::NavigateIframeToURL( |
690 tab2, "child-1", extension2->GetResourceURL("/blank_iframe.html")); | 735 tab2, "child-1", extension2->GetResourceURL("/blank_iframe.html")); |
691 details = new TestMemoryDetails(); | 736 details = new TestMemoryDetails(); |
692 details->StartFetchAndWait(); | 737 details->StartFetchAndWait(); |
693 EXPECT_THAT(details->uma()->GetAllSamples( | 738 EXPECT_THAT(details->uma()->GetAllSamples( |
694 "SiteIsolation.CurrentRendererProcessCount"), | 739 "SiteIsolation.CurrentRendererProcessCount"), |
695 ElementsAre(Bucket(GetRenderProcessCount(), 1))); | 740 HasOneSample(GetRenderProcessCount())); |
696 EXPECT_THAT(details->uma()->GetAllSamples( | 741 EXPECT_THAT(details->uma()->GetAllSamples( |
697 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 742 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
698 ElementsAre(Bucket(3, 1))); | 743 HasOneSample(3)); |
699 EXPECT_THAT(details->uma()->GetAllSamples( | 744 EXPECT_THAT(details->uma()->GetAllSamples( |
700 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 745 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
701 ElementsAre(Bucket(4, 1))); | 746 HasOneSample(4)); |
702 EXPECT_THAT(details->uma()->GetAllSamples( | 747 EXPECT_THAT(details->uma()->GetAllSamples( |
703 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 748 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
704 ElementsAre(Bucket(3, 1))); | 749 HasOneSample(3)); |
705 EXPECT_THAT(details->uma()->GetAllSamples( | 750 EXPECT_THAT(details->uma()->GetAllSamples( |
706 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 751 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
707 ElementsAre(Bucket(4, 1))); | 752 HasOneSample(4)); |
708 EXPECT_THAT(GetRenderProcessCount(), EqualsIfExtensionsIsolated(4)); | 753 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 4, 4)); |
709 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 754 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
710 EqualsIfExtensionsIsolated(4)); | 755 DependingOnPolicy(0, 4, 4)); |
711 EXPECT_THAT(details->GetOutOfProcessIframeCount(), EqualsIfSitePerProcess(4)); | |
712 | 756 |
713 // Install extension3 (identical config to extension2) | 757 // Install extension3 (identical config to extension2) |
714 const Extension* extension3 = CreateExtension("Extension Three", false); | 758 const Extension* extension3 = CreateExtension("Extension Three", false); |
715 | 759 |
716 // Navigate Tab2 to a top-level page from extension3. There are four processes | 760 // Navigate Tab2 to a top-level page from extension3. There are four processes |
717 // now: one for tab1's main frame, and one for each of the extensions: | 761 // now: one for tab1's main frame, and one for each of the extensions: |
718 // extension1 has a process because it has a background page; extension2 is | 762 // extension1 has a process because it has a background page; extension2 is |
719 // used as an iframe in tab1, and extension3 is the top-level frame in tab2. | 763 // used as an iframe in tab1, and extension3 is the top-level frame in tab2. |
720 ui_test_utils::NavigateToURL(browser(), | 764 ui_test_utils::NavigateToURL(browser(), |
721 extension3->GetResourceURL("blank_iframe.html")); | 765 extension3->GetResourceURL("blank_iframe.html")); |
722 details = new TestMemoryDetails(); | 766 details = new TestMemoryDetails(); |
723 details->StartFetchAndWait(); | 767 details->StartFetchAndWait(); |
724 EXPECT_THAT(details->uma()->GetAllSamples( | 768 EXPECT_THAT(details->uma()->GetAllSamples( |
725 "SiteIsolation.CurrentRendererProcessCount"), | 769 "SiteIsolation.CurrentRendererProcessCount"), |
726 ElementsAre(Bucket(GetRenderProcessCount(), 1))); | 770 HasOneSample(GetRenderProcessCount())); |
727 EXPECT_THAT(details->uma()->GetAllSamples( | 771 EXPECT_THAT(details->uma()->GetAllSamples( |
728 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 772 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
729 ElementsAre(Bucket(3, 1))); | 773 HasOneSample(3)); |
730 EXPECT_THAT(details->uma()->GetAllSamples( | 774 EXPECT_THAT(details->uma()->GetAllSamples( |
731 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 775 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
732 ElementsAre(Bucket(4, 1))); | 776 HasOneSample(4)); |
733 EXPECT_THAT(details->uma()->GetAllSamples( | 777 EXPECT_THAT(details->uma()->GetAllSamples( |
734 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 778 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
735 ElementsAre(Bucket(4, 1))); | 779 HasOneSample(4)); |
736 EXPECT_THAT(details->uma()->GetAllSamples( | 780 EXPECT_THAT(details->uma()->GetAllSamples( |
737 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 781 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
738 ElementsAre(Bucket(4, 1))); | 782 HasOneSample(4)); |
739 EXPECT_THAT(GetRenderProcessCount(), EqualsIfExtensionsIsolated(4)); | 783 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 4, 4)); |
740 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 784 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
741 EqualsIfExtensionsIsolated(2)); | 785 DependingOnPolicy(0, 2, 2)); |
742 EXPECT_THAT(details->GetOutOfProcessIframeCount(), EqualsIfSitePerProcess(2)); | |
743 | 786 |
744 // Navigate tab2 to a different extension3 page containing a web iframe. The | 787 // Navigate tab2 to a different extension3 page containing a web iframe. The |
745 // iframe should get its own process. The lower bound number indicates that, | 788 // iframe should get its own process. The lower bound number indicates that, |
746 // in theory, the iframe could share a process with tab1's main frame. | 789 // in theory, the iframe could share a process with tab1's main frame. |
747 ui_test_utils::NavigateToURL(browser(), | 790 ui_test_utils::NavigateToURL(browser(), |
748 extension3->GetResourceURL("http_iframe.html")); | 791 extension3->GetResourceURL("http_iframe.html")); |
749 details = new TestMemoryDetails(); | 792 details = new TestMemoryDetails(); |
750 details->StartFetchAndWait(); | 793 details->StartFetchAndWait(); |
751 EXPECT_THAT(details->uma()->GetAllSamples( | 794 EXPECT_THAT(details->uma()->GetAllSamples( |
752 "SiteIsolation.CurrentRendererProcessCount"), | 795 "SiteIsolation.CurrentRendererProcessCount"), |
753 ElementsAre(Bucket(GetRenderProcessCount(), 1))); | 796 HasOneSample(GetRenderProcessCount())); |
754 EXPECT_THAT(details->uma()->GetAllSamples( | 797 EXPECT_THAT(details->uma()->GetAllSamples( |
755 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 798 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
756 ElementsAre(Bucket(3, 1))); | 799 HasOneSample(3)); |
757 EXPECT_THAT(details->uma()->GetAllSamples( | 800 EXPECT_THAT(details->uma()->GetAllSamples( |
758 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 801 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
759 ElementsAre(Bucket(5, 1))); | 802 HasOneSample(5)); |
760 EXPECT_THAT(details->uma()->GetAllSamples( | 803 EXPECT_THAT(details->uma()->GetAllSamples( |
761 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 804 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
762 ElementsAre(Bucket(4, 1))); | 805 HasOneSample(4)); |
763 EXPECT_THAT(details->uma()->GetAllSamples( | 806 EXPECT_THAT(details->uma()->GetAllSamples( |
764 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 807 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
765 ElementsAre(Bucket(5, 1))); | 808 HasOneSample(5)); |
766 EXPECT_THAT(GetRenderProcessCount(), EqualsIfExtensionsIsolated(5)); | 809 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 5, 5)); |
767 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 810 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
768 EqualsIfExtensionsIsolated(3)); | 811 DependingOnPolicy(0, 3, 3)); |
769 EXPECT_THAT(details->GetOutOfProcessIframeCount(), EqualsIfSitePerProcess(3)); | |
770 | 812 |
771 // Navigate tab1 to an extension3 page with an extension3 iframe. There should | 813 // Navigate tab1 to an extension3 page with an extension3 iframe. There should |
772 // be three processes estimated by IsolateExtensions: one for extension3, one | 814 // be three processes estimated by IsolateExtensions: one for extension3, one |
773 // for extension1's background page, and one for the web iframe in tab2. | 815 // for extension1's background page, and one for the web iframe in tab2. |
774 browser()->tab_strip_model()->ActivateTabAt(0, true); | 816 browser()->tab_strip_model()->ActivateTabAt(0, true); |
775 ui_test_utils::NavigateToURL(browser(), | 817 ui_test_utils::NavigateToURL(browser(), |
776 extension3->GetResourceURL("blank_iframe.html")); | 818 extension3->GetResourceURL("blank_iframe.html")); |
777 details = new TestMemoryDetails(); | 819 details = new TestMemoryDetails(); |
778 details->StartFetchAndWait(); | 820 details->StartFetchAndWait(); |
779 EXPECT_THAT(details->uma()->GetAllSamples( | 821 EXPECT_THAT(details->uma()->GetAllSamples( |
780 "SiteIsolation.CurrentRendererProcessCount"), | 822 "SiteIsolation.CurrentRendererProcessCount"), |
781 ElementsAre(Bucket(GetRenderProcessCount(), 1))); | 823 HasOneSample(GetRenderProcessCount())); |
782 EXPECT_THAT(details->uma()->GetAllSamples( | 824 EXPECT_THAT(details->uma()->GetAllSamples( |
783 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 825 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
784 ElementsAre(Bucket(2, 1))); | 826 HasOneSample(2)); |
785 EXPECT_THAT(details->uma()->GetAllSamples( | 827 EXPECT_THAT(details->uma()->GetAllSamples( |
786 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 828 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
787 ElementsAre(Bucket(3, 1))); | 829 HasOneSample(3)); |
788 EXPECT_THAT(details->uma()->GetAllSamples( | 830 EXPECT_THAT(details->uma()->GetAllSamples( |
789 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 831 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
790 ElementsAre(Bucket(3, 1))); | 832 HasOneSample(3)); |
791 EXPECT_THAT(details->uma()->GetAllSamples( | 833 EXPECT_THAT(details->uma()->GetAllSamples( |
792 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 834 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
793 ElementsAre(Bucket(3, 1))); | 835 HasOneSample(3)); |
794 EXPECT_THAT(GetRenderProcessCount(), EqualsIfExtensionsIsolated(3)); | 836 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(2, 3, 3)); |
795 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 837 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
796 EqualsIfExtensionsIsolated(1)); | 838 DependingOnPolicy(0, 1, 1)); |
797 EXPECT_THAT(details->GetOutOfProcessIframeCount(), EqualsIfSitePerProcess(1)); | |
798 | 839 |
799 // Now navigate tab1 to an extension3 page with a web iframe. This could share | 840 // Now navigate tab1 to an extension3 page with a web iframe. This could share |
800 // a process with tab2's iframe (the LowerBound number), or it could get its | 841 // a process with tab2's iframe (the LowerBound number), or it could get its |
801 // own process (the Estimate number). | 842 // own process (the Estimate number). |
802 ui_test_utils::NavigateToURL(browser(), | 843 ui_test_utils::NavigateToURL(browser(), |
803 extension3->GetResourceURL("http_iframe.html")); | 844 extension3->GetResourceURL("http_iframe.html")); |
804 details = new TestMemoryDetails(); | 845 details = new TestMemoryDetails(); |
805 details->StartFetchAndWait(); | 846 details->StartFetchAndWait(); |
806 EXPECT_THAT(details->uma()->GetAllSamples( | 847 EXPECT_THAT(details->uma()->GetAllSamples( |
807 "SiteIsolation.CurrentRendererProcessCount"), | 848 "SiteIsolation.CurrentRendererProcessCount"), |
808 ElementsAre(Bucket(GetRenderProcessCount(), 1))); | 849 HasOneSample(GetRenderProcessCount())); |
809 EXPECT_THAT(details->uma()->GetAllSamples( | 850 EXPECT_THAT(details->uma()->GetAllSamples( |
810 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 851 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
811 ElementsAre(Bucket(2, 1))); | 852 HasOneSample(2)); |
812 EXPECT_THAT(details->uma()->GetAllSamples( | 853 EXPECT_THAT(details->uma()->GetAllSamples( |
813 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 854 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
814 ElementsAre(Bucket(4, 1))); | 855 HasOneSample(4)); |
815 EXPECT_THAT(details->uma()->GetAllSamples( | 856 EXPECT_THAT(details->uma()->GetAllSamples( |
816 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 857 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
817 ElementsAre(Bucket(3, 1))); | 858 HasOneSample(3)); |
818 EXPECT_THAT(details->uma()->GetAllSamples( | 859 EXPECT_THAT(details->uma()->GetAllSamples( |
819 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 860 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
820 ElementsAre(Bucket(4, 1))); | 861 HasOneSample(4)); |
821 EXPECT_THAT(GetRenderProcessCount(), EqualsIfExtensionsIsolated(4)); | 862 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(2, 4, 4)); |
822 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 863 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
823 EqualsIfExtensionsIsolated(2)); | 864 DependingOnPolicy(0, 2, 2)); |
824 EXPECT_THAT(details->GetOutOfProcessIframeCount(), EqualsIfSitePerProcess(2)); | |
825 | 865 |
826 EXPECT_TRUE(IsInTrial("SiteIsolationExtensionsActive")); | 866 EXPECT_TRUE(IsInTrial("SiteIsolationExtensionsActive")); |
827 } | 867 } |
828 | 868 |
829 // Exercises accounting in the case where an extension has two different-site | 869 // Exercises accounting in the case where an extension has two different-site |
830 // web iframes. | 870 // web iframes. |
831 IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, ExtensionWithTwoWebIframes) { | 871 IN_PROC_BROWSER_TEST_P(SiteDetailsBrowserTest, ExtensionWithTwoWebIframes) { |
832 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); | 872 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); |
833 details->StartFetchAndWait(); | 873 details->StartFetchAndWait(); |
834 | 874 |
835 // Install one script-injecting extension with background page, and an | 875 // Install one script-injecting extension with background page, and an |
836 // extension with web accessible resources. | 876 // extension with web accessible resources. |
837 const Extension* extension = CreateExtension("Test Extension", false); | 877 const Extension* extension = CreateExtension("Test Extension", false); |
838 | 878 |
839 ui_test_utils::NavigateToURL( | 879 ui_test_utils::NavigateToURL( |
840 browser(), extension->GetResourceURL("/two_http_iframes.html")); | 880 browser(), extension->GetResourceURL("/two_http_iframes.html")); |
841 | 881 |
842 details = new TestMemoryDetails(); | 882 details = new TestMemoryDetails(); |
843 details->StartFetchAndWait(); | 883 details->StartFetchAndWait(); |
844 EXPECT_THAT(details->uma()->GetAllSamples( | 884 EXPECT_THAT(details->uma()->GetAllSamples( |
845 "SiteIsolation.CurrentRendererProcessCount"), | 885 "SiteIsolation.CurrentRendererProcessCount"), |
846 ElementsAre(Bucket(GetRenderProcessCount(), 1))); | 886 HasOneSample(GetRenderProcessCount())); |
847 EXPECT_THAT(details->uma()->GetAllSamples( | 887 EXPECT_THAT(details->uma()->GetAllSamples( |
848 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 888 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
849 ElementsAre(Bucket(1, 1))); | 889 HasOneSample(1)); |
850 EXPECT_THAT(details->uma()->GetAllSamples( | 890 EXPECT_THAT(details->uma()->GetAllSamples( |
851 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 891 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
852 ElementsAre(Bucket(2, 1))); | 892 HasOneSample(2)); |
853 EXPECT_THAT(details->uma()->GetAllSamples( | 893 EXPECT_THAT(details->uma()->GetAllSamples( |
854 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 894 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
855 ElementsAre(Bucket(2, 1))); | 895 HasOneSample(2)); |
856 EXPECT_THAT(details->uma()->GetAllSamples( | 896 EXPECT_THAT(details->uma()->GetAllSamples( |
857 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 897 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
858 ElementsAre(Bucket(2, 1))); | 898 HasOneSample(2)); |
859 // TODO(nick): https://crbug.com/512560 Make the number below agree with the | 899 // TODO(nick): https://crbug.com/512560 Make the number below agree with the |
860 // estimates above, which assume consolidation of subframe processes. | 900 // estimates above, which assume consolidation of subframe processes. |
861 EXPECT_THAT(GetRenderProcessCount(), EqualsIfExtensionsIsolated(3)); | 901 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 3, 3)); |
862 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 902 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
863 EqualsIfExtensionsIsolated(2)); | 903 DependingOnPolicy(0, 2, 2)); |
864 EXPECT_THAT(details->GetOutOfProcessIframeCount(), EqualsIfSitePerProcess(2)); | |
865 | 904 |
866 EXPECT_TRUE(IsInTrial("SiteIsolationExtensionsActive")); | 905 EXPECT_TRUE(IsInTrial("SiteIsolationExtensionsActive")); |
867 } | 906 } |
868 | 907 |
869 // Verifies that --isolate-extensions doesn't isolate hosted apps. | 908 // Verifies that --isolate-extensions doesn't isolate hosted apps. |
870 IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, IsolateExtensionsHostedApps) { | 909 IN_PROC_BROWSER_TEST_P(SiteDetailsBrowserTest, IsolateExtensionsHostedApps) { |
871 GURL app_with_web_iframe_url = embedded_test_server()->GetURL( | 910 GURL app_with_web_iframe_url = embedded_test_server()->GetURL( |
872 "app.org", "/cross_site_iframe_factory.html?app.org(b.com)"); | 911 "app.org", "/cross_site_iframe_factory.html?app.org(b.com)"); |
873 GURL app_in_web_iframe_url = embedded_test_server()->GetURL( | 912 GURL app_in_web_iframe_url = embedded_test_server()->GetURL( |
874 "b.com", "/cross_site_iframe_factory.html?b.com(app.org)"); | 913 "b.com", "/cross_site_iframe_factory.html?b.com(app.org)"); |
875 | 914 |
876 // No hosted app is installed: app.org just behaves like a normal domain. | 915 // No hosted app is installed: app.org just behaves like a normal domain. |
877 ui_test_utils::NavigateToURL(browser(), app_with_web_iframe_url); | 916 ui_test_utils::NavigateToURL(browser(), app_with_web_iframe_url); |
878 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); | 917 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); |
879 details->StartFetchAndWait(); | 918 details->StartFetchAndWait(); |
880 EXPECT_THAT(details->uma()->GetAllSamples( | 919 EXPECT_THAT(details->uma()->GetAllSamples( |
881 "SiteIsolation.CurrentRendererProcessCount"), | 920 "SiteIsolation.CurrentRendererProcessCount"), |
882 ElementsAre(Bucket(GetRenderProcessCount(), 1))); | 921 HasOneSample(GetRenderProcessCount())); |
883 EXPECT_THAT(details->uma()->GetAllSamples( | 922 EXPECT_THAT(details->uma()->GetAllSamples( |
884 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 923 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
885 ElementsAre(Bucket(1, 1))); | 924 HasOneSample(1)); |
886 EXPECT_THAT(details->uma()->GetAllSamples( | 925 EXPECT_THAT(details->uma()->GetAllSamples( |
887 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 926 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
888 ElementsAre(Bucket(1, 1))); | 927 HasOneSample(1)); |
889 EXPECT_THAT(details->uma()->GetAllSamples( | 928 EXPECT_THAT(details->uma()->GetAllSamples( |
890 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 929 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
891 ElementsAre(Bucket(1, 1))); | 930 HasOneSample(1)); |
892 EXPECT_THAT(details->uma()->GetAllSamples( | 931 EXPECT_THAT(details->uma()->GetAllSamples( |
893 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 932 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
894 ElementsAre(Bucket(1, 1))); | 933 HasOneSample(1)); |
895 EXPECT_THAT(GetRenderProcessCount(), EqualsIfExtensionsIsolated(1)); | 934 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); |
896 EXPECT_THAT(details->uma()->GetAllSamples( | 935 EXPECT_THAT(details->uma()->GetAllSamples( |
897 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), | 936 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), |
898 ElementsAre(Bucket(2, 1))); | 937 HasOneSample(2)); |
899 EXPECT_THAT(details->uma()->GetAllSamples( | 938 EXPECT_THAT(details->uma()->GetAllSamples( |
900 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), | 939 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), |
901 ElementsAre(Bucket(2, 1))); | 940 HasOneSample(2)); |
902 EXPECT_THAT(details->uma()->GetAllSamples( | 941 EXPECT_THAT(details->uma()->GetAllSamples( |
903 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), | 942 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), |
904 ElementsAre(Bucket(2, 1))); | 943 HasOneSample(2)); |
905 EXPECT_THAT(GetRenderProcessCount(), EqualsIfSitePerProcess(2)); | 944 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); |
906 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 945 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
907 EqualsIfExtensionsIsolated(0)); | 946 DependingOnPolicy(0, 0, 1)); |
908 EXPECT_THAT(details->GetOutOfProcessIframeCount(), EqualsIfSitePerProcess(1)); | |
909 | 947 |
910 ui_test_utils::NavigateToURL(browser(), app_in_web_iframe_url); | 948 ui_test_utils::NavigateToURL(browser(), app_in_web_iframe_url); |
911 details = new TestMemoryDetails(); | 949 details = new TestMemoryDetails(); |
912 details->StartFetchAndWait(); | 950 details->StartFetchAndWait(); |
913 EXPECT_THAT(details->uma()->GetAllSamples( | 951 EXPECT_THAT(details->uma()->GetAllSamples( |
914 "SiteIsolation.CurrentRendererProcessCount"), | 952 "SiteIsolation.CurrentRendererProcessCount"), |
915 ElementsAre(Bucket(GetRenderProcessCount(), 1))); | 953 HasOneSample(GetRenderProcessCount())); |
916 EXPECT_THAT(details->uma()->GetAllSamples( | 954 EXPECT_THAT(details->uma()->GetAllSamples( |
917 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 955 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
918 ElementsAre(Bucket(1, 1))); | 956 HasOneSample(1)); |
919 EXPECT_THAT(details->uma()->GetAllSamples( | 957 EXPECT_THAT(details->uma()->GetAllSamples( |
920 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 958 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
921 ElementsAre(Bucket(1, 1))); | 959 HasOneSample(1)); |
922 EXPECT_THAT(details->uma()->GetAllSamples( | 960 EXPECT_THAT(details->uma()->GetAllSamples( |
923 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 961 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
924 ElementsAre(Bucket(1, 1))); | 962 HasOneSample(1)); |
925 EXPECT_THAT(details->uma()->GetAllSamples( | 963 EXPECT_THAT(details->uma()->GetAllSamples( |
926 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 964 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
927 ElementsAre(Bucket(1, 1))); | 965 HasOneSample(1)); |
928 EXPECT_THAT(GetRenderProcessCount(), EqualsIfExtensionsIsolated(1)); | 966 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); |
929 EXPECT_THAT(details->uma()->GetAllSamples( | 967 EXPECT_THAT(details->uma()->GetAllSamples( |
930 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), | 968 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), |
931 ElementsAre(Bucket(2, 1))); | 969 HasOneSample(2)); |
932 EXPECT_THAT(details->uma()->GetAllSamples( | 970 EXPECT_THAT(details->uma()->GetAllSamples( |
933 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), | 971 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), |
934 ElementsAre(Bucket(2, 1))); | 972 HasOneSample(2)); |
935 EXPECT_THAT(details->uma()->GetAllSamples( | 973 EXPECT_THAT(details->uma()->GetAllSamples( |
936 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), | 974 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), |
937 ElementsAre(Bucket(2, 1))); | 975 HasOneSample(2)); |
938 EXPECT_THAT(GetRenderProcessCount(), EqualsIfSitePerProcess(2)); | 976 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); |
939 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 977 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
940 EqualsIfExtensionsIsolated(0)); | 978 DependingOnPolicy(0, 0, 1)); |
941 EXPECT_THAT(details->GetOutOfProcessIframeCount(), EqualsIfSitePerProcess(1)); | |
942 | 979 |
943 // Now install app.org as a hosted app. | 980 // Now install app.org as a hosted app. |
944 CreateHostedApp("App", GURL("http://app.org")); | 981 CreateHostedApp("App", GURL("http://app.org")); |
945 | 982 |
946 // Reload the same two pages, and verify that the hosted app still is not | 983 // Reload the same two pages, and verify that the hosted app still is not |
947 // isolated by --isolate-extensions, but is isolated by --site-per-process. | 984 // isolated by --isolate-extensions, but is isolated by --site-per-process. |
948 ui_test_utils::NavigateToURL(browser(), app_with_web_iframe_url); | 985 ui_test_utils::NavigateToURL(browser(), app_with_web_iframe_url); |
949 details = new TestMemoryDetails(); | 986 details = new TestMemoryDetails(); |
950 details->StartFetchAndWait(); | 987 details->StartFetchAndWait(); |
951 EXPECT_THAT(details->uma()->GetAllSamples( | 988 EXPECT_THAT(details->uma()->GetAllSamples( |
952 "SiteIsolation.CurrentRendererProcessCount"), | 989 "SiteIsolation.CurrentRendererProcessCount"), |
953 ElementsAre(Bucket(GetRenderProcessCount(), 1))); | 990 HasOneSample(GetRenderProcessCount())); |
954 EXPECT_THAT(details->uma()->GetAllSamples( | 991 EXPECT_THAT(details->uma()->GetAllSamples( |
955 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 992 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
956 ElementsAre(Bucket(1, 1))); | 993 HasOneSample(1)); |
957 EXPECT_THAT(details->uma()->GetAllSamples( | 994 EXPECT_THAT(details->uma()->GetAllSamples( |
958 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 995 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
959 ElementsAre(Bucket(1, 1))); | 996 HasOneSample(1)); |
960 EXPECT_THAT(details->uma()->GetAllSamples( | 997 EXPECT_THAT(details->uma()->GetAllSamples( |
961 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 998 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
962 ElementsAre(Bucket(1, 1))); | 999 HasOneSample(1)); |
963 EXPECT_THAT(details->uma()->GetAllSamples( | 1000 EXPECT_THAT(details->uma()->GetAllSamples( |
964 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 1001 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
965 ElementsAre(Bucket(1, 1))); | 1002 HasOneSample(1)); |
966 EXPECT_THAT(GetRenderProcessCount(), EqualsIfExtensionsIsolated(1)); | 1003 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); |
967 EXPECT_THAT(details->uma()->GetAllSamples( | 1004 EXPECT_THAT(details->uma()->GetAllSamples( |
968 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), | 1005 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), |
969 ElementsAre(Bucket(2, 1))); | 1006 HasOneSample(2)); |
970 EXPECT_THAT(details->uma()->GetAllSamples( | 1007 EXPECT_THAT(details->uma()->GetAllSamples( |
971 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), | 1008 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), |
972 ElementsAre(Bucket(2, 1))); | 1009 HasOneSample(2)); |
973 EXPECT_THAT(details->uma()->GetAllSamples( | 1010 EXPECT_THAT(details->uma()->GetAllSamples( |
974 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), | 1011 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), |
975 ElementsAre(Bucket(2, 1))); | 1012 HasOneSample(2)); |
976 EXPECT_THAT(GetRenderProcessCount(), EqualsIfSitePerProcess(2)); | 1013 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); |
977 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 1014 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
978 EqualsIfExtensionsIsolated(0)); | 1015 DependingOnPolicy(0, 0, 1)); |
979 EXPECT_THAT(details->GetOutOfProcessIframeCount(), EqualsIfSitePerProcess(1)); | |
980 | 1016 |
981 ui_test_utils::NavigateToURL(browser(), app_in_web_iframe_url); | 1017 ui_test_utils::NavigateToURL(browser(), app_in_web_iframe_url); |
982 details = new TestMemoryDetails(); | 1018 details = new TestMemoryDetails(); |
983 details->StartFetchAndWait(); | 1019 details->StartFetchAndWait(); |
984 EXPECT_THAT(details->uma()->GetAllSamples( | 1020 EXPECT_THAT(details->uma()->GetAllSamples( |
985 "SiteIsolation.CurrentRendererProcessCount"), | 1021 "SiteIsolation.CurrentRendererProcessCount"), |
986 ElementsAre(Bucket(GetRenderProcessCount(), 1))); | 1022 HasOneSample(GetRenderProcessCount())); |
987 EXPECT_THAT(details->uma()->GetAllSamples( | 1023 EXPECT_THAT(details->uma()->GetAllSamples( |
988 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 1024 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
989 ElementsAre(Bucket(1, 1))); | 1025 HasOneSample(1)); |
990 EXPECT_THAT(details->uma()->GetAllSamples( | 1026 EXPECT_THAT(details->uma()->GetAllSamples( |
991 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 1027 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), |
992 ElementsAre(Bucket(1, 1))); | 1028 HasOneSample(1)); |
993 EXPECT_THAT(details->uma()->GetAllSamples( | 1029 EXPECT_THAT(details->uma()->GetAllSamples( |
994 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 1030 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
995 ElementsAre(Bucket(1, 1))); | 1031 HasOneSample(1)); |
996 EXPECT_THAT(details->uma()->GetAllSamples( | 1032 EXPECT_THAT(details->uma()->GetAllSamples( |
997 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 1033 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
998 ElementsAre(Bucket(1, 1))); | 1034 HasOneSample(1)); |
999 EXPECT_THAT(GetRenderProcessCount(), EqualsIfExtensionsIsolated(1)); | 1035 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); |
1000 EXPECT_THAT(details->uma()->GetAllSamples( | 1036 EXPECT_THAT(details->uma()->GetAllSamples( |
1001 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), | 1037 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), |
1002 ElementsAre(Bucket(2, 1))); | 1038 HasOneSample(2)); |
1003 EXPECT_THAT(details->uma()->GetAllSamples( | 1039 EXPECT_THAT(details->uma()->GetAllSamples( |
1004 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), | 1040 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), |
1005 ElementsAre(Bucket(2, 1))); | 1041 HasOneSample(2)); |
1006 EXPECT_THAT(details->uma()->GetAllSamples( | 1042 EXPECT_THAT(details->uma()->GetAllSamples( |
1007 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), | 1043 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), |
1008 ElementsAre(Bucket(2, 1))); | 1044 HasOneSample(2)); |
1009 EXPECT_THAT(GetRenderProcessCount(), EqualsIfSitePerProcess(2)); | 1045 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); |
1010 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 1046 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
1011 EqualsIfExtensionsIsolated(0)); | 1047 DependingOnPolicy(0, 0, 1)); |
1012 EXPECT_THAT(details->GetOutOfProcessIframeCount(), EqualsIfSitePerProcess(1)); | |
1013 | 1048 |
1014 // Since hosted apps are excluded from isolation, this test should not be | 1049 // Since hosted apps are excluded from isolation, this test should not be |
1015 // in any of the field trial groups. | 1050 // in any of the field trial groups. |
1016 EXPECT_FALSE(IsInTrial("SiteIsolationExtensionsActive")); | 1051 EXPECT_FALSE(IsInTrial("SiteIsolationExtensionsActive")); |
1017 } | 1052 } |
1018 | 1053 |
1019 // Verifies that the client is put in the appropriate field trial group. | 1054 // Verifies that the client is put in the appropriate field trial group. |
1020 IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, VerifyFieldTrialGroup) { | 1055 IN_PROC_BROWSER_TEST_P(SiteDetailsBrowserTest, VerifyFieldTrialGroup) { |
1021 const Extension* extension = CreateExtension("Extension", false); | 1056 const Extension* extension = CreateExtension("Extension", false); |
1022 GURL tab1_url = embedded_test_server()->GetURL( | 1057 GURL tab1_url = embedded_test_server()->GetURL( |
1023 "a.com", "/cross_site_iframe_factory.html?a(b,c)"); | 1058 "a.com", "/cross_site_iframe_factory.html?a(b,c)"); |
1024 ui_test_utils::NavigateToURL(browser(), tab1_url); | 1059 ui_test_utils::NavigateToURL(browser(), tab1_url); |
1025 WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0); | 1060 WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0); |
1026 | 1061 |
1027 // Tab navigates its second iframe to a page of the extension. | 1062 // Tab navigates its second iframe to a page of the extension. |
1028 content::NavigateIframeToURL(tab, "child-1", | 1063 content::NavigateIframeToURL(tab, "child-1", |
1029 extension->GetResourceURL("/blank_iframe.html")); | 1064 extension->GetResourceURL("/blank_iframe.html")); |
1030 | 1065 |
(...skipping 10 matching lines...) Expand all Loading... |
1041 } | 1076 } |
1042 } else { | 1077 } else { |
1043 group = "Default"; | 1078 group = "Default"; |
1044 } | 1079 } |
1045 | 1080 |
1046 EXPECT_TRUE(IsInTrialGroup("SiteIsolationExtensionsActive", group)); | 1081 EXPECT_TRUE(IsInTrialGroup("SiteIsolationExtensionsActive", group)); |
1047 } | 1082 } |
1048 | 1083 |
1049 // Verifies that the UMA counter for SiteInstances in a BrowsingInstance is | 1084 // Verifies that the UMA counter for SiteInstances in a BrowsingInstance is |
1050 // correct when using tabs with web pages. | 1085 // correct when using tabs with web pages. |
1051 IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, | 1086 IN_PROC_BROWSER_TEST_P(SiteDetailsBrowserTest, |
1052 VerifySiteInstanceCountInBrowsingInstance) { | 1087 VerifySiteInstanceCountInBrowsingInstance) { |
1053 // Page with 14 nested oopifs across 9 sites (a.com through i.com). | 1088 // Page with 14 nested oopifs across 9 sites (a.com through i.com). |
1054 GURL abcdefghi_url = embedded_test_server()->GetURL( | 1089 GURL abcdefghi_url = embedded_test_server()->GetURL( |
1055 "a.com", | 1090 "a.com", |
1056 "/cross_site_iframe_factory.html?a(b(a(b,c,d,e,f,g,h)),c,d,e,i(f))"); | 1091 "/cross_site_iframe_factory.html?a(b(a(b,c,d,e,f,g,h)),c,d,e,i(f))"); |
1057 ui_test_utils::NavigateToURL(browser(), abcdefghi_url); | 1092 ui_test_utils::NavigateToURL(browser(), abcdefghi_url); |
1058 | 1093 |
1059 // Get the metrics. | 1094 // Get the metrics. |
1060 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); | 1095 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); |
1061 details->StartFetchAndWait(); | 1096 details->StartFetchAndWait(); |
1062 if (content::AreAllSitesIsolatedForTesting()) { | 1097 |
1063 EXPECT_THAT(details->uma()->GetAllSamples( | 1098 // Since there are no extensions involved, the results in the default case |
1064 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | 1099 // and extensions::IsIsolateExtensionsEnabled() are the same. |
1065 ElementsAre(Bucket(9, 1))); | 1100 EXPECT_THAT(details->uma()->GetAllSamples( |
1066 } else { | 1101 "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
1067 // Since there are no extensions involved, the results in the default case | 1102 HasOneSample(DependingOnPolicy(1, 1, 9))); |
1068 // and extensions::IsIsolateExtensionsEnabled() are the same. | |
1069 EXPECT_THAT(details->uma()->GetAllSamples( | |
1070 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | |
1071 ElementsAre(Bucket(1, 1))); | |
1072 } | |
1073 | 1103 |
1074 // Open another tab through window.open(), which will be in the same | 1104 // Open another tab through window.open(), which will be in the same |
1075 // BrowsingInstance. | 1105 // BrowsingInstance. |
1076 GURL dcbae_url = embedded_test_server()->GetURL( | 1106 GURL dcbae_url = embedded_test_server()->GetURL( |
1077 "a.com", "/cross_site_iframe_factory.html?d(c(b(j(k))))"); | 1107 "a.com", "/cross_site_iframe_factory.html?d(c(b(j(k))))"); |
1078 ui_test_utils::UrlLoadObserver load_complete( | 1108 ui_test_utils::UrlLoadObserver load_complete( |
1079 dcbae_url, content::NotificationService::AllSources()); | 1109 dcbae_url, content::NotificationService::AllSources()); |
1080 ASSERT_EQ(1, browser()->tab_strip_model()->count()); | 1110 ASSERT_EQ(1, browser()->tab_strip_model()->count()); |
1081 ASSERT_TRUE(content::ExecuteScript( | 1111 ASSERT_TRUE(content::ExecuteScript( |
1082 browser()->tab_strip_model()->GetActiveWebContents(), | 1112 browser()->tab_strip_model()->GetActiveWebContents(), |
1083 "window.open('" + dcbae_url.spec() + "');")); | 1113 "window.open('" + dcbae_url.spec() + "');")); |
1084 ASSERT_EQ(2, browser()->tab_strip_model()->count()); | 1114 ASSERT_EQ(2, browser()->tab_strip_model()->count()); |
1085 load_complete.Wait(); | 1115 load_complete.Wait(); |
1086 | 1116 |
1087 details = new TestMemoryDetails(); | 1117 details = new TestMemoryDetails(); |
1088 details->StartFetchAndWait(); | 1118 details->StartFetchAndWait(); |
1089 if (content::AreAllSitesIsolatedForTesting()) { | 1119 EXPECT_THAT(details->uma()->GetAllSamples( |
1090 EXPECT_THAT(details->uma()->GetAllSamples( | 1120 "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
1091 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | 1121 HasOneSample(DependingOnPolicy(1, 1, 11))); |
1092 ElementsAre(Bucket(11, 1))); | |
1093 } else { | |
1094 EXPECT_THAT(details->uma()->GetAllSamples( | |
1095 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | |
1096 ElementsAre(Bucket(1, 1))); | |
1097 } | |
1098 | 1122 |
1099 // Open a tab, which will be in a different BrowsingInstance. | 1123 // Open a tab, which will be in a different BrowsingInstance. |
1100 GURL abcd_url = embedded_test_server()->GetURL( | 1124 GURL abcd_url = embedded_test_server()->GetURL( |
1101 "a.com", "/cross_site_iframe_factory.html?a(b(c(d())))"); | 1125 "a.com", "/cross_site_iframe_factory.html?a(b(c(d())))"); |
1102 AddTabAtIndex(1, abcd_url, ui::PAGE_TRANSITION_TYPED); | 1126 AddTabAtIndex(1, abcd_url, ui::PAGE_TRANSITION_TYPED); |
1103 | 1127 |
1104 details = new TestMemoryDetails(); | 1128 details = new TestMemoryDetails(); |
1105 details->StartFetchAndWait(); | 1129 details->StartFetchAndWait(); |
1106 if (content::AreAllSitesIsolatedForTesting()) { | 1130 EXPECT_THAT( |
1107 EXPECT_THAT(details->uma()->GetAllSamples( | 1131 details->uma()->GetAllSamples( |
1108 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | 1132 "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
1109 ElementsAre(Bucket(4, 1), Bucket(11, 1))); | 1133 DependingOnPolicy(ElementsAre(Sample(1, 2)), ElementsAre(Sample(1, 2)), |
1110 } else { | 1134 ElementsAre(Sample(4, 1), Sample(11, 1)))); |
1111 EXPECT_THAT(details->uma()->GetAllSamples( | |
1112 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | |
1113 ElementsAre(Bucket(1, 2))); | |
1114 } | |
1115 } | 1135 } |
1116 | 1136 |
1117 // Verifies that the UMA counter for SiteInstances in a BrowsingInstance is | 1137 // Verifies that the UMA counter for SiteInstances in a BrowsingInstance is |
1118 // correct when extensions and web pages are mixed together. | 1138 // correct when extensions and web pages are mixed together. |
1119 IN_PROC_BROWSER_TEST_F( | 1139 IN_PROC_BROWSER_TEST_P( |
1120 SiteDetailsBrowserTest, | 1140 SiteDetailsBrowserTest, |
1121 VerifySiteInstanceCountInBrowsingInstanceWithExtensions) { | 1141 VerifySiteInstanceCountInBrowsingInstanceWithExtensions) { |
1122 // Open two a.com tabs (with cross site http iframes). IsolateExtensions mode | 1142 // Open two a.com tabs (with cross site http iframes). IsolateExtensions mode |
1123 // should have no effect so far, since there are no frames straddling the | 1143 // should have no effect so far, since there are no frames straddling the |
1124 // extension/web boundary. | 1144 // extension/web boundary. |
1125 GURL tab_url = embedded_test_server()->GetURL( | 1145 GURL tab_url = embedded_test_server()->GetURL( |
1126 "a.com", "/cross_site_iframe_factory.html?a(b,c,d(e))"); | 1146 "a.com", "/cross_site_iframe_factory.html?a(b,c,d(e))"); |
1127 ui_test_utils::NavigateToURL(browser(), tab_url); | 1147 ui_test_utils::NavigateToURL(browser(), tab_url); |
1128 WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0); | 1148 WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0); |
1129 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); | 1149 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); |
1130 details->StartFetchAndWait(); | 1150 details->StartFetchAndWait(); |
1131 if (content::AreAllSitesIsolatedForTesting()) { | 1151 |
1132 EXPECT_THAT(details->uma()->GetAllSamples( | 1152 // Since there are no extensions loaded yet, the results in the default case |
1133 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | 1153 // and extensions::IsIsolateExtensionsEnabled() are the same. |
1134 ElementsAre(Bucket(5, 1))); | 1154 EXPECT_THAT(details->uma()->GetAllSamples( |
1135 } else { | 1155 "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
1136 // Since there are no extensions loaded yet, the results in the default case | 1156 HasOneSample(DependingOnPolicy(1, 1, 5))); |
1137 // and extensions::IsIsolateExtensionsEnabled() are the same. | |
1138 EXPECT_THAT(details->uma()->GetAllSamples( | |
1139 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | |
1140 ElementsAre(Bucket(1, 1))); | |
1141 } | |
1142 | 1157 |
1143 // Load an extension without a background page, which will avoid creating a | 1158 // Load an extension without a background page, which will avoid creating a |
1144 // BrowsingInstance for it. | 1159 // BrowsingInstance for it. |
1145 const Extension* extension1 = CreateExtension("Extension One", false); | 1160 const Extension* extension1 = CreateExtension("Extension One", false); |
1146 | 1161 |
1147 // Navigate the tab's first iframe to a resource of the extension. The | 1162 // Navigate the tab's first iframe to a resource of the extension. The |
1148 // extension iframe will be put in the same BrowsingInstance as it is part | 1163 // extension iframe will be put in the same BrowsingInstance as it is part |
1149 // of the frame tree. | 1164 // of the frame tree. |
1150 content::NavigateIframeToURL( | 1165 content::NavigateIframeToURL( |
1151 tab, "child-0", extension1->GetResourceURL("/blank_iframe.html")); | 1166 tab, "child-0", extension1->GetResourceURL("/blank_iframe.html")); |
1152 details = new TestMemoryDetails(); | 1167 details = new TestMemoryDetails(); |
1153 details->StartFetchAndWait(); | 1168 details->StartFetchAndWait(); |
1154 if (content::AreAllSitesIsolatedForTesting()) { | 1169 EXPECT_THAT(details->uma()->GetAllSamples( |
1155 EXPECT_THAT(details->uma()->GetAllSamples( | 1170 "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
1156 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | 1171 HasOneSample(DependingOnPolicy(1, 2, 5))); |
1157 ElementsAre(Bucket(5, 1))); | |
1158 } else if (extensions::IsIsolateExtensionsEnabled()) { | |
1159 EXPECT_THAT(details->uma()->GetAllSamples( | |
1160 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | |
1161 ElementsAre(Bucket(2, 1))); | |
1162 } else { | |
1163 EXPECT_THAT(details->uma()->GetAllSamples( | |
1164 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | |
1165 ElementsAre(Bucket(1, 1))); | |
1166 } | |
1167 | 1172 |
1168 // Now load an extension with a background page. This will result in a | 1173 // Now load an extension with a background page. This will result in a |
1169 // BrowsingInstance for the background page. | 1174 // BrowsingInstance for the background page. |
1170 const Extension* extension2 = CreateExtension("Extension One", true); | 1175 const Extension* extension2 = CreateExtension("Extension One", true); |
1171 details = new TestMemoryDetails(); | 1176 details = new TestMemoryDetails(); |
1172 details->StartFetchAndWait(); | 1177 details->StartFetchAndWait(); |
1173 if (content::AreAllSitesIsolatedForTesting()) { | 1178 EXPECT_THAT(details->uma()->GetAllSamples( |
1174 EXPECT_THAT(details->uma()->GetAllSamples( | 1179 "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
1175 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | 1180 DependingOnPolicy(ElementsAre(Bucket(1, 2)), |
1176 ElementsAre(Bucket(1, 1), Bucket(5, 1))); | 1181 ElementsAre(Bucket(1, 1), Bucket(2, 1)), |
1177 } else if (extensions::IsIsolateExtensionsEnabled()) { | 1182 ElementsAre(Bucket(1, 1), Bucket(5, 1)))); |
1178 EXPECT_THAT(details->uma()->GetAllSamples( | |
1179 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | |
1180 ElementsAre(Bucket(1, 1), Bucket(2, 1))); | |
1181 } else { | |
1182 EXPECT_THAT(details->uma()->GetAllSamples( | |
1183 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | |
1184 ElementsAre(Bucket(1, 2))); | |
1185 } | |
1186 | 1183 |
1187 // Navigate the second iframe of the tab to the second extension. It should | 1184 // Navigate the second iframe of the tab to the second extension. It should |
1188 // stay in the same BrowsingInstance as the page. | 1185 // stay in the same BrowsingInstance as the page. |
1189 content::NavigateIframeToURL( | 1186 content::NavigateIframeToURL( |
1190 tab, "child-1", extension2->GetResourceURL("/blank_iframe.html")); | 1187 tab, "child-1", extension2->GetResourceURL("/blank_iframe.html")); |
1191 details = new TestMemoryDetails(); | 1188 details = new TestMemoryDetails(); |
1192 details->StartFetchAndWait(); | 1189 details->StartFetchAndWait(); |
1193 if (content::AreAllSitesIsolatedForTesting()) { | 1190 EXPECT_THAT(details->uma()->GetAllSamples( |
1194 EXPECT_THAT(details->uma()->GetAllSamples( | 1191 "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
1195 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | 1192 DependingOnPolicy(ElementsAre(Bucket(1, 2)), |
1196 ElementsAre(Bucket(1, 1), Bucket(5, 1))); | 1193 ElementsAre(Bucket(1, 1), Bucket(3, 1)), |
1197 } else if (extensions::IsIsolateExtensionsEnabled()) { | 1194 ElementsAre(Bucket(1, 1), Bucket(5, 1)))); |
1198 EXPECT_THAT(details->uma()->GetAllSamples( | |
1199 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | |
1200 ElementsAre(Bucket(1, 1), Bucket(3, 1))); | |
1201 } else { | |
1202 EXPECT_THAT(details->uma()->GetAllSamples( | |
1203 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | |
1204 ElementsAre(Bucket(1, 2))); | |
1205 } | |
1206 } | 1195 } |
| 1196 |
| 1197 INSTANTIATE_TEST_CASE_P( |
| 1198 , |
| 1199 SiteDetailsBrowserTest, |
| 1200 testing::Values("", |
| 1201 extensions::switches::kIsolateExtensions, |
| 1202 switches::kSitePerProcess)); |
OLD | NEW |