Chromium Code Reviews| 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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 HasOneSample(1)); | 369 HasOneSample(1)); |
| 370 EXPECT_THAT(details->uma()->GetAllSamples( | 370 EXPECT_THAT(details->uma()->GetAllSamples( |
| 371 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 371 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
| 372 HasOneSample(1)); | 372 HasOneSample(1)); |
| 373 EXPECT_THAT(details->uma()->GetAllSamples( | 373 EXPECT_THAT(details->uma()->GetAllSamples( |
| 374 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 374 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
| 375 HasOneSample(1)); | 375 HasOneSample(1)); |
| 376 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 9)); | 376 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 9)); |
| 377 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 377 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
| 378 DependingOnPolicy(0, 0, 14)); | 378 DependingOnPolicy(0, 0, 14)); |
| 379 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), | |
| 380 HasOneSample(DependingOnPolicy(0, 0, 100))); | |
|
Charlie Reis
2016/02/10 22:37:52
Looks like we have 15*(9-1) proxies in this case (
ncarter (slow)
2016/02/10 23:22:14
Increased both to 10000. The higher max doesn't ac
| |
| 381 EXPECT_THAT(details->uma()->GetAllSamples( | |
| 382 "SiteIsolation.ProxyCountPerBrowsingInstance"), | |
| 383 HasOneSample(DependingOnPolicy(0, 0, 120))); | |
| 379 | 384 |
| 380 // Navigate to a different, disjoint set of 7 sites. | 385 // Navigate to a different, disjoint set of 7 sites. |
| 381 GURL pqrstuv_url = embedded_test_server()->GetURL( | 386 GURL pqrstuv_url = embedded_test_server()->GetURL( |
| 382 "p.com", | 387 "p.com", |
| 383 "/cross_site_iframe_factory.html?p(q(r),r(s),s(t),t(q),u(u),v(p))"); | 388 "/cross_site_iframe_factory.html?p(q(r),r(s),s(t),t(q),u(u),v(p))"); |
| 384 ui_test_utils::NavigateToURL(browser(), pqrstuv_url); | 389 ui_test_utils::NavigateToURL(browser(), pqrstuv_url); |
| 385 | 390 |
| 386 details = new TestMemoryDetails(); | 391 details = new TestMemoryDetails(); |
| 387 details->StartFetchAndWait(); | 392 details->StartFetchAndWait(); |
| 388 | 393 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 419 HasOneSample(1)); | 424 HasOneSample(1)); |
| 420 EXPECT_THAT(details->uma()->GetAllSamples( | 425 EXPECT_THAT(details->uma()->GetAllSamples( |
| 421 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 426 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
| 422 HasOneSample(1)); | 427 HasOneSample(1)); |
| 423 EXPECT_THAT(details->uma()->GetAllSamples( | 428 EXPECT_THAT(details->uma()->GetAllSamples( |
| 424 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 429 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
| 425 HasOneSample(1)); | 430 HasOneSample(1)); |
| 426 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 7)); | 431 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(1, 1, 7)); |
| 427 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 432 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
| 428 DependingOnPolicy(0, 0, 11)); | 433 DependingOnPolicy(0, 0, 11)); |
| 434 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), | |
| 435 HasOneSample(DependingOnPolicy(0, 0, 76))); | |
| 436 EXPECT_THAT(details->uma()->GetAllSamples( | |
| 437 "SiteIsolation.ProxyCountPerBrowsingInstance"), | |
| 438 HasOneSample(DependingOnPolicy(0, 0, 75))); | |
|
Charlie Reis
2016/02/10 22:37:51
No discrepancy expected here, right?
ncarter (slow)
2016/02/10 23:22:14
They are the same input value, but the histograms
| |
| 429 | 439 |
| 430 // Open a second tab (different BrowsingInstance) with 4 sites (a through d). | 440 // Open a second tab (different BrowsingInstance) with 4 sites (a through d). |
| 431 GURL abcd_url = embedded_test_server()->GetURL( | 441 GURL abcd_url = embedded_test_server()->GetURL( |
| 432 "a.com", "/cross_site_iframe_factory.html?a(b(c(d())))"); | 442 "a.com", "/cross_site_iframe_factory.html?a(b(c(d())))"); |
| 433 AddTabAtIndex(1, abcd_url, ui::PAGE_TRANSITION_TYPED); | 443 AddTabAtIndex(1, abcd_url, ui::PAGE_TRANSITION_TYPED); |
| 434 | 444 |
| 435 details = new TestMemoryDetails(); | 445 details = new TestMemoryDetails(); |
| 436 details->StartFetchAndWait(); | 446 details->StartFetchAndWait(); |
| 437 | 447 |
| 438 EXPECT_EQ(2U, details->CountPageTitles()); | 448 EXPECT_EQ(2U, details->CountPageTitles()); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 468 HasOneSample(2)); | 478 HasOneSample(2)); |
| 469 EXPECT_THAT(details->uma()->GetAllSamples( | 479 EXPECT_THAT(details->uma()->GetAllSamples( |
| 470 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 480 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
| 471 HasOneSample(1)); | 481 HasOneSample(1)); |
| 472 EXPECT_THAT(details->uma()->GetAllSamples( | 482 EXPECT_THAT(details->uma()->GetAllSamples( |
| 473 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 483 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
| 474 HasOneSample(2)); | 484 HasOneSample(2)); |
| 475 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(2, 2, 11)); | 485 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(2, 2, 11)); |
| 476 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 486 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
| 477 DependingOnPolicy(0, 0, 14)); | 487 DependingOnPolicy(0, 0, 14)); |
| 488 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), | |
| 489 HasOneSample(DependingOnPolicy(0, 0, 90))); | |
| 490 EXPECT_THAT( | |
| 491 details->uma()->GetAllSamples( | |
| 492 "SiteIsolation.ProxyCountPerBrowsingInstance"), | |
| 493 DependingOnPolicy(ElementsAre(Bucket(0, 2)), ElementsAre(Bucket(0, 2)), | |
| 494 ElementsAre(Bucket(12, 1), Bucket(75, 1)))); | |
| 478 | 495 |
| 479 // Open a third tab (different BrowsingInstance) with the same 4 sites. | 496 // Open a third tab (different BrowsingInstance) with the same 4 sites. |
| 480 AddTabAtIndex(2, abcd_url, ui::PAGE_TRANSITION_TYPED); | 497 AddTabAtIndex(2, abcd_url, ui::PAGE_TRANSITION_TYPED); |
| 481 | 498 |
| 482 details = new TestMemoryDetails(); | 499 details = new TestMemoryDetails(); |
| 483 details->StartFetchAndWait(); | 500 details->StartFetchAndWait(); |
| 484 | 501 |
| 485 EXPECT_THAT( | 502 EXPECT_THAT( |
| 486 details->uma()->GetAllSamples("SiteIsolation.BrowsingInstanceCount"), | 503 details->uma()->GetAllSamples("SiteIsolation.BrowsingInstanceCount"), |
| 487 HasOneSample(3)); | 504 HasOneSample(3)); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 515 HasOneSample(3)); | 532 HasOneSample(3)); |
| 516 EXPECT_THAT(details->uma()->GetAllSamples( | 533 EXPECT_THAT(details->uma()->GetAllSamples( |
| 517 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 534 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
| 518 HasOneSample(1)); | 535 HasOneSample(1)); |
| 519 EXPECT_THAT(details->uma()->GetAllSamples( | 536 EXPECT_THAT(details->uma()->GetAllSamples( |
| 520 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 537 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
| 521 HasOneSample(3)); | 538 HasOneSample(3)); |
| 522 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 3, 15)); | 539 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 3, 15)); |
| 523 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 540 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
| 524 DependingOnPolicy(0, 0, 17)); | 541 DependingOnPolicy(0, 0, 17)); |
| 542 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), | |
| 543 HasOneSample(DependingOnPolicy(0, 0, 100))); | |
| 544 EXPECT_THAT( | |
| 545 details->uma()->GetAllSamples( | |
| 546 "SiteIsolation.ProxyCountPerBrowsingInstance"), | |
| 547 DependingOnPolicy(ElementsAre(Bucket(0, 3)), ElementsAre(Bucket(0, 3)), | |
| 548 ElementsAre(Bucket(12, 2), Bucket(75, 1)))); | |
| 525 | 549 |
| 526 // From the third tab, window.open() a fourth tab in the same | 550 // From the third tab, window.open() a fourth tab in the same |
| 527 // BrowsingInstance, to a page using the same four sites "a-d" as third tab, | 551 // BrowsingInstance, to a page using the same four sites "a-d" as third tab, |
| 528 // plus an additional site "e". The estimated process counts should increase | 552 // plus an additional site "e". The estimated process counts should increase |
| 529 // by one (not five) from the previous scenario, as the new tab can reuse the | 553 // by one (not five) from the previous scenario, as the new tab can reuse the |
| 530 // four processes already in the BrowsingInstance. | 554 // four processes already in the BrowsingInstance. |
| 531 GURL dcbae_url = embedded_test_server()->GetURL( | 555 GURL dcbae_url = embedded_test_server()->GetURL( |
| 532 "a.com", "/cross_site_iframe_factory.html?d(c(b(a(e))))"); | 556 "a.com", "/cross_site_iframe_factory.html?d(c(b(a(e))))"); |
| 533 ui_test_utils::UrlLoadObserver load_complete( | 557 ui_test_utils::UrlLoadObserver load_complete( |
| 534 dcbae_url, content::NotificationService::AllSources()); | 558 dcbae_url, content::NotificationService::AllSources()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 575 HasOneSample(3)); | 599 HasOneSample(3)); |
| 576 EXPECT_THAT(details->uma()->GetAllSamples( | 600 EXPECT_THAT(details->uma()->GetAllSamples( |
| 577 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), | 601 "SiteIsolation.IsolateExtensionsProcessCountLowerBound"), |
| 578 HasOneSample(1)); | 602 HasOneSample(1)); |
| 579 EXPECT_THAT(details->uma()->GetAllSamples( | 603 EXPECT_THAT(details->uma()->GetAllSamples( |
| 580 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), | 604 "SiteIsolation.IsolateExtensionsProcessCountNoLimit"), |
| 581 HasOneSample(3)); | 605 HasOneSample(3)); |
| 582 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 3, 16)); | 606 EXPECT_THAT(GetRenderProcessCount(), DependingOnPolicy(3, 3, 16)); |
| 583 EXPECT_THAT(details->GetOutOfProcessIframeCount(), | 607 EXPECT_THAT(details->GetOutOfProcessIframeCount(), |
| 584 DependingOnPolicy(0, 0, 21)); | 608 DependingOnPolicy(0, 0, 21)); |
| 609 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), | |
| 610 HasOneSample(DependingOnPolicy(0, 0, 100))); | |
| 611 EXPECT_THAT(details->uma()->GetAllSamples( | |
| 612 "SiteIsolation.ProxyCountPerBrowsingInstance"), | |
| 613 DependingOnPolicy( | |
| 614 ElementsAre(Bucket(0, 3)), ElementsAre(Bucket(0, 3)), | |
| 615 ElementsAre(Bucket(12, 1), Bucket(29, 1), Bucket(75, 1)))); | |
| 585 | 616 |
| 586 // This test doesn't navigate to any extensions URLs, so it should not be | 617 // This test doesn't navigate to any extensions URLs, so it should not be |
| 587 // in any of the field trial groups. | 618 // in any of the field trial groups. |
| 588 EXPECT_FALSE(IsInTrial("SiteIsolationExtensionsActive")); | 619 EXPECT_FALSE(IsInTrial("SiteIsolationExtensionsActive")); |
| 589 } | 620 } |
| 590 | 621 |
| 591 IN_PROC_BROWSER_TEST_P(SiteDetailsBrowserTest, IsolateExtensions) { | 622 IN_PROC_BROWSER_TEST_P(SiteDetailsBrowserTest, IsolateExtensions) { |
| 592 // We start on "about:blank", which should be credited with a process in this | 623 // We start on "about:blank", which should be credited with a process in this |
| 593 // case. | 624 // case. |
| 594 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); | 625 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1093 | 1124 |
| 1094 // Get the metrics. | 1125 // Get the metrics. |
| 1095 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); | 1126 scoped_refptr<TestMemoryDetails> details = new TestMemoryDetails(); |
| 1096 details->StartFetchAndWait(); | 1127 details->StartFetchAndWait(); |
| 1097 | 1128 |
| 1098 // Since there are no extensions involved, the results in the default case | 1129 // Since there are no extensions involved, the results in the default case |
| 1099 // and extensions::IsIsolateExtensionsEnabled() are the same. | 1130 // and extensions::IsIsolateExtensionsEnabled() are the same. |
| 1100 EXPECT_THAT(details->uma()->GetAllSamples( | 1131 EXPECT_THAT(details->uma()->GetAllSamples( |
| 1101 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | 1132 "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
| 1102 HasOneSample(DependingOnPolicy(1, 1, 9))); | 1133 HasOneSample(DependingOnPolicy(1, 1, 9))); |
| 1134 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), | |
| 1135 HasOneSample(DependingOnPolicy(0, 0, 100))); | |
|
Charlie Reis
2016/02/10 22:37:51
Let's add the per-BrowsingInstance count expectati
ncarter (slow)
2016/02/10 23:22:14
Done.
| |
| 1103 | 1136 |
| 1104 // Open another tab through window.open(), which will be in the same | 1137 // Open another tab through window.open(), which will be in the same |
| 1105 // BrowsingInstance. | 1138 // BrowsingInstance. |
| 1106 GURL dcbae_url = embedded_test_server()->GetURL( | 1139 GURL dcbae_url = embedded_test_server()->GetURL( |
| 1107 "a.com", "/cross_site_iframe_factory.html?d(c(b(j(k))))"); | 1140 "a.com", "/cross_site_iframe_factory.html?d(c(b(j(k))))"); |
| 1108 ui_test_utils::UrlLoadObserver load_complete( | 1141 ui_test_utils::UrlLoadObserver load_complete( |
| 1109 dcbae_url, content::NotificationService::AllSources()); | 1142 dcbae_url, content::NotificationService::AllSources()); |
| 1110 ASSERT_EQ(1, browser()->tab_strip_model()->count()); | 1143 ASSERT_EQ(1, browser()->tab_strip_model()->count()); |
| 1111 ASSERT_TRUE(content::ExecuteScript( | 1144 ASSERT_TRUE(content::ExecuteScript( |
| 1112 browser()->tab_strip_model()->GetActiveWebContents(), | 1145 browser()->tab_strip_model()->GetActiveWebContents(), |
| 1113 "window.open('" + dcbae_url.spec() + "');")); | 1146 "window.open('" + dcbae_url.spec() + "');")); |
| 1114 ASSERT_EQ(2, browser()->tab_strip_model()->count()); | 1147 ASSERT_EQ(2, browser()->tab_strip_model()->count()); |
| 1115 load_complete.Wait(); | 1148 load_complete.Wait(); |
| 1116 | 1149 |
| 1117 details = new TestMemoryDetails(); | 1150 details = new TestMemoryDetails(); |
| 1118 details->StartFetchAndWait(); | 1151 details->StartFetchAndWait(); |
| 1119 EXPECT_THAT(details->uma()->GetAllSamples( | 1152 EXPECT_THAT(details->uma()->GetAllSamples( |
| 1120 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | 1153 "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
| 1121 HasOneSample(DependingOnPolicy(1, 1, 11))); | 1154 HasOneSample(DependingOnPolicy(1, 1, 11))); |
| 1155 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), | |
| 1156 HasOneSample(DependingOnPolicy(0, 0, 100))); | |
| 1122 | 1157 |
| 1123 // Open a tab, which will be in a different BrowsingInstance. | 1158 // Open a tab, which will be in a different BrowsingInstance. |
| 1124 GURL abcd_url = embedded_test_server()->GetURL( | 1159 GURL abcd_url = embedded_test_server()->GetURL( |
| 1125 "a.com", "/cross_site_iframe_factory.html?a(b(c(d())))"); | 1160 "a.com", "/cross_site_iframe_factory.html?a(b(c(d())))"); |
| 1126 AddTabAtIndex(1, abcd_url, ui::PAGE_TRANSITION_TYPED); | 1161 AddTabAtIndex(1, abcd_url, ui::PAGE_TRANSITION_TYPED); |
| 1127 | 1162 |
| 1128 details = new TestMemoryDetails(); | 1163 details = new TestMemoryDetails(); |
| 1129 details->StartFetchAndWait(); | 1164 details->StartFetchAndWait(); |
| 1130 EXPECT_THAT( | 1165 EXPECT_THAT( |
| 1131 details->uma()->GetAllSamples( | 1166 details->uma()->GetAllSamples( |
| 1132 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | 1167 "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
| 1133 DependingOnPolicy(ElementsAre(Sample(1, 2)), ElementsAre(Sample(1, 2)), | 1168 DependingOnPolicy(ElementsAre(Sample(1, 2)), ElementsAre(Sample(1, 2)), |
| 1134 ElementsAre(Sample(4, 1), Sample(11, 1)))); | 1169 ElementsAre(Sample(4, 1), Sample(11, 1)))); |
| 1170 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), | |
| 1171 HasOneSample(DependingOnPolicy(0, 0, 100))); | |
| 1135 } | 1172 } |
| 1136 | 1173 |
| 1137 // Verifies that the UMA counter for SiteInstances in a BrowsingInstance is | 1174 // Verifies that the UMA counter for SiteInstances in a BrowsingInstance is |
| 1138 // correct when extensions and web pages are mixed together. | 1175 // correct when extensions and web pages are mixed together. |
| 1139 IN_PROC_BROWSER_TEST_P( | 1176 IN_PROC_BROWSER_TEST_P( |
| 1140 SiteDetailsBrowserTest, | 1177 SiteDetailsBrowserTest, |
| 1141 VerifySiteInstanceCountInBrowsingInstanceWithExtensions) { | 1178 VerifySiteInstanceCountInBrowsingInstanceWithExtensions) { |
| 1142 // Open two a.com tabs (with cross site http iframes). IsolateExtensions mode | 1179 // Open two a.com tabs (with cross site http iframes). IsolateExtensions mode |
| 1143 // should have no effect so far, since there are no frames straddling the | 1180 // should have no effect so far, since there are no frames straddling the |
| 1144 // extension/web boundary. | 1181 // extension/web boundary. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1193 ElementsAre(Bucket(1, 1), Bucket(3, 1)), | 1230 ElementsAre(Bucket(1, 1), Bucket(3, 1)), |
| 1194 ElementsAre(Bucket(1, 1), Bucket(5, 1)))); | 1231 ElementsAre(Bucket(1, 1), Bucket(5, 1)))); |
| 1195 } | 1232 } |
| 1196 | 1233 |
| 1197 INSTANTIATE_TEST_CASE_P( | 1234 INSTANTIATE_TEST_CASE_P( |
| 1198 , | 1235 , |
| 1199 SiteDetailsBrowserTest, | 1236 SiteDetailsBrowserTest, |
| 1200 testing::Values("", | 1237 testing::Values("", |
| 1201 extensions::switches::kIsolateExtensions, | 1238 extensions::switches::kIsolateExtensions, |
| 1202 switches::kSitePerProcess)); | 1239 switches::kSitePerProcess)); |
| OLD | NEW |