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

Unified Diff: content/browser/frame_host/navigation_controller_impl_browsertest.cc

Issue 1225593003: OOPIF: Fix willSendRequest in A-B-A nested case. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also fix cross-process location.replace Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/navigation_controller_impl_browsertest.cc
diff --git a/content/browser/frame_host/navigation_controller_impl_browsertest.cc b/content/browser/frame_host/navigation_controller_impl_browsertest.cc
index d676d4504475ba7db098c54adf46a622294a95ec..baf1751c89bd392879d1b7343e68d387650ff4cb 100644
--- a/content/browser/frame_host/navigation_controller_impl_browsertest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_browsertest.cc
@@ -723,6 +723,19 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
capturer.params().transition);
EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type);
}
+
+ {
+ // Cross-site location.replace().
+ FrameNavigateParamsCapturer capturer(root);
+ GURL frame_url(embedded_test_server()->GetURL(
+ "foo.com", "/navigation_controller/simple_page_1.html"));
+ std::string script = "location.replace('" + frame_url.spec() + "')";
+ EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script));
+ capturer.Wait();
+ EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT,
+ capturer.params().transition);
+ EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type);
Charlie Reis 2015/07/09 17:40:11 We were treating this as NEW_PAGE before, with |re
Avi (use Gerrit) 2015/07/09 19:05:53 Acknowledged. It's nice that it classifies just li
+ }
}
// Verify that navigations for NAVIGATION_TYPE_SAME_PAGE are correctly
@@ -945,6 +958,18 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
}
{
+ // Cross-site location.replace().
+ LoadCommittedCapturer capturer(root->child_at(0));
+ GURL frame_url(embedded_test_server()->GetURL(
+ "foo.com", "/navigation_controller/simple_page_2.html"));
+ std::string script = "location.replace('" + frame_url.spec() + "')";
+ EXPECT_TRUE(content::ExecuteScript(root->child_at(0)->current_frame_host(),
+ script));
+ capturer.Wait();
+ EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type());
Charlie Reis 2015/07/09 17:40:11 We were treating this as NEW_SUBFRAME, which didn'
Avi (use Gerrit) 2015/07/09 19:05:53 Same as above; it's nice to see that this classifi
+ }
+
+ {
// history.pushState().
FrameNavigateParamsCapturer capturer(root->child_at(0));
std::string script =
@@ -1361,8 +1386,69 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(0U, entry->root_node()->children.size());
}
- // TODO(creis): Add tests for another subframe on B, and for a subframe on A
- // within it. Both are currently broken.
+ // 4. Create a third iframe on the same site as the second. This ensures that
+ // the commit type is correct even when the subframe process already exists.
+ {
+ LoadCommittedCapturer capturer(shell()->web_contents());
+ std::string script = "var iframe = document.createElement('iframe');"
+ "iframe.src = '" + foo_url.spec() + "';"
+ "document.body.appendChild(iframe);";
+ EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script));
+ capturer.Wait();
+ EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type());
+ }
+
+ // The last committed NavigationEntry shouldn't have changed.
+ EXPECT_EQ(1, controller.GetEntryCount());
+ entry = controller.GetLastCommittedEntry();
+ EXPECT_EQ(main_url, entry->GetURL());
+ root_entry = entry->root_node()->frame_entry.get();
+ EXPECT_EQ(main_url, root_entry->url());
+
+ // Verify subframe entries if we're in --site-per-process mode.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ // The entry should now have 3 subframe FrameNavigationEntries.
+ ASSERT_EQ(3U, entry->root_node()->children.size());
+ FrameNavigationEntry* frame_entry =
+ entry->root_node()->children[2]->frame_entry.get();
+ EXPECT_EQ(foo_url, frame_entry->url());
+ } else {
+ // There are no subframe FrameNavigationEntries by default.
+ EXPECT_EQ(0U, entry->root_node()->children.size());
+ }
+
+ // 5. Create a nested iframe on the original site (A-B-A).
+ {
+ LoadCommittedCapturer capturer(shell()->web_contents());
+ std::string script = "var iframe = document.createElement('iframe');"
+ "iframe.src = '" + frame_url.spec() + "';"
+ "document.body.appendChild(iframe);";
+ FrameTreeNode* child = root->child_at(2);
+ EXPECT_TRUE(content::ExecuteScript(child->current_frame_host(), script));
+ capturer.Wait();
+ EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type());
+ }
+
+ // The last committed NavigationEntry shouldn't have changed.
+ EXPECT_EQ(1, controller.GetEntryCount());
+ entry = controller.GetLastCommittedEntry();
+ EXPECT_EQ(main_url, entry->GetURL());
+ root_entry = entry->root_node()->frame_entry.get();
+ EXPECT_EQ(main_url, root_entry->url());
+
+ // Verify subframe entries if we're in --site-per-process mode.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ // There should be a corresponding FrameNavigationEntry.
+ ASSERT_EQ(1U, entry->root_node()->children[2]->children.size());
+ FrameNavigationEntry* frame_entry =
+ entry->root_node()->children[2]->children[0]->frame_entry.get();
+ EXPECT_EQ(frame_url, frame_entry->url());
+ } else {
+ // There are no subframe FrameNavigationEntries by default.
+ EXPECT_EQ(0U, entry->root_node()->children.size());
+ }
// Check the end result of the frame tree.
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
@@ -1371,8 +1457,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(
" Site A ------------ proxies for B\n"
" |--Site A ------- proxies for B\n"
+ " |--Site B ------- proxies for A\n"
+ " | +--Site B -- proxies for A\n"
" +--Site B ------- proxies for A\n"
- " +--Site B -- proxies for A\n"
+ " +--Site A -- proxies for B\n"
"Where A = http://127.0.0.1/\n"
" B = http://foo.com/",
visualizer.DepictFrameTree(root));

Powered by Google App Engine
This is Rietveld 408576698