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

Side by Side Diff: content/browser/frame_host/navigation_controller_impl_browsertest.cc

Issue 1208143002: Move existing kSitePerProcess checks to a policy-oracle object (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@swapped_out_cmdline_checks
Patch Set: Attempt to fix compile. Created 5 years, 4 months 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h"
7 #include "base/strings/stringprintf.h" 6 #include "base/strings/stringprintf.h"
8 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
9 #include "content/browser/frame_host/frame_navigation_entry.h" 8 #include "content/browser/frame_host/frame_navigation_entry.h"
10 #include "content/browser/frame_host/frame_tree.h" 9 #include "content/browser/frame_host/frame_tree.h"
11 #include "content/browser/frame_host/navigation_controller_impl.h" 10 #include "content/browser/frame_host/navigation_controller_impl.h"
12 #include "content/browser/frame_host/navigation_entry_impl.h" 11 #include "content/browser/frame_host/navigation_entry_impl.h"
13 #include "content/browser/web_contents/web_contents_impl.h" 12 #include "content/browser/web_contents/web_contents_impl.h"
13 #include "content/common/site_isolation_policy.h"
14 #include "content/public/browser/render_view_host.h" 14 #include "content/public/browser/render_view_host.h"
15 #include "content/public/browser/resource_controller.h" 15 #include "content/public/browser/resource_controller.h"
16 #include "content/public/browser/resource_dispatcher_host.h" 16 #include "content/public/browser/resource_dispatcher_host.h"
17 #include "content/public/browser/resource_dispatcher_host_delegate.h" 17 #include "content/public/browser/resource_dispatcher_host_delegate.h"
18 #include "content/public/browser/resource_throttle.h" 18 #include "content/public/browser/resource_throttle.h"
19 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
20 #include "content/public/browser/web_contents_observer.h" 20 #include "content/public/browser/web_contents_observer.h"
21 #include "content/public/common/bindings_policy.h" 21 #include "content/public/common/bindings_policy.h"
22 #include "content/public/common/content_switches.h"
23 #include "content/public/common/url_constants.h" 22 #include "content/public/common/url_constants.h"
24 #include "content/public/test/browser_test_utils.h" 23 #include "content/public/test/browser_test_utils.h"
25 #include "content/public/test/content_browser_test.h" 24 #include "content/public/test/content_browser_test.h"
26 #include "content/public/test/content_browser_test_utils.h" 25 #include "content/public/test/content_browser_test_utils.h"
27 #include "content/public/test/test_navigation_observer.h" 26 #include "content/public/test/test_navigation_observer.h"
28 #include "content/public/test/test_utils.h" 27 #include "content/public/test/test_utils.h"
29 #include "content/shell/browser/shell.h" 28 #include "content/shell/browser/shell.h"
30 #include "content/test/content_browser_test_utils_internal.h" 29 #include "content/test/content_browser_test_utils_internal.h"
31 #include "net/dns/mock_host_resolver.h" 30 #include "net/dns/mock_host_resolver.h"
32 #include "net/test/embedded_test_server/embedded_test_server.h" 31 #include "net/test/embedded_test_server/embedded_test_server.h"
(...skipping 24 matching lines...) Expand all
57 56
58 // Use NavigateFrameToURL to go cross-site in the subframe. 57 // Use NavigateFrameToURL to go cross-site in the subframe.
59 GURL foo_url(embedded_test_server()->GetURL( 58 GURL foo_url(embedded_test_server()->GetURL(
60 "foo.com", "/navigation_controller/simple_page_1.html")); 59 "foo.com", "/navigation_controller/simple_page_1.html"));
61 NavigateFrameToURL(root->child_at(0), foo_url); 60 NavigateFrameToURL(root->child_at(0), foo_url);
62 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); 61 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
63 62
64 // We should only have swapped processes in --site-per-process. 63 // We should only have swapped processes in --site-per-process.
65 bool cross_process = root->current_frame_host()->GetProcess() != 64 bool cross_process = root->current_frame_host()->GetProcess() !=
66 root->child_at(0)->current_frame_host()->GetProcess(); 65 root->child_at(0)->current_frame_host()->GetProcess();
67 EXPECT_EQ(base::CommandLine::ForCurrentProcess()->HasSwitch( 66 EXPECT_EQ(AreAllSitesIsolatedForTesting(), cross_process);
68 switches::kSitePerProcess),
69 cross_process);
70 } 67 }
71 68
72 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, LoadDataWithBaseURL) { 69 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, LoadDataWithBaseURL) {
73 const GURL base_url("http://baseurl"); 70 const GURL base_url("http://baseurl");
74 const GURL history_url("http://historyurl"); 71 const GURL history_url("http://historyurl");
75 const std::string data = "<html><body>foo</body></html>"; 72 const std::string data = "<html><body>foo</body></html>";
76 73
77 const NavigationController& controller = 74 const NavigationController& controller =
78 shell()->web_contents()->GetController(); 75 shell()->web_contents()->GetController();
79 // Load data. Blocks until it is done. 76 // Load data. Blocks until it is done.
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); 1149 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type());
1153 } 1150 }
1154 1151
1155 // Check last committed NavigationEntry. 1152 // Check last committed NavigationEntry.
1156 EXPECT_EQ(1, controller.GetEntryCount()); 1153 EXPECT_EQ(1, controller.GetEntryCount());
1157 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); 1154 NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
1158 EXPECT_EQ(main_url, entry->GetURL()); 1155 EXPECT_EQ(main_url, entry->GetURL());
1159 FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get(); 1156 FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get();
1160 EXPECT_EQ(main_url, root_entry->url()); 1157 EXPECT_EQ(main_url, root_entry->url());
1161 1158
1162 // Verify subframe entries if we're in --site-per-process mode. 1159 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
1163 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1160 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1164 switches::kSitePerProcess)) {
1165 // The entry should now have one blank subframe FrameNavigationEntry, but 1161 // The entry should now have one blank subframe FrameNavigationEntry, but
1166 // this does not count as committing a real load. 1162 // this does not count as committing a real load.
1167 ASSERT_EQ(1U, entry->root_node()->children.size()); 1163 ASSERT_EQ(1U, entry->root_node()->children.size());
1168 FrameNavigationEntry* frame_entry = 1164 FrameNavigationEntry* frame_entry =
1169 entry->root_node()->children[0]->frame_entry.get(); 1165 entry->root_node()->children[0]->frame_entry.get();
1170 EXPECT_EQ(about_blank_url, frame_entry->url()); 1166 EXPECT_EQ(about_blank_url, frame_entry->url());
1171 } else { 1167 } else {
1172 // There are no subframe FrameNavigationEntries by default. 1168 // There are no subframe FrameNavigationEntries by default.
1173 EXPECT_EQ(0U, entry->root_node()->children.size()); 1169 EXPECT_EQ(0U, entry->root_node()->children.size());
1174 } 1170 }
1175 EXPECT_FALSE(root->child_at(0)->has_committed_real_load()); 1171 EXPECT_FALSE(root->child_at(0)->has_committed_real_load());
1176 1172
1177 // 1a. A nested iframe with no URL should also create a subframe entry but not 1173 // 1a. A nested iframe with no URL should also create a subframe entry but not
1178 // count as a real load. 1174 // count as a real load.
1179 { 1175 {
1180 LoadCommittedCapturer capturer(shell()->web_contents()); 1176 LoadCommittedCapturer capturer(shell()->web_contents());
1181 std::string script = "var iframe = document.createElement('iframe');" 1177 std::string script = "var iframe = document.createElement('iframe');"
1182 "document.body.appendChild(iframe);"; 1178 "document.body.appendChild(iframe);";
1183 EXPECT_TRUE(content::ExecuteScript(root->child_at(0)->current_frame_host(), 1179 EXPECT_TRUE(content::ExecuteScript(root->child_at(0)->current_frame_host(),
1184 script)); 1180 script));
1185 capturer.Wait(); 1181 capturer.Wait();
1186 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); 1182 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type());
1187 } 1183 }
1188 1184
1189 // Verify subframe entries if we're in --site-per-process mode. 1185 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
1190 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1186 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1191 switches::kSitePerProcess)) {
1192 // The nested entry should have one blank subframe FrameNavigationEntry, but 1187 // The nested entry should have one blank subframe FrameNavigationEntry, but
1193 // this does not count as committing a real load. 1188 // this does not count as committing a real load.
1194 ASSERT_EQ(1U, entry->root_node()->children[0]->children.size()); 1189 ASSERT_EQ(1U, entry->root_node()->children[0]->children.size());
1195 FrameNavigationEntry* frame_entry = 1190 FrameNavigationEntry* frame_entry =
1196 entry->root_node()->children[0]->children[0]->frame_entry.get(); 1191 entry->root_node()->children[0]->children[0]->frame_entry.get();
1197 EXPECT_EQ(about_blank_url, frame_entry->url()); 1192 EXPECT_EQ(about_blank_url, frame_entry->url());
1198 } else { 1193 } else {
1199 // There are no subframe FrameNavigationEntries by default. 1194 // There are no subframe FrameNavigationEntries by default.
1200 EXPECT_EQ(0U, entry->root_node()->children.size()); 1195 EXPECT_EQ(0U, entry->root_node()->children.size());
1201 } 1196 }
1202 EXPECT_FALSE(root->child_at(0)->child_at(0)->has_committed_real_load()); 1197 EXPECT_FALSE(root->child_at(0)->child_at(0)->has_committed_real_load());
1203 1198
1204 // 2. Create another iframe with an explicit about:blank URL. 1199 // 2. Create another iframe with an explicit about:blank URL.
1205 { 1200 {
1206 LoadCommittedCapturer capturer(shell()->web_contents()); 1201 LoadCommittedCapturer capturer(shell()->web_contents());
1207 std::string script = "var iframe = document.createElement('iframe');" 1202 std::string script = "var iframe = document.createElement('iframe');"
1208 "iframe.src = 'about:blank';" 1203 "iframe.src = 'about:blank';"
1209 "document.body.appendChild(iframe);"; 1204 "document.body.appendChild(iframe);";
1210 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); 1205 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script));
1211 capturer.Wait(); 1206 capturer.Wait();
1212 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); 1207 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type());
1213 } 1208 }
1214 1209
1215 // Check last committed NavigationEntry. 1210 // Check last committed NavigationEntry.
1216 EXPECT_EQ(1, controller.GetEntryCount()); 1211 EXPECT_EQ(1, controller.GetEntryCount());
1217 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); 1212 EXPECT_EQ(entry, controller.GetLastCommittedEntry());
1218 1213
1219 // Verify subframe entries if we're in --site-per-process mode. 1214 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
1220 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1215 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1221 switches::kSitePerProcess)) {
1222 // The new entry should have one blank subframe FrameNavigationEntry, but 1216 // The new entry should have one blank subframe FrameNavigationEntry, but
1223 // this does not count as committing a real load. 1217 // this does not count as committing a real load.
1224 ASSERT_EQ(2U, entry->root_node()->children.size()); 1218 ASSERT_EQ(2U, entry->root_node()->children.size());
1225 FrameNavigationEntry* frame_entry = 1219 FrameNavigationEntry* frame_entry =
1226 entry->root_node()->children[1]->frame_entry.get(); 1220 entry->root_node()->children[1]->frame_entry.get();
1227 EXPECT_EQ(about_blank_url, frame_entry->url()); 1221 EXPECT_EQ(about_blank_url, frame_entry->url());
1228 } else { 1222 } else {
1229 // There are no subframe FrameNavigationEntries by default. 1223 // There are no subframe FrameNavigationEntries by default.
1230 EXPECT_EQ(0U, entry->root_node()->children.size()); 1224 EXPECT_EQ(0U, entry->root_node()->children.size());
1231 } 1225 }
(...skipping 10 matching lines...) Expand all
1242 script)); 1236 script));
1243 capturer.Wait(); 1237 capturer.Wait();
1244 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); 1238 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type());
1245 } 1239 }
1246 1240
1247 // Check last committed NavigationEntry. It should have replaced the previous 1241 // Check last committed NavigationEntry. It should have replaced the previous
1248 // frame entry in the original NavigationEntry. 1242 // frame entry in the original NavigationEntry.
1249 EXPECT_EQ(1, controller.GetEntryCount()); 1243 EXPECT_EQ(1, controller.GetEntryCount());
1250 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); 1244 EXPECT_EQ(entry, controller.GetLastCommittedEntry());
1251 1245
1252 // Verify subframe entries if we're in --site-per-process mode. 1246 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
1253 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1247 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1254 switches::kSitePerProcess)) {
1255 // The entry should still have one nested subframe FrameNavigationEntry. 1248 // The entry should still have one nested subframe FrameNavigationEntry.
1256 ASSERT_EQ(1U, entry->root_node()->children[0]->children.size()); 1249 ASSERT_EQ(1U, entry->root_node()->children[0]->children.size());
1257 FrameNavigationEntry* frame_entry = 1250 FrameNavigationEntry* frame_entry =
1258 entry->root_node()->children[0]->children[0]->frame_entry.get(); 1251 entry->root_node()->children[0]->children[0]->frame_entry.get();
1259 EXPECT_EQ(frame_url, frame_entry->url()); 1252 EXPECT_EQ(frame_url, frame_entry->url());
1260 } else { 1253 } else {
1261 // There are no subframe FrameNavigationEntries by default. 1254 // There are no subframe FrameNavigationEntries by default.
1262 EXPECT_EQ(0U, entry->root_node()->children.size()); 1255 EXPECT_EQ(0U, entry->root_node()->children.size());
1263 } 1256 }
1264 EXPECT_FALSE(root->child_at(0)->has_committed_real_load()); 1257 EXPECT_FALSE(root->child_at(0)->has_committed_real_load());
1265 EXPECT_TRUE(root->child_at(0)->child_at(0)->has_committed_real_load()); 1258 EXPECT_TRUE(root->child_at(0)->child_at(0)->has_committed_real_load());
1266 EXPECT_FALSE(root->child_at(1)->has_committed_real_load()); 1259 EXPECT_FALSE(root->child_at(1)->has_committed_real_load());
1267 1260
1268 // 4. A real cross-site navigation in the second iframe should be AUTO. 1261 // 4. A real cross-site navigation in the second iframe should be AUTO.
1269 GURL foo_url(embedded_test_server()->GetURL( 1262 GURL foo_url(embedded_test_server()->GetURL(
1270 "foo.com", "/navigation_controller/simple_page_2.html")); 1263 "foo.com", "/navigation_controller/simple_page_2.html"));
1271 { 1264 {
1272 LoadCommittedCapturer capturer(root->child_at(1)); 1265 LoadCommittedCapturer capturer(root->child_at(1));
1273 std::string script = "var frames = document.getElementsByTagName('iframe');" 1266 std::string script = "var frames = document.getElementsByTagName('iframe');"
1274 "frames[1].src = '" + foo_url.spec() + "';"; 1267 "frames[1].src = '" + foo_url.spec() + "';";
1275 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); 1268 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script));
1276 capturer.Wait(); 1269 capturer.Wait();
1277 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); 1270 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type());
1278 } 1271 }
1279 1272
1280 // Check last committed NavigationEntry. 1273 // Check last committed NavigationEntry.
1281 EXPECT_EQ(1, controller.GetEntryCount()); 1274 EXPECT_EQ(1, controller.GetEntryCount());
1282 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); 1275 EXPECT_EQ(entry, controller.GetLastCommittedEntry());
1283 1276
1284 // Verify subframe entries if we're in --site-per-process mode. 1277 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
1285 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1278 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1286 switches::kSitePerProcess)) {
1287 // The entry should still have two subframe FrameNavigationEntries. 1279 // The entry should still have two subframe FrameNavigationEntries.
1288 ASSERT_EQ(2U, entry->root_node()->children.size()); 1280 ASSERT_EQ(2U, entry->root_node()->children.size());
1289 FrameNavigationEntry* frame_entry = 1281 FrameNavigationEntry* frame_entry =
1290 entry->root_node()->children[1]->frame_entry.get(); 1282 entry->root_node()->children[1]->frame_entry.get();
1291 EXPECT_EQ(foo_url, frame_entry->url()); 1283 EXPECT_EQ(foo_url, frame_entry->url());
1292 } else { 1284 } else {
1293 // There are no subframe FrameNavigationEntries by default. 1285 // There are no subframe FrameNavigationEntries by default.
1294 EXPECT_EQ(0U, entry->root_node()->children.size()); 1286 EXPECT_EQ(0U, entry->root_node()->children.size());
1295 } 1287 }
1296 EXPECT_FALSE(root->child_at(0)->has_committed_real_load()); 1288 EXPECT_FALSE(root->child_at(0)->has_committed_real_load());
(...skipping 11 matching lines...) Expand all
1308 script)); 1300 script));
1309 capturer.Wait(); 1301 capturer.Wait();
1310 EXPECT_EQ(ui::PAGE_TRANSITION_MANUAL_SUBFRAME, capturer.transition_type()); 1302 EXPECT_EQ(ui::PAGE_TRANSITION_MANUAL_SUBFRAME, capturer.transition_type());
1311 } 1303 }
1312 1304
1313 // This should have created a new NavigationEntry. 1305 // This should have created a new NavigationEntry.
1314 EXPECT_EQ(2, controller.GetEntryCount()); 1306 EXPECT_EQ(2, controller.GetEntryCount());
1315 EXPECT_NE(entry, controller.GetLastCommittedEntry()); 1307 EXPECT_NE(entry, controller.GetLastCommittedEntry());
1316 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); 1308 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry();
1317 1309
1318 // Verify subframe entries if we're in --site-per-process mode. 1310 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
1319 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1311 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1320 switches::kSitePerProcess)) {
1321 ASSERT_EQ(2U, entry->root_node()->children.size()); 1312 ASSERT_EQ(2U, entry->root_node()->children.size());
1322 FrameNavigationEntry* frame_entry = 1313 FrameNavigationEntry* frame_entry =
1323 entry2->root_node()->children[0]->children[0]->frame_entry.get(); 1314 entry2->root_node()->children[0]->children[0]->frame_entry.get();
1324 EXPECT_EQ(about_blank_url, frame_entry->url()); 1315 EXPECT_EQ(about_blank_url, frame_entry->url());
1325 } else { 1316 } else {
1326 // There are no subframe FrameNavigationEntries by default. 1317 // There are no subframe FrameNavigationEntries by default.
1327 EXPECT_EQ(0U, entry->root_node()->children.size()); 1318 EXPECT_EQ(0U, entry->root_node()->children.size());
1328 } 1319 }
1329 EXPECT_FALSE(root->child_at(0)->has_committed_real_load()); 1320 EXPECT_FALSE(root->child_at(0)->has_committed_real_load());
1330 EXPECT_TRUE(root->child_at(0)->child_at(0)->has_committed_real_load()); 1321 EXPECT_TRUE(root->child_at(0)->child_at(0)->has_committed_real_load());
1331 EXPECT_TRUE(root->child_at(1)->has_committed_real_load()); 1322 EXPECT_TRUE(root->child_at(1)->has_committed_real_load());
1332 1323
1333 // Check the end result of the frame tree. 1324 // Check the end result of the frame tree.
1334 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1325 if (AreAllSitesIsolatedForTesting()) {
1335 switches::kSitePerProcess)) {
1336 FrameTreeVisualizer visualizer; 1326 FrameTreeVisualizer visualizer;
1337 EXPECT_EQ( 1327 EXPECT_EQ(
1338 " Site A ------------ proxies for B\n" 1328 " Site A ------------ proxies for B\n"
1339 " |--Site A ------- proxies for B\n" 1329 " |--Site A ------- proxies for B\n"
1340 " | +--Site A -- proxies for B\n" 1330 " | +--Site A -- proxies for B\n"
1341 " +--Site B ------- proxies for A\n" 1331 " +--Site B ------- proxies for A\n"
1342 "Where A = http://127.0.0.1/\n" 1332 "Where A = http://127.0.0.1/\n"
1343 " B = http://foo.com/", 1333 " B = http://foo.com/",
1344 visualizer.DepictFrameTree(root)); 1334 visualizer.DepictFrameTree(root));
1345 } 1335 }
(...skipping 28 matching lines...) Expand all
1374 } 1364 }
1375 1365
1376 // Check last committed NavigationEntry. 1366 // Check last committed NavigationEntry.
1377 EXPECT_EQ(1, controller.GetEntryCount()); 1367 EXPECT_EQ(1, controller.GetEntryCount());
1378 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); 1368 NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
1379 EXPECT_EQ(main_url, entry->GetURL()); 1369 EXPECT_EQ(main_url, entry->GetURL());
1380 FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get(); 1370 FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get();
1381 EXPECT_EQ(main_url, root_entry->url()); 1371 EXPECT_EQ(main_url, root_entry->url());
1382 EXPECT_FALSE(controller.GetPendingEntry()); 1372 EXPECT_FALSE(controller.GetPendingEntry());
1383 1373
1384 // Verify subframe entries if we're in --site-per-process mode. 1374 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
1385 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1375 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1386 switches::kSitePerProcess)) {
1387 // The entry should now have a subframe FrameNavigationEntry. 1376 // The entry should now have a subframe FrameNavigationEntry.
1388 ASSERT_EQ(1U, entry->root_node()->children.size()); 1377 ASSERT_EQ(1U, entry->root_node()->children.size());
1389 FrameNavigationEntry* frame_entry = 1378 FrameNavigationEntry* frame_entry =
1390 entry->root_node()->children[0]->frame_entry.get(); 1379 entry->root_node()->children[0]->frame_entry.get();
1391 EXPECT_EQ(frame_url, frame_entry->url()); 1380 EXPECT_EQ(frame_url, frame_entry->url());
1392 EXPECT_TRUE(root->child_at(0)->has_committed_real_load()); 1381 EXPECT_TRUE(root->child_at(0)->has_committed_real_load());
1393 } else { 1382 } else {
1394 // There are no subframe FrameNavigationEntries by default. 1383 // There are no subframe FrameNavigationEntries by default.
1395 EXPECT_EQ(0U, entry->root_node()->children.size()); 1384 EXPECT_EQ(0U, entry->root_node()->children.size());
1396 } 1385 }
(...skipping 12 matching lines...) Expand all
1409 } 1398 }
1410 1399
1411 // The last committed NavigationEntry shouldn't have changed. 1400 // The last committed NavigationEntry shouldn't have changed.
1412 EXPECT_EQ(1, controller.GetEntryCount()); 1401 EXPECT_EQ(1, controller.GetEntryCount());
1413 entry = controller.GetLastCommittedEntry(); 1402 entry = controller.GetLastCommittedEntry();
1414 EXPECT_EQ(main_url, entry->GetURL()); 1403 EXPECT_EQ(main_url, entry->GetURL());
1415 root_entry = entry->root_node()->frame_entry.get(); 1404 root_entry = entry->root_node()->frame_entry.get();
1416 EXPECT_EQ(main_url, root_entry->url()); 1405 EXPECT_EQ(main_url, root_entry->url());
1417 EXPECT_FALSE(controller.GetPendingEntry()); 1406 EXPECT_FALSE(controller.GetPendingEntry());
1418 1407
1419 // Verify subframe entries if we're in --site-per-process mode. 1408 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
1420 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1409 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1421 switches::kSitePerProcess)) {
1422 // The entry should now have 2 subframe FrameNavigationEntries. 1410 // The entry should now have 2 subframe FrameNavigationEntries.
1423 ASSERT_EQ(2U, entry->root_node()->children.size()); 1411 ASSERT_EQ(2U, entry->root_node()->children.size());
1424 FrameNavigationEntry* frame_entry = 1412 FrameNavigationEntry* frame_entry =
1425 entry->root_node()->children[1]->frame_entry.get(); 1413 entry->root_node()->children[1]->frame_entry.get();
1426 EXPECT_EQ(foo_url, frame_entry->url()); 1414 EXPECT_EQ(foo_url, frame_entry->url());
1427 EXPECT_TRUE(root->child_at(1)->has_committed_real_load()); 1415 EXPECT_TRUE(root->child_at(1)->has_committed_real_load());
1428 } else { 1416 } else {
1429 // There are no subframe FrameNavigationEntries by default. 1417 // There are no subframe FrameNavigationEntries by default.
1430 EXPECT_EQ(0U, entry->root_node()->children.size()); 1418 EXPECT_EQ(0U, entry->root_node()->children.size());
1431 } 1419 }
(...skipping 10 matching lines...) Expand all
1442 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); 1430 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type());
1443 } 1431 }
1444 1432
1445 // The last committed NavigationEntry shouldn't have changed. 1433 // The last committed NavigationEntry shouldn't have changed.
1446 EXPECT_EQ(1, controller.GetEntryCount()); 1434 EXPECT_EQ(1, controller.GetEntryCount());
1447 entry = controller.GetLastCommittedEntry(); 1435 entry = controller.GetLastCommittedEntry();
1448 EXPECT_EQ(main_url, entry->GetURL()); 1436 EXPECT_EQ(main_url, entry->GetURL());
1449 root_entry = entry->root_node()->frame_entry.get(); 1437 root_entry = entry->root_node()->frame_entry.get();
1450 EXPECT_EQ(main_url, root_entry->url()); 1438 EXPECT_EQ(main_url, root_entry->url());
1451 1439
1452 // Verify subframe entries if we're in --site-per-process mode. 1440 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
1453 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1441 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1454 switches::kSitePerProcess)) {
1455 // The entry should now have 2 subframe FrameNavigationEntries. 1442 // The entry should now have 2 subframe FrameNavigationEntries.
1456 ASSERT_EQ(2U, entry->root_node()->children.size()); 1443 ASSERT_EQ(2U, entry->root_node()->children.size());
1457 ASSERT_EQ(1U, entry->root_node()->children[1]->children.size()); 1444 ASSERT_EQ(1U, entry->root_node()->children[1]->children.size());
1458 FrameNavigationEntry* frame_entry = 1445 FrameNavigationEntry* frame_entry =
1459 entry->root_node()->children[1]->children[0]->frame_entry.get(); 1446 entry->root_node()->children[1]->children[0]->frame_entry.get();
1460 EXPECT_EQ(foo_url, frame_entry->url()); 1447 EXPECT_EQ(foo_url, frame_entry->url());
1461 } else { 1448 } else {
1462 // There are no subframe FrameNavigationEntries by default. 1449 // There are no subframe FrameNavigationEntries by default.
1463 EXPECT_EQ(0U, entry->root_node()->children.size()); 1450 EXPECT_EQ(0U, entry->root_node()->children.size());
1464 } 1451 }
(...skipping 10 matching lines...) Expand all
1475 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); 1462 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type());
1476 } 1463 }
1477 1464
1478 // The last committed NavigationEntry shouldn't have changed. 1465 // The last committed NavigationEntry shouldn't have changed.
1479 EXPECT_EQ(1, controller.GetEntryCount()); 1466 EXPECT_EQ(1, controller.GetEntryCount());
1480 entry = controller.GetLastCommittedEntry(); 1467 entry = controller.GetLastCommittedEntry();
1481 EXPECT_EQ(main_url, entry->GetURL()); 1468 EXPECT_EQ(main_url, entry->GetURL());
1482 root_entry = entry->root_node()->frame_entry.get(); 1469 root_entry = entry->root_node()->frame_entry.get();
1483 EXPECT_EQ(main_url, root_entry->url()); 1470 EXPECT_EQ(main_url, root_entry->url());
1484 1471
1485 // Verify subframe entries if we're in --site-per-process mode. 1472 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
1486 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1473 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1487 switches::kSitePerProcess)) {
1488 // The entry should now have 3 subframe FrameNavigationEntries. 1474 // The entry should now have 3 subframe FrameNavigationEntries.
1489 ASSERT_EQ(3U, entry->root_node()->children.size()); 1475 ASSERT_EQ(3U, entry->root_node()->children.size());
1490 FrameNavigationEntry* frame_entry = 1476 FrameNavigationEntry* frame_entry =
1491 entry->root_node()->children[2]->frame_entry.get(); 1477 entry->root_node()->children[2]->frame_entry.get();
1492 EXPECT_EQ(foo_url, frame_entry->url()); 1478 EXPECT_EQ(foo_url, frame_entry->url());
1493 } else { 1479 } else {
1494 // There are no subframe FrameNavigationEntries by default. 1480 // There are no subframe FrameNavigationEntries by default.
1495 EXPECT_EQ(0U, entry->root_node()->children.size()); 1481 EXPECT_EQ(0U, entry->root_node()->children.size());
1496 } 1482 }
1497 1483
1498 // 5. Create a nested iframe on the original site (A-B-A). 1484 // 5. Create a nested iframe on the original site (A-B-A).
1499 { 1485 {
1500 LoadCommittedCapturer capturer(shell()->web_contents()); 1486 LoadCommittedCapturer capturer(shell()->web_contents());
1501 std::string script = "var iframe = document.createElement('iframe');" 1487 std::string script = "var iframe = document.createElement('iframe');"
1502 "iframe.src = '" + frame_url.spec() + "';" 1488 "iframe.src = '" + frame_url.spec() + "';"
1503 "document.body.appendChild(iframe);"; 1489 "document.body.appendChild(iframe);";
1504 FrameTreeNode* child = root->child_at(2); 1490 FrameTreeNode* child = root->child_at(2);
1505 EXPECT_TRUE(content::ExecuteScript(child->current_frame_host(), script)); 1491 EXPECT_TRUE(content::ExecuteScript(child->current_frame_host(), script));
1506 capturer.Wait(); 1492 capturer.Wait();
1507 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); 1493 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type());
1508 } 1494 }
1509 1495
1510 // The last committed NavigationEntry shouldn't have changed. 1496 // The last committed NavigationEntry shouldn't have changed.
1511 EXPECT_EQ(1, controller.GetEntryCount()); 1497 EXPECT_EQ(1, controller.GetEntryCount());
1512 entry = controller.GetLastCommittedEntry(); 1498 entry = controller.GetLastCommittedEntry();
1513 EXPECT_EQ(main_url, entry->GetURL()); 1499 EXPECT_EQ(main_url, entry->GetURL());
1514 root_entry = entry->root_node()->frame_entry.get(); 1500 root_entry = entry->root_node()->frame_entry.get();
1515 EXPECT_EQ(main_url, root_entry->url()); 1501 EXPECT_EQ(main_url, root_entry->url());
1516 1502
1517 // Verify subframe entries if we're in --site-per-process mode. 1503 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
1518 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1504 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1519 switches::kSitePerProcess)) {
1520 // There should be a corresponding FrameNavigationEntry. 1505 // There should be a corresponding FrameNavigationEntry.
1521 ASSERT_EQ(1U, entry->root_node()->children[2]->children.size()); 1506 ASSERT_EQ(1U, entry->root_node()->children[2]->children.size());
1522 FrameNavigationEntry* frame_entry = 1507 FrameNavigationEntry* frame_entry =
1523 entry->root_node()->children[2]->children[0]->frame_entry.get(); 1508 entry->root_node()->children[2]->children[0]->frame_entry.get();
1524 EXPECT_EQ(frame_url, frame_entry->url()); 1509 EXPECT_EQ(frame_url, frame_entry->url());
1525 } else { 1510 } else {
1526 // There are no subframe FrameNavigationEntries by default. 1511 // There are no subframe FrameNavigationEntries by default.
1527 EXPECT_EQ(0U, entry->root_node()->children.size()); 1512 EXPECT_EQ(0U, entry->root_node()->children.size());
1528 } 1513 }
1529 1514
1530 // Check the end result of the frame tree. 1515 // Check the end result of the frame tree.
1531 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1516 if (AreAllSitesIsolatedForTesting()) {
1532 switches::kSitePerProcess)) {
1533 FrameTreeVisualizer visualizer; 1517 FrameTreeVisualizer visualizer;
1534 EXPECT_EQ( 1518 EXPECT_EQ(
1535 " Site A ------------ proxies for B\n" 1519 " Site A ------------ proxies for B\n"
1536 " |--Site A ------- proxies for B\n" 1520 " |--Site A ------- proxies for B\n"
1537 " |--Site B ------- proxies for A\n" 1521 " |--Site B ------- proxies for A\n"
1538 " | +--Site B -- proxies for A\n" 1522 " | +--Site B -- proxies for A\n"
1539 " +--Site B ------- proxies for A\n" 1523 " +--Site B ------- proxies for A\n"
1540 " +--Site A -- proxies for B\n" 1524 " +--Site A -- proxies for B\n"
1541 "Where A = http://127.0.0.1/\n" 1525 "Where A = http://127.0.0.1/\n"
1542 " B = http://foo.com/", 1526 " B = http://foo.com/",
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 1569
1586 // We should have created a new NavigationEntry with the same main frame URL. 1570 // We should have created a new NavigationEntry with the same main frame URL.
1587 EXPECT_EQ(2, controller.GetEntryCount()); 1571 EXPECT_EQ(2, controller.GetEntryCount());
1588 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); 1572 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
1589 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); 1573 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry();
1590 EXPECT_NE(entry, entry2); 1574 EXPECT_NE(entry, entry2);
1591 EXPECT_EQ(main_url, entry2->GetURL()); 1575 EXPECT_EQ(main_url, entry2->GetURL());
1592 FrameNavigationEntry* root_entry2 = entry2->root_node()->frame_entry.get(); 1576 FrameNavigationEntry* root_entry2 = entry2->root_node()->frame_entry.get();
1593 EXPECT_EQ(main_url, root_entry2->url()); 1577 EXPECT_EQ(main_url, root_entry2->url());
1594 1578
1595 // Verify subframe entries if we're in --site-per-process mode. 1579 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
1596 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1580 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1597 switches::kSitePerProcess)) {
1598 // The entry should have a new FrameNavigationEntries for the subframe. 1581 // The entry should have a new FrameNavigationEntries for the subframe.
1599 ASSERT_EQ(1U, entry2->root_node()->children.size()); 1582 ASSERT_EQ(1U, entry2->root_node()->children.size());
1600 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url()); 1583 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url());
1601 } else { 1584 } else {
1602 // There are no subframe FrameNavigationEntries by default. 1585 // There are no subframe FrameNavigationEntries by default.
1603 EXPECT_EQ(0U, entry2->root_node()->children.size()); 1586 EXPECT_EQ(0U, entry2->root_node()->children.size());
1604 } 1587 }
1605 1588
1606 // 3. Create a second, initially cross-site iframe. 1589 // 3. Create a second, initially cross-site iframe.
1607 GURL foo_url(embedded_test_server()->GetURL( 1590 GURL foo_url(embedded_test_server()->GetURL(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 1622
1640 // We should have created a new NavigationEntry with the same main frame URL. 1623 // We should have created a new NavigationEntry with the same main frame URL.
1641 EXPECT_EQ(3, controller.GetEntryCount()); 1624 EXPECT_EQ(3, controller.GetEntryCount());
1642 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); 1625 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
1643 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry(); 1626 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry();
1644 EXPECT_NE(entry, entry3); 1627 EXPECT_NE(entry, entry3);
1645 EXPECT_EQ(main_url, entry3->GetURL()); 1628 EXPECT_EQ(main_url, entry3->GetURL());
1646 FrameNavigationEntry* root_entry3 = entry3->root_node()->frame_entry.get(); 1629 FrameNavigationEntry* root_entry3 = entry3->root_node()->frame_entry.get();
1647 EXPECT_EQ(main_url, root_entry3->url()); 1630 EXPECT_EQ(main_url, root_entry3->url());
1648 1631
1649 // Verify subframe entries if we're in --site-per-process mode. 1632 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
1650 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1633 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1651 switches::kSitePerProcess)) {
1652 // The entry should still have FrameNavigationEntries for all 3 subframes. 1634 // The entry should still have FrameNavigationEntries for all 3 subframes.
1653 ASSERT_EQ(2U, entry3->root_node()->children.size()); 1635 ASSERT_EQ(2U, entry3->root_node()->children.size());
1654 EXPECT_EQ(frame_url2, entry3->root_node()->children[0]->frame_entry->url()); 1636 EXPECT_EQ(frame_url2, entry3->root_node()->children[0]->frame_entry->url());
1655 EXPECT_EQ(foo_url, entry3->root_node()->children[1]->frame_entry->url()); 1637 EXPECT_EQ(foo_url, entry3->root_node()->children[1]->frame_entry->url());
1656 ASSERT_EQ(1U, entry3->root_node()->children[1]->children.size()); 1638 ASSERT_EQ(1U, entry3->root_node()->children[1]->children.size());
1657 EXPECT_EQ( 1639 EXPECT_EQ(
1658 bar_url, 1640 bar_url,
1659 entry3->root_node()->children[1]->children[0]->frame_entry->url()); 1641 entry3->root_node()->children[1]->children[0]->frame_entry->url());
1660 } else { 1642 } else {
1661 // There are no subframe FrameNavigationEntries by default. 1643 // There are no subframe FrameNavigationEntries by default.
(...skipping 16 matching lines...) Expand all
1678 1660
1679 // We should have created a new NavigationEntry with the same main frame URL. 1661 // We should have created a new NavigationEntry with the same main frame URL.
1680 EXPECT_EQ(4, controller.GetEntryCount()); 1662 EXPECT_EQ(4, controller.GetEntryCount());
1681 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); 1663 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex());
1682 NavigationEntryImpl* entry4 = controller.GetLastCommittedEntry(); 1664 NavigationEntryImpl* entry4 = controller.GetLastCommittedEntry();
1683 EXPECT_NE(entry, entry4); 1665 EXPECT_NE(entry, entry4);
1684 EXPECT_EQ(main_url, entry4->GetURL()); 1666 EXPECT_EQ(main_url, entry4->GetURL());
1685 FrameNavigationEntry* root_entry4 = entry4->root_node()->frame_entry.get(); 1667 FrameNavigationEntry* root_entry4 = entry4->root_node()->frame_entry.get();
1686 EXPECT_EQ(main_url, root_entry4->url()); 1668 EXPECT_EQ(main_url, root_entry4->url());
1687 1669
1688 // Verify subframe entries if we're in --site-per-process mode. 1670 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
1689 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1671 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1690 switches::kSitePerProcess)) {
1691 // The entry should still have FrameNavigationEntries for all 3 subframes. 1672 // The entry should still have FrameNavigationEntries for all 3 subframes.
1692 ASSERT_EQ(2U, entry4->root_node()->children.size()); 1673 ASSERT_EQ(2U, entry4->root_node()->children.size());
1693 EXPECT_EQ(frame_url2, entry4->root_node()->children[0]->frame_entry->url()); 1674 EXPECT_EQ(frame_url2, entry4->root_node()->children[0]->frame_entry->url());
1694 EXPECT_EQ(baz_url, entry4->root_node()->children[1]->frame_entry->url()); 1675 EXPECT_EQ(baz_url, entry4->root_node()->children[1]->frame_entry->url());
1695 ASSERT_EQ(0U, entry4->root_node()->children[1]->children.size()); 1676 ASSERT_EQ(0U, entry4->root_node()->children[1]->children.size());
1696 } else { 1677 } else {
1697 // There are no subframe FrameNavigationEntries by default. 1678 // There are no subframe FrameNavigationEntries by default.
1698 EXPECT_EQ(0U, entry4->root_node()->children.size()); 1679 EXPECT_EQ(0U, entry4->root_node()->children.size());
1699 } 1680 }
1700 1681
1701 // Check the end result of the frame tree. 1682 // Check the end result of the frame tree.
1702 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1683 if (AreAllSitesIsolatedForTesting()) {
1703 switches::kSitePerProcess)) {
1704 FrameTreeVisualizer visualizer; 1684 FrameTreeVisualizer visualizer;
1705 EXPECT_EQ( 1685 EXPECT_EQ(
1706 " Site A ------------ proxies for B\n" 1686 " Site A ------------ proxies for B\n"
1707 " |--Site A ------- proxies for B\n" 1687 " |--Site A ------- proxies for B\n"
1708 " +--Site B ------- proxies for A\n" 1688 " +--Site B ------- proxies for A\n"
1709 "Where A = http://127.0.0.1/\n" 1689 "Where A = http://127.0.0.1/\n"
1710 " B = http://baz.com/", 1690 " B = http://baz.com/",
1711 visualizer.DepictFrameTree(root)); 1691 visualizer.DepictFrameTree(root));
1712 } 1692 }
1713 } 1693 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1768 FrameNavigateParamsCapturer capturer(root->child_at(0)); 1748 FrameNavigateParamsCapturer capturer(root->child_at(0));
1769 shell()->web_contents()->GetController().GoBack(); 1749 shell()->web_contents()->GetController().GoBack();
1770 capturer.Wait(); 1750 capturer.Wait();
1771 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); 1751 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition);
1772 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); 1752 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type);
1773 } 1753 }
1774 EXPECT_EQ(3, controller.GetEntryCount()); 1754 EXPECT_EQ(3, controller.GetEntryCount());
1775 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); 1755 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
1776 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); 1756 EXPECT_EQ(entry2, controller.GetLastCommittedEntry());
1777 1757
1778 // Verify subframe entries if we're in --site-per-process mode. 1758 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
1779 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1759 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1780 switches::kSitePerProcess)) {
1781 // The entry should have a new FrameNavigationEntries for the subframe. 1760 // The entry should have a new FrameNavigationEntries for the subframe.
1782 ASSERT_EQ(1U, entry2->root_node()->children.size()); 1761 ASSERT_EQ(1U, entry2->root_node()->children.size());
1783 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url()); 1762 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url());
1784 } else { 1763 } else {
1785 // There are no subframe FrameNavigationEntries by default. 1764 // There are no subframe FrameNavigationEntries by default.
1786 EXPECT_EQ(0U, entry2->root_node()->children.size()); 1765 EXPECT_EQ(0U, entry2->root_node()->children.size());
1787 } 1766 }
1788 1767
1789 // 5. Go back in the subframe again to the parent page's site. 1768 // 5. Go back in the subframe again to the parent page's site.
1790 { 1769 {
1791 FrameNavigateParamsCapturer capturer(root->child_at(0)); 1770 FrameNavigateParamsCapturer capturer(root->child_at(0));
1792 shell()->web_contents()->GetController().GoBack(); 1771 shell()->web_contents()->GetController().GoBack();
1793 capturer.Wait(); 1772 capturer.Wait();
1794 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); 1773 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition);
1795 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); 1774 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type);
1796 } 1775 }
1797 EXPECT_EQ(3, controller.GetEntryCount()); 1776 EXPECT_EQ(3, controller.GetEntryCount());
1798 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); 1777 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
1799 EXPECT_EQ(entry1, controller.GetLastCommittedEntry()); 1778 EXPECT_EQ(entry1, controller.GetLastCommittedEntry());
1800 1779
1801 // Verify subframe entries if we're in --site-per-process mode. 1780 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
1802 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1781 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1803 switches::kSitePerProcess)) {
1804 // The entry should have a new FrameNavigationEntries for the subframe. 1782 // The entry should have a new FrameNavigationEntries for the subframe.
1805 ASSERT_EQ(1U, entry1->root_node()->children.size()); 1783 ASSERT_EQ(1U, entry1->root_node()->children.size());
1806 EXPECT_EQ(frame_url, entry1->root_node()->children[0]->frame_entry->url()); 1784 EXPECT_EQ(frame_url, entry1->root_node()->children[0]->frame_entry->url());
1807 } else { 1785 } else {
1808 // There are no subframe FrameNavigationEntries by default. 1786 // There are no subframe FrameNavigationEntries by default.
1809 EXPECT_EQ(0U, entry1->root_node()->children.size()); 1787 EXPECT_EQ(0U, entry1->root_node()->children.size());
1810 } 1788 }
1811 1789
1812 // 6. Go forward in the subframe cross-site. 1790 // 6. Go forward in the subframe cross-site.
1813 { 1791 {
1814 FrameNavigateParamsCapturer capturer(root->child_at(0)); 1792 FrameNavigateParamsCapturer capturer(root->child_at(0));
1815 shell()->web_contents()->GetController().GoForward(); 1793 shell()->web_contents()->GetController().GoForward();
1816 capturer.Wait(); 1794 capturer.Wait();
1817 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); 1795 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition);
1818 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); 1796 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type);
1819 } 1797 }
1820 EXPECT_EQ(3, controller.GetEntryCount()); 1798 EXPECT_EQ(3, controller.GetEntryCount());
1821 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); 1799 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
1822 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); 1800 EXPECT_EQ(entry2, controller.GetLastCommittedEntry());
1823 1801
1824 // Verify subframe entries if we're in --site-per-process mode. 1802 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
1825 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1803 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1826 switches::kSitePerProcess)) {
1827 // The entry should have a new FrameNavigationEntries for the subframe. 1804 // The entry should have a new FrameNavigationEntries for the subframe.
1828 ASSERT_EQ(1U, entry2->root_node()->children.size()); 1805 ASSERT_EQ(1U, entry2->root_node()->children.size());
1829 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url()); 1806 EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url());
1830 } else { 1807 } else {
1831 // There are no subframe FrameNavigationEntries by default. 1808 // There are no subframe FrameNavigationEntries by default.
1832 EXPECT_EQ(0U, entry2->root_node()->children.size()); 1809 EXPECT_EQ(0U, entry2->root_node()->children.size());
1833 } 1810 }
1834 1811
1835 // 7. Go forward in the subframe again, cross-site. 1812 // 7. Go forward in the subframe again, cross-site.
1836 { 1813 {
1837 FrameNavigateParamsCapturer capturer(root->child_at(0)); 1814 FrameNavigateParamsCapturer capturer(root->child_at(0));
1838 shell()->web_contents()->GetController().GoForward(); 1815 shell()->web_contents()->GetController().GoForward();
1839 capturer.Wait(); 1816 capturer.Wait();
1840 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition); 1817 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.params().transition);
1841 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type); 1818 EXPECT_EQ(NAVIGATION_TYPE_AUTO_SUBFRAME, capturer.details().type);
1842 } 1819 }
1843 EXPECT_EQ(3, controller.GetEntryCount()); 1820 EXPECT_EQ(3, controller.GetEntryCount());
1844 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); 1821 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
1845 EXPECT_EQ(entry3, controller.GetLastCommittedEntry()); 1822 EXPECT_EQ(entry3, controller.GetLastCommittedEntry());
1846 1823
1847 // Verify subframe entries if we're in --site-per-process mode. 1824 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
1848 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1825 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1849 switches::kSitePerProcess)) {
1850 // The entry should have a new FrameNavigationEntries for the subframe. 1826 // The entry should have a new FrameNavigationEntries for the subframe.
1851 ASSERT_EQ(1U, entry3->root_node()->children.size()); 1827 ASSERT_EQ(1U, entry3->root_node()->children.size());
1852 EXPECT_EQ(frame_url3, entry3->root_node()->children[0]->frame_entry->url()); 1828 EXPECT_EQ(frame_url3, entry3->root_node()->children[0]->frame_entry->url());
1853 } else { 1829 } else {
1854 // There are no subframe FrameNavigationEntries by default. 1830 // There are no subframe FrameNavigationEntries by default.
1855 EXPECT_EQ(0U, entry3->root_node()->children.size()); 1831 EXPECT_EQ(0U, entry3->root_node()->children.size());
1856 } 1832 }
1857 } 1833 }
1858 1834
1859 // Verifies that item sequence numbers and document sequence numbers update 1835 // Verifies that item sequence numbers and document sequence numbers update
(...skipping 24 matching lines...) Expand all
1884 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); 1860 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script));
1885 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); 1861 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
1886 1862
1887 frame_entry = controller.GetLastCommittedEntry()->GetFrameEntry(root); 1863 frame_entry = controller.GetLastCommittedEntry()->GetFrameEntry(root);
1888 int64 isn_2 = frame_entry->item_sequence_number(); 1864 int64 isn_2 = frame_entry->item_sequence_number();
1889 int64 dsn_2 = frame_entry->document_sequence_number(); 1865 int64 dsn_2 = frame_entry->document_sequence_number();
1890 EXPECT_NE(-1, isn_2); 1866 EXPECT_NE(-1, isn_2);
1891 EXPECT_NE(isn_1, isn_2); 1867 EXPECT_NE(isn_1, isn_2);
1892 EXPECT_EQ(dsn_1, dsn_2); 1868 EXPECT_EQ(dsn_1, dsn_2);
1893 1869
1894 // Also test subframe sequence numbers, but only in --site-per-proces mode. 1870 // Test subframe sequence numbers only if enabled, e.g. in --site-per-process.
1895 // (We do not create subframe FrameNavigationEntries in default mode yet.) 1871 if (!SiteIsolationPolicy::UseSubframeNavigationEntries())
1896 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
1897 switches::kSitePerProcess))
1898 return; 1872 return;
1899 1873
1900 // 3. Add a subframe, which does an AUTO_SUBFRAME navigation. 1874 // 3. Add a subframe, which does an AUTO_SUBFRAME navigation.
1901 { 1875 {
1902 LoadCommittedCapturer capturer(shell()->web_contents()); 1876 LoadCommittedCapturer capturer(shell()->web_contents());
1903 std::string script = "var iframe = document.createElement('iframe');" 1877 std::string script = "var iframe = document.createElement('iframe');"
1904 "iframe.src = '" + url.spec() + "';" 1878 "iframe.src = '" + url.spec() + "';"
1905 "document.body.appendChild(iframe);"; 1879 "document.body.appendChild(iframe);";
1906 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); 1880 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script));
1907 capturer.Wait(); 1881 capturer.Wait();
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 EXPECT_EQ(original_url, capturer.all_params()[1].url); 2334 EXPECT_EQ(original_url, capturer.all_params()[1].url);
2361 EXPECT_EQ(original_url, shell()->web_contents()->GetLastCommittedURL()); 2335 EXPECT_EQ(original_url, shell()->web_contents()->GetLastCommittedURL());
2362 } 2336 }
2363 2337
2364 // Make sure the renderer is still alive. 2338 // Make sure the renderer is still alive.
2365 EXPECT_TRUE( 2339 EXPECT_TRUE(
2366 ExecuteScript(shell()->web_contents(), "console.log('Success');")); 2340 ExecuteScript(shell()->web_contents(), "console.log('Success');"));
2367 } 2341 }
2368 2342
2369 } // namespace content 2343 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698