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

Side by Side 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, 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 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 "content/browser/frame_host/navigation_controller_impl.h" 5 #include "content/browser/frame_host/navigation_controller_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 6852 matching lines...) Expand 10 before | Expand all | Expand 10 after
6863 // navigation logic is no longer needed. https://crbug.com/723796 6863 // navigation logic is no longer needed. https://crbug.com/723796
6864 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); 6864 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
6865 EXPECT_FALSE( 6865 EXPECT_FALSE(
6866 controller.GetLastCommittedEntry()->GetURL().SchemeIs(url::kDataScheme)); 6866 controller.GetLastCommittedEntry()->GetURL().SchemeIs(url::kDataScheme));
6867 EXPECT_EQ(redirect_to_unsafe_url, 6867 EXPECT_EQ(redirect_to_unsafe_url,
6868 controller.GetLastCommittedEntry()->GetVirtualURL()); 6868 controller.GetLastCommittedEntry()->GetVirtualURL());
6869 EXPECT_EQ(url::kAboutBlankURL, 6869 EXPECT_EQ(url::kAboutBlankURL,
6870 controller.GetLastCommittedEntry()->GetURL().spec()); 6870 controller.GetLastCommittedEntry()->GetURL().spec());
6871 } 6871 }
6872 6872
6873 // If the main frame does a load, it should not be reported as a subframe
6874 // navigation. This used to occur in the following case:
6875 // 1. You're on a site with frames.
6876 // 2. You do a subframe navigation. This was stored with transition type
6877 // MANUAL_SUBFRAME.
6878 // 3. You navigate to some non-frame site.
6879 // 4. You navigate back to the page from step 2. Since it was initially
6880 // MANUAL_SUBFRAME, it will be that same transition type here.
6881 // We don't want that, because any navigation that changes the toplevel frame
6882 // should be tracked as a toplevel navigation (this allows us to update the URL
6883 // bar, etc).
6884 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
6885 GoBackToManualSubFrame) {
6886 GURL main_url(embedded_test_server()->GetURL(
6887 "/navigation_controller/page_with_iframe.html"));
6888 EXPECT_TRUE(NavigateToURL(shell(), main_url));
6889
6890 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
6891 ->GetFrameTree()
6892 ->root();
6893
6894 ASSERT_EQ(1U, root->child_count());
6895 ASSERT_NE(nullptr, root->child_at(0));
6896
6897 {
6898 // Iframe initial load.
6899 LoadCommittedCapturer capturer(root->child_at(0));
6900 GURL frame_url(embedded_test_server()->GetURL(
6901 "/navigation_controller/simple_page_1.html"));
6902 NavigateFrameToURL(root->child_at(0), frame_url);
6903 capturer.Wait();
6904 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
6905 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME));
6906 }
6907
6908 {
6909 // Iframe manual navigation.
6910 FrameNavigateParamsCapturer capturer(root->child_at(0));
6911 GURL frame_url(embedded_test_server()->GetURL(
6912 "/navigation_controller/simple_page_2.html"));
6913 NavigateFrameToURL(root->child_at(0), frame_url);
6914 capturer.Wait();
6915 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
6916 capturer.transition(), ui::PAGE_TRANSITION_MANUAL_SUBFRAME));
6917 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.navigation_type());
6918 }
6919
6920 {
6921 // Main frame navigation.
6922 FrameNavigateParamsCapturer capturer(root);
6923 GURL main_url_2(embedded_test_server()->GetURL(
6924 "/navigation_controller/simple_page_2.html"));
6925 NavigateFrameToURL(root, main_url_2);
6926 capturer.Wait();
6927 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.navigation_type());
6928 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
6929 capturer.transition(), ui::PAGE_TRANSITION_LINK));
6930 }
6931
6932 {
6933 // Check the history before going back.
6934 NavigationControllerImpl& controller =
6935 static_cast<NavigationControllerImpl&>(
6936 shell()->web_contents()->GetController());
6937 EXPECT_EQ(3, controller.GetEntryCount());
6938 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
6939 controller.GetEntryAtIndex(0)->GetTransitionType(),
6940 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED |
6941 ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)));
6942 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
6943 controller.GetEntryAtIndex(1)->GetTransitionType(),
6944 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED |
6945 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
6946 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
6947 controller.GetEntryAtIndex(2)->GetTransitionType(),
6948 ui::PAGE_TRANSITION_LINK));
6949 }
6950
6951 {
6952 // Back.
6953 FrameNavigateParamsCapturer capturer(root);
6954 shell()->web_contents()->GetController().GoBack();
6955 capturer.Wait();
6956 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
6957 capturer.transition(),
6958 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED |
6959 ui::PAGE_TRANSITION_FORWARD_BACK |
6960 ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)));
6961 }
6962
6963 {
6964 // Check the history again.
6965 NavigationControllerImpl& controller =
6966 static_cast<NavigationControllerImpl&>(
6967 shell()->web_contents()->GetController());
6968 EXPECT_EQ(3, controller.GetEntryCount());
6969 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
6970 controller.GetEntryAtIndex(0)->GetTransitionType(),
6971 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED |
6972 ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)));
6973 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
6974 controller.GetEntryAtIndex(1)->GetTransitionType(),
6975 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED |
6976 ui::PAGE_TRANSITION_FORWARD_BACK |
6977 ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)));
6978 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
6979 controller.GetEntryAtIndex(2)->GetTransitionType(),
6980 ui::PAGE_TRANSITION_LINK));
6981 }
6982 }
6983
6873 } // namespace content 6984 } // namespace content
OLDNEW
« 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