Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: chrome/browser/site_details_browsertest.cc

Issue 1495993002: Enforce all subframes to be in the same BrowsingInstance as the parent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes based on Charlie's review. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 EXPECT_THAT(details->uma()->GetAllSamples( 1128 EXPECT_THAT(details->uma()->GetAllSamples(
1129 "SiteIsolation.SiteInstancesPerBrowsingInstance"), 1129 "SiteIsolation.SiteInstancesPerBrowsingInstance"),
1130 ElementsAre(Bucket(1, 1))); 1130 ElementsAre(Bucket(1, 1)));
1131 } 1131 }
1132 1132
1133 // Load an extension without a background page, which will avoid creating a 1133 // Load an extension without a background page, which will avoid creating a
1134 // BrowsingInstance for it. 1134 // BrowsingInstance for it.
1135 const Extension* extension1 = CreateExtension("Extension One", false); 1135 const Extension* extension1 = CreateExtension("Extension One", false);
1136 1136
1137 // Navigate the tab's first iframe to a resource of the extension. The 1137 // Navigate the tab's first iframe to a resource of the extension. The
1138 // extension iframe will be put in a separate BrowsingInstance (see 1138 // extension iframe will be put in the same BrowsingInstance as it is part
1139 // https://crbug.com/522302) unless in the default process model. 1139 // of the frame tree.
1140 content::NavigateIframeToURL( 1140 content::NavigateIframeToURL(
1141 tab, "child-0", extension1->GetResourceURL("/blank_iframe.html")); 1141 tab, "child-0", extension1->GetResourceURL("/blank_iframe.html"));
1142 details = new TestMemoryDetails(); 1142 details = new TestMemoryDetails();
1143 details->StartFetchAndWait(); 1143 details->StartFetchAndWait();
1144 if (content::AreAllSitesIsolatedForTesting()) { 1144 if (content::AreAllSitesIsolatedForTesting()) {
1145 EXPECT_THAT(details->uma()->GetAllSamples( 1145 EXPECT_THAT(details->uma()->GetAllSamples(
1146 "SiteIsolation.SiteInstancesPerBrowsingInstance"), 1146 "SiteIsolation.SiteInstancesPerBrowsingInstance"),
1147 ElementsAre(Bucket(1, 1), Bucket(4, 1))); 1147 ElementsAre(Bucket(5, 1)));
1148 } else if (extensions::IsIsolateExtensionsEnabled()) { 1148 } else if (extensions::IsIsolateExtensionsEnabled()) {
1149 EXPECT_THAT(details->uma()->GetAllSamples( 1149 EXPECT_THAT(details->uma()->GetAllSamples(
1150 "SiteIsolation.SiteInstancesPerBrowsingInstance"), 1150 "SiteIsolation.SiteInstancesPerBrowsingInstance"),
1151 ElementsAre(Bucket(1, 2))); 1151 ElementsAre(Bucket(1, 2)));
1152 } else { 1152 } else {
1153 EXPECT_THAT(details->uma()->GetAllSamples( 1153 EXPECT_THAT(details->uma()->GetAllSamples(
1154 "SiteIsolation.SiteInstancesPerBrowsingInstance"), 1154 "SiteIsolation.SiteInstancesPerBrowsingInstance"),
1155 ElementsAre(Bucket(1, 1))); 1155 ElementsAre(Bucket(1, 1)));
1156 } 1156 }
1157 1157
1158 // Now load an extension with a background page. This will result in a 1158 // Now load an extension with a background page. This will result in a
1159 // BrowsingInstance for the background page. 1159 // BrowsingInstance for the background page.
1160 const Extension* extension2 = CreateExtension("Extension One", true); 1160 const Extension* extension2 = CreateExtension("Extension One", true);
1161 details = new TestMemoryDetails(); 1161 details = new TestMemoryDetails();
1162 details->StartFetchAndWait(); 1162 details->StartFetchAndWait();
1163 if (content::AreAllSitesIsolatedForTesting()) { 1163 if (content::AreAllSitesIsolatedForTesting()) {
1164 EXPECT_THAT(details->uma()->GetAllSamples( 1164 EXPECT_THAT(details->uma()->GetAllSamples(
1165 "SiteIsolation.SiteInstancesPerBrowsingInstance"), 1165 "SiteIsolation.SiteInstancesPerBrowsingInstance"),
1166 ElementsAre(Bucket(1, 2), Bucket(4, 1))); 1166 ElementsAre(Bucket(1, 1), Bucket(5, 1)));
1167 } else if (extensions::IsIsolateExtensionsEnabled()) { 1167 } else if (extensions::IsIsolateExtensionsEnabled()) {
1168 EXPECT_THAT(details->uma()->GetAllSamples( 1168 EXPECT_THAT(details->uma()->GetAllSamples(
1169 "SiteIsolation.SiteInstancesPerBrowsingInstance"), 1169 "SiteIsolation.SiteInstancesPerBrowsingInstance"),
1170 ElementsAre(Bucket(1, 3))); 1170 ElementsAre(Bucket(1, 3)));
1171 } else { 1171 } else {
1172 EXPECT_THAT(details->uma()->GetAllSamples( 1172 EXPECT_THAT(details->uma()->GetAllSamples(
1173 "SiteIsolation.SiteInstancesPerBrowsingInstance"), 1173 "SiteIsolation.SiteInstancesPerBrowsingInstance"),
1174 ElementsAre(Bucket(1, 2))); 1174 ElementsAre(Bucket(1, 2)));
1175 } 1175 }
1176 1176
1177 // Navigate the second iframe of the tab to the second extension. This will 1177 // Navigate the second iframe of the tab to the second extension. It should
1178 // create a new BrowsingInstance again due to https://crbug.com/522302 for 1178 // stay in the same BrowsingInstance as the page.
1179 // --site-per-process and --isolate-extensions.
1180 content::NavigateIframeToURL( 1179 content::NavigateIframeToURL(
1181 tab, "child-1", extension2->GetResourceURL("/blank_iframe.html")); 1180 tab, "child-1", extension2->GetResourceURL("/blank_iframe.html"));
1182 details = new TestMemoryDetails(); 1181 details = new TestMemoryDetails();
1183 details->StartFetchAndWait(); 1182 details->StartFetchAndWait();
1184 if (content::AreAllSitesIsolatedForTesting()) { 1183 if (content::AreAllSitesIsolatedForTesting()) {
1185 EXPECT_THAT(details->uma()->GetAllSamples( 1184 EXPECT_THAT(details->uma()->GetAllSamples(
1186 "SiteIsolation.SiteInstancesPerBrowsingInstance"), 1185 "SiteIsolation.SiteInstancesPerBrowsingInstance"),
1187 ElementsAre(Bucket(1, 3), Bucket(3, 1))); 1186 ElementsAre(Bucket(1, 1), Bucket(5, 1)));
1188 } else if (extensions::IsIsolateExtensionsEnabled()) { 1187 } else if (extensions::IsIsolateExtensionsEnabled()) {
1189 EXPECT_THAT(details->uma()->GetAllSamples( 1188 EXPECT_THAT(details->uma()->GetAllSamples(
1190 "SiteIsolation.SiteInstancesPerBrowsingInstance"), 1189 "SiteIsolation.SiteInstancesPerBrowsingInstance"),
1191 ElementsAre(Bucket(1, 4))); 1190 ElementsAre(Bucket(1, 4)));
1192 } else { 1191 } else {
1193 EXPECT_THAT(details->uma()->GetAllSamples( 1192 EXPECT_THAT(details->uma()->GetAllSamples(
1194 "SiteIsolation.SiteInstancesPerBrowsingInstance"), 1193 "SiteIsolation.SiteInstancesPerBrowsingInstance"),
1195 ElementsAre(Bucket(1, 2))); 1194 ElementsAre(Bucket(1, 2)));
1196 } 1195 }
1197 } 1196 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698