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

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

Issue 2961903003: PageTransition: Remove unreached code. (Closed)
Patch Set: CHECK => DCHECK, Add test. Created 3 years, 6 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
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.cc » ('j') | content/renderer/render_frame_impl.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 db6deecf05b40ba85fbf6a58ff511424da894e12..96dfd7066153a81ec5bd8d46cb8d865386b210c4 100644
--- a/content/browser/frame_host/navigation_controller_impl_browsertest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_browsertest.cc
@@ -6870,4 +6870,115 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
controller.GetLastCommittedEntry()->GetURL().spec());
}
+// If the main frame does a load, it should not be reported as a subframe
+// navigation. This used to occur in the following case:
+// 1. You're on a site with frames.
+// 2. You do a subframe navigation. This was stored with transition type
+// MANUAL_SUBFRAME.
+// 3. You navigate to some non-frame site.
+// 4. You navigate back to the page from step 2. Since it was initially
+// MANUAL_SUBFRAME, it will be that same transition type here.
+// We don't want that, because any navigation that changes the toplevel frame
+// should be tracked as a toplevel navigation (this allows us to update the URL
+// bar, etc).
+IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
+ GoBackToManualSubFrame) {
+ GURL main_url(embedded_test_server()->GetURL(
+ "/navigation_controller/page_with_iframe.html"));
+ EXPECT_TRUE(NavigateToURL(shell(), main_url));
+
+ FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
+ ->GetFrameTree()
+ ->root();
+
+ ASSERT_EQ(1U, root->child_count());
+ ASSERT_NE(nullptr, root->child_at(0));
+
+ {
+ // Iframe initial load.
+ LoadCommittedCapturer capturer(root->child_at(0));
+ GURL frame_url(embedded_test_server()->GetURL(
+ "/navigation_controller/simple_page_1.html"));
+ NavigateFrameToURL(root->child_at(0), frame_url);
+ capturer.Wait();
+ EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
+ capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME));
+ }
+
+ {
+ // Iframe manual navigation.
+ FrameNavigateParamsCapturer capturer(root->child_at(0));
+ GURL frame_url(embedded_test_server()->GetURL(
+ "/navigation_controller/simple_page_2.html"));
+ NavigateFrameToURL(root->child_at(0), frame_url);
+ capturer.Wait();
+ EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
+ capturer.transition(), ui::PAGE_TRANSITION_MANUAL_SUBFRAME));
+ EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.navigation_type());
+ }
+
+ {
+ // Main frame navigation.
+ FrameNavigateParamsCapturer capturer(root);
+ GURL main_url_2(embedded_test_server()->GetURL(
+ "/navigation_controller/simple_page_2.html"));
+ NavigateFrameToURL(root, main_url_2);
+ capturer.Wait();
+ EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.navigation_type());
+ EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
+ capturer.transition(), ui::PAGE_TRANSITION_LINK));
+ }
+
+ {
+ // Check the history before going back.
+ NavigationControllerImpl& controller =
+ static_cast<NavigationControllerImpl&>(
+ shell()->web_contents()->GetController());
+ EXPECT_EQ(3, controller.GetEntryCount());
+ EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
+ controller.GetEntryAtIndex(0)->GetTransitionType(),
+ ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED |
+ ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)));
+ EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
+ controller.GetEntryAtIndex(1)->GetTransitionType(),
+ ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED |
+ ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)));
arthursonzogni 2017/06/28 15:19:30 That's interesting... In the past, I bet it used t
Avi (use Gerrit) 2017/06/28 17:03:17 I don't know. The history of Page Transitions is a
Charlie Reis 2017/07/07 23:11:09 Huh, this might explain why the code isn't reached
+ EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
+ controller.GetEntryAtIndex(2)->GetTransitionType(),
+ ui::PAGE_TRANSITION_LINK));
+ }
+
+ {
+ // Back.
+ FrameNavigateParamsCapturer capturer(root);
+ shell()->web_contents()->GetController().GoBack();
+ capturer.Wait();
+ EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
+ capturer.transition(),
+ ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED |
+ ui::PAGE_TRANSITION_FORWARD_BACK |
+ ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)));
+ }
+
+ {
+ // Check the history again.
+ NavigationControllerImpl& controller =
+ static_cast<NavigationControllerImpl&>(
+ shell()->web_contents()->GetController());
+ EXPECT_EQ(3, controller.GetEntryCount());
+ EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
+ controller.GetEntryAtIndex(0)->GetTransitionType(),
+ ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED |
+ ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)));
+ EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
+ controller.GetEntryAtIndex(1)->GetTransitionType(),
+ ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED |
+ ui::PAGE_TRANSITION_FORWARD_BACK |
+ ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)));
+ EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
+ controller.GetEntryAtIndex(2)->GetTransitionType(),
+ ui::PAGE_TRANSITION_LINK));
+ }
+}
+
} // namespace content
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.cc » ('j') | content/renderer/render_frame_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698