| 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 <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1876 // 1. Create a iframe with a URL that doesn't commit. | 1876 // 1. Create a iframe with a URL that doesn't commit. |
| 1877 GURL slow_url(embedded_test_server()->GetURL( | 1877 GURL slow_url(embedded_test_server()->GetURL( |
| 1878 "/navigation_controller/simple_page_2.html")); | 1878 "/navigation_controller/simple_page_2.html")); |
| 1879 TestNavigationManager subframe_delayer(shell()->web_contents(), slow_url); | 1879 TestNavigationManager subframe_delayer(shell()->web_contents(), slow_url); |
| 1880 { | 1880 { |
| 1881 std::string script = "var iframe = document.createElement('iframe');" | 1881 std::string script = "var iframe = document.createElement('iframe');" |
| 1882 "iframe.src = '" + slow_url.spec() + "';" | 1882 "iframe.src = '" + slow_url.spec() + "';" |
| 1883 "document.body.appendChild(iframe);"; | 1883 "document.body.appendChild(iframe);"; |
| 1884 EXPECT_TRUE(ExecuteScript(root, script)); | 1884 EXPECT_TRUE(ExecuteScript(root, script)); |
| 1885 } | 1885 } |
| 1886 subframe_delayer.WaitForWillStartRequest(); | 1886 EXPECT_TRUE(subframe_delayer.WaitForWillStartRequest()); |
| 1887 | 1887 |
| 1888 // Stop the request so that we can wait for load stop below, without ending up | 1888 // Stop the request so that we can wait for load stop below, without ending up |
| 1889 // with a commit for this frame. | 1889 // with a commit for this frame. |
| 1890 shell()->web_contents()->Stop(); | 1890 shell()->web_contents()->Stop(); |
| 1891 | 1891 |
| 1892 // 2. A nested iframe with a cross-site URL should be able to commit. | 1892 // 2. A nested iframe with a cross-site URL should be able to commit. |
| 1893 GURL foo_url(embedded_test_server()->GetURL( | 1893 GURL foo_url(embedded_test_server()->GetURL( |
| 1894 "foo.com", "/navigation_controller/simple_page_1.html")); | 1894 "foo.com", "/navigation_controller/simple_page_1.html")); |
| 1895 { | 1895 { |
| 1896 std::string script = "var iframe = document.createElement('iframe');" | 1896 std::string script = "var iframe = document.createElement('iframe');" |
| (...skipping 2170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4067 std::string script = "document.getElementById('thelink').click()"; | 4067 std::string script = "document.getElementById('thelink').click()"; |
| 4068 EXPECT_TRUE(ExecuteScript(root, script)); | 4068 EXPECT_TRUE(ExecuteScript(root, script)); |
| 4069 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 4069 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 4070 EXPECT_EQ(2, controller.GetEntryCount()); | 4070 EXPECT_EQ(2, controller.GetEntryCount()); |
| 4071 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 4071 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 4072 | 4072 |
| 4073 // Go back to the first page, which never completes. The attempt to unload the | 4073 // Go back to the first page, which never completes. The attempt to unload the |
| 4074 // second page, though, causes it to do a replaceState(). | 4074 // second page, though, causes it to do a replaceState(). |
| 4075 TestNavigationManager manager(shell()->web_contents(), start_url); | 4075 TestNavigationManager manager(shell()->web_contents(), start_url); |
| 4076 controller.GoBack(); | 4076 controller.GoBack(); |
| 4077 manager.WaitForWillStartRequest(); | 4077 EXPECT_TRUE(manager.WaitForWillStartRequest()); |
| 4078 | 4078 |
| 4079 // The navigation that just happened was the replaceState(), which should not | 4079 // The navigation that just happened was the replaceState(), which should not |
| 4080 // have changed the position into the navigation entry list. Make sure that | 4080 // have changed the position into the navigation entry list. Make sure that |
| 4081 // the pending navigation didn't confuse anything. | 4081 // the pending navigation didn't confuse anything. |
| 4082 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 4082 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 4083 } | 4083 } |
| 4084 | 4084 |
| 4085 // Ensure the renderer process does not get confused about the current entry | 4085 // Ensure the renderer process does not get confused about the current entry |
| 4086 // due to subframes and replaced entries. See https://crbug.com/480201. | 4086 // due to subframes and replaced entries. See https://crbug.com/480201. |
| 4087 // TODO(creis): Re-enable for Site Isolation FYI bots: https://crbug.com/502317. | 4087 // TODO(creis): Re-enable for Site Isolation FYI bots: https://crbug.com/502317. |
| (...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4985 controller.GoToOffset(-2); | 4985 controller.GoToOffset(-2); |
| 4986 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 4986 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 4987 | 4987 |
| 4988 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 4988 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| 4989 EXPECT_EQ(url_a, root->current_url()); | 4989 EXPECT_EQ(url_a, root->current_url()); |
| 4990 EXPECT_EQ(frame_url_a1, root->child_at(0)->current_url()); | 4990 EXPECT_EQ(frame_url_a1, root->child_at(0)->current_url()); |
| 4991 | 4991 |
| 4992 // Go forward two times in a row, being careful that the subframe commits | 4992 // Go forward two times in a row, being careful that the subframe commits |
| 4993 // after the second forward navigation begins but before the main frame | 4993 // after the second forward navigation begins but before the main frame |
| 4994 // commits. | 4994 // commits. |
| 4995 TestNavigationManager subframe_delayer( | 4995 FrameTestNavigationManager subframe_delayer( |
| 4996 root->child_at(0)->frame_tree_node_id(), shell()->web_contents(), | 4996 root->child_at(0)->frame_tree_node_id(), shell()->web_contents(), |
| 4997 frame_url_a2); | 4997 frame_url_a2); |
| 4998 TestNavigationManager mainframe_delayer(shell()->web_contents(), url_b); | 4998 TestNavigationManager mainframe_delayer(shell()->web_contents(), url_b); |
| 4999 controller.GoForward(); | 4999 controller.GoForward(); |
| 5000 subframe_delayer.WaitForWillStartRequest(); | 5000 EXPECT_TRUE(subframe_delayer.WaitForWillStartRequest()); |
| 5001 controller.GoForward(); | 5001 controller.GoForward(); |
| 5002 mainframe_delayer.WaitForWillStartRequest(); | 5002 EXPECT_TRUE(mainframe_delayer.WaitForWillStartRequest()); |
| 5003 EXPECT_EQ(2, controller.GetPendingEntryIndex()); | 5003 EXPECT_EQ(2, controller.GetPendingEntryIndex()); |
| 5004 | 5004 |
| 5005 // Let the subframe commit. | 5005 // Let the subframe commit. |
| 5006 subframe_delayer.WaitForNavigationFinished(); | 5006 subframe_delayer.WaitForNavigationFinished(); |
| 5007 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 5007 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 5008 EXPECT_EQ(url_a, root->current_url()); | 5008 EXPECT_EQ(url_a, root->current_url()); |
| 5009 EXPECT_EQ(frame_url_a2, root->child_at(0)->current_url()); | 5009 EXPECT_EQ(frame_url_a2, root->child_at(0)->current_url()); |
| 5010 | 5010 |
| 5011 // Let the main frame commit. | 5011 // Let the main frame commit. |
| 5012 mainframe_delayer.WaitForNavigationFinished(); | 5012 mainframe_delayer.WaitForNavigationFinished(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 5035 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 5035 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 5036 AbortProvisionalLoadRetainsNavigationParams) { | 5036 AbortProvisionalLoadRetainsNavigationParams) { |
| 5037 EXPECT_TRUE( | 5037 EXPECT_TRUE( |
| 5038 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"))); | 5038 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"))); |
| 5039 EXPECT_TRUE( | 5039 EXPECT_TRUE( |
| 5040 NavigateToURL(shell(), embedded_test_server()->GetURL("/title2.html"))); | 5040 NavigateToURL(shell(), embedded_test_server()->GetURL("/title2.html"))); |
| 5041 | 5041 |
| 5042 TestNavigationManager delayer(shell()->web_contents(), | 5042 TestNavigationManager delayer(shell()->web_contents(), |
| 5043 embedded_test_server()->GetURL("/title3.html")); | 5043 embedded_test_server()->GetURL("/title3.html")); |
| 5044 shell()->LoadURL(embedded_test_server()->GetURL("/title3.html")); | 5044 shell()->LoadURL(embedded_test_server()->GetURL("/title3.html")); |
| 5045 delayer.WaitForWillStartRequest(); | 5045 EXPECT_TRUE(delayer.WaitForWillStartRequest()); |
| 5046 | 5046 |
| 5047 NavigationController& controller = shell()->web_contents()->GetController(); | 5047 NavigationController& controller = shell()->web_contents()->GetController(); |
| 5048 | 5048 |
| 5049 TestNavigationManager back_manager( | 5049 TestNavigationManager back_manager( |
| 5050 shell()->web_contents(), embedded_test_server()->GetURL("/title1.html")); | 5050 shell()->web_contents(), embedded_test_server()->GetURL("/title1.html")); |
| 5051 controller.GoBack(); | 5051 controller.GoBack(); |
| 5052 back_manager.WaitForNavigationFinished(); | 5052 back_manager.WaitForNavigationFinished(); |
| 5053 | 5053 |
| 5054 EXPECT_TRUE(controller.CanGoForward()); | 5054 EXPECT_TRUE(controller.CanGoForward()); |
| 5055 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); | 5055 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } // namespace content | 5619 } // namespace content |
| OLD | NEW |