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, 114))); |
| 381 EXPECT_THAT(details->uma()->GetAllSamples( |
| 382 "SiteIsolation.ProxyCountPerBrowsingInstance"), |
| 383 HasOneSample(DependingOnPolicy(0, 0, 114))); |
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, 68))); |
| 436 EXPECT_THAT(details->uma()->GetAllSamples( |
| 437 "SiteIsolation.ProxyCountPerBrowsingInstance"), |
| 438 HasOneSample(DependingOnPolicy(0, 0, 68))); |
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, 81))); |
| 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(68, 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, 96))); |
| 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(68, 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, 114))); |
| 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(68, 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, 114))); |
| 1136 EXPECT_THAT(details->uma()->GetAllSamples( |
| 1137 "SiteIsolation.ProxyCountPerBrowsingInstance"), |
| 1138 HasOneSample(DependingOnPolicy(0, 0, 114))); |
1103 | 1139 |
1104 // Open another tab through window.open(), which will be in the same | 1140 // Open another tab through window.open(), which will be in the same |
1105 // BrowsingInstance. | 1141 // BrowsingInstance. |
1106 GURL dcbae_url = embedded_test_server()->GetURL( | 1142 GURL dcbae_url = embedded_test_server()->GetURL( |
1107 "a.com", "/cross_site_iframe_factory.html?d(c(b(j(k))))"); | 1143 "a.com", "/cross_site_iframe_factory.html?d(c(b(j(k))))"); |
1108 ui_test_utils::UrlLoadObserver load_complete( | 1144 ui_test_utils::UrlLoadObserver load_complete( |
1109 dcbae_url, content::NotificationService::AllSources()); | 1145 dcbae_url, content::NotificationService::AllSources()); |
1110 ASSERT_EQ(1, browser()->tab_strip_model()->count()); | 1146 ASSERT_EQ(1, browser()->tab_strip_model()->count()); |
1111 ASSERT_TRUE(content::ExecuteScript( | 1147 ASSERT_TRUE(content::ExecuteScript( |
1112 browser()->tab_strip_model()->GetActiveWebContents(), | 1148 browser()->tab_strip_model()->GetActiveWebContents(), |
1113 "window.open('" + dcbae_url.spec() + "');")); | 1149 "window.open('" + dcbae_url.spec() + "');")); |
1114 ASSERT_EQ(2, browser()->tab_strip_model()->count()); | 1150 ASSERT_EQ(2, browser()->tab_strip_model()->count()); |
1115 load_complete.Wait(); | 1151 load_complete.Wait(); |
1116 | 1152 |
1117 details = new TestMemoryDetails(); | 1153 details = new TestMemoryDetails(); |
1118 details->StartFetchAndWait(); | 1154 details->StartFetchAndWait(); |
1119 EXPECT_THAT(details->uma()->GetAllSamples( | 1155 EXPECT_THAT(details->uma()->GetAllSamples( |
1120 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | 1156 "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
1121 HasOneSample(DependingOnPolicy(1, 1, 11))); | 1157 HasOneSample(DependingOnPolicy(1, 1, 11))); |
| 1158 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), |
| 1159 HasOneSample(DependingOnPolicy(0, 0, 160))); |
| 1160 EXPECT_THAT(details->uma()->GetAllSamples( |
| 1161 "SiteIsolation.ProxyCountPerBrowsingInstance"), |
| 1162 HasOneSample(DependingOnPolicy(0, 0, 160))); |
1122 | 1163 |
1123 // Open a tab, which will be in a different BrowsingInstance. | 1164 // Open a tab, which will be in a different BrowsingInstance. |
1124 GURL abcd_url = embedded_test_server()->GetURL( | 1165 GURL abcd_url = embedded_test_server()->GetURL( |
1125 "a.com", "/cross_site_iframe_factory.html?a(b(c(d())))"); | 1166 "a.com", "/cross_site_iframe_factory.html?a(b(c(d())))"); |
1126 AddTabAtIndex(1, abcd_url, ui::PAGE_TRANSITION_TYPED); | 1167 AddTabAtIndex(1, abcd_url, ui::PAGE_TRANSITION_TYPED); |
1127 | 1168 |
1128 details = new TestMemoryDetails(); | 1169 details = new TestMemoryDetails(); |
1129 details->StartFetchAndWait(); | 1170 details->StartFetchAndWait(); |
1130 EXPECT_THAT( | 1171 EXPECT_THAT( |
1131 details->uma()->GetAllSamples( | 1172 details->uma()->GetAllSamples( |
1132 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | 1173 "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
1133 DependingOnPolicy(ElementsAre(Sample(1, 2)), ElementsAre(Sample(1, 2)), | 1174 DependingOnPolicy(ElementsAre(Sample(1, 2)), ElementsAre(Sample(1, 2)), |
1134 ElementsAre(Sample(4, 1), Sample(11, 1)))); | 1175 ElementsAre(Sample(4, 1), Sample(11, 1)))); |
| 1176 EXPECT_THAT(details->uma()->GetAllSamples("SiteIsolation.ProxyCount"), |
| 1177 HasOneSample(DependingOnPolicy(0, 0, 160))); |
| 1178 EXPECT_THAT( |
| 1179 details->uma()->GetAllSamples( |
| 1180 "SiteIsolation.ProxyCountPerBrowsingInstance"), |
| 1181 DependingOnPolicy(ElementsAre(Sample(0, 2)), ElementsAre(Sample(0, 2)), |
| 1182 ElementsAre(Sample(12, 1), Sample(160, 1)))); |
1135 } | 1183 } |
1136 | 1184 |
1137 // Verifies that the UMA counter for SiteInstances in a BrowsingInstance is | 1185 // Verifies that the UMA counter for SiteInstances in a BrowsingInstance is |
1138 // correct when extensions and web pages are mixed together. | 1186 // correct when extensions and web pages are mixed together. |
1139 IN_PROC_BROWSER_TEST_P( | 1187 IN_PROC_BROWSER_TEST_P( |
1140 SiteDetailsBrowserTest, | 1188 SiteDetailsBrowserTest, |
1141 VerifySiteInstanceCountInBrowsingInstanceWithExtensions) { | 1189 VerifySiteInstanceCountInBrowsingInstanceWithExtensions) { |
1142 // Open two a.com tabs (with cross site http iframes). IsolateExtensions mode | 1190 // 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 | 1191 // should have no effect so far, since there are no frames straddling the |
1144 // extension/web boundary. | 1192 // extension/web boundary. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1193 ElementsAre(Bucket(1, 1), Bucket(3, 1)), | 1241 ElementsAre(Bucket(1, 1), Bucket(3, 1)), |
1194 ElementsAre(Bucket(1, 1), Bucket(5, 1)))); | 1242 ElementsAre(Bucket(1, 1), Bucket(5, 1)))); |
1195 } | 1243 } |
1196 | 1244 |
1197 INSTANTIATE_TEST_CASE_P( | 1245 INSTANTIATE_TEST_CASE_P( |
1198 , | 1246 , |
1199 SiteDetailsBrowserTest, | 1247 SiteDetailsBrowserTest, |
1200 testing::Values("", | 1248 testing::Values("", |
1201 extensions::switches::kIsolateExtensions, | 1249 extensions::switches::kIsolateExtensions, |
1202 switches::kSitePerProcess)); | 1250 switches::kSitePerProcess)); |
OLD | NEW |