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 <algorithm> | 8 #include <algorithm> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 6891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6902 | 6902 |
6903 // Verify that the extra header was NOT present for the subresource. | 6903 // Verify that the extra header was NOT present for the subresource. |
6904 const net::test_server::HttpRequest* image_request = | 6904 const net::test_server::HttpRequest* image_request = |
6905 FindAccumulatedRequest(image_url); | 6905 FindAccumulatedRequest(image_url); |
6906 ASSERT_TRUE(image_request); | 6906 ASSERT_TRUE(image_request); |
6907 EXPECT_THAT(image_request->headers, | 6907 EXPECT_THAT(image_request->headers, |
6908 testing::Not(testing::Contains( | 6908 testing::Not(testing::Contains( |
6909 testing::Key("X-ExtraHeadersVsSubresources")))); | 6909 testing::Key("X-ExtraHeadersVsSubresources")))); |
6910 } | 6910 } |
6911 | 6911 |
| 6912 // Test that a same-page navigation does not lead to the deletion of the |
| 6913 // NavigationHandle for an ongoing different page navigation. |
| 6914 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 6915 SamePageNavigationDoesntDeleteNavigationHandle) { |
| 6916 const GURL kURL1 = embedded_test_server()->GetURL("/title1.html"); |
| 6917 const GURL kPushStateURL = |
| 6918 embedded_test_server()->GetURL("/title1.html#fragment"); |
| 6919 const GURL kURL2 = embedded_test_server()->GetURL("/title2.html"); |
| 6920 |
| 6921 // Navigate to the initial page. |
| 6922 EXPECT_TRUE(NavigateToURL(shell(), kURL1)); |
| 6923 RenderFrameHostImpl* main_frame = |
| 6924 static_cast<WebContentsImpl*>(shell()->web_contents())->GetMainFrame(); |
| 6925 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 6926 ->GetFrameTree() |
| 6927 ->root(); |
| 6928 EXPECT_FALSE(main_frame->navigation_handle()); |
| 6929 EXPECT_FALSE(root->navigation_request()); |
| 6930 |
| 6931 // Start navigating to the second page. |
| 6932 TestNavigationManager manager(shell()->web_contents(), kURL2); |
| 6933 shell()->web_contents()->GetController().LoadURL( |
| 6934 kURL2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); |
| 6935 EXPECT_TRUE(manager.WaitForRequestStart()); |
| 6936 |
| 6937 // This should create a NavigationHandle. |
| 6938 if (IsBrowserSideNavigationEnabled()) { |
| 6939 EXPECT_TRUE(root->navigation_request()); |
| 6940 } else { |
| 6941 EXPECT_TRUE(main_frame->navigation_handle()); |
| 6942 } |
| 6943 |
| 6944 // The current page does a PushState. |
| 6945 std::string push_state = |
| 6946 "var stateObj = {}; history.pushState(stateObj, \"title 1\", \"" + |
| 6947 kPushStateURL.spec() + "\");"; |
| 6948 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), push_state)); |
| 6949 NavigationEntry* last_committed = |
| 6950 shell()->web_contents()->GetController().GetLastCommittedEntry(); |
| 6951 ASSERT_TRUE(last_committed); |
| 6952 EXPECT_EQ(kPushStateURL, last_committed->GetURL()); |
| 6953 |
| 6954 // This shouldn't affect the ongoing navigation. |
| 6955 if (IsBrowserSideNavigationEnabled()) { |
| 6956 EXPECT_TRUE(root->navigation_request()); |
| 6957 } else { |
| 6958 EXPECT_TRUE(main_frame->navigation_handle()); |
| 6959 } |
| 6960 |
| 6961 // Let the navigation finish. It should commit successfully. |
| 6962 manager.WaitForNavigationFinished(); |
| 6963 last_committed = |
| 6964 shell()->web_contents()->GetController().GetLastCommittedEntry(); |
| 6965 ASSERT_TRUE(last_committed); |
| 6966 EXPECT_EQ(kURL2, last_committed->GetURL()); |
| 6967 } |
| 6968 |
6912 } // namespace content | 6969 } // namespace content |
OLD | NEW |