| OLD | NEW |
| 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 <algorithm> | 8 #include <algorithm> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 5970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5981 EXPECT_EQ(1U, root->child_count()); | 5981 EXPECT_EQ(1U, root->child_count()); |
| 5982 EXPECT_NE("foo-frame-name", root->child_at(0)->frame_name()); | 5982 EXPECT_NE("foo-frame-name", root->child_at(0)->frame_name()); |
| 5983 | 5983 |
| 5984 // Add a nested frame with the previously used name. | 5984 // Add a nested frame with the previously used name. |
| 5985 EXPECT_TRUE(ExecuteScript(root->child_at(0), kAddNamedFrameScript)); | 5985 EXPECT_TRUE(ExecuteScript(root->child_at(0), kAddNamedFrameScript)); |
| 5986 EXPECT_EQ(1U, root->child_at(0)->child_count()); | 5986 EXPECT_EQ(1U, root->child_at(0)->child_count()); |
| 5987 EXPECT_EQ("foo-frame-name", root->child_at(0)->child_at(0)->frame_name()); | 5987 EXPECT_EQ("foo-frame-name", root->child_at(0)->child_at(0)->frame_name()); |
| 5988 | 5988 |
| 5989 EXPECT_EQ(1U, nav_entry->root_node()->children.size()); | 5989 EXPECT_EQ(1U, nav_entry->root_node()->children.size()); |
| 5990 | 5990 |
| 5991 NavigationEntryImpl::TreeNode* tree_node = | 5991 EXPECT_EQ(1U, nav_entry->root_node()->children[0]->children.size()); |
| 5992 nav_entry->root_node()->children[0]; | |
| 5993 EXPECT_EQ(1U, tree_node->children.size()); | |
| 5994 | 5992 |
| 5995 tree_node = tree_node->children[0]; | 5993 const auto& tree_node = nav_entry->root_node()->children[0]->children[0]; |
| 5996 EXPECT_EQ(0U, tree_node->children.size()); | 5994 EXPECT_EQ(0U, tree_node->children.size()); |
| 5997 EXPECT_EQ("foo-frame-name", tree_node->frame_entry->frame_unique_name()); | 5995 EXPECT_EQ("foo-frame-name", tree_node->frame_entry->frame_unique_name()); |
| 5998 | 5996 |
| 5999 EXPECT_TRUE(ExecuteScript(root->child_at(0), kRemoveFrameScript)); | 5997 EXPECT_TRUE(ExecuteScript(root->child_at(0), kRemoveFrameScript)); |
| 6000 EXPECT_EQ(0U, root->child_at(0)->child_count()); | 5998 EXPECT_EQ(0U, root->child_at(0)->child_count()); |
| 6001 } | 5999 } |
| 6002 | 6000 |
| 6003 // This test ensures that the comparison of tree position between a | 6001 // This test ensures that the comparison of tree position between a |
| 6004 // FrameTreeNode and FrameNavigationEntry works correctly for matching | 6002 // FrameTreeNode and FrameNavigationEntry works correctly for matching |
| 6005 // first-level frames. | 6003 // first-level frames. |
| 6006 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 6004 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 6007 EnsureFirstLevelFrameNavigationEntriesMatch) { | 6005 EnsureFirstLevelFrameNavigationEntriesMatch) { |
| 6008 WebContentsImpl* web_contents = | 6006 WebContentsImpl* web_contents = |
| 6009 static_cast<WebContentsImpl*>(shell()->web_contents()); | 6007 static_cast<WebContentsImpl*>(shell()->web_contents()); |
| 6010 FrameTreeNode* root = web_contents->GetFrameTree()->root(); | 6008 FrameTreeNode* root = web_contents->GetFrameTree()->root(); |
| 6011 NavigationEntryImpl::TreeNode* tree_node = nullptr; | |
| 6012 | 6009 |
| 6013 GURL start_url(embedded_test_server()->GetURL("/title1.html")); | 6010 GURL start_url(embedded_test_server()->GetURL("/title1.html")); |
| 6014 EXPECT_TRUE(NavigateToURL(shell(), start_url)); | 6011 EXPECT_TRUE(NavigateToURL(shell(), start_url)); |
| 6015 NavigationEntryImpl* nav_entry = | 6012 NavigationEntryImpl* nav_entry = |
| 6016 web_contents->GetController().GetLastCommittedEntry(); | 6013 web_contents->GetController().GetLastCommittedEntry(); |
| 6017 | 6014 |
| 6018 // Add, then remove a named frame. It will create a FrameNavigationEntry | 6015 // Add, then remove a named frame. It will create a FrameNavigationEntry |
| 6019 // for the name and leave it around. | 6016 // for the name and leave it around. |
| 6020 EXPECT_TRUE(ExecuteScript(root, kAddNamedFrameScript)); | 6017 EXPECT_TRUE(ExecuteScript(root, kAddNamedFrameScript)); |
| 6021 EXPECT_EQ(1U, root->child_count()); | 6018 EXPECT_EQ(1U, root->child_count()); |
| 6022 EXPECT_EQ(1U, nav_entry->root_node()->children.size()); | 6019 EXPECT_EQ(1U, nav_entry->root_node()->children.size()); |
| 6023 tree_node = nav_entry->root_node()->children[0]; | 6020 auto* tree_node = nav_entry->root_node()->children[0].get(); |
| 6024 | 6021 |
| 6025 EXPECT_TRUE(ExecuteScript(root, kRemoveFrameScript)); | 6022 EXPECT_TRUE(ExecuteScript(root, kRemoveFrameScript)); |
| 6026 EXPECT_EQ(0U, root->child_count()); | 6023 EXPECT_EQ(0U, root->child_count()); |
| 6027 EXPECT_EQ(1U, nav_entry->root_node()->children.size()); | 6024 EXPECT_EQ(1U, nav_entry->root_node()->children.size()); |
| 6028 | 6025 |
| 6029 // Add another frame with the same name as before. The matching logic | 6026 // Add another frame with the same name as before. The matching logic |
| 6030 // should consider them the same and result in the FrameNavigationEntry | 6027 // should consider them the same and result in the FrameNavigationEntry |
| 6031 // being reused. | 6028 // being reused. |
| 6032 EXPECT_TRUE(ExecuteScript(root, kAddNamedFrameScript)); | 6029 EXPECT_TRUE(ExecuteScript(root, kAddNamedFrameScript)); |
| 6033 EXPECT_EQ(1U, root->child_count()); | 6030 EXPECT_EQ(1U, root->child_count()); |
| 6034 EXPECT_EQ(1U, nav_entry->root_node()->children.size()); | 6031 EXPECT_EQ(1U, nav_entry->root_node()->children.size()); |
| 6035 EXPECT_EQ(tree_node, nav_entry->root_node()->children[0]); | 6032 EXPECT_EQ(tree_node, nav_entry->root_node()->children[0].get()); |
| 6036 | 6033 |
| 6037 EXPECT_TRUE(ExecuteScript(root, kRemoveFrameScript)); | 6034 EXPECT_TRUE(ExecuteScript(root, kRemoveFrameScript)); |
| 6038 EXPECT_EQ(0U, root->child_count()); | 6035 EXPECT_EQ(0U, root->child_count()); |
| 6039 } | 6036 } |
| 6040 | 6037 |
| 6041 // Test that navigations classified as SAME_PAGE properly update all the | 6038 // Test that navigations classified as SAME_PAGE properly update all the |
| 6042 // members of FrameNavigationEntry. If not, it is possible to get a mismatch | 6039 // members of FrameNavigationEntry. If not, it is possible to get a mismatch |
| 6043 // between the origin and URL of a document as seen in | 6040 // between the origin and URL of a document as seen in |
| 6044 // https://crbug.com/630103. | 6041 // https://crbug.com/630103. |
| 6045 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 6042 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6791 | 6788 |
| 6792 // Do a 204 navigation. | 6789 // Do a 204 navigation. |
| 6793 EXPECT_FALSE(NavigateToURL(shell(), kURL204)); | 6790 EXPECT_FALSE(NavigateToURL(shell(), kURL204)); |
| 6794 | 6791 |
| 6795 entry = controller.GetLastCommittedEntry(); | 6792 entry = controller.GetLastCommittedEntry(); |
| 6796 EXPECT_EQ(kURL, entry->GetURL()); | 6793 EXPECT_EQ(kURL, entry->GetURL()); |
| 6797 EXPECT_EQ(1, controller.GetEntryCount()); | 6794 EXPECT_EQ(1, controller.GetEntryCount()); |
| 6798 } | 6795 } |
| 6799 | 6796 |
| 6800 } // namespace content | 6797 } // namespace content |
| OLD | NEW |