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

Side by Side Diff: content/browser/frame_host/navigation_controller_impl_browsertest.cc

Issue 2961903003: PageTransition: Remove unreached code. (Closed)
Patch Set: Add TODO (and rebase) 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
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // TODO(creis, arthursonzogni): The correct PageTransition is still an open
6943 // question. Maybe PAGE_TRANSITION_MANUAL_SUBFRAME is more appropriate.
6944 // Please see https://crbug.com/740461.
6945 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
6946 controller.GetEntryAtIndex(1)->GetTransitionType(),
6947 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED |
6948 ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)));
6949 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
6950 controller.GetEntryAtIndex(2)->GetTransitionType(),
6951 ui::PAGE_TRANSITION_LINK));
6952 }
6953
6954 {
6955 // Back.
6956 FrameNavigateParamsCapturer capturer(root);
6957 shell()->web_contents()->GetController().GoBack();
6958 capturer.Wait();
6959 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
6960 capturer.transition(),
6961 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED |
6962 ui::PAGE_TRANSITION_FORWARD_BACK |
6963 ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)));
6964 }
6965
6966 {
6967 // Check the history again.
6968 NavigationControllerImpl& controller =
6969 static_cast<NavigationControllerImpl&>(
6970 shell()->web_contents()->GetController());
6971 EXPECT_EQ(3, controller.GetEntryCount());
6972 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
6973 controller.GetEntryAtIndex(0)->GetTransitionType(),
6974 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED |
6975 ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)));
6976 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
6977 controller.GetEntryAtIndex(1)->GetTransitionType(),
6978 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED |
6979 ui::PAGE_TRANSITION_FORWARD_BACK |
6980 ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)));
6981 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
6982 controller.GetEntryAtIndex(2)->GetTransitionType(),
6983 ui::PAGE_TRANSITION_LINK));
6984 }
6985 }
6986
6873 } // namespace content 6987 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698