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

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

Issue 2149203002: Update HistoryController::current_entry_ on all main frame back/forwards. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 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/history_controller.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 <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 4374 matching lines...) Expand 10 before | Expand all | Expand 10 after
4385 NavigationEntry* entry = controller.GetEntryAtIndex(1); 4385 NavigationEntry* entry = controller.GetEntryAtIndex(1);
4386 EXPECT_EQ(url_a, entry->GetURL()); 4386 EXPECT_EQ(url_a, entry->GetURL());
4387 ExplodedPageState exploded_state; 4387 ExplodedPageState exploded_state;
4388 EXPECT_TRUE( 4388 EXPECT_TRUE(
4389 DecodePageState(entry->GetPageState().ToEncodedData(), &exploded_state)); 4389 DecodePageState(entry->GetPageState().ToEncodedData(), &exploded_state));
4390 EXPECT_EQ(url_a, GURL(exploded_state.top.url_string.string())); 4390 EXPECT_EQ(url_a, GURL(exploded_state.top.url_string.string()));
4391 EXPECT_EQ(frame_url_a2, 4391 EXPECT_EQ(frame_url_a2,
4392 GURL(exploded_state.top.children.at(0).url_string.string())); 4392 GURL(exploded_state.top.children.at(0).url_string.string()));
4393 } 4393 }
4394 4394
4395 // Ensure that we do not corrupt a NavigationEntry's PageState if two forward
4396 // navigations compete in different frames. See https://crbug.com/623319.
4397 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
4398 PageStateAfterForwardInCompetingFrames) {
4399 // Navigate to a page with an iframe.
4400 GURL url_a(embedded_test_server()->GetURL(
4401 "/navigation_controller/page_with_data_iframe.html"));
4402 GURL frame_url_a1("data:text/html,Subframe");
4403 EXPECT_TRUE(NavigateToURL(shell(), url_a));
4404
4405 NavigationController& controller = shell()->web_contents()->GetController();
4406 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
4407 ->GetFrameTree()
4408 ->root();
4409 EXPECT_EQ(url_a, root->current_url());
4410 EXPECT_EQ(frame_url_a1, root->child_at(0)->current_url());
4411
4412 // Navigate the iframe to a second page.
4413 GURL frame_url_a2 = embedded_test_server()->GetURL(
4414 "/navigation_controller/simple_page_1.html");
4415 NavigateFrameToURL(root->child_at(0), frame_url_a2);
4416
4417 // Navigate the iframe to about:blank.
4418 GURL blank_url(url::kAboutBlankURL);
4419 NavigateFrameToURL(root->child_at(0), blank_url);
4420 EXPECT_EQ(3, controller.GetEntryCount());
4421 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
4422 EXPECT_EQ(url_a, root->current_url());
4423 EXPECT_EQ(blank_url, root->child_at(0)->current_url());
4424
4425 // Go back to the middle entry.
4426 controller.GoBack();
4427 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
4428 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
4429
4430 // Replace the entry with a cross-site top-level page. By doing a
4431 // replacement, the main frame pages before and after have the same item
4432 // sequence number, and thus going between them only requires loads in the
4433 // subframe.
4434 GURL url_b(embedded_test_server()->GetURL(
4435 "b.com", "/navigation_controller/simple_page_2.html"));
4436 std::string replace_script = "location.replace('" + url_b.spec() + "')";
4437 TestNavigationObserver replace_observer(shell()->web_contents());
4438 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), replace_script));
4439 replace_observer.Wait();
4440 EXPECT_EQ(3, controller.GetEntryCount());
4441 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
4442 EXPECT_EQ(url_b, root->current_url());
4443
4444 // Go back to the original page.
4445 controller.GoBack();
4446 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
4447
4448 // Navigate forward twice using script. In https://crbug.com/623319, this
4449 // caused a mismatch between the NavigationEntry's URL and PageState.
4450 EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
4451 "history.forward(); history.forward();"));
4452 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
4453 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
4454 EXPECT_EQ(url_b, root->current_url());
4455 NavigationEntry* entry = controller.GetLastCommittedEntry();
4456 EXPECT_EQ(url_b, entry->GetURL());
4457 ExplodedPageState exploded_state;
4458 EXPECT_TRUE(
4459 DecodePageState(entry->GetPageState().ToEncodedData(), &exploded_state));
4460 EXPECT_EQ(url_b, GURL(exploded_state.top.url_string.string()));
4461 // TODO(creis): Clear subframe FNEs after location.replace in
4462 // --isolate-extensions mode. See https://crbug.com/596707.
4463 if (!SiteIsolationPolicy::UseSubframeNavigationEntries())
4464 EXPECT_EQ(0U, exploded_state.top.children.size());
4465
4466 // Go back and then forward to see if the PageState loads correctly.
4467 controller.GoBack();
4468 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
4469 controller.GoForward();
4470 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
4471
4472 // We should be on url_b, and the renderer process shouldn't be killed.
4473 ASSERT_TRUE(root->current_frame_host()->IsRenderFrameLive());
4474 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
4475 EXPECT_EQ(url_b, shell()->web_contents()->GetVisibleURL());
4476 EXPECT_EQ(url_b, root->current_url());
4477 EXPECT_EQ(0U, root->child_count());
4478 }
4479
4395 // Ensure that forward navigations in cloned tabs can commit if they redirect to 4480 // Ensure that forward navigations in cloned tabs can commit if they redirect to
4396 // a different site than before. This causes the navigation's item sequence 4481 // a different site than before. This causes the navigation's item sequence
4397 // number to change, meaning that we can't use it for determining whether the 4482 // number to change, meaning that we can't use it for determining whether the
4398 // commit matches the history item. See https://crbug.com/600238. 4483 // commit matches the history item. See https://crbug.com/600238.
4399 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, 4484 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
4400 ForwardRedirectWithNoCommittedEntry) { 4485 ForwardRedirectWithNoCommittedEntry) {
4401 NavigationController& controller = shell()->web_contents()->GetController(); 4486 NavigationController& controller = shell()->web_contents()->GetController();
4402 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 4487 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
4403 ->GetFrameTree() 4488 ->GetFrameTree()
4404 ->root(); 4489 ->root();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
4505 // TODO(clamy): Check the post id as well when PlzNavigate handles it 4590 // TODO(clamy): Check the post id as well when PlzNavigate handles it
4506 // properly. 4591 // properly.
4507 if (!IsBrowserSideNavigationEnabled()) 4592 if (!IsBrowserSideNavigationEnabled())
4508 EXPECT_NE(-1, frame_entry->post_id()); 4593 EXPECT_NE(-1, frame_entry->post_id());
4509 EXPECT_FALSE(entry->GetHasPostData()); 4594 EXPECT_FALSE(entry->GetHasPostData());
4510 EXPECT_EQ(-1, entry->GetPostID()); 4595 EXPECT_EQ(-1, entry->GetPostID());
4511 } 4596 }
4512 } 4597 }
4513 4598
4514 } // namespace content 4599 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/history_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698