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 <memory> | 10 #include <memory> |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 } | 95 } |
96 | 96 |
97 std::unique_ptr<base::HistogramTester> uma_; | 97 std::unique_ptr<base::HistogramTester> uma_; |
98 | 98 |
99 DISALLOW_COPY_AND_ASSIGN(TestMemoryDetails); | 99 DISALLOW_COPY_AND_ASSIGN(TestMemoryDetails); |
100 }; | 100 }; |
101 | 101 |
102 IsolationScenarioType GetCurrentPolicy() { | 102 IsolationScenarioType GetCurrentPolicy() { |
103 if (content::AreAllSitesIsolatedForTesting()) | 103 if (content::AreAllSitesIsolatedForTesting()) |
104 return ISOLATE_ALL_SITES; | 104 return ISOLATE_ALL_SITES; |
105 if (extensions::IsIsolateExtensionsEnabled()) | |
106 return ISOLATE_EXTENSIONS; | |
107 return ISOLATE_NOTHING; | 105 return ISOLATE_NOTHING; |
108 } | 106 } |
109 | 107 |
110 // This matcher takes three other matchers as arguments, and applies one of them | 108 // This matcher takes two other matchers as arguments, and applies one of them |
111 // depending on the current site isolation mode. The first applies if no site | 109 // depending on the current site isolation mode. The first applies if no site |
112 // isolation mode is active; the second applies under --isolate-extensions mode; | 110 // isolation mode is active; and the second applies under --site-per-process |
113 // and the third applies under --site-per-process mode. | 111 // mode. |
114 MATCHER_P3(DependingOnPolicy, | 112 MATCHER_P2(DependingOnPolicy, |
115 isolate_nothing, | 113 isolate_nothing, |
116 isolate_extensions, | |
117 isolate_all_sites, | 114 isolate_all_sites, |
118 GetCurrentPolicy() == ISOLATE_NOTHING | 115 GetCurrentPolicy() == ISOLATE_NOTHING |
119 ? std::string("(with oopifs disabled) ") + | 116 ? std::string("(with oopifs disabled) ") + |
120 PrintToString(isolate_nothing) | 117 PrintToString(isolate_nothing) |
121 : GetCurrentPolicy() == ISOLATE_EXTENSIONS | 118 : std::string("(under --site-per-process) ") + |
122 ? std::string("(under --isolate-extensions) ") + | 119 PrintToString(isolate_all_sites)) { |
123 PrintToString(isolate_extensions) | |
124 : std::string("(under --site-per-process) ") + | |
125 PrintToString(isolate_all_sites)) { | |
126 switch (GetCurrentPolicy()) { | 120 switch (GetCurrentPolicy()) { |
127 case ISOLATE_NOTHING: | 121 case ISOLATE_NOTHING: |
ncarter (slow)
2017/05/01 20:15:19
ISOLATE_NOTHING ought to be the unreachable case n
nasko
2017/05/01 21:25:37
Are you suggesting it should be #ifdef'd for Andro
ncarter (slow)
2017/05/01 21:37:43
Hmm, probably not necessary to ifdef on android, s
| |
128 return ExplainMatchResult(isolate_nothing, arg, result_listener); | 122 return ExplainMatchResult(isolate_nothing, arg, result_listener); |
129 case ISOLATE_EXTENSIONS: | |
130 return ExplainMatchResult(isolate_extensions, arg, result_listener); | |
131 case ISOLATE_ALL_SITES: | 123 case ISOLATE_ALL_SITES: |
132 return ExplainMatchResult(isolate_all_sites, arg, result_listener); | 124 return ExplainMatchResult(isolate_all_sites, arg, result_listener); |
133 default: | 125 default: |
134 return false; | 126 return false; |
135 } | 127 } |
136 } | 128 } |
137 | 129 |
138 // Matcher for base::Bucket objects that allows bucket_min to be a matcher. | 130 // Matcher for base::Bucket objects that allows bucket_min to be a matcher. |
139 MATCHER_P2(Sample, | 131 MATCHER_P2(Sample, |
140 bucket_min, | 132 bucket_min, |
141 count, | 133 count, |
142 std::string("is a Bucket whose count is ") + PrintToString(count) + | 134 std::string("is a Bucket whose count is ") + PrintToString(count) + |
143 std::string(" and whose value is ") + | 135 std::string(" and whose value is ") + |
144 PrintToString(bucket_min)) { | 136 PrintToString(bucket_min)) { |
145 return ExplainMatchResult(count, arg.count, result_listener) && | 137 return ExplainMatchResult(count, arg.count, result_listener) && |
146 ExplainMatchResult(bucket_min, arg.min, result_listener); | 138 ExplainMatchResult(bucket_min, arg.min, result_listener); |
147 } | 139 } |
148 | 140 |
149 // Allow matchers to be pretty-printed when passed to PrintToString() for the | 141 // Allow matchers to be pretty-printed when passed to PrintToString() for the |
150 // cases we care about. | 142 // cases we care about. |
151 template <typename P1, typename P2, typename P3> | 143 template <typename P1, typename P2> |
152 void PrintTo(const DependingOnPolicyMatcherP3<P1, P2, P3>& matcher, | 144 void PrintTo(const DependingOnPolicyMatcherP2<P1, P2>& matcher, |
153 std::ostream* os) { | 145 std::ostream* os) { |
154 testing::Matcher<int> matcherCast = matcher; | 146 testing::Matcher<int> matcherCast = matcher; |
155 matcherCast.DescribeTo(os); | 147 matcherCast.DescribeTo(os); |
156 } | 148 } |
157 | 149 |
158 template <typename P1, typename P2> | 150 template <typename P1, typename P2> |
159 void PrintTo(const SampleMatcherP2<P1, P2>& matcher, std::ostream* os) { | 151 void PrintTo(const SampleMatcherP2<P1, P2>& matcher, std::ostream* os) { |
160 testing::Matcher<Bucket> matcherCast = matcher; | 152 testing::Matcher<Bucket> matcherCast = matcher; |
161 matcherCast.DescribeTo(os); | 153 matcherCast.DescribeTo(os); |
162 } | 154 } |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
396 HasOneSample(9)); | 388 HasOneSample(9)); |
397 EXPECT_THAT(details->uma()->GetAllSamples( | 389 EXPECT_THAT(details->uma()->GetAllSamples( |
398 "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), | 390 "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), |
399 HasOneSample(1)); | 391 HasOneSample(1)); |
400 EXPECT_THAT(details->uma()->GetAllSamples( | 392 EXPECT_THAT(details->uma()->GetAllSamples( |
401 "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), | 393 "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), |
402 HasOneSample(1)); | 394 HasOneSample(1)); |
403 EXPECT_THAT(details->uma()->GetAllSamples( | 395 EXPECT_THAT(details->uma()->GetAllSamples( |
404 "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), | 396 "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), |
405 HasOneSample(1)); | 397 HasOneSample(1)); |
406 EXPECT_THAT(details->uma()->GetAllSamples( | 398 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 9)); |
407 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 399 EXPECT_THAT(details->GetOutOfProcessIframeCount(), DependingOnPolicy(0, 14)); |
408 HasOneSample(1)); | |
409 EXPECT_THAT(details->uma()->GetAllSamples( | |
410 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | |
411 HasOneSample(1)); | |
412 EXPECT_THAT(details->uma()->GetAllSamples( | |
413 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | |
414 HasOneSample(1)); | |
415 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 9)); | |
416 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | |
417 DependingOnPolicy(0, 0, 14)); | |
418 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), | 400 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), |
419 HasOneSample(DependingOnPolicy(0, 0, 114))); | 401 HasOneSample(DependingOnPolicy(0, 114))); |
420 EXPECT_THAT(details->uma()->GetAllSamples( | 402 EXPECT_THAT(details->uma()->GetAllSamples( |
421 "SiteIsolation.ProxyCountPerBrowsingInstance"), | 403 "SiteIsolation.ProxyCountPerBrowsingInstance"), |
422 HasOneSample(DependingOnPolicy(0, 0, 114))); | 404 HasOneSample(DependingOnPolicy(0, 114))); |
423 | 405 |
424 // Navigate to a different, disjoint set of 7 sites. | 406 // Navigate to a different, disjoint set of 7 sites. |
425 GURL pqrstuv_url = embedded_test_server()->GetURL( | 407 GURL pqrstuv_url = embedded_test_server()->GetURL( |
426 "p.com", | 408 "p.com", |
427 "/cross_site_iframe_factory.html?p(q(r),r(s),s(t),t(q),u(u),v(p))"); | 409 "/cross_site_iframe_factory.html?p(q(r),r(s),s(t),t(q),u(u),v(p))"); |
428 ui_test_utils::NavigateToURL(browser(), pqrstuv_url); | 410 ui_test_utils::NavigateToURL(browser(), pqrstuv_url); |
429 | 411 |
430 details = new TestMemoryDetails(); | 412 details = new TestMemoryDetails(); |
431 details->StartFetchAndWait(); | 413 details->StartFetchAndWait(); |
432 | 414 |
(...skipping 18 matching lines...) Expand all Loading... | |
451 HasOneSample(7)); | 433 HasOneSample(7)); |
452 EXPECT_THAT(details->uma()->GetAllSamples( | 434 EXPECT_THAT(details->uma()->GetAllSamples( |
453 "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), | 435 "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), |
454 HasOneSample(1)); | 436 HasOneSample(1)); |
455 EXPECT_THAT(details->uma()->GetAllSamples( | 437 EXPECT_THAT(details->uma()->GetAllSamples( |
456 "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), | 438 "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), |
457 HasOneSample(1)); | 439 HasOneSample(1)); |
458 EXPECT_THAT(details->uma()->GetAllSamples( | 440 EXPECT_THAT(details->uma()->GetAllSamples( |
459 "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), | 441 "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), |
460 HasOneSample(1)); | 442 HasOneSample(1)); |
461 EXPECT_THAT(details->uma()->GetAllSamples( | 443 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 7)); |
462 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 444 EXPECT_THAT(details->GetOutOfProcessIframeCount(), DependingOnPolicy(0, 11)); |
463 HasOneSample(1)); | |
464 EXPECT_THAT(details->uma()->GetAllSamples( | |
465 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | |
466 HasOneSample(1)); | |
467 EXPECT_THAT(details->uma()->GetAllSamples( | |
468 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | |
469 HasOneSample(1)); | |
470 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 7)); | |
471 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | |
472 DependingOnPolicy(0, 0, 11)); | |
473 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), | 445 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), |
474 HasOneSample(DependingOnPolicy(0, 0, 68))); | 446 HasOneSample(DependingOnPolicy(0, 68))); |
475 EXPECT_THAT(details->uma()->GetAllSamples( | 447 EXPECT_THAT(details->uma()->GetAllSamples( |
476 "SiteIsolation.ProxyCountPerBrowsingInstance"), | 448 "SiteIsolation.ProxyCountPerBrowsingInstance"), |
477 HasOneSample(DependingOnPolicy(0, 0, 68))); | 449 HasOneSample(DependingOnPolicy(0, 68))); |
478 | 450 |
479 // Open a second tab (different BrowsingInstance) with 4 sites (a through d). | 451 // Open a second tab (different BrowsingInstance) with 4 sites (a through d). |
480 GURL abcd_url = embedded_test_server()->GetURL( | 452 GURL abcd_url = embedded_test_server()->GetURL( |
481 "a.com", "/cross_site_iframe_factory.html?a(b(c(d())))"); | 453 "a.com", "/cross_site_iframe_factory.html?a(b(c(d())))"); |
482 AddTabAtIndex(1, abcd_url, ui::PAGE_TRANSITION_TYPED); | 454 AddTabAtIndex(1, abcd_url, ui::PAGE_TRANSITION_TYPED); |
483 | 455 |
484 details = new TestMemoryDetails(); | 456 details = new TestMemoryDetails(); |
485 details->StartFetchAndWait(); | 457 details->StartFetchAndWait(); |
486 | 458 |
487 EXPECT_EQ(2U, details->CountPageTitles()); | 459 EXPECT_EQ(2U, details->CountPageTitles()); |
(...skipping 17 matching lines...) Expand all Loading... | |
505 HasOneSample(11)); | 477 HasOneSample(11)); |
506 EXPECT_THAT(details->uma()->GetAllSamples( | 478 EXPECT_THAT(details->uma()->GetAllSamples( |
507 "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), | 479 "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), |
508 HasOneSample(2)); | 480 HasOneSample(2)); |
509 EXPECT_THAT(details->uma()->GetAllSamples( | 481 EXPECT_THAT(details->uma()->GetAllSamples( |
510 "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), | 482 "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), |
511 HasOneSample(1)); // TODO(nick): This should be 2. | 483 HasOneSample(1)); // TODO(nick): This should be 2. |
512 EXPECT_THAT(details->uma()->GetAllSamples( | 484 EXPECT_THAT(details->uma()->GetAllSamples( |
513 "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), | 485 "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), |
514 HasOneSample(2)); | 486 HasOneSample(2)); |
487 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(2, 11)); | |
488 EXPECT_THAT(details->GetOutOfProcessIframeCount(), DependingOnPolicy(0, 14)); | |
489 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), | |
490 HasOneSample(DependingOnPolicy(0, 81))); | |
515 EXPECT_THAT(details->uma()->GetAllSamples( | 491 EXPECT_THAT(details->uma()->GetAllSamples( |
516 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 492 "SiteIsolation.ProxyCountPerBrowsingInstance"), |
517 HasOneSample(2)); | 493 DependingOnPolicy(ElementsAre(Bucket(0, 2)), |
518 EXPECT_THAT(details->uma()->GetAllSamples( | 494 ElementsAre(Bucket(12, 1), Bucket(68, 1)))); |
519 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | |
520 HasOneSample(1)); | |
521 EXPECT_THAT(details->uma()->GetAllSamples( | |
522 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | |
523 HasOneSample(2)); | |
524 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(2, 2, 11)); | |
525 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | |
526 DependingOnPolicy(0, 0, 14)); | |
527 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), | |
528 HasOneSample(DependingOnPolicy(0, 0, 81))); | |
529 EXPECT_THAT( | |
530 details->uma()->GetAllSamples( | |
531 "SiteIsolation.ProxyCountPerBrowsingInstance"), | |
532 DependingOnPolicy(ElementsAre(Bucket(0, 2)), ElementsAre(Bucket(0, 2)), | |
533 ElementsAre(Bucket(12, 1), Bucket(68, 1)))); | |
534 | 495 |
535 // Open a third tab (different BrowsingInstance) with the same 4 sites. | 496 // Open a third tab (different BrowsingInstance) with the same 4 sites. |
536 AddTabAtIndex(2, abcd_url, ui::PAGE_TRANSITION_TYPED); | 497 AddTabAtIndex(2, abcd_url, ui::PAGE_TRANSITION_TYPED); |
537 | 498 |
538 details = new TestMemoryDetails(); | 499 details = new TestMemoryDetails(); |
539 details->StartFetchAndWait(); | 500 details->StartFetchAndWait(); |
540 | 501 |
541 EXPECT_THAT( | 502 EXPECT_THAT( |
542 details->uma()->GetAllSamples("SiteIsolation.BrowsingInstanceCount"), | 503 details->uma()->GetAllSamples("SiteIsolation.BrowsingInstanceCount"), |
543 HasOneSample(3)); | 504 HasOneSample(3)); |
(...skipping 15 matching lines...) Expand all Loading... | |
559 HasOneSample(15)); | 520 HasOneSample(15)); |
560 EXPECT_THAT(details->uma()->GetAllSamples( | 521 EXPECT_THAT(details->uma()->GetAllSamples( |
561 "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), | 522 "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), |
562 HasOneSample(3)); | 523 HasOneSample(3)); |
563 EXPECT_THAT(details->uma()->GetAllSamples( | 524 EXPECT_THAT(details->uma()->GetAllSamples( |
564 "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), | 525 "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), |
565 HasOneSample(1)); // TODO(nick): This should be 3. | 526 HasOneSample(1)); // TODO(nick): This should be 3. |
566 EXPECT_THAT(details->uma()->GetAllSamples( | 527 EXPECT_THAT(details->uma()->GetAllSamples( |
567 "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), | 528 "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), |
568 HasOneSample(3)); | 529 HasOneSample(3)); |
530 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 15)); | |
531 EXPECT_THAT(details->GetOutOfProcessIframeCount(), DependingOnPolicy(0, 17)); | |
532 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), | |
533 HasOneSample(DependingOnPolicy(0, 96))); | |
569 EXPECT_THAT(details->uma()->GetAllSamples( | 534 EXPECT_THAT(details->uma()->GetAllSamples( |
570 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 535 "SiteIsolation.ProxyCountPerBrowsingInstance"), |
571 HasOneSample(3)); | 536 DependingOnPolicy(ElementsAre(Bucket(0, 3)), |
572 EXPECT_THAT(details->uma()->GetAllSamples( | 537 ElementsAre(Bucket(12, 2), Bucket(68, 1)))); |
573 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | |
574 HasOneSample(1)); | |
575 EXPECT_THAT(details->uma()->GetAllSamples( | |
576 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | |
577 HasOneSample(3)); | |
578 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 3, 15)); | |
579 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | |
580 DependingOnPolicy(0, 0, 17)); | |
581 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), | |
582 HasOneSample(DependingOnPolicy(0, 0, 96))); | |
583 EXPECT_THAT( | |
584 details->uma()->GetAllSamples( | |
585 "SiteIsolation.ProxyCountPerBrowsingInstance"), | |
586 DependingOnPolicy(ElementsAre(Bucket(0, 3)), ElementsAre(Bucket(0, 3)), | |
587 ElementsAre(Bucket(12, 2), Bucket(68, 1)))); | |
588 | 538 |
589 // From the third tab, window.open() a fourth tab in the same | 539 // From the third tab, window.open() a fourth tab in the same |
590 // BrowsingInstance, to a page using the same four sites "a-d" as third tab, | 540 // BrowsingInstance, to a page using the same four sites "a-d" as third tab, |
591 // plus an additional site "e". The estimated process counts should increase | 541 // plus an additional site "e". The estimated process counts should increase |
592 // by one (not five) from the previous scenario, as the new tab can reuse the | 542 // by one (not five) from the previous scenario, as the new tab can reuse the |
593 // four processes already in the BrowsingInstance. | 543 // four processes already in the BrowsingInstance. |
594 GURL dcbae_url = embedded_test_server()->GetURL( | 544 GURL dcbae_url = embedded_test_server()->GetURL( |
595 "a.com", "/cross_site_iframe_factory.html?d(c(b(a(e))))"); | 545 "a.com", "/cross_site_iframe_factory.html?d(c(b(a(e))))"); |
596 ui_test_utils::UrlLoadObserver load_complete( | 546 ui_test_utils::UrlLoadObserver load_complete( |
597 dcbae_url, content::NotificationService::AllSources()); | 547 dcbae_url, content::NotificationService::AllSources()); |
(...skipping 28 matching lines...) Expand all Loading... | |
626 HasOneSample(16)); | 576 HasOneSample(16)); |
627 EXPECT_THAT(details->uma()->GetAllSamples( | 577 EXPECT_THAT(details->uma()->GetAllSamples( |
628 "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), | 578 "SiteIsolation.IsolateHttpsSitesProcessCountEstimate"), |
629 HasOneSample(3)); | 579 HasOneSample(3)); |
630 EXPECT_THAT(details->uma()->GetAllSamples( | 580 EXPECT_THAT(details->uma()->GetAllSamples( |
631 "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), | 581 "SiteIsolation.IsolateHttpsSitesProcessCountLowerBound"), |
632 HasOneSample(1)); // TODO(nick): This should be 3. | 582 HasOneSample(1)); // TODO(nick): This should be 3. |
633 EXPECT_THAT(details->uma()->GetAllSamples( | 583 EXPECT_THAT(details->uma()->GetAllSamples( |
634 "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), | 584 "SiteIsolation.IsolateHttpsSitesProcessCountNoLimit"), |
635 HasOneSample(3)); | 585 HasOneSample(3)); |
636 EXPECT_THAT(details->uma()->GetAllSamples( | 586 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 16)); |
637 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | 587 EXPECT_THAT(details->GetOutOfProcessIframeCount(), DependingOnPolicy(0, 21)); |
638 HasOneSample(3)); | |
639 EXPECT_THAT(details->uma()->GetAllSamples( | |
640 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | |
641 HasOneSample(1)); | |
642 EXPECT_THAT(details->uma()->GetAllSamples( | |
643 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | |
644 HasOneSample(3)); | |
645 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 3, 16)); | |
646 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | |
647 DependingOnPolicy(0, 0, 21)); | |
648 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), | 588 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), |
649 HasOneSample(DependingOnPolicy(0, 0, 114))); | 589 HasOneSample(DependingOnPolicy(0, 114))); |
650 EXPECT_THAT(details->uma()->GetAllSamples( | 590 EXPECT_THAT(details->uma()->GetAllSamples( |
651 "SiteIsolation.ProxyCountPerBrowsingInstance"), | 591 "SiteIsolation.ProxyCountPerBrowsingInstance"), |
652 DependingOnPolicy( | 592 DependingOnPolicy( |
653 ElementsAre(Bucket(0, 3)), ElementsAre(Bucket(0, 3)), | 593 ElementsAre(Bucket(0, 3)), |
654 ElementsAre(Bucket(12, 1), Bucket(29, 1), Bucket(68, 1)))); | 594 ElementsAre(Bucket(12, 1), Bucket(29, 1), Bucket(68, 1)))); |
655 | |
656 // This test doesn't navigate to any extensions URLs, so it should not be | |
657 // in any of the field trial groups. | |
658 EXPECT_FALSE(IsInTrial("SiteIsolationExtensionsActive")); | |
659 } | |
660 | |
661 // Flaky on Windows and Mac. crbug.com/671891 | |
662 #if defined(OS_WIN) || defined(OS_MACOSX) | |
663 #define MAYBE_IsolateExtensions DISABLED_IsolateExtensions | |
664 #else | |
665 #define MAYBE_IsolateExtensions IsolateExtensions | |
666 #endif | |
667 IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, MAYBE_IsolateExtensions) { | |
668 // We start on "about:blank", which should be credited with a process in this | |
669 // case. | |
670 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); | |
671 details->StartFetchAndWait(); | |
672 EXPECT_THAT(details->uma()->GetAllSamples( | |
673 "SiteIsolation.CurrentRendererProcessCount"), | |
674 HasOneSample(GetRenderProcessCount())); | |
675 EXPECT_THAT(details->uma()->GetAllSamples( | |
676 "SiteIsolation.IsolateNothingProcessCountEstimate"), | |
677 HasOneSample(1)); | |
678 EXPECT_THAT(details->uma()->GetAllSamples( | |
679 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | |
680 HasOneSample(1)); | |
681 EXPECT_THAT(details->uma()->GetAllSamples( | |
682 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | |
683 HasOneSample(1)); | |
684 EXPECT_THAT(details->uma()->GetAllSamples( | |
685 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | |
686 HasOneSample(1)); | |
687 EXPECT_THAT(GetRenderProcessCount(), 1); | |
688 EXPECT_EQ(0, details->GetOutOfProcessIframeCount()); | |
689 | |
690 // Install one script-injecting extension with background page, and an | |
691 // extension with web accessible resources. | |
692 const Extension* extension1 = CreateExtension("Extension One", true); | |
693 const Extension* extension2 = CreateExtension("Extension Two", false); | |
694 | |
695 // Open two a.com tabs (with cross site http iframes). IsolateExtensions mode | |
696 // should have no effect so far, since there are no frames straddling the | |
697 // extension/web boundary. | |
698 GURL tab1_url = embedded_test_server()->GetURL( | |
699 "a.com", "/cross_site_iframe_factory.html?a(b,c)"); | |
700 ui_test_utils::NavigateToURL(browser(), tab1_url); | |
701 WebContents* tab1 = browser()->tab_strip_model()->GetWebContentsAt(0); | |
702 GURL tab2_url = embedded_test_server()->GetURL( | |
703 "a.com", "/cross_site_iframe_factory.html?a(d,e)"); | |
704 AddTabAtIndex(1, tab2_url, ui::PAGE_TRANSITION_TYPED); | |
705 WebContents* tab2 = browser()->tab_strip_model()->GetWebContentsAt(1); | |
706 | |
707 details = new TestMemoryDetails(); | |
708 details->StartFetchAndWait(); | |
709 EXPECT_THAT(details->uma()->GetAllSamples( | |
710 "SiteIsolation.CurrentRendererProcessCount"), | |
711 HasOneSample(GetRenderProcessCount())); | |
712 EXPECT_THAT(details->uma()->GetAllSamples( | |
713 "SiteIsolation.IsolateNothingProcessCountEstimate"), | |
714 HasOneSample(3)); | |
715 EXPECT_THAT(details->uma()->GetAllSamples( | |
716 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | |
717 HasOneSample(3)); | |
718 EXPECT_THAT(details->uma()->GetAllSamples( | |
719 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | |
720 HasOneSample(2)); | |
721 EXPECT_THAT(details->uma()->GetAllSamples( | |
722 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | |
723 HasOneSample(3)); | |
724 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 3, 7)); | |
725 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | |
726 DependingOnPolicy(0, 0, 4)); | |
727 | |
728 // Test that "one process per extension" applies even when web content has an | |
729 // extension iframe. | |
730 | |
731 // Tab1 navigates its first iframe to a resource of extension1. This shouldn't | |
732 // result in a new extension process (it should share with extension1's | |
733 // background page). | |
734 content::NavigateIframeToURL( | |
735 tab1, "child-0", extension1->GetResourceURL("/blank_iframe.html")); | |
736 details = new TestMemoryDetails(); | |
737 details->StartFetchAndWait(); | |
738 EXPECT_THAT(details->uma()->GetAllSamples( | |
739 "SiteIsolation.CurrentRendererProcessCount"), | |
740 HasOneSample(GetRenderProcessCount())); | |
741 EXPECT_THAT(details->uma()->GetAllSamples( | |
742 "SiteIsolation.IsolateNothingProcessCountEstimate"), | |
743 HasOneSample(3)); | |
744 EXPECT_THAT(details->uma()->GetAllSamples( | |
745 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | |
746 HasOneSample(3)); | |
747 EXPECT_THAT(details->uma()->GetAllSamples( | |
748 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | |
749 HasOneSample(2)); | |
750 EXPECT_THAT(details->uma()->GetAllSamples( | |
751 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | |
752 HasOneSample(3)); | |
753 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 3, 6)); | |
754 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | |
755 DependingOnPolicy(0, 1, 4)); | |
756 | |
757 // Tab2 navigates its first iframe to a resource of extension1. This also | |
758 // shouldn't result in a new extension process (it should share with the | |
759 // background page and the other iframe). | |
760 content::NavigateIframeToURL( | |
761 tab2, "child-0", extension1->GetResourceURL("/blank_iframe.html")); | |
762 details = new TestMemoryDetails(); | |
763 details->StartFetchAndWait(); | |
764 EXPECT_THAT(details->uma()->GetAllSamples( | |
765 "SiteIsolation.CurrentRendererProcessCount"), | |
766 HasOneSample(GetRenderProcessCount())); | |
767 EXPECT_THAT(details->uma()->GetAllSamples( | |
768 "SiteIsolation.IsolateNothingProcessCountEstimate"), | |
769 HasOneSample(3)); | |
770 EXPECT_THAT(details->uma()->GetAllSamples( | |
771 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | |
772 HasOneSample(3)); | |
773 EXPECT_THAT(details->uma()->GetAllSamples( | |
774 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | |
775 HasOneSample(2)); | |
776 EXPECT_THAT(details->uma()->GetAllSamples( | |
777 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | |
778 HasOneSample(3)); | |
779 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 3, 5)); | |
780 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | |
781 DependingOnPolicy(0, 2, 4)); | |
782 | |
783 // Tab1 navigates its second iframe to a resource of extension2. This SHOULD | |
784 // result in a new process since extension2 had no existing process. | |
785 content::NavigateIframeToURL( | |
786 tab1, "child-1", extension2->GetResourceURL("/blank_iframe.html")); | |
787 details = new TestMemoryDetails(); | |
788 details->StartFetchAndWait(); | |
789 EXPECT_THAT(details->uma()->GetAllSamples( | |
790 "SiteIsolation.CurrentRendererProcessCount"), | |
791 HasOneSample(GetRenderProcessCount())); | |
792 EXPECT_THAT(details->uma()->GetAllSamples( | |
793 "SiteIsolation.IsolateNothingProcessCountEstimate"), | |
794 HasOneSample(3)); | |
795 EXPECT_THAT(details->uma()->GetAllSamples( | |
796 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | |
797 HasOneSample(4)); | |
798 EXPECT_THAT(details->uma()->GetAllSamples( | |
799 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | |
800 HasOneSample(3)); | |
801 EXPECT_THAT(details->uma()->GetAllSamples( | |
802 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | |
803 HasOneSample(4)); | |
804 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 4, 5)); | |
805 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | |
806 DependingOnPolicy(0, 3, 4)); | |
807 | |
808 // Tab2 navigates its second iframe to a resource of extension2. This should | |
809 // share the existing extension2 process. | |
810 content::NavigateIframeToURL( | |
811 tab2, "child-1", extension2->GetResourceURL("/blank_iframe.html")); | |
812 details = new TestMemoryDetails(); | |
813 details->StartFetchAndWait(); | |
814 EXPECT_THAT(details->uma()->GetAllSamples( | |
815 "SiteIsolation.CurrentRendererProcessCount"), | |
816 HasOneSample(GetRenderProcessCount())); | |
817 EXPECT_THAT(details->uma()->GetAllSamples( | |
818 "SiteIsolation.IsolateNothingProcessCountEstimate"), | |
819 HasOneSample(3)); | |
820 EXPECT_THAT(details->uma()->GetAllSamples( | |
821 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | |
822 HasOneSample(4)); | |
823 EXPECT_THAT(details->uma()->GetAllSamples( | |
824 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | |
825 HasOneSample(3)); | |
826 EXPECT_THAT(details->uma()->GetAllSamples( | |
827 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | |
828 HasOneSample(4)); | |
829 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 4, 4)); | |
830 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | |
831 DependingOnPolicy(0, 4, 4)); | |
832 | |
833 // Install extension3 (identical config to extension2) | |
834 const Extension* extension3 = CreateExtension("Extension Three", false); | |
835 | |
836 // Navigate Tab2 to a top-level page from extension3. There are four processes | |
837 // now: one for tab1's main frame, and one for each of the extensions: | |
838 // extension1 has a process because it has a background page; extension2 is | |
839 // used as an iframe in tab1, and extension3 is the top-level frame in tab2. | |
840 ui_test_utils::NavigateToURL(browser(), | |
841 extension3->GetResourceURL("blank_iframe.html")); | |
842 details = new TestMemoryDetails(); | |
843 details->StartFetchAndWait(); | |
844 EXPECT_THAT(details->uma()->GetAllSamples( | |
845 "SiteIsolation.CurrentRendererProcessCount"), | |
846 HasOneSample(GetRenderProcessCount())); | |
847 EXPECT_THAT(details->uma()->GetAllSamples( | |
848 "SiteIsolation.IsolateNothingProcessCountEstimate"), | |
849 HasOneSample(3)); | |
850 EXPECT_THAT(details->uma()->GetAllSamples( | |
851 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | |
852 HasOneSample(4)); | |
853 EXPECT_THAT(details->uma()->GetAllSamples( | |
854 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | |
855 HasOneSample(4)); | |
856 EXPECT_THAT(details->uma()->GetAllSamples( | |
857 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | |
858 HasOneSample(4)); | |
859 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 4, 4)); | |
860 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | |
861 DependingOnPolicy(0, 2, 2)); | |
862 | |
863 // Navigate tab2 to a different extension3 page containing a web iframe. The | |
864 // iframe should get its own process. The lower bound number indicates that, | |
865 // in theory, the iframe could share a process with tab1's main frame. | |
866 ui_test_utils::NavigateToURL(browser(), | |
867 extension3->GetResourceURL("http_iframe.html")); | |
868 details = new TestMemoryDetails(); | |
869 details->StartFetchAndWait(); | |
870 EXPECT_THAT(details->uma()->GetAllSamples( | |
871 "SiteIsolation.CurrentRendererProcessCount"), | |
872 HasOneSample(GetRenderProcessCount())); | |
873 EXPECT_THAT(details->uma()->GetAllSamples( | |
874 "SiteIsolation.IsolateNothingProcessCountEstimate"), | |
875 HasOneSample(3)); | |
876 EXPECT_THAT(details->uma()->GetAllSamples( | |
877 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | |
878 HasOneSample(5)); | |
879 EXPECT_THAT(details->uma()->GetAllSamples( | |
880 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | |
881 HasOneSample(4)); | |
882 EXPECT_THAT(details->uma()->GetAllSamples( | |
883 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | |
884 HasOneSample(5)); | |
885 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 5, 5)); | |
886 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | |
887 DependingOnPolicy(0, 3, 3)); | |
888 | |
889 // Navigate tab1 to an extension3 page with an extension3 iframe. There should | |
890 // be three processes estimated by IsolateExtensions: one for extension3, one | |
891 // for extension1's background page, and one for the web iframe in tab2. | |
892 browser()->tab_strip_model()->ActivateTabAt(0, true); | |
893 ui_test_utils::NavigateToURL(browser(), | |
894 extension3->GetResourceURL("blank_iframe.html")); | |
895 details = new TestMemoryDetails(); | |
896 details->StartFetchAndWait(); | |
897 EXPECT_THAT(details->uma()->GetAllSamples( | |
898 "SiteIsolation.CurrentRendererProcessCount"), | |
899 HasOneSample(GetRenderProcessCount())); | |
900 EXPECT_THAT(details->uma()->GetAllSamples( | |
901 "SiteIsolation.IsolateNothingProcessCountEstimate"), | |
902 HasOneSample(2)); | |
903 EXPECT_THAT(details->uma()->GetAllSamples( | |
904 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | |
905 HasOneSample(3)); | |
906 EXPECT_THAT(details->uma()->GetAllSamples( | |
907 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | |
908 HasOneSample(3)); | |
909 EXPECT_THAT(details->uma()->GetAllSamples( | |
910 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | |
911 HasOneSample(3)); | |
912 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(2, 3, 3)); | |
913 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | |
914 DependingOnPolicy(0, 1, 1)); | |
915 | |
916 // Now navigate tab1 to an extension3 page with a web iframe. This could share | |
917 // a process with tab2's iframe (the LowerBound number), or it could get its | |
918 // own process (the Estimate number). | |
919 ui_test_utils::NavigateToURL(browser(), | |
920 extension3->GetResourceURL("http_iframe.html")); | |
921 details = new TestMemoryDetails(); | |
922 details->StartFetchAndWait(); | |
923 EXPECT_THAT(details->uma()->GetAllSamples( | |
924 "SiteIsolation.CurrentRendererProcessCount"), | |
925 HasOneSample(GetRenderProcessCount())); | |
926 EXPECT_THAT(details->uma()->GetAllSamples( | |
927 "SiteIsolation.IsolateNothingProcessCountEstimate"), | |
928 HasOneSample(2)); | |
929 EXPECT_THAT(details->uma()->GetAllSamples( | |
930 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | |
931 HasOneSample(4)); | |
932 EXPECT_THAT(details->uma()->GetAllSamples( | |
933 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | |
934 HasOneSample(3)); | |
935 EXPECT_THAT(details->uma()->GetAllSamples( | |
936 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | |
937 HasOneSample(4)); | |
938 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(2, 4, 4)); | |
939 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | |
940 DependingOnPolicy(0, 2, 2)); | |
941 | |
942 EXPECT_TRUE(IsInTrial("SiteIsolationExtensionsActive")); | |
943 } | 595 } |
944 | 596 |
945 // Due to http://crbug.com/612711, we are not isolating iframes from platform | 597 // Due to http://crbug.com/612711, we are not isolating iframes from platform |
946 // apps with --isolate-extenions. | 598 // apps with --isolate-extenions. |
947 IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, PlatformAppsNotIsolated) { | 599 IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, PlatformAppsNotIsolated) { |
948 // --site-per-process will still isolate iframes from platform apps, so skip | 600 // --site-per-process will still isolate iframes from platform apps, so skip |
949 // the test in that case. | 601 // the test in that case. |
950 if (content::AreAllSitesIsolatedForTesting()) | 602 if (content::AreAllSitesIsolatedForTesting()) |
951 return; | 603 return; |
952 CreateAppWithSandboxPage("Extension One"); | 604 CreateAppWithSandboxPage("Extension One"); |
953 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); | 605 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); |
954 details->StartFetchAndWait(); | 606 details->StartFetchAndWait(); |
955 EXPECT_EQ(0, details->GetOutOfProcessIframeCount()); | 607 EXPECT_EQ(0, details->GetOutOfProcessIframeCount()); |
956 } | 608 } |
957 | 609 |
958 // Exercises accounting in the case where an extension has two different-site | 610 // Verifies that hosted apps are not isolated. |
959 // web iframes. | |
960 IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, ExtensionWithTwoWebIframes) { | |
961 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); | |
962 details->StartFetchAndWait(); | |
963 | |
964 // Install one script-injecting extension with background page, and an | |
965 // extension with web accessible resources. | |
966 const Extension* extension = CreateExtension("Test Extension", false); | |
967 | |
968 ui_test_utils::NavigateToURL( | |
969 browser(), extension->GetResourceURL("/two_http_iframes.html")); | |
970 | |
971 details = new TestMemoryDetails(); | |
972 details->StartFetchAndWait(); | |
973 EXPECT_THAT(details->uma()->GetAllSamples( | |
974 "SiteIsolation.CurrentRendererProcessCount"), | |
975 HasOneSample(GetRenderProcessCount())); | |
976 EXPECT_THAT(details->uma()->GetAllSamples( | |
977 "SiteIsolation.IsolateNothingProcessCountEstimate"), | |
978 HasOneSample(1)); | |
979 EXPECT_THAT(details->uma()->GetAllSamples( | |
980 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | |
981 HasOneSample(2)); | |
982 EXPECT_THAT(details->uma()->GetAllSamples( | |
983 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | |
984 HasOneSample(2)); | |
985 EXPECT_THAT(details->uma()->GetAllSamples( | |
986 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | |
987 HasOneSample(2)); | |
988 // TODO(nick): https://crbug.com/512560 Make the number below agree with the | |
989 // estimates above, which assume consolidation of subframe processes. | |
990 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 3, 3)); | |
991 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | |
992 DependingOnPolicy(0, 2, 2)); | |
993 | |
994 EXPECT_TRUE(IsInTrial("SiteIsolationExtensionsActive")); | |
995 } | |
996 | |
997 // Verifies that --isolate-extensions doesn't isolate hosted apps. | |
998 IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, IsolateExtensionsHostedApps) { | 611 IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, IsolateExtensionsHostedApps) { |
999 GURL app_with_web_iframe_url = embedded_test_server()->GetURL( | 612 GURL app_with_web_iframe_url = embedded_test_server()->GetURL( |
1000 "app.org", "/cross_site_iframe_factory.html?app.org(b.com)"); | 613 "app.org", "/cross_site_iframe_factory.html?app.org(b.com)"); |
1001 GURL app_in_web_iframe_url = embedded_test_server()->GetURL( | 614 GURL app_in_web_iframe_url = embedded_test_server()->GetURL( |
1002 "b.com", "/cross_site_iframe_factory.html?b.com(app.org)"); | 615 "b.com", "/cross_site_iframe_factory.html?b.com(app.org)"); |
1003 | 616 |
1004 // No hosted app is installed: app.org just behaves like a normal domain. | 617 // No hosted app is installed: app.org just behaves like a normal domain. |
1005 ui_test_utils::NavigateToURL(browser(), app_with_web_iframe_url); | 618 ui_test_utils::NavigateToURL(browser(), app_with_web_iframe_url); |
1006 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); | 619 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); |
1007 details->StartFetchAndWait(); | 620 details->StartFetchAndWait(); |
1008 EXPECT_THAT(details->uma()->GetAllSamples( | 621 EXPECT_THAT(details->uma()->GetAllSamples( |
1009 "SiteIsolation.CurrentRendererProcessCount"), | 622 "SiteIsolation.CurrentRendererProcessCount"), |
1010 HasOneSample(GetRenderProcessCount())); | 623 HasOneSample(GetRenderProcessCount())); |
1011 EXPECT_THAT(details->uma()->GetAllSamples( | 624 EXPECT_THAT(details->uma()->GetAllSamples( |
1012 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 625 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
1013 HasOneSample(1)); | 626 HasOneSample(1)); |
1014 EXPECT_THAT(details->uma()->GetAllSamples( | 627 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 2)); |
1015 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | |
1016 HasOneSample(1)); | |
1017 EXPECT_THAT(details->uma()->GetAllSamples( | |
1018 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | |
1019 HasOneSample(1)); | |
1020 EXPECT_THAT(details->uma()->GetAllSamples( | |
1021 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | |
1022 HasOneSample(1)); | |
1023 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); | |
1024 EXPECT_THAT(details->uma()->GetAllSamples( | 628 EXPECT_THAT(details->uma()->GetAllSamples( |
1025 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), | 629 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), |
1026 HasOneSample(2)); | 630 HasOneSample(2)); |
1027 EXPECT_THAT(details->uma()->GetAllSamples( | 631 EXPECT_THAT(details->uma()->GetAllSamples( |
1028 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), | 632 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), |
1029 HasOneSample(2)); | 633 HasOneSample(2)); |
1030 EXPECT_THAT(details->uma()->GetAllSamples( | 634 EXPECT_THAT(details->uma()->GetAllSamples( |
1031 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), | 635 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), |
1032 HasOneSample(2)); | 636 HasOneSample(2)); |
1033 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); | 637 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 2)); |
1034 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 638 EXPECT_THAT(details->GetOutOfProcessIframeCount(), DependingOnPolicy(0, 1)); |
1035 DependingOnPolicy(0, 0, 1)); | |
1036 | 639 |
1037 ui_test_utils::NavigateToURL(browser(), app_in_web_iframe_url); | 640 ui_test_utils::NavigateToURL(browser(), app_in_web_iframe_url); |
1038 details = new TestMemoryDetails(); | 641 details = new TestMemoryDetails(); |
1039 details->StartFetchAndWait(); | 642 details->StartFetchAndWait(); |
1040 EXPECT_THAT(details->uma()->GetAllSamples( | 643 EXPECT_THAT(details->uma()->GetAllSamples( |
1041 "SiteIsolation.CurrentRendererProcessCount"), | 644 "SiteIsolation.CurrentRendererProcessCount"), |
1042 HasOneSample(GetRenderProcessCount())); | 645 HasOneSample(GetRenderProcessCount())); |
1043 EXPECT_THAT(details->uma()->GetAllSamples( | 646 EXPECT_THAT(details->uma()->GetAllSamples( |
1044 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 647 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
1045 HasOneSample(1)); | 648 HasOneSample(1)); |
1046 EXPECT_THAT(details->uma()->GetAllSamples( | 649 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 2)); |
1047 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | |
1048 HasOneSample(1)); | |
1049 EXPECT_THAT(details->uma()->GetAllSamples( | |
1050 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | |
1051 HasOneSample(1)); | |
1052 EXPECT_THAT(details->uma()->GetAllSamples( | |
1053 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | |
1054 HasOneSample(1)); | |
1055 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); | |
1056 EXPECT_THAT(details->uma()->GetAllSamples( | 650 EXPECT_THAT(details->uma()->GetAllSamples( |
1057 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), | 651 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), |
1058 HasOneSample(2)); | 652 HasOneSample(2)); |
1059 EXPECT_THAT(details->uma()->GetAllSamples( | 653 EXPECT_THAT(details->uma()->GetAllSamples( |
1060 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), | 654 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), |
1061 HasOneSample(2)); | 655 HasOneSample(2)); |
1062 EXPECT_THAT(details->uma()->GetAllSamples( | 656 EXPECT_THAT(details->uma()->GetAllSamples( |
1063 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), | 657 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), |
1064 HasOneSample(2)); | 658 HasOneSample(2)); |
1065 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); | 659 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 2)); |
1066 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 660 EXPECT_THAT(details->GetOutOfProcessIframeCount(), DependingOnPolicy(0, 1)); |
1067 DependingOnPolicy(0, 0, 1)); | |
1068 | 661 |
1069 // Now install app.org as a hosted app. | 662 // Now install app.org as a hosted app. |
1070 CreateHostedApp("App", GURL("http://app.org")); | 663 CreateHostedApp("App", GURL("http://app.org")); |
1071 | 664 |
1072 // Reload the same two pages, and verify that the hosted app still is not | 665 // Reload the same two pages, and verify that the hosted app still is not |
1073 // isolated by --isolate-extensions, but is isolated by --site-per-process. | 666 // isolated by default, but is isolated by --site-per-process. |
1074 ui_test_utils::NavigateToURL(browser(), app_with_web_iframe_url); | 667 ui_test_utils::NavigateToURL(browser(), app_with_web_iframe_url); |
1075 details = new TestMemoryDetails(); | 668 details = new TestMemoryDetails(); |
1076 details->StartFetchAndWait(); | 669 details->StartFetchAndWait(); |
1077 EXPECT_THAT(details->uma()->GetAllSamples( | 670 EXPECT_THAT(details->uma()->GetAllSamples( |
1078 "SiteIsolation.CurrentRendererProcessCount"), | 671 "SiteIsolation.CurrentRendererProcessCount"), |
1079 HasOneSample(GetRenderProcessCount())); | 672 HasOneSample(GetRenderProcessCount())); |
1080 EXPECT_THAT(details->uma()->GetAllSamples( | 673 EXPECT_THAT(details->uma()->GetAllSamples( |
1081 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 674 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
1082 HasOneSample(1)); | 675 HasOneSample(1)); |
1083 EXPECT_THAT(details->uma()->GetAllSamples( | 676 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 2)); |
1084 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | |
1085 HasOneSample(1)); | |
1086 EXPECT_THAT(details->uma()->GetAllSamples( | |
1087 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | |
1088 HasOneSample(1)); | |
1089 EXPECT_THAT(details->uma()->GetAllSamples( | |
1090 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | |
1091 HasOneSample(1)); | |
1092 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); | |
1093 EXPECT_THAT(details->uma()->GetAllSamples( | 677 EXPECT_THAT(details->uma()->GetAllSamples( |
1094 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), | 678 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), |
1095 HasOneSample(2)); | 679 HasOneSample(2)); |
1096 EXPECT_THAT(details->uma()->GetAllSamples( | 680 EXPECT_THAT(details->uma()->GetAllSamples( |
1097 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), | 681 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), |
1098 HasOneSample(2)); | 682 HasOneSample(2)); |
1099 EXPECT_THAT(details->uma()->GetAllSamples( | 683 EXPECT_THAT(details->uma()->GetAllSamples( |
1100 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), | 684 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), |
1101 HasOneSample(2)); | 685 HasOneSample(2)); |
1102 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); | 686 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 2)); |
1103 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 687 EXPECT_THAT(details->GetOutOfProcessIframeCount(), DependingOnPolicy(0, 1)); |
1104 DependingOnPolicy(0, 0, 1)); | |
1105 | 688 |
1106 ui_test_utils::NavigateToURL(browser(), app_in_web_iframe_url); | 689 ui_test_utils::NavigateToURL(browser(), app_in_web_iframe_url); |
1107 details = new TestMemoryDetails(); | 690 details = new TestMemoryDetails(); |
1108 details->StartFetchAndWait(); | 691 details->StartFetchAndWait(); |
1109 EXPECT_THAT(details->uma()->GetAllSamples( | 692 EXPECT_THAT(details->uma()->GetAllSamples( |
1110 "SiteIsolation.CurrentRendererProcessCount"), | 693 "SiteIsolation.CurrentRendererProcessCount"), |
1111 HasOneSample(GetRenderProcessCount())); | 694 HasOneSample(GetRenderProcessCount())); |
1112 EXPECT_THAT(details->uma()->GetAllSamples( | 695 EXPECT_THAT(details->uma()->GetAllSamples( |
1113 "SiteIsolation.IsolateNothingProcessCountEstimate"), | 696 "SiteIsolation.IsolateNothingProcessCountEstimate"), |
1114 HasOneSample(1)); | 697 HasOneSample(1)); |
1115 EXPECT_THAT(details->uma()->GetAllSamples( | 698 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 2)); |
1116 "SiteIsolation.IsolateExtensionsProcessCountEstimate"), | |
1117 HasOneSample(1)); | |
1118 EXPECT_THAT(details->uma()->GetAllSamples( | |
1119 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | |
1120 HasOneSample(1)); | |
1121 EXPECT_THAT(details->uma()->GetAllSamples( | |
1122 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | |
1123 HasOneSample(1)); | |
1124 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); | |
1125 EXPECT_THAT(details->uma()->GetAllSamples( | 699 EXPECT_THAT(details->uma()->GetAllSamples( |
1126 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), | 700 "SiteIsolation.IsolateAllSitesProcessCountEstimate"), |
1127 HasOneSample(2)); | 701 HasOneSample(2)); |
1128 EXPECT_THAT(details->uma()->GetAllSamples( | 702 EXPECT_THAT(details->uma()->GetAllSamples( |
1129 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), | 703 "SiteIsolation.IsolateAllSitesProcessCountLowerBound"), |
1130 HasOneSample(2)); | 704 HasOneSample(2)); |
1131 EXPECT_THAT(details->uma()->GetAllSamples( | 705 EXPECT_THAT(details->uma()->GetAllSamples( |
1132 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), | 706 "SiteIsolation.IsolateAllSitesProcessCountNoLimit"), |
1133 HasOneSample(2)); | 707 HasOneSample(2)); |
1134 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 2)); | 708 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 2)); |
1135 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 709 EXPECT_THAT(details->GetOutOfProcessIframeCount(), DependingOnPolicy(0, 1)); |
1136 DependingOnPolicy(0, 0, 1)); | |
1137 | |
1138 // Since hosted apps are excluded from isolation, this test should not be | |
1139 // in any of the field trial groups. | |
1140 EXPECT_FALSE(IsInTrial("SiteIsolationExtensionsActive")); | |
1141 } | |
1142 | |
1143 // Verifies that the client is put in the appropriate field trial group. | |
1144 IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, VerifyFieldTrialGroup) { | |
1145 const Extension* extension = CreateExtension("Extension", false); | |
1146 GURL tab1_url = embedded_test_server()->GetURL( | |
1147 "a.com", "/cross_site_iframe_factory.html?a(b,c)"); | |
1148 ui_test_utils::NavigateToURL(browser(), tab1_url); | |
1149 WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0); | |
1150 | |
1151 // Tab navigates its second iframe to a page of the extension. | |
1152 content::NavigateIframeToURL(tab, "child-1", | |
1153 extension->GetResourceURL("/blank_iframe.html")); | |
1154 | |
1155 std::string group; | |
1156 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
1157 switches::kSitePerProcess)) { | |
1158 group = "SitePerProcessFlag"; | |
1159 } else if (extensions::IsIsolateExtensionsEnabled()) { | |
1160 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
1161 extensions::switches::kIsolateExtensions)) { | |
1162 group = "IsolateExtensionsFlag"; | |
1163 } else { | |
1164 group = "FieldTrial"; | |
1165 } | |
1166 } else { | |
1167 if (base::FieldTrialList::FindFullName("SiteIsolationExtensions").empty()) | |
1168 group = "Default"; | |
1169 else | |
1170 group = "Control"; | |
1171 } | |
1172 | |
1173 EXPECT_TRUE(IsInTrialGroup("SiteIsolationExtensionsActive", group)); | |
1174 } | 710 } |
1175 | 711 |
1176 // Verifies that the UMA counter for SiteInstances in a BrowsingInstance is | 712 // Verifies that the UMA counter for SiteInstances in a BrowsingInstance is |
1177 // correct when using tabs with web pages. | 713 // correct when using tabs with web pages. |
1178 IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, | 714 IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, |
1179 VerifySiteInstanceCountInBrowsingInstance) { | 715 VerifySiteInstanceCountInBrowsingInstance) { |
1180 // Page with 14 nested oopifs across 9 sites (a.com through i.com). | 716 // Page with 14 nested oopifs across 9 sites (a.com through i.com). |
1181 GURL abcdefghi_url = embedded_test_server()->GetURL( | 717 GURL abcdefghi_url = embedded_test_server()->GetURL( |
1182 "a.com", | 718 "a.com", |
1183 "/cross_site_iframe_factory.html?a(b(a(b,c,d,e,f,g,h)),c,d,e,i(f))"); | 719 "/cross_site_iframe_factory.html?a(b(a(b,c,d,e,f,g,h)),c,d,e,i(f))"); |
1184 ui_test_utils::NavigateToURL(browser(), abcdefghi_url); | 720 ui_test_utils::NavigateToURL(browser(), abcdefghi_url); |
1185 | 721 |
1186 // Get the metrics. | 722 // Get the metrics. |
1187 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); | 723 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); |
1188 details->StartFetchAndWait(); | 724 details->StartFetchAndWait(); |
1189 | 725 |
1190 // Since there are no extensions involved, the results in the default case | |
1191 // and extensions::IsIsolateExtensionsEnabled() are the same. | |
1192 EXPECT_THAT(details->uma()->GetAllSamples( | 726 EXPECT_THAT(details->uma()->GetAllSamples( |
1193 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | 727 "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
1194 HasOneSample(DependingOnPolicy(1, 1, 9))); | 728 HasOneSample(DependingOnPolicy(1, 9))); |
1195 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), | 729 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), |
1196 HasOneSample(DependingOnPolicy(0, 0, 114))); | 730 HasOneSample(DependingOnPolicy(0, 114))); |
1197 EXPECT_THAT(details->uma()->GetAllSamples( | 731 EXPECT_THAT(details->uma()->GetAllSamples( |
1198 "SiteIsolation.ProxyCountPerBrowsingInstance"), | 732 "SiteIsolation.ProxyCountPerBrowsingInstance"), |
1199 HasOneSample(DependingOnPolicy(0, 0, 114))); | 733 HasOneSample(DependingOnPolicy(0, 114))); |
1200 | 734 |
1201 // Open another tab through window.open(), which will be in the same | 735 // Open another tab through window.open(), which will be in the same |
1202 // BrowsingInstance. | 736 // BrowsingInstance. |
1203 GURL dcbae_url = embedded_test_server()->GetURL( | 737 GURL dcbae_url = embedded_test_server()->GetURL( |
1204 "a.com", "/cross_site_iframe_factory.html?d(c(b(j(k))))"); | 738 "a.com", "/cross_site_iframe_factory.html?d(c(b(j(k))))"); |
1205 ui_test_utils::UrlLoadObserver load_complete( | 739 ui_test_utils::UrlLoadObserver load_complete( |
1206 dcbae_url, content::NotificationService::AllSources()); | 740 dcbae_url, content::NotificationService::AllSources()); |
1207 ASSERT_EQ(1, browser()->tab_strip_model()->count()); | 741 ASSERT_EQ(1, browser()->tab_strip_model()->count()); |
1208 ASSERT_TRUE(content::ExecuteScript( | 742 ASSERT_TRUE(content::ExecuteScript( |
1209 browser()->tab_strip_model()->GetActiveWebContents(), | 743 browser()->tab_strip_model()->GetActiveWebContents(), |
1210 "window.open('" + dcbae_url.spec() + "');")); | 744 "window.open('" + dcbae_url.spec() + "');")); |
1211 ASSERT_EQ(2, browser()->tab_strip_model()->count()); | 745 ASSERT_EQ(2, browser()->tab_strip_model()->count()); |
1212 load_complete.Wait(); | 746 load_complete.Wait(); |
1213 | 747 |
1214 details = new TestMemoryDetails(); | 748 details = new TestMemoryDetails(); |
1215 details->StartFetchAndWait(); | 749 details->StartFetchAndWait(); |
1216 EXPECT_THAT(details->uma()->GetAllSamples( | 750 EXPECT_THAT(details->uma()->GetAllSamples( |
1217 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | 751 "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
1218 HasOneSample(DependingOnPolicy(1, 1, 11))); | 752 HasOneSample(DependingOnPolicy(1, 11))); |
1219 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), | 753 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), |
1220 HasOneSample(DependingOnPolicy(0, 0, 160))); | 754 HasOneSample(DependingOnPolicy(0, 160))); |
1221 EXPECT_THAT(details->uma()->GetAllSamples( | 755 EXPECT_THAT(details->uma()->GetAllSamples( |
1222 "SiteIsolation.ProxyCountPerBrowsingInstance"), | 756 "SiteIsolation.ProxyCountPerBrowsingInstance"), |
1223 HasOneSample(DependingOnPolicy(0, 0, 160))); | 757 HasOneSample(DependingOnPolicy(0, 160))); |
1224 | 758 |
1225 // Open a tab, which will be in a different BrowsingInstance. | 759 // Open a tab, which will be in a different BrowsingInstance. |
1226 GURL abcd_url = embedded_test_server()->GetURL( | 760 GURL abcd_url = embedded_test_server()->GetURL( |
1227 "a.com", "/cross_site_iframe_factory.html?a(b(c(d())))"); | 761 "a.com", "/cross_site_iframe_factory.html?a(b(c(d())))"); |
1228 AddTabAtIndex(1, abcd_url, ui::PAGE_TRANSITION_TYPED); | 762 AddTabAtIndex(1, abcd_url, ui::PAGE_TRANSITION_TYPED); |
1229 | 763 |
1230 details = new TestMemoryDetails(); | 764 details = new TestMemoryDetails(); |
1231 details->StartFetchAndWait(); | 765 details->StartFetchAndWait(); |
1232 EXPECT_THAT( | 766 EXPECT_THAT(details->uma()->GetAllSamples( |
1233 details->uma()->GetAllSamples( | 767 "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
1234 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | 768 DependingOnPolicy(ElementsAre(Sample(1, 2)), |
1235 DependingOnPolicy(ElementsAre(Sample(1, 2)), ElementsAre(Sample(1, 2)), | 769 ElementsAre(Sample(4, 1), Sample(11, 1)))); |
1236 ElementsAre(Sample(4, 1), Sample(11, 1)))); | |
1237 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), | 770 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), |
1238 HasOneSample(DependingOnPolicy(0, 0, 160))); | 771 HasOneSample(DependingOnPolicy(0, 160))); |
1239 EXPECT_THAT( | 772 EXPECT_THAT(details->uma()->GetAllSamples( |
1240 details->uma()->GetAllSamples( | 773 "SiteIsolation.ProxyCountPerBrowsingInstance"), |
1241 "SiteIsolation.ProxyCountPerBrowsingInstance"), | 774 DependingOnPolicy(ElementsAre(Sample(0, 2)), |
1242 DependingOnPolicy(ElementsAre(Sample(0, 2)), ElementsAre(Sample(0, 2)), | 775 ElementsAre(Sample(12, 1), Sample(160, 1)))); |
1243 ElementsAre(Sample(12, 1), Sample(160, 1)))); | |
1244 } | 776 } |
1245 | 777 |
1246 // Verifies that the UMA counter for SiteInstances in a BrowsingInstance is | 778 // Verifies that the UMA counter for SiteInstances in a BrowsingInstance is |
1247 // correct when extensions and web pages are mixed together. | 779 // correct when extensions and web pages are mixed together. |
1248 IN_PROC_BROWSER_TEST_F( | 780 IN_PROC_BROWSER_TEST_F( |
1249 SiteDetailsBrowserTest, | 781 SiteDetailsBrowserTest, |
1250 VerifySiteInstanceCountInBrowsingInstanceWithExtensions) { | 782 VerifySiteInstanceCountInBrowsingInstanceWithExtensions) { |
1251 // Open two a.com tabs (with cross site http iframes). IsolateExtensions mode | 783 // Open two a.com tabs (with cross site http iframes). Isolating extensions |
1252 // should have no effect so far, since there are no frames straddling the | 784 // should have no effect so far, since there are no frames straddling the |
1253 // extension/web boundary. | 785 // extension/web boundary. |
1254 GURL tab_url = embedded_test_server()->GetURL( | 786 GURL tab_url = embedded_test_server()->GetURL( |
1255 "a.com", "/cross_site_iframe_factory.html?a(b,c,d(e))"); | 787 "a.com", "/cross_site_iframe_factory.html?a(b,c,d(e))"); |
1256 ui_test_utils::NavigateToURL(browser(), tab_url); | 788 ui_test_utils::NavigateToURL(browser(), tab_url); |
1257 WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0); | 789 WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0); |
1258 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); | 790 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); |
1259 details->StartFetchAndWait(); | 791 details->StartFetchAndWait(); |
1260 | |
1261 // Since there are no extensions loaded yet, the results in the default case | |
1262 // and extensions::IsIsolateExtensionsEnabled() are the same. | |
1263 EXPECT_THAT(details->uma()->GetAllSamples( | 792 EXPECT_THAT(details->uma()->GetAllSamples( |
1264 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | 793 "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
1265 HasOneSample(DependingOnPolicy(1, 1, 5))); | 794 HasOneSample(DependingOnPolicy(1, 5))); |
1266 | 795 |
1267 // Load an extension without a background page, which will avoid creating a | 796 // Load an extension without a background page, which will avoid creating a |
1268 // BrowsingInstance for it. | 797 // BrowsingInstance for it. |
1269 const Extension* extension1 = CreateExtension("Extension One", false); | 798 const Extension* extension1 = CreateExtension("Extension One", false); |
1270 | 799 |
1271 // Navigate the tab's first iframe to a resource of the extension. The | 800 // Navigate the tab's first iframe to a resource of the extension. The |
1272 // extension iframe will be put in the same BrowsingInstance as it is part | 801 // extension iframe will be put in the same BrowsingInstance as it is part |
1273 // of the frame tree. | 802 // of the frame tree. |
1274 content::NavigateIframeToURL( | 803 content::NavigateIframeToURL( |
1275 tab, "child-0", extension1->GetResourceURL("/blank_iframe.html")); | 804 tab, "child-0", extension1->GetResourceURL("/blank_iframe.html")); |
1276 details = new TestMemoryDetails(); | 805 details = new TestMemoryDetails(); |
1277 details->StartFetchAndWait(); | 806 details->StartFetchAndWait(); |
1278 EXPECT_THAT(details->uma()->GetAllSamples( | 807 EXPECT_THAT(details->uma()->GetAllSamples( |
1279 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | 808 "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
1280 HasOneSample(DependingOnPolicy(1, 2, 5))); | 809 HasOneSample(DependingOnPolicy(2, 5))); |
1281 | 810 |
1282 // Now load an extension with a background page. This will result in a | 811 // Now load an extension with a background page. This will result in a |
1283 // BrowsingInstance for the background page. | 812 // BrowsingInstance for the background page. |
1284 const Extension* extension2 = CreateExtension("Extension Two", true); | 813 const Extension* extension2 = CreateExtension("Extension Two", true); |
1285 details = new TestMemoryDetails(); | 814 details = new TestMemoryDetails(); |
1286 details->StartFetchAndWait(); | 815 details->StartFetchAndWait(); |
1287 EXPECT_THAT(details->uma()->GetAllSamples( | 816 EXPECT_THAT(details->uma()->GetAllSamples( |
1288 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | 817 "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
1289 DependingOnPolicy(ElementsAre(Bucket(1, 2)), | 818 DependingOnPolicy(ElementsAre(Bucket(1, 1), Bucket(2, 1)), |
1290 ElementsAre(Bucket(1, 1), Bucket(2, 1)), | |
1291 ElementsAre(Bucket(1, 1), Bucket(5, 1)))); | 819 ElementsAre(Bucket(1, 1), Bucket(5, 1)))); |
1292 | 820 |
1293 // Navigate the second iframe of the tab to the second extension. It should | 821 // Navigate the second iframe of the tab to the second extension. It should |
1294 // stay in the same BrowsingInstance as the page. | 822 // stay in the same BrowsingInstance as the page. |
1295 content::NavigateIframeToURL( | 823 content::NavigateIframeToURL( |
1296 tab, "child-1", extension2->GetResourceURL("/blank_iframe.html")); | 824 tab, "child-1", extension2->GetResourceURL("/blank_iframe.html")); |
1297 details = new TestMemoryDetails(); | 825 details = new TestMemoryDetails(); |
1298 details->StartFetchAndWait(); | 826 details->StartFetchAndWait(); |
1299 EXPECT_THAT(details->uma()->GetAllSamples( | 827 EXPECT_THAT(details->uma()->GetAllSamples( |
1300 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | 828 "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
1301 DependingOnPolicy(ElementsAre(Bucket(1, 2)), | 829 DependingOnPolicy(ElementsAre(Bucket(1, 1), Bucket(3, 1)), |
1302 ElementsAre(Bucket(1, 1), Bucket(3, 1)), | |
1303 ElementsAre(Bucket(1, 1), Bucket(5, 1)))); | 830 ElementsAre(Bucket(1, 1), Bucket(5, 1)))); |
1304 } | 831 } |
OLD | NEW |