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 6148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6159 web_contents->GetMainFrame()->GetProcess()->AddFilter(filter.get()); | 6159 web_contents->GetMainFrame()->GetProcess()->AddFilter(filter.get()); |
6160 | 6160 |
6161 // Navigate cross-origin, waiting for the commit to occur. | 6161 // Navigate cross-origin, waiting for the commit to occur. |
6162 UrlCommitObserver cross_origin_commit_observer(root, cross_origin_url); | 6162 UrlCommitObserver cross_origin_commit_observer(root, cross_origin_url); |
6163 UrlCommitObserver history_commit_observer(root, start_url); | 6163 UrlCommitObserver history_commit_observer(root, start_url); |
6164 shell()->LoadURL(cross_origin_url); | 6164 shell()->LoadURL(cross_origin_url); |
6165 cross_origin_commit_observer.Wait(); | 6165 cross_origin_commit_observer.Wait(); |
6166 EXPECT_EQ(cross_origin_url, web_contents->GetLastCommittedURL()); | 6166 EXPECT_EQ(cross_origin_url, web_contents->GetLastCommittedURL()); |
6167 EXPECT_EQ(2, web_contents->GetController().GetLastCommittedEntryIndex()); | 6167 EXPECT_EQ(2, web_contents->GetController().GetLastCommittedEntryIndex()); |
6168 | 6168 |
6169 // Wait for the back navigation to commit as well. | 6169 if (IsBrowserSideNavigationEnabled()) { |
6170 history_commit_observer.Wait(); | 6170 // With browser-side-navigation, the history navigation is dropped. |
6171 EXPECT_EQ(start_url, web_contents->GetLastCommittedURL()); | 6171 // Navigate to another URL to give the back navigation the opportunity to |
6172 EXPECT_EQ(0, web_contents->GetController().GetLastCommittedEntryIndex()); | 6172 // commit if it was not dropped. |
| 6173 GURL another_url(embedded_test_server()->GetURL("b.com", "/title1.html")); |
| 6174 EXPECT_TRUE(NavigateToURL(shell(), another_url)); |
| 6175 EXPECT_EQ(3, web_contents->GetController().GetLastCommittedEntryIndex()); |
| 6176 EXPECT_EQ(4, web_contents->GetController().GetEntryCount()); |
6173 | 6177 |
6174 // Verify the expected origin through JavaScript. It also has the additional | 6178 // Verify the expected origin through JavaScript. It also has the additional |
6175 // verification of the process also being still alive. | 6179 // verification of the process also being still alive. |
6176 std::string origin; | 6180 std::string origin; |
6177 EXPECT_TRUE(ExecuteScriptAndExtractString( | 6181 EXPECT_TRUE(ExecuteScriptAndExtractString( |
6178 web_contents, "domAutomationController.send(document.origin)", &origin)); | 6182 web_contents, "domAutomationController.send(document.origin)", |
6179 EXPECT_EQ(start_url.GetOrigin().spec(), origin + "/"); | 6183 &origin)); |
| 6184 EXPECT_EQ(another_url.GetOrigin().spec(), origin + "/"); |
| 6185 } else { |
| 6186 // Wait for the back navigation to commit as well. |
| 6187 history_commit_observer.Wait(); |
| 6188 EXPECT_EQ(start_url, web_contents->GetLastCommittedURL()); |
| 6189 EXPECT_EQ(0, web_contents->GetController().GetLastCommittedEntryIndex()); |
| 6190 EXPECT_EQ(3, web_contents->GetController().GetEntryCount()); |
| 6191 |
| 6192 // Verify the expected origin through JavaScript. It also has the additional |
| 6193 // verification of the process also being still alive. |
| 6194 std::string origin; |
| 6195 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 6196 web_contents, "domAutomationController.send(document.origin)", |
| 6197 &origin)); |
| 6198 EXPECT_EQ(start_url.GetOrigin().spec(), origin + "/"); |
| 6199 } |
6180 } | 6200 } |
6181 | 6201 |
6182 // Test that verifies that Referer and Origin http headers are correctly sent | 6202 // Test that verifies that Referer and Origin http headers are correctly sent |
6183 // to the final destination of a cross-site POST with a few redirects thrown in. | 6203 // to the final destination of a cross-site POST with a few redirects thrown in. |
6184 // This test is somewhat related to https://crbug.com/635400. | 6204 // This test is somewhat related to https://crbug.com/635400. |
6185 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 6205 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
6186 RefererAndOriginHeadersAfterRedirects) { | 6206 RefererAndOriginHeadersAfterRedirects) { |
6187 // Navigate to the page with form that posts via 307 redirection to | 6207 // Navigate to the page with form that posts via 307 redirection to |
6188 // |redirect_target_url| (cross-site from |form_url|). Using 307 (rather than | 6208 // |redirect_target_url| (cross-site from |form_url|). Using 307 (rather than |
6189 // 302) redirection is important to preserve the HTTP method and POST body. | 6209 // 302) redirection is important to preserve the HTTP method and POST body. |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6711 NavigationHandleCommitObserver handle_observer(shell()->web_contents(), | 6731 NavigationHandleCommitObserver handle_observer(shell()->web_contents(), |
6712 kFragmentURL); | 6732 kFragmentURL); |
6713 EXPECT_TRUE(NavigateToURL(shell(), kFragmentURL)); | 6733 EXPECT_TRUE(NavigateToURL(shell(), kFragmentURL)); |
6714 | 6734 |
6715 EXPECT_TRUE(handle_observer.has_committed()); | 6735 EXPECT_TRUE(handle_observer.has_committed()); |
6716 EXPECT_TRUE(handle_observer.was_same_page()); | 6736 EXPECT_TRUE(handle_observer.was_same_page()); |
6717 EXPECT_FALSE(handle_observer.was_renderer_initiated()); | 6737 EXPECT_FALSE(handle_observer.was_renderer_initiated()); |
6718 } | 6738 } |
6719 | 6739 |
6720 } // namespace content | 6740 } // namespace content |
OLD | NEW |