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

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

Issue 2224213005: Ensure FrameNavigationEntry is fully updated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use cross-origin instead of cross-site. Created 4 years, 4 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 "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 5598 matching lines...) Expand 10 before | Expand all | Expand 10 after
5609 EXPECT_EQ(1U, root->child_count()); 5609 EXPECT_EQ(1U, root->child_count());
5610 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { 5610 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
5611 EXPECT_EQ(1U, nav_entry->root_node()->children.size()); 5611 EXPECT_EQ(1U, nav_entry->root_node()->children.size());
5612 EXPECT_EQ(tree_node, nav_entry->root_node()->children[0]); 5612 EXPECT_EQ(tree_node, nav_entry->root_node()->children[0]);
5613 } 5613 }
5614 5614
5615 EXPECT_TRUE(ExecuteScript(root, kRemoveFrameScript)); 5615 EXPECT_TRUE(ExecuteScript(root, kRemoveFrameScript));
5616 EXPECT_EQ(0U, root->child_count()); 5616 EXPECT_EQ(0U, root->child_count());
5617 } 5617 }
5618 5618
5619 // Test that navigations classified as SAME_PAGE properly update all the
5620 // members of FrameNavigationEntry. If not, it is possible to get a mismatch
5621 // between the origin and URL of a document as seen in
5622 // https://crbug.com/630103.
5623 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
5624 EnsureSamePageNavigationUpdatesFrameNavigationEntry) {
5625 WebContentsImpl* web_contents =
5626 static_cast<WebContentsImpl*>(shell()->web_contents());
5627 FrameTreeNode* root = web_contents->GetFrameTree()->root();
5628
5629 // Navigate to a simple page and then perform an in-page navigation.
5630 GURL start_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
5631 EXPECT_TRUE(NavigateToURL(shell(), start_url));
5632
5633 GURL same_page_url(
5634 embedded_test_server()->GetURL("a.com", "/title1.html#foo"));
5635 EXPECT_TRUE(NavigateToURL(shell(), same_page_url));
5636 EXPECT_EQ(2, web_contents->GetController().GetEntryCount());
5637
5638 // Replace the URL of the current NavigationEntry with one that will cause
5639 // a server redirect when loaded.
5640 {
5641 GURL redirect_dest_url(
5642 embedded_test_server()->GetURL("sub.a.com", "/simple_page.html"));
nasko 2016/08/10 21:26:56 Went back to using cross-origin instead of cross-s
Charlie Reis 2016/08/10 21:28:58 Yes, I could believe --site-per-process gets that
5643 TestNavigationObserver observer(web_contents);
5644 std::string script = "history.replaceState({}, '', '/server-redirect?" +
5645 redirect_dest_url.spec() + "')";
5646 EXPECT_TRUE(ExecuteScript(root, script));
5647 observer.Wait();
5648 }
5649
5650 // Simulate the user hitting Enter in the omnibox without changing the URL.
5651 {
5652 TestNavigationObserver observer(web_contents);
5653 web_contents->GetController().LoadURL(web_contents->GetLastCommittedURL(),
5654 Referrer(), ui::PAGE_TRANSITION_LINK,
5655 std::string());
5656 observer.Wait();
5657 }
5658
5659 // Prior to fixing the issue, the above omnibox navigation (which is
5660 // classified as SAME_PAGE) was leaving the FrameNavigationEntry with the
5661 // same document sequence number as the previous entry but updates the URL.
5662 // Doing a back session history navigation now will cause the browser to
5663 // consider it as in-page because of this matching document sequence number
5664 // and lead to a mismatch of origin and URL in the renderer process.
5665 {
5666 TestNavigationObserver observer(web_contents);
5667 web_contents->GetController().GoBack();
5668 observer.Wait();
5669 }
5670
5671 // Verify the expected origin through JavaScript. It also has the additional
5672 // verification of the process also being still alive.
5673 std::string origin;
5674 EXPECT_TRUE(ExecuteScriptAndExtractString(
5675 web_contents, "domAutomationController.send(document.origin)", &origin));
5676 EXPECT_EQ(start_url.GetOrigin().spec(), origin + "/");
5677 }
5678
5619 } // namespace content 5679 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl.cc ('k') | content/browser/frame_host/navigation_entry_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698