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 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 TestNavigationManager 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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5391 std::string body; | 5391 std::string body; |
5392 EXPECT_TRUE(ExecuteScriptAndExtractString( | 5392 EXPECT_TRUE(ExecuteScriptAndExtractString( |
5393 shell()->web_contents(), | 5393 shell()->web_contents(), |
5394 "window.domAutomationController.send(" | 5394 "window.domAutomationController.send(" |
5395 "document.getElementsByTagName('pre')[0].innerText);", | 5395 "document.getElementsByTagName('pre')[0].innerText);", |
5396 &body)); | 5396 &body)); |
5397 EXPECT_EQ("text=value\n", body); | 5397 EXPECT_EQ("text=value\n", body); |
5398 } | 5398 } |
5399 | 5399 |
5400 } // namespace content | 5400 } // namespace content |
OLD | NEW |