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

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

Issue 1134193003: Avoid renderer kills on subframe navigations after main frame replaceState. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl.cc ('k') | no next file » | 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 "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 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 forward_load_observer.Wait(); 1200 forward_load_observer.Wait();
1201 1201
1202 // Make sure the URL is correct for both the entry and the main frame, and 1202 // Make sure the URL is correct for both the entry and the main frame, and
1203 // that the process hasn't been killed for showing a spoof. 1203 // that the process hasn't been killed for showing a spoof.
1204 EXPECT_TRUE(root->current_frame_host()->IsRenderFrameLive()); 1204 EXPECT_TRUE(root->current_frame_host()->IsRenderFrameLive());
1205 EXPECT_EQ(url3, shell()->web_contents()->GetLastCommittedURL()); 1205 EXPECT_EQ(url3, shell()->web_contents()->GetLastCommittedURL());
1206 EXPECT_EQ(url3, root->current_url()); 1206 EXPECT_EQ(url3, root->current_url());
1207 } 1207 }
1208 } 1208 }
1209 1209
1210 // Ensure the renderer process does not get killed if the main frame URL's path
1211 // changes when going back in a subframe, since this is currently possible after
1212 // a replaceState in the main frame (thanks to https://crbug.com/373041).
1213 // See https:///crbug.com/486916.
1214 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
1215 SubframeBackFromReplaceState) {
1216 // Start at a page with a real iframe.
1217 GURL url1(embedded_test_server()->GetURL(
1218 "/navigation_controller/page_with_data_iframe.html"));
1219 NavigateToURL(shell(), url1);
1220
1221 // It is safe to obtain the root frame tree node here, as it doesn't change.
1222 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
1223 ->GetFrameTree()
1224 ->root();
1225 ASSERT_EQ(1U, root->child_count());
1226 ASSERT_NE(nullptr, root->child_at(0));
1227
1228 {
1229 // Navigate in the iframe.
1230 FrameNavigateParamsCapturer capturer(root->child_at(0));
1231 GURL frame_url(embedded_test_server()->GetURL(
1232 "/navigation_controller/simple_page_2.html"));
1233 NavigateFrameToURL(root->child_at(0), frame_url);
1234 capturer.Wait();
1235 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type);
1236 }
1237
1238 {
1239 // history.replaceState().
1240 FrameNavigateParamsCapturer capturer(root);
1241 std::string script =
1242 "history.replaceState({}, 'replaced', 'replaced')";
1243 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script));
1244 capturer.Wait();
1245 }
1246
1247 {
1248 // Go back in the iframe.
1249 TestNavigationObserver back_load_observer(shell()->web_contents());
1250 shell()->web_contents()->GetController().GoBack();
1251 back_load_observer.Wait();
1252 }
1253
1254 // For now, we expect the main frame's URL to revert. This won't happen once
1255 // https://crbug.com/373041 is fixed.
1256 EXPECT_EQ(url1, shell()->web_contents()->GetLastCommittedURL());
1257
1258 // Make sure the renderer process has not been killed.
1259 EXPECT_TRUE(root->current_frame_host()->IsRenderFrameLive());
1260 }
1261
1210 namespace { 1262 namespace {
1211 1263
1212 class FailureWatcher : public WebContentsObserver { 1264 class FailureWatcher : public WebContentsObserver {
1213 public: 1265 public:
1214 // Observes failure for the specified |node|. 1266 // Observes failure for the specified |node|.
1215 explicit FailureWatcher(FrameTreeNode* node) 1267 explicit FailureWatcher(FrameTreeNode* node)
1216 : WebContentsObserver( 1268 : WebContentsObserver(
1217 node->current_frame_host()->delegate()->GetAsWebContents()), 1269 node->current_frame_host()->delegate()->GetAsWebContents()),
1218 frame_tree_node_id_(node->frame_tree_node_id()), 1270 frame_tree_node_id_(node->frame_tree_node_id()),
1219 message_loop_runner_(new MessageLoopRunner) {} 1271 message_loop_runner_(new MessageLoopRunner) {}
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 // tricky. 1345 // tricky.
1294 EXPECT_EQ(nullptr, controller.GetPendingEntry()); 1346 EXPECT_EQ(nullptr, controller.GetPendingEntry());
1295 shell()->web_contents()->Stop(); 1347 shell()->web_contents()->Stop();
1296 watcher.Wait(); 1348 watcher.Wait();
1297 } 1349 }
1298 1350
1299 ResourceDispatcherHost::Get()->SetDelegate(nullptr); 1351 ResourceDispatcherHost::Get()->SetDelegate(nullptr);
1300 } 1352 }
1301 1353
1302 } // namespace content 1354 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698