| 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 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1861 // 1. Create a iframe with a URL that doesn't commit. | 1861 // 1. Create a iframe with a URL that doesn't commit. |
| 1862 GURL slow_url(embedded_test_server()->GetURL( | 1862 GURL slow_url(embedded_test_server()->GetURL( |
| 1863 "/navigation_controller/simple_page_2.html")); | 1863 "/navigation_controller/simple_page_2.html")); |
| 1864 TestNavigationManager subframe_delayer(shell()->web_contents(), slow_url); | 1864 TestNavigationManager subframe_delayer(shell()->web_contents(), slow_url); |
| 1865 { | 1865 { |
| 1866 std::string script = "var iframe = document.createElement('iframe');" | 1866 std::string script = "var iframe = document.createElement('iframe');" |
| 1867 "iframe.src = '" + slow_url.spec() + "';" | 1867 "iframe.src = '" + slow_url.spec() + "';" |
| 1868 "document.body.appendChild(iframe);"; | 1868 "document.body.appendChild(iframe);"; |
| 1869 EXPECT_TRUE(ExecuteScript(root, script)); | 1869 EXPECT_TRUE(ExecuteScript(root, script)); |
| 1870 } | 1870 } |
| 1871 subframe_delayer.WaitForWillStartRequest(); | 1871 EXPECT_TRUE(subframe_delayer.WaitForWillStartRequest()); |
| 1872 | 1872 |
| 1873 // Stop the request so that we can wait for load stop below, without ending up | 1873 // Stop the request so that we can wait for load stop below, without ending up |
| 1874 // with a commit for this frame. | 1874 // with a commit for this frame. |
| 1875 shell()->web_contents()->Stop(); | 1875 shell()->web_contents()->Stop(); |
| 1876 | 1876 |
| 1877 // 2. A nested iframe with a cross-site URL should be able to commit. | 1877 // 2. A nested iframe with a cross-site URL should be able to commit. |
| 1878 GURL foo_url(embedded_test_server()->GetURL( | 1878 GURL foo_url(embedded_test_server()->GetURL( |
| 1879 "foo.com", "/navigation_controller/simple_page_1.html")); | 1879 "foo.com", "/navigation_controller/simple_page_1.html")); |
| 1880 { | 1880 { |
| 1881 std::string script = "var iframe = document.createElement('iframe');" | 1881 std::string script = "var iframe = document.createElement('iframe');" |
| (...skipping 2170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4052 std::string script = "document.getElementById('thelink').click()"; | 4052 std::string script = "document.getElementById('thelink').click()"; |
| 4053 EXPECT_TRUE(ExecuteScript(root, script)); | 4053 EXPECT_TRUE(ExecuteScript(root, script)); |
| 4054 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 4054 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 4055 EXPECT_EQ(2, controller.GetEntryCount()); | 4055 EXPECT_EQ(2, controller.GetEntryCount()); |
| 4056 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 4056 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 4057 | 4057 |
| 4058 // Go back to the first page, which never completes. The attempt to unload the | 4058 // Go back to the first page, which never completes. The attempt to unload the |
| 4059 // second page, though, causes it to do a replaceState(). | 4059 // second page, though, causes it to do a replaceState(). |
| 4060 TestNavigationManager manager(shell()->web_contents(), start_url); | 4060 TestNavigationManager manager(shell()->web_contents(), start_url); |
| 4061 controller.GoBack(); | 4061 controller.GoBack(); |
| 4062 manager.WaitForWillStartRequest(); | 4062 EXPECT_TRUE(manager.WaitForWillStartRequest()); |
| 4063 | 4063 |
| 4064 // The navigation that just happened was the replaceState(), which should not | 4064 // The navigation that just happened was the replaceState(), which should not |
| 4065 // have changed the position into the navigation entry list. Make sure that | 4065 // have changed the position into the navigation entry list. Make sure that |
| 4066 // the pending navigation didn't confuse anything. | 4066 // the pending navigation didn't confuse anything. |
| 4067 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 4067 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 4068 } | 4068 } |
| 4069 | 4069 |
| 4070 // Ensure the renderer process does not get confused about the current entry | 4070 // Ensure the renderer process does not get confused about the current entry |
| 4071 // due to subframes and replaced entries. See https://crbug.com/480201. | 4071 // due to subframes and replaced entries. See https://crbug.com/480201. |
| 4072 // TODO(creis): Re-enable for Site Isolation FYI bots: https://crbug.com/502317. | 4072 // 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... |
| 4970 controller.GoToOffset(-2); | 4970 controller.GoToOffset(-2); |
| 4971 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 4971 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 4972 | 4972 |
| 4973 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 4973 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| 4974 EXPECT_EQ(url_a, root->current_url()); | 4974 EXPECT_EQ(url_a, root->current_url()); |
| 4975 EXPECT_EQ(frame_url_a1, root->child_at(0)->current_url()); | 4975 EXPECT_EQ(frame_url_a1, root->child_at(0)->current_url()); |
| 4976 | 4976 |
| 4977 // Go forward two times in a row, being careful that the subframe commits | 4977 // Go forward two times in a row, being careful that the subframe commits |
| 4978 // after the second forward navigation begins but before the main frame | 4978 // after the second forward navigation begins but before the main frame |
| 4979 // commits. | 4979 // commits. |
| 4980 TestNavigationManager subframe_delayer( | 4980 PerFrameTestNavigationManager subframe_delayer( |
| 4981 root->child_at(0)->frame_tree_node_id(), shell()->web_contents(), | 4981 root->child_at(0)->frame_tree_node_id(), shell()->web_contents(), |
| 4982 frame_url_a2); | 4982 frame_url_a2); |
| 4983 TestNavigationManager mainframe_delayer(shell()->web_contents(), url_b); | 4983 TestNavigationManager mainframe_delayer(shell()->web_contents(), url_b); |
| 4984 controller.GoForward(); | 4984 controller.GoForward(); |
| 4985 subframe_delayer.WaitForWillStartRequest(); | 4985 EXPECT_TRUE(subframe_delayer.WaitForWillStartRequest()); |
| 4986 controller.GoForward(); | 4986 controller.GoForward(); |
| 4987 mainframe_delayer.WaitForWillStartRequest(); | 4987 EXPECT_TRUE(mainframe_delayer.WaitForWillStartRequest()); |
| 4988 EXPECT_EQ(2, controller.GetPendingEntryIndex()); | 4988 EXPECT_EQ(2, controller.GetPendingEntryIndex()); |
| 4989 | 4989 |
| 4990 // Let the subframe commit. | 4990 // Let the subframe commit. |
| 4991 subframe_delayer.WaitForNavigationFinished(); | 4991 subframe_delayer.WaitForNavigationFinished(); |
| 4992 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 4992 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 4993 EXPECT_EQ(url_a, root->current_url()); | 4993 EXPECT_EQ(url_a, root->current_url()); |
| 4994 EXPECT_EQ(frame_url_a2, root->child_at(0)->current_url()); | 4994 EXPECT_EQ(frame_url_a2, root->child_at(0)->current_url()); |
| 4995 | 4995 |
| 4996 // Let the main frame commit. | 4996 // Let the main frame commit. |
| 4997 mainframe_delayer.WaitForNavigationFinished(); | 4997 mainframe_delayer.WaitForNavigationFinished(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 5020 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 5020 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 5021 AbortProvisionalLoadRetainsNavigationParams) { | 5021 AbortProvisionalLoadRetainsNavigationParams) { |
| 5022 EXPECT_TRUE( | 5022 EXPECT_TRUE( |
| 5023 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"))); | 5023 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"))); |
| 5024 EXPECT_TRUE( | 5024 EXPECT_TRUE( |
| 5025 NavigateToURL(shell(), embedded_test_server()->GetURL("/title2.html"))); | 5025 NavigateToURL(shell(), embedded_test_server()->GetURL("/title2.html"))); |
| 5026 | 5026 |
| 5027 TestNavigationManager delayer(shell()->web_contents(), | 5027 TestNavigationManager delayer(shell()->web_contents(), |
| 5028 embedded_test_server()->GetURL("/title3.html")); | 5028 embedded_test_server()->GetURL("/title3.html")); |
| 5029 shell()->LoadURL(embedded_test_server()->GetURL("/title3.html")); | 5029 shell()->LoadURL(embedded_test_server()->GetURL("/title3.html")); |
| 5030 delayer.WaitForWillStartRequest(); | 5030 EXPECT_TRUE(delayer.WaitForWillStartRequest()); |
| 5031 | 5031 |
| 5032 NavigationController& controller = shell()->web_contents()->GetController(); | 5032 NavigationController& controller = shell()->web_contents()->GetController(); |
| 5033 | 5033 |
| 5034 TestNavigationManager back_manager( | 5034 TestNavigationManager back_manager( |
| 5035 shell()->web_contents(), embedded_test_server()->GetURL("/title1.html")); | 5035 shell()->web_contents(), embedded_test_server()->GetURL("/title1.html")); |
| 5036 controller.GoBack(); | 5036 controller.GoBack(); |
| 5037 back_manager.WaitForNavigationFinished(); | 5037 back_manager.WaitForNavigationFinished(); |
| 5038 | 5038 |
| 5039 EXPECT_TRUE(controller.CanGoForward()); | 5039 EXPECT_TRUE(controller.CanGoForward()); |
| 5040 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); | 5040 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5420 std::string body; | 5420 std::string body; |
| 5421 EXPECT_TRUE(ExecuteScriptAndExtractString( | 5421 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 5422 shell()->web_contents(), | 5422 shell()->web_contents(), |
| 5423 "window.domAutomationController.send(" | 5423 "window.domAutomationController.send(" |
| 5424 "document.getElementsByTagName('pre')[0].innerText);", | 5424 "document.getElementsByTagName('pre')[0].innerText);", |
| 5425 &body)); | 5425 &body)); |
| 5426 EXPECT_EQ("text=value\n", body); | 5426 EXPECT_EQ("text=value\n", body); |
| 5427 } | 5427 } |
| 5428 | 5428 |
| 5429 } // namespace content | 5429 } // namespace content |
| OLD | NEW |