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 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
6172 EXPECT_EQ(0, web_contents->GetController().GetLastCommittedEntryIndex()); | 6172 EXPECT_EQ(2, web_contents->GetController().GetLastCommittedEntryIndex()); |
6173 EXPECT_EQ(3, web_contents->GetController().GetEntryCount()); | |
6173 | 6174 |
6174 // Verify the expected origin through JavaScript. It also has the additional | 6175 // Verify the expected origin through JavaScript. It also has the additional |
6175 // verification of the process also being still alive. | 6176 // verification of the process also being still alive. |
6176 std::string origin; | 6177 std::string origin; |
6177 EXPECT_TRUE(ExecuteScriptAndExtractString( | 6178 EXPECT_TRUE(ExecuteScriptAndExtractString( |
6178 web_contents, "domAutomationController.send(document.origin)", &origin)); | 6179 web_contents, "domAutomationController.send(document.origin)", |
6179 EXPECT_EQ(start_url.GetOrigin().spec(), origin + "/"); | 6180 &origin)); |
6181 EXPECT_EQ(cross_origin_url.GetOrigin().spec(), origin + "/"); | |
6182 | |
6183 // Navigate back another time. | |
nasko
2017/01/24 16:59:36
nit: "Navigate back again."
arthursonzogni
2017/01/25 13:13:59
Done.
| |
6184 web_contents->GetController().GoBack(); | |
6185 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | |
6186 EXPECT_EQ(1, web_contents->GetController().GetLastCommittedEntryIndex()); | |
6187 EXPECT_EQ(3, web_contents->GetController().GetEntryCount()); | |
6188 | |
6189 // Verify the expected origin through JavaScript. It also has the additional | |
6190 // verification of the process also being still alive. | |
6191 EXPECT_TRUE(ExecuteScriptAndExtractString( | |
6192 web_contents, "domAutomationController.send(document.origin)", | |
6193 &origin)); | |
6194 EXPECT_EQ(same_page_url.GetOrigin().spec(), origin + "/"); | |
6195 } else { | |
6196 // Wait for the back navigation to commit as well. | |
6197 history_commit_observer.Wait(); | |
6198 EXPECT_EQ(start_url, web_contents->GetLastCommittedURL()); | |
6199 EXPECT_EQ(0, web_contents->GetController().GetLastCommittedEntryIndex()); | |
6200 EXPECT_EQ(3, web_contents->GetController().GetEntryCount()); | |
6201 | |
6202 // Verify the expected origin through JavaScript. It also has the additional | |
6203 // verification of the process also being still alive. | |
6204 std::string origin; | |
6205 EXPECT_TRUE(ExecuteScriptAndExtractString( | |
6206 web_contents, "domAutomationController.send(document.origin)", | |
6207 &origin)); | |
6208 EXPECT_EQ(start_url.GetOrigin().spec(), origin + "/"); | |
6209 } | |
6180 } | 6210 } |
6181 | 6211 |
6182 // Test that verifies that Referer and Origin http headers are correctly sent | 6212 // 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. | 6213 // 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. | 6214 // This test is somewhat related to https://crbug.com/635400. |
6185 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 6215 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
6186 RefererAndOriginHeadersAfterRedirects) { | 6216 RefererAndOriginHeadersAfterRedirects) { |
6187 // Navigate to the page with form that posts via 307 redirection to | 6217 // 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 | 6218 // |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. | 6219 // 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(), | 6741 NavigationHandleCommitObserver handle_observer(shell()->web_contents(), |
6712 kFragmentURL); | 6742 kFragmentURL); |
6713 EXPECT_TRUE(NavigateToURL(shell(), kFragmentURL)); | 6743 EXPECT_TRUE(NavigateToURL(shell(), kFragmentURL)); |
6714 | 6744 |
6715 EXPECT_TRUE(handle_observer.has_committed()); | 6745 EXPECT_TRUE(handle_observer.has_committed()); |
6716 EXPECT_TRUE(handle_observer.was_same_page()); | 6746 EXPECT_TRUE(handle_observer.was_same_page()); |
6717 EXPECT_FALSE(handle_observer.was_renderer_initiated()); | 6747 EXPECT_FALSE(handle_observer.was_renderer_initiated()); |
6718 } | 6748 } |
6719 | 6749 |
6720 } // namespace content | 6750 } // namespace content |
OLD | NEW |