Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" | 6 #include "base/command_line.h" |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "content/browser/frame_host/frame_navigation_entry.h" | 8 #include "content/browser/frame_host/frame_navigation_entry.h" |
| 9 #include "content/browser/frame_host/frame_tree.h" | 9 #include "content/browser/frame_host/frame_tree.h" |
| 10 #include "content/browser/frame_host/navigation_controller_impl.h" | 10 #include "content/browser/frame_host/navigation_controller_impl.h" |
| (...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1354 ASSERT_EQ(2U, entry->root_node()->children.size()); | 1354 ASSERT_EQ(2U, entry->root_node()->children.size()); |
| 1355 ASSERT_EQ(1U, entry->root_node()->children[1]->children.size()); | 1355 ASSERT_EQ(1U, entry->root_node()->children[1]->children.size()); |
| 1356 FrameNavigationEntry* frame_entry = | 1356 FrameNavigationEntry* frame_entry = |
| 1357 entry->root_node()->children[1]->children[0]->frame_entry.get(); | 1357 entry->root_node()->children[1]->children[0]->frame_entry.get(); |
| 1358 EXPECT_EQ(foo_url, frame_entry->url()); | 1358 EXPECT_EQ(foo_url, frame_entry->url()); |
| 1359 } else { | 1359 } else { |
| 1360 // There are no subframe FrameNavigationEntries by default. | 1360 // There are no subframe FrameNavigationEntries by default. |
| 1361 EXPECT_EQ(0U, entry->root_node()->children.size()); | 1361 EXPECT_EQ(0U, entry->root_node()->children.size()); |
| 1362 } | 1362 } |
| 1363 | 1363 |
| 1364 // TODO(creis): Add tests for another subframe on B, and for a subframe on A | 1364 // 4. Create a third iframe on the same site as the second. This ensures that |
| 1365 // within it. Both are currently broken. | 1365 // the commit type is correct even when the subframe process already exists. |
| 1366 { | |
| 1367 LoadCommittedCapturer capturer(shell()->web_contents()); | |
| 1368 std::string script = "var iframe = document.createElement('iframe');" | |
| 1369 "iframe.src = '" + foo_url.spec() + "';" | |
| 1370 "document.body.appendChild(iframe);"; | |
| 1371 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); | |
| 1372 capturer.Wait(); | |
| 1373 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | |
| 1374 } | |
| 1375 | |
| 1376 // The last committed NavigationEntry shouldn't have changed. | |
| 1377 EXPECT_EQ(1, controller.GetEntryCount()); | |
| 1378 entry = controller.GetLastCommittedEntry(); | |
| 1379 EXPECT_EQ(main_url, entry->GetURL()); | |
| 1380 root_entry = entry->root_node()->frame_entry.get(); | |
| 1381 EXPECT_EQ(main_url, root_entry->url()); | |
| 1382 | |
| 1383 // Verify subframe entries if we're in --site-per-process mode. | |
| 1384 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 1385 switches::kSitePerProcess)) { | |
| 1386 // The entry should now have 3 subframe FrameNavigationEntries. | |
| 1387 ASSERT_EQ(3U, entry->root_node()->children.size()); | |
| 1388 FrameNavigationEntry* frame_entry = | |
| 1389 entry->root_node()->children[2]->frame_entry.get(); | |
| 1390 EXPECT_EQ(foo_url, frame_entry->url()); | |
| 1391 } else { | |
| 1392 // There are no subframe FrameNavigationEntries by default. | |
| 1393 EXPECT_EQ(0U, entry->root_node()->children.size()); | |
| 1394 } | |
| 1395 | |
| 1396 // 5. Create a nested iframe on the original site (A-B-A). | |
| 1397 { | |
| 1398 LoadCommittedCapturer capturer(shell()->web_contents()); | |
|
Avi (use Gerrit)
2015/07/08 18:49:23
Why a LoadCommittedCapturer? A LoadCommittedCaptur
Charlie Reis
2015/07/08 20:27:03
I don't understand how this one is different than
Avi (use Gerrit)
2015/07/08 20:36:15
OK. That's right.
| |
| 1399 std::string script = "var iframe = document.createElement('iframe');" | |
| 1400 "iframe.src = '" + frame_url.spec() + "';" | |
| 1401 "document.body.appendChild(iframe);"; | |
| 1402 FrameTreeNode* child = root->child_at(2); | |
| 1403 EXPECT_TRUE(content::ExecuteScript(child->current_frame_host(), script)); | |
| 1404 capturer.Wait(); | |
| 1405 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | |
| 1406 } | |
| 1407 | |
| 1408 // The last committed NavigationEntry shouldn't have changed. | |
| 1409 EXPECT_EQ(1, controller.GetEntryCount()); | |
| 1410 entry = controller.GetLastCommittedEntry(); | |
| 1411 EXPECT_EQ(main_url, entry->GetURL()); | |
| 1412 root_entry = entry->root_node()->frame_entry.get(); | |
| 1413 EXPECT_EQ(main_url, root_entry->url()); | |
| 1414 | |
| 1415 // Verify subframe entries if we're in --site-per-process mode. | |
| 1416 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 1417 switches::kSitePerProcess)) { | |
| 1418 // There should be a corresponding FrameNavigationEntry. | |
| 1419 ASSERT_EQ(1U, entry->root_node()->children[2]->children.size()); | |
| 1420 FrameNavigationEntry* frame_entry = | |
| 1421 entry->root_node()->children[2]->children[0]->frame_entry.get(); | |
| 1422 EXPECT_EQ(frame_url, frame_entry->url()); | |
| 1423 } else { | |
| 1424 // There are no subframe FrameNavigationEntries by default. | |
| 1425 EXPECT_EQ(0U, entry->root_node()->children.size()); | |
| 1426 } | |
| 1366 | 1427 |
| 1367 // Check the end result of the frame tree. | 1428 // Check the end result of the frame tree. |
| 1368 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1429 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1369 switches::kSitePerProcess)) { | 1430 switches::kSitePerProcess)) { |
| 1370 FrameTreeVisualizer visualizer; | 1431 FrameTreeVisualizer visualizer; |
| 1371 EXPECT_EQ( | 1432 EXPECT_EQ( |
| 1372 " Site A ------------ proxies for B\n" | 1433 " Site A ------------ proxies for B\n" |
| 1373 " |--Site A ------- proxies for B\n" | 1434 " |--Site A ------- proxies for B\n" |
| 1435 " |--Site B ------- proxies for A\n" | |
| 1436 " | +--Site B -- proxies for A\n" | |
| 1374 " +--Site B ------- proxies for A\n" | 1437 " +--Site B ------- proxies for A\n" |
| 1375 " +--Site B -- proxies for A\n" | 1438 " +--Site A -- proxies for B\n" |
| 1376 "Where A = http://127.0.0.1/\n" | 1439 "Where A = http://127.0.0.1/\n" |
| 1377 " B = http://foo.com/", | 1440 " B = http://foo.com/", |
| 1378 visualizer.DepictFrameTree(root)); | 1441 visualizer.DepictFrameTree(root)); |
| 1379 } | 1442 } |
| 1380 } | 1443 } |
| 1381 | 1444 |
| 1382 // Verify the tree of FrameNavigationEntries after NAVIGATION_TYPE_NEW_SUBFRAME | 1445 // Verify the tree of FrameNavigationEntries after NAVIGATION_TYPE_NEW_SUBFRAME |
| 1383 // commits. | 1446 // commits. |
| 1384 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 1447 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 1385 FrameNavigationEntry_NewSubframe) { | 1448 FrameNavigationEntry_NewSubframe) { |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2119 // tricky. | 2182 // tricky. |
| 2120 EXPECT_EQ(nullptr, controller.GetPendingEntry()); | 2183 EXPECT_EQ(nullptr, controller.GetPendingEntry()); |
| 2121 shell()->web_contents()->Stop(); | 2184 shell()->web_contents()->Stop(); |
| 2122 watcher.Wait(); | 2185 watcher.Wait(); |
| 2123 } | 2186 } |
| 2124 | 2187 |
| 2125 ResourceDispatcherHost::Get()->SetDelegate(nullptr); | 2188 ResourceDispatcherHost::Get()->SetDelegate(nullptr); |
| 2126 } | 2189 } |
| 2127 | 2190 |
| 2128 } // namespace content | 2191 } // namespace content |
| OLD | NEW |