| 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 4993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5004 NavigationEntry* entry = controller.GetEntryAtIndex(1); | 5004 NavigationEntry* entry = controller.GetEntryAtIndex(1); |
| 5005 EXPECT_EQ(url_a, entry->GetURL()); | 5005 EXPECT_EQ(url_a, entry->GetURL()); |
| 5006 ExplodedPageState exploded_state; | 5006 ExplodedPageState exploded_state; |
| 5007 EXPECT_TRUE( | 5007 EXPECT_TRUE( |
| 5008 DecodePageState(entry->GetPageState().ToEncodedData(), &exploded_state)); | 5008 DecodePageState(entry->GetPageState().ToEncodedData(), &exploded_state)); |
| 5009 EXPECT_EQ(url_a, GURL(exploded_state.top.url_string.string())); | 5009 EXPECT_EQ(url_a, GURL(exploded_state.top.url_string.string())); |
| 5010 EXPECT_EQ(frame_url_a2, | 5010 EXPECT_EQ(frame_url_a2, |
| 5011 GURL(exploded_state.top.children.at(0).url_string.string())); | 5011 GURL(exploded_state.top.children.at(0).url_string.string())); |
| 5012 } | 5012 } |
| 5013 | 5013 |
| 5014 // Start a provisional navigation, but abort it by going back before it commits. |
| 5015 // In crbug.com/631617 there was an issue which cleared the |
| 5016 // pending_navigation_params_ in RenderFrameImpl. This caused the interrupting |
| 5017 // navigation to lose important navigation data like its nav_entry_id, which |
| 5018 // could cause it to commit in-place instead of in the correct location in the |
| 5019 // browsing history. |
| 5020 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 5021 AbortProvisionalLoadRetainsNavigationParams) { |
| 5022 EXPECT_TRUE( |
| 5023 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"))); |
| 5024 EXPECT_TRUE( |
| 5025 NavigateToURL(shell(), embedded_test_server()->GetURL("/title2.html"))); |
| 5026 |
| 5027 TestNavigationManager delayer(shell()->web_contents(), |
| 5028 embedded_test_server()->GetURL("/title3.html")); |
| 5029 shell()->LoadURL(embedded_test_server()->GetURL("/title3.html")); |
| 5030 delayer.WaitForWillStartRequest(); |
| 5031 |
| 5032 NavigationController& controller = shell()->web_contents()->GetController(); |
| 5033 |
| 5034 TestNavigationManager back_manager( |
| 5035 shell()->web_contents(), embedded_test_server()->GetURL("/title1.html")); |
| 5036 controller.GoBack(); |
| 5037 back_manager.WaitForNavigationFinished(); |
| 5038 |
| 5039 EXPECT_TRUE(controller.CanGoForward()); |
| 5040 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); |
| 5041 } |
| 5042 |
| 5014 // Ensure that we do not corrupt a NavigationEntry's PageState if two forward | 5043 // Ensure that we do not corrupt a NavigationEntry's PageState if two forward |
| 5015 // navigations compete in different frames. See https://crbug.com/623319. | 5044 // navigations compete in different frames. See https://crbug.com/623319. |
| 5016 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 5045 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 5017 PageStateAfterForwardInCompetingFrames) { | 5046 PageStateAfterForwardInCompetingFrames) { |
| 5018 // Navigate to a page with an iframe. | 5047 // Navigate to a page with an iframe. |
| 5019 GURL url_a(embedded_test_server()->GetURL( | 5048 GURL url_a(embedded_test_server()->GetURL( |
| 5020 "/navigation_controller/page_with_data_iframe.html")); | 5049 "/navigation_controller/page_with_data_iframe.html")); |
| 5021 GURL frame_url_a1("data:text/html,Subframe"); | 5050 GURL frame_url_a1("data:text/html,Subframe"); |
| 5022 EXPECT_TRUE(NavigateToURL(shell(), url_a)); | 5051 EXPECT_TRUE(NavigateToURL(shell(), url_a)); |
| 5023 | 5052 |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5391 std::string body; | 5420 std::string body; |
| 5392 EXPECT_TRUE(ExecuteScriptAndExtractString( | 5421 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 5393 shell()->web_contents(), | 5422 shell()->web_contents(), |
| 5394 "window.domAutomationController.send(" | 5423 "window.domAutomationController.send(" |
| 5395 "document.getElementsByTagName('pre')[0].innerText);", | 5424 "document.getElementsByTagName('pre')[0].innerText);", |
| 5396 &body)); | 5425 &body)); |
| 5397 EXPECT_EQ("text=value\n", body); | 5426 EXPECT_EQ("text=value\n", body); |
| 5398 } | 5427 } |
| 5399 | 5428 |
| 5400 } // namespace content | 5429 } // namespace content |
| OLD | NEW |