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

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

Issue 1112823005: Ensure that HistoryController's current entry is updated on inert commits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use switch statement. Created 5 years, 7 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "content/browser/frame_host/frame_navigation_entry.h" 8 #include "content/browser/frame_host/frame_navigation_entry.h"
9 #include "content/browser/frame_host/frame_tree.h" 9 #include "content/browser/frame_host/frame_tree.h"
10 #include "content/browser/frame_host/navigation_controller_impl.h" 10 #include "content/browser/frame_host/navigation_controller_impl.h"
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 capturer.Wait(); 1063 capturer.Wait();
1064 1064
1065 // The fact that there was a pending entry shouldn't interfere with the 1065 // The fact that there was a pending entry shouldn't interfere with the
1066 // classification. 1066 // classification.
1067 EXPECT_EQ(NAVIGATION_TYPE_IN_PAGE, capturer.details().type); 1067 EXPECT_EQ(NAVIGATION_TYPE_IN_PAGE, capturer.details().type);
1068 } 1068 }
1069 1069
1070 ResourceDispatcherHost::Get()->SetDelegate(nullptr); 1070 ResourceDispatcherHost::Get()->SetDelegate(nullptr);
1071 } 1071 }
1072 1072
1073 // Ensure the renderer process does not get confused about the current entry
1074 // due to subframes and replaced entries. See https://crbug.com/480201.
1075 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
1076 PreventSpoofFromSubframeAndReplace) {
1077 // Start at an initial URL.
1078 GURL url1(embedded_test_server()->GetURL(
1079 "/navigation_controller/simple_page_1.html"));
1080 NavigateToURL(shell(), url1);
1081
1082 // Now go to a page with a real iframe.
1083 GURL url2(embedded_test_server()->GetURL(
1084 "/navigation_controller/page_with_data_iframe.html"));
1085 NavigateToURL(shell(), url2);
1086
1087 // It is safe to obtain the root frame tree node here, as it doesn't change.
1088 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
1089 ->GetFrameTree()
1090 ->root();
1091 ASSERT_EQ(1U, root->child_count());
1092 ASSERT_NE(nullptr, root->child_at(0));
1093
1094 {
1095 // Navigate in the iframe.
1096 FrameNavigateParamsCapturer capturer(root->child_at(0));
1097 GURL frame_url(embedded_test_server()->GetURL(
1098 "/navigation_controller/simple_page_2.html"));
1099 NavigateFrameToURL(root->child_at(0), frame_url);
1100 capturer.Wait();
1101 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type);
1102 }
1103
1104 {
1105 // Go back in the iframe.
1106 TestNavigationObserver back_load_observer(shell()->web_contents());
1107 shell()->web_contents()->GetController().GoBack();
1108 back_load_observer.Wait();
1109 }
1110
1111 {
1112 // Go forward in the iframe.
1113 TestNavigationObserver forward_load_observer(shell()->web_contents());
1114 shell()->web_contents()->GetController().GoForward();
1115 forward_load_observer.Wait();
1116 }
1117
1118 GURL url3(embedded_test_server()->GetURL(
1119 "/navigation_controller/page_with_iframe.html"));
1120 {
1121 // location.replace() to cause an inert commit.
1122 TestNavigationObserver replace_load_observer(shell()->web_contents());
1123 std::string script = "location.replace('" + url3.spec() + "')";
1124 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script));
1125 replace_load_observer.Wait();
1126 }
1127
1128 {
1129 // Go back to url2.
1130 TestNavigationObserver back_load_observer(shell()->web_contents());
1131 shell()->web_contents()->GetController().GoBack();
1132 back_load_observer.Wait();
1133
1134 // Make sure the URL is correct for both the entry and the main frame, and
1135 // that the process hasn't been killed for showing a spoof.
1136 EXPECT_TRUE(root->current_frame_host()->IsRenderFrameLive());
1137 EXPECT_EQ(url2, shell()->web_contents()->GetLastCommittedURL());
1138 EXPECT_EQ(url2, root->current_url());
1139 }
1140
1141 {
1142 // Go back to reset main frame entirely.
1143 TestNavigationObserver back_load_observer(shell()->web_contents());
1144 shell()->web_contents()->GetController().GoBack();
1145 back_load_observer.Wait();
1146 EXPECT_EQ(url1, shell()->web_contents()->GetLastCommittedURL());
1147 EXPECT_EQ(url1, root->current_url());
1148 }
1149
1150 {
1151 // Go forward.
1152 TestNavigationObserver back_load_observer(shell()->web_contents());
1153 shell()->web_contents()->GetController().GoForward();
1154 back_load_observer.Wait();
1155 EXPECT_EQ(url2, shell()->web_contents()->GetLastCommittedURL());
1156 EXPECT_EQ(url2, root->current_url());
1157 }
1158
1159 {
1160 // Go forward to the replaced URL.
1161 TestNavigationObserver forward_load_observer(shell()->web_contents());
1162 shell()->web_contents()->GetController().GoForward();
1163 forward_load_observer.Wait();
1164
1165 // Make sure the URL is correct for both the entry and the main frame, and
1166 // that the process hasn't been killed for showing a spoof.
1167 EXPECT_TRUE(root->current_frame_host()->IsRenderFrameLive());
1168 EXPECT_EQ(url3, shell()->web_contents()->GetLastCommittedURL());
1169 EXPECT_EQ(url3, root->current_url());
1170 }
1171 }
1172
1073 } // namespace content 1173 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl.cc ('k') | content/renderer/history_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698