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

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

Issue 2134493002: Update HistoryController::current_entry_ on all main frame back/forwards. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes from review 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 4582 matching lines...) Expand 10 before | Expand all | Expand 10 after
4593 NavigationEntry* entry = controller.GetEntryAtIndex(1); 4593 NavigationEntry* entry = controller.GetEntryAtIndex(1);
4594 EXPECT_EQ(url_a, entry->GetURL()); 4594 EXPECT_EQ(url_a, entry->GetURL());
4595 ExplodedPageState exploded_state; 4595 ExplodedPageState exploded_state;
4596 EXPECT_TRUE( 4596 EXPECT_TRUE(
4597 DecodePageState(entry->GetPageState().ToEncodedData(), &exploded_state)); 4597 DecodePageState(entry->GetPageState().ToEncodedData(), &exploded_state));
4598 EXPECT_EQ(url_a, GURL(exploded_state.top.url_string.string())); 4598 EXPECT_EQ(url_a, GURL(exploded_state.top.url_string.string()));
4599 EXPECT_EQ(frame_url_a2, 4599 EXPECT_EQ(frame_url_a2,
4600 GURL(exploded_state.top.children.at(0).url_string.string())); 4600 GURL(exploded_state.top.children.at(0).url_string.string()));
4601 } 4601 }
4602 4602
4603 // Ensure that we do not corrupt a NavigationEntry's PageState if two forward
4604 // navigations compete in different frames. See https://crbug.com/623319.
4605 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
4606 PageStateAfterForwardInCompetingFrames) {
4607 // Navigate to a page with an iframe.
4608 GURL url_a(embedded_test_server()->GetURL(
4609 "/navigation_controller/page_with_data_iframe.html"));
4610 GURL frame_url_a1("data:text/html,Subframe");
4611 EXPECT_TRUE(NavigateToURL(shell(), url_a));
4612
4613 NavigationController& controller = shell()->web_contents()->GetController();
4614 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
4615 ->GetFrameTree()
4616 ->root();
4617 EXPECT_EQ(url_a, root->current_url());
4618 EXPECT_EQ(frame_url_a1, root->child_at(0)->current_url());
4619
4620 // Navigate the iframe to a second page.
4621 GURL frame_url_a2 = embedded_test_server()->GetURL(
4622 "/navigation_controller/simple_page_1.html");
4623 NavigateFrameToURL(root->child_at(0), frame_url_a2);
4624
4625 // Navigate the iframe to about:blank.
4626 GURL blank_url(url::kAboutBlankURL);
4627 NavigateFrameToURL(root->child_at(0), blank_url);
4628 EXPECT_EQ(3, controller.GetEntryCount());
4629 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
4630 EXPECT_EQ(url_a, root->current_url());
4631 EXPECT_EQ(blank_url, root->child_at(0)->current_url());
4632
4633 // Go back to the middle entry.
4634 controller.GoBack();
4635 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
4636 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
4637
4638 // Replace the entry with a cross-site top-level page. By doing a
4639 // replacement, the main frame pages before and after have the same item
4640 // sequence number, and thus going between them only requires loads in the
4641 // subframe.
4642 GURL url_b(embedded_test_server()->GetURL(
4643 "b.com", "/navigation_controller/simple_page_2.html"));
4644 std::string replace_script = "location.replace('" + url_b.spec() + "')";
4645 TestNavigationObserver replace_observer(shell()->web_contents());
4646 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), replace_script));
4647 replace_observer.Wait();
4648 EXPECT_EQ(3, controller.GetEntryCount());
4649 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
4650 EXPECT_EQ(url_b, root->current_url());
4651
4652 // Go back to the original page.
4653 controller.GoBack();
4654 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
4655
4656 // Navigate forward twice using script. In https://crbug.com/623319, this
4657 // caused a mismatch between the NavigationEntry's URL and PageState.
4658 EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
4659 "history.forward(); history.forward();"));
4660 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
4661 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
4662 EXPECT_EQ(url_b, root->current_url());
4663 NavigationEntry* entry = controller.GetLastCommittedEntry();
4664 EXPECT_EQ(url_b, entry->GetURL());
4665 ExplodedPageState exploded_state;
4666 EXPECT_TRUE(
4667 DecodePageState(entry->GetPageState().ToEncodedData(), &exploded_state));
4668 EXPECT_EQ(url_b, GURL(exploded_state.top.url_string.string()));
4669 // TODO(creis): Clear subframe FNEs after location.replace in
4670 // --isolate-extensions mode. See https://crbug.com/596707.
4671 if (!SiteIsolationPolicy::UseSubframeNavigationEntries())
4672 EXPECT_EQ(0U, exploded_state.top.children.size());
4673
4674 // Go back and then forward to see if the PageState loads correctly.
4675 controller.GoBack();
4676 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
4677 controller.GoForward();
4678 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
4679
4680 // We should be on url_b, and the renderer process shouldn't be killed.
4681 ASSERT_TRUE(root->current_frame_host()->IsRenderFrameLive());
4682 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
4683 EXPECT_EQ(url_b, shell()->web_contents()->GetVisibleURL());
4684 EXPECT_EQ(url_b, root->current_url());
4685 EXPECT_EQ(0U, root->child_count());
4686 }
4687
4603 // Ensure that forward navigations in cloned tabs can commit if they redirect to 4688 // Ensure that forward navigations in cloned tabs can commit if they redirect to
4604 // a different site than before. This causes the navigation's item sequence 4689 // a different site than before. This causes the navigation's item sequence
4605 // number to change, meaning that we can't use it for determining whether the 4690 // number to change, meaning that we can't use it for determining whether the
4606 // commit matches the history item. See https://crbug.com/600238. 4691 // commit matches the history item. See https://crbug.com/600238.
4607 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, 4692 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
4608 ForwardRedirectWithNoCommittedEntry) { 4693 ForwardRedirectWithNoCommittedEntry) {
4609 NavigationController& controller = shell()->web_contents()->GetController(); 4694 NavigationController& controller = shell()->web_contents()->GetController();
4610 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 4695 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
4611 ->GetFrameTree() 4696 ->GetFrameTree()
4612 ->root(); 4697 ->root();
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
4749 std::string body; 4834 std::string body;
4750 EXPECT_TRUE(ExecuteScriptAndExtractString( 4835 EXPECT_TRUE(ExecuteScriptAndExtractString(
4751 shell()->web_contents(), 4836 shell()->web_contents(),
4752 "window.domAutomationController.send(" 4837 "window.domAutomationController.send("
4753 "document.getElementsByTagName('pre')[0].innerText);", 4838 "document.getElementsByTagName('pre')[0].innerText);",
4754 &body)); 4839 &body));
4755 EXPECT_EQ("text=value\n", body); 4840 EXPECT_EQ("text=value\n", body);
4756 } 4841 }
4757 4842
4758 } // namespace content 4843 } // 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