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 6f54e00f1e96155094ac5adcfb32d3f6fd7f003b..997a6fdb051ae3ebcf6f6b1de0119286ea08b846 100644 |
--- a/content/browser/frame_host/navigation_controller_impl_browsertest.cc |
+++ b/content/browser/frame_host/navigation_controller_impl_browsertest.cc |
@@ -3,7 +3,9 @@ |
// found in the LICENSE file. |
#include "base/bind.h" |
+#include "base/command_line.h" |
#include "base/strings/stringprintf.h" |
+#include "content/browser/frame_host/frame_navigation_entry.h" |
#include "content/browser/frame_host/frame_tree.h" |
#include "content/browser/frame_host/navigation_controller_impl.h" |
#include "content/browser/frame_host/navigation_entry_impl.h" |
@@ -12,6 +14,7 @@ |
#include "content/public/browser/web_contents.h" |
#include "content/public/browser/web_contents_observer.h" |
#include "content/public/common/bindings_policy.h" |
+#include "content/public/common/content_switches.h" |
#include "content/public/common/url_constants.h" |
#include "content/public/test/browser_test_utils.h" |
#include "content/public/test/content_browser_test.h" |
@@ -853,4 +856,55 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
} |
} |
+ |
+// Verify the tree of FrameNavigationEntries after NAVIGATION_TYPE_AUTO_SUBFRAME |
+// commits. |
+// TODO(creis): Test cross-site and nested iframes. |
+// TODO(creis): Test updating entries for history auto subframe navigations. |
+IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
+ FrameNavigationEntry_AutoSubframe) { |
+ GURL main_url(embedded_test_server()->GetURL( |
+ "/navigation_controller/simple_page_1.html")); |
+ NavigateToURL(shell(), main_url); |
+ const NavigationControllerImpl& controller = |
+ static_cast<const NavigationControllerImpl&>( |
+ shell()->web_contents()->GetController()); |
+ FrameTreeNode* root = |
+ static_cast<WebContentsImpl*>(shell()->web_contents())-> |
+ GetFrameTree()->root(); |
+ |
+ // Create an iframe. |
+ GURL frame_url(embedded_test_server()->GetURL( |
+ "/navigation_controller/simple_page_2.html")); |
+ { |
+ LoadCommittedCapturer capturer(shell()->web_contents()); |
+ std::string script = "var iframe = document.createElement('iframe');" |
+ "iframe.src = '" + frame_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()); |
+ } |
+ |
+ // Check last committed NavigationEntry. |
+ EXPECT_EQ(1, controller.GetEntryCount()); |
+ NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
+ EXPECT_EQ(main_url, entry->GetURL()); |
+ FrameNavigationEntry* 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 a subframe FrameNavigationEntry. |
+ ASSERT_EQ(1U, entry->root_node()->children.size()); |
+ FrameNavigationEntry* frame_entry = |
+ entry->root_node()->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()); |
+ } |
+} |
+ |
} // namespace content |