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 1880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1891 // 1. Create a iframe with a URL that doesn't commit. | 1891 // 1. Create a iframe with a URL that doesn't commit. |
1892 GURL slow_url(embedded_test_server()->GetURL( | 1892 GURL slow_url(embedded_test_server()->GetURL( |
1893 "/navigation_controller/simple_page_2.html")); | 1893 "/navigation_controller/simple_page_2.html")); |
1894 TestNavigationManager subframe_delayer(shell()->web_contents(), slow_url); | 1894 TestNavigationManager subframe_delayer(shell()->web_contents(), slow_url); |
1895 { | 1895 { |
1896 std::string script = "var iframe = document.createElement('iframe');" | 1896 std::string script = "var iframe = document.createElement('iframe');" |
1897 "iframe.src = '" + slow_url.spec() + "';" | 1897 "iframe.src = '" + slow_url.spec() + "';" |
1898 "document.body.appendChild(iframe);"; | 1898 "document.body.appendChild(iframe);"; |
1899 EXPECT_TRUE(ExecuteScript(root, script)); | 1899 EXPECT_TRUE(ExecuteScript(root, script)); |
1900 } | 1900 } |
1901 EXPECT_TRUE(subframe_delayer.WaitForWillStartRequest()); | 1901 EXPECT_TRUE(subframe_delayer.WaitForRequestStart()); |
1902 | 1902 |
1903 // Stop the request so that we can wait for load stop below, without ending up | 1903 // Stop the request so that we can wait for load stop below, without ending up |
1904 // with a commit for this frame. | 1904 // with a commit for this frame. |
1905 shell()->web_contents()->Stop(); | 1905 shell()->web_contents()->Stop(); |
1906 | 1906 |
1907 // 2. A nested iframe with a cross-site URL should be able to commit. | 1907 // 2. A nested iframe with a cross-site URL should be able to commit. |
1908 GURL foo_url(embedded_test_server()->GetURL( | 1908 GURL foo_url(embedded_test_server()->GetURL( |
1909 "foo.com", "/navigation_controller/simple_page_1.html")); | 1909 "foo.com", "/navigation_controller/simple_page_1.html")); |
1910 { | 1910 { |
1911 std::string script = "var iframe = document.createElement('iframe');" | 1911 std::string script = "var iframe = document.createElement('iframe');" |
(...skipping 2649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4561 std::string script = "document.getElementById('thelink').click()"; | 4561 std::string script = "document.getElementById('thelink').click()"; |
4562 EXPECT_TRUE(ExecuteScript(root, script)); | 4562 EXPECT_TRUE(ExecuteScript(root, script)); |
4563 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 4563 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
4564 EXPECT_EQ(2, controller.GetEntryCount()); | 4564 EXPECT_EQ(2, controller.GetEntryCount()); |
4565 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 4565 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
4566 | 4566 |
4567 // Go back to the first page, which never completes. The attempt to unload the | 4567 // Go back to the first page, which never completes. The attempt to unload the |
4568 // second page, though, causes it to do a replaceState(). | 4568 // second page, though, causes it to do a replaceState(). |
4569 TestNavigationManager manager(shell()->web_contents(), start_url); | 4569 TestNavigationManager manager(shell()->web_contents(), start_url); |
4570 controller.GoBack(); | 4570 controller.GoBack(); |
4571 EXPECT_TRUE(manager.WaitForWillStartRequest()); | 4571 EXPECT_TRUE(manager.WaitForRequestStart()); |
4572 | 4572 |
4573 // The navigation that just happened was the replaceState(), which should not | 4573 // The navigation that just happened was the replaceState(), which should not |
4574 // have changed the position into the navigation entry list. Make sure that | 4574 // have changed the position into the navigation entry list. Make sure that |
4575 // the pending navigation didn't confuse anything. | 4575 // the pending navigation didn't confuse anything. |
4576 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 4576 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
4577 } | 4577 } |
4578 | 4578 |
4579 // Ensure the renderer process does not get confused about the current entry | 4579 // Ensure the renderer process does not get confused about the current entry |
4580 // due to subframes and replaced entries. See https://crbug.com/480201. | 4580 // due to subframes and replaced entries. See https://crbug.com/480201. |
4581 // TODO(creis): Re-enable for Site Isolation FYI bots: https://crbug.com/502317. | 4581 // 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... |
5484 EXPECT_EQ(frame_url_a1, root->child_at(0)->current_url()); | 5484 EXPECT_EQ(frame_url_a1, root->child_at(0)->current_url()); |
5485 | 5485 |
5486 // Go forward two times in a row, being careful that the subframe commits | 5486 // Go forward two times in a row, being careful that the subframe commits |
5487 // after the second forward navigation begins but before the main frame | 5487 // after the second forward navigation begins but before the main frame |
5488 // commits. | 5488 // commits. |
5489 FrameTestNavigationManager subframe_delayer( | 5489 FrameTestNavigationManager subframe_delayer( |
5490 root->child_at(0)->frame_tree_node_id(), shell()->web_contents(), | 5490 root->child_at(0)->frame_tree_node_id(), shell()->web_contents(), |
5491 frame_url_a2); | 5491 frame_url_a2); |
5492 TestNavigationManager mainframe_delayer(shell()->web_contents(), url_b); | 5492 TestNavigationManager mainframe_delayer(shell()->web_contents(), url_b); |
5493 controller.GoForward(); | 5493 controller.GoForward(); |
5494 EXPECT_TRUE(subframe_delayer.WaitForWillStartRequest()); | 5494 EXPECT_TRUE(subframe_delayer.WaitForRequestStart()); |
5495 controller.GoForward(); | 5495 controller.GoForward(); |
5496 EXPECT_TRUE(mainframe_delayer.WaitForWillStartRequest()); | 5496 EXPECT_TRUE(mainframe_delayer.WaitForRequestStart()); |
5497 EXPECT_EQ(2, controller.GetPendingEntryIndex()); | 5497 EXPECT_EQ(2, controller.GetPendingEntryIndex()); |
5498 | 5498 |
5499 // Let the subframe commit. | 5499 // Let the subframe commit. |
5500 subframe_delayer.WaitForNavigationFinished(); | 5500 subframe_delayer.WaitForNavigationFinished(); |
5501 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 5501 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
5502 EXPECT_EQ(url_a, root->current_url()); | 5502 EXPECT_EQ(url_a, root->current_url()); |
5503 EXPECT_EQ(frame_url_a2, root->child_at(0)->current_url()); | 5503 EXPECT_EQ(frame_url_a2, root->child_at(0)->current_url()); |
5504 | 5504 |
5505 // Let the main frame commit. | 5505 // Let the main frame commit. |
5506 mainframe_delayer.WaitForNavigationFinished(); | 5506 mainframe_delayer.WaitForNavigationFinished(); |
(...skipping 29 matching lines...) Expand all Loading... |
5536 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 5536 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
5537 AbortProvisionalLoadRetainsNavigationParams) { | 5537 AbortProvisionalLoadRetainsNavigationParams) { |
5538 EXPECT_TRUE( | 5538 EXPECT_TRUE( |
5539 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"))); | 5539 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"))); |
5540 EXPECT_TRUE( | 5540 EXPECT_TRUE( |
5541 NavigateToURL(shell(), embedded_test_server()->GetURL("/title2.html"))); | 5541 NavigateToURL(shell(), embedded_test_server()->GetURL("/title2.html"))); |
5542 | 5542 |
5543 TestNavigationManager delayer(shell()->web_contents(), | 5543 TestNavigationManager delayer(shell()->web_contents(), |
5544 embedded_test_server()->GetURL("/title3.html")); | 5544 embedded_test_server()->GetURL("/title3.html")); |
5545 shell()->LoadURL(embedded_test_server()->GetURL("/title3.html")); | 5545 shell()->LoadURL(embedded_test_server()->GetURL("/title3.html")); |
5546 EXPECT_TRUE(delayer.WaitForWillStartRequest()); | 5546 EXPECT_TRUE(delayer.WaitForRequestStart()); |
5547 | 5547 |
5548 NavigationController& controller = shell()->web_contents()->GetController(); | 5548 NavigationController& controller = shell()->web_contents()->GetController(); |
5549 | 5549 |
5550 TestNavigationManager back_manager( | 5550 TestNavigationManager back_manager( |
5551 shell()->web_contents(), embedded_test_server()->GetURL("/title1.html")); | 5551 shell()->web_contents(), embedded_test_server()->GetURL("/title1.html")); |
5552 controller.GoBack(); | 5552 controller.GoBack(); |
5553 back_manager.WaitForNavigationFinished(); | 5553 back_manager.WaitForNavigationFinished(); |
5554 | 5554 |
5555 EXPECT_TRUE(controller.CanGoForward()); | 5555 EXPECT_TRUE(controller.CanGoForward()); |
5556 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); | 5556 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); |
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6550 histogram.ExpectTotalCount(kReloadToReloadMetricName, 4); | 6550 histogram.ExpectTotalCount(kReloadToReloadMetricName, 4); |
6551 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 3); | 6551 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 3); |
6552 | 6552 |
6553 controller.ReloadToRefreshContent(false); | 6553 controller.ReloadToRefreshContent(false); |
6554 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 6554 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
6555 histogram.ExpectTotalCount(kReloadToReloadMetricName, 4); | 6555 histogram.ExpectTotalCount(kReloadToReloadMetricName, 4); |
6556 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 3); | 6556 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 3); |
6557 } | 6557 } |
6558 | 6558 |
6559 } // namespace content | 6559 } // namespace content |
OLD | NEW |