OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <utility> | 5 #include <utility> |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "content/public/browser/navigation_controller.h" | 10 #include "content/public/browser/navigation_controller.h" |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 // Test that verifies that a cross-process transfer doesn't lose session | 499 // Test that verifies that a cross-process transfer doesn't lose session |
500 // history state - https://crbug.com/613004. | 500 // history state - https://crbug.com/613004. |
501 // | 501 // |
502 // Trigerring a cross-process transfer via embedded_test_server requires use of | 502 // Trigerring a cross-process transfer via embedded_test_server requires use of |
503 // a HTTP redirect response (to preserve port number). Therefore the test ends | 503 // a HTTP redirect response (to preserve port number). Therefore the test ends |
504 // up accidentally testing redirection logic as well - in particular, the test | 504 // up accidentally testing redirection logic as well - in particular, the test |
505 // uses 307 (rather than 302) redirect to preserve the body of HTTP POST across | 505 // uses 307 (rather than 302) redirect to preserve the body of HTTP POST across |
506 // redirects (as mandated by https://tools.ietf.org/html/rfc7231#section-6.4.7). | 506 // redirects (as mandated by https://tools.ietf.org/html/rfc7231#section-6.4.7). |
507 IN_PROC_BROWSER_TEST_F(SessionHistoryTest, GoBackToCrossSitePostWithRedirect) { | 507 IN_PROC_BROWSER_TEST_F(SessionHistoryTest, GoBackToCrossSitePostWithRedirect) { |
508 GURL form_url(embedded_test_server()->GetURL( | 508 GURL form_url(embedded_test_server()->GetURL( |
509 "a.com", "/form_that_posts_cross_site.html")); | 509 "a.com", "/session_history/form_that_posts_cross_site.html")); |
510 GURL redirect_target_url(embedded_test_server()->GetURL("x.com", "/echoall")); | 510 GURL redirect_target_url(embedded_test_server()->GetURL("x.com", "/echoall")); |
511 GURL page_to_go_back_from( | 511 GURL page_to_go_back_from( |
512 embedded_test_server()->GetURL("c.com", "/title1.html")); | 512 embedded_test_server()->GetURL("c.com", "/title1.html")); |
513 | 513 |
514 // Navigate to the page with form that posts via 307 redirection to | 514 // Navigate to the page with form that posts via 307 redirection to |
515 // |redirect_target_url| (cross-site from |form_url|). | 515 // |redirect_target_url| (cross-site from |form_url|). |
516 EXPECT_TRUE(NavigateToURL(shell(), form_url)); | 516 EXPECT_TRUE(NavigateToURL(shell(), form_url)); |
517 | 517 |
518 // Submit the form. | 518 // Submit the form. |
519 TestNavigationObserver form_post_observer(shell()->web_contents(), 1); | 519 TestNavigationObserver form_post_observer(shell()->web_contents(), 1); |
520 EXPECT_TRUE( | 520 EXPECT_TRUE( |
521 ExecuteScript(shell(), "document.getElementById('text-form').submit();")); | 521 ExecuteScript(shell(), "document.getElementById('form').submit();")); |
522 form_post_observer.Wait(); | 522 form_post_observer.Wait(); |
523 | 523 |
524 // Verify that we arrived at the expected, redirected location. | 524 // Verify that we arrived at the expected, redirected location. |
525 EXPECT_EQ(redirect_target_url, | 525 EXPECT_EQ(redirect_target_url, |
526 shell()->web_contents()->GetLastCommittedURL()); | 526 shell()->web_contents()->GetLastCommittedURL()); |
527 | 527 |
528 // Verify that POST body got preserved by 307 redirect. This expectation | 528 // Verify that POST body got preserved by 307 redirect. This expectation |
529 // comes from: https://tools.ietf.org/html/rfc7231#section-6.4.7 | 529 // comes from: https://tools.ietf.org/html/rfc7231#section-6.4.7 |
530 std::string body; | 530 std::string body; |
531 EXPECT_TRUE(ExecuteScriptAndExtractString( | 531 EXPECT_TRUE(ExecuteScriptAndExtractString( |
(...skipping 19 matching lines...) Expand all Loading... |
551 std::string body_after_back_navigation; | 551 std::string body_after_back_navigation; |
552 EXPECT_TRUE(ExecuteScriptAndExtractString( | 552 EXPECT_TRUE(ExecuteScriptAndExtractString( |
553 shell(), | 553 shell(), |
554 "window.domAutomationController.send(" | 554 "window.domAutomationController.send(" |
555 "document.getElementsByTagName('pre')[0].innerText);", | 555 "document.getElementsByTagName('pre')[0].innerText);", |
556 &body_after_back_navigation)); | 556 &body_after_back_navigation)); |
557 EXPECT_EQ("text=value\n", body_after_back_navigation); | 557 EXPECT_EQ("text=value\n", body_after_back_navigation); |
558 } | 558 } |
559 | 559 |
560 } // namespace content | 560 } // namespace content |
OLD | NEW |