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 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 // Test that verifies that a cross-process transfer doesn't lose session | 507 // Test that verifies that a cross-process transfer doesn't lose session |
508 // history state - https://crbug.com/613004. | 508 // history state - https://crbug.com/613004. |
509 // | 509 // |
510 // Trigerring a cross-process transfer via embedded_test_server requires use of | 510 // Trigerring a cross-process transfer via embedded_test_server requires use of |
511 // a HTTP redirect response (to preserve port number). Therefore the test ends | 511 // a HTTP redirect response (to preserve port number). Therefore the test ends |
512 // up accidentally testing redirection logic as well - in particular, the test | 512 // up accidentally testing redirection logic as well - in particular, the test |
513 // uses 307 (rather than 302) redirect to preserve the body of HTTP POST across | 513 // uses 307 (rather than 302) redirect to preserve the body of HTTP POST across |
514 // redirects (as mandated by https://tools.ietf.org/html/rfc7231#section-6.4.7). | 514 // redirects (as mandated by https://tools.ietf.org/html/rfc7231#section-6.4.7). |
515 IN_PROC_BROWSER_TEST_F(SessionHistoryTest, GoBackToCrossSitePostWithRedirect) { | 515 IN_PROC_BROWSER_TEST_F(SessionHistoryTest, GoBackToCrossSitePostWithRedirect) { |
516 GURL form_url(embedded_test_server()->GetURL( | 516 GURL form_url(embedded_test_server()->GetURL( |
517 "a.com", "/session_history/form_that_posts_cross_site.html")); | 517 "a.com", "/form_that_posts_cross_site.html")); |
518 GURL redirect_target_url(embedded_test_server()->GetURL("x.com", "/echoall")); | 518 GURL redirect_target_url(embedded_test_server()->GetURL("x.com", "/echoall")); |
519 GURL page_to_go_back_from( | 519 GURL page_to_go_back_from( |
520 embedded_test_server()->GetURL("c.com", "/title1.html")); | 520 embedded_test_server()->GetURL("c.com", "/title1.html")); |
521 | 521 |
522 // Navigate to the page with form that posts via 307 redirection to | 522 // Navigate to the page with form that posts via 307 redirection to |
523 // |redirect_target_url| (cross-site from |form_url|). | 523 // |redirect_target_url| (cross-site from |form_url|). |
524 EXPECT_TRUE(NavigateToURL(shell(), form_url)); | 524 EXPECT_TRUE(NavigateToURL(shell(), form_url)); |
525 | 525 |
526 // Submit the form. | 526 // Submit the form. |
527 TestNavigationObserver form_post_observer(shell()->web_contents(), 1); | 527 TestNavigationObserver form_post_observer(shell()->web_contents(), 1); |
528 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), | 528 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), |
529 "document.getElementById('form').submit();")); | 529 "document.getElementById('text-form').submit();")); |
530 form_post_observer.Wait(); | 530 form_post_observer.Wait(); |
531 | 531 |
532 // Verify that we arrived at the expected, redirected location. | 532 // Verify that we arrived at the expected, redirected location. |
533 EXPECT_EQ(redirect_target_url, | 533 EXPECT_EQ(redirect_target_url, |
534 shell()->web_contents()->GetLastCommittedURL()); | 534 shell()->web_contents()->GetLastCommittedURL()); |
535 | 535 |
536 // Verify that POST body got preserved by 307 redirect. This expectation | 536 // Verify that POST body got preserved by 307 redirect. This expectation |
537 // comes from: https://tools.ietf.org/html/rfc7231#section-6.4.7 | 537 // comes from: https://tools.ietf.org/html/rfc7231#section-6.4.7 |
538 std::string body; | 538 std::string body; |
539 EXPECT_TRUE(ExecuteScriptAndExtractString( | 539 EXPECT_TRUE(ExecuteScriptAndExtractString( |
(...skipping 19 matching lines...) Expand all Loading... |
559 std::string body_after_back_navigation; | 559 std::string body_after_back_navigation; |
560 EXPECT_TRUE(ExecuteScriptAndExtractString( | 560 EXPECT_TRUE(ExecuteScriptAndExtractString( |
561 shell()->web_contents(), | 561 shell()->web_contents(), |
562 "window.domAutomationController.send(" | 562 "window.domAutomationController.send(" |
563 "document.getElementsByTagName('pre')[0].innerText);", | 563 "document.getElementsByTagName('pre')[0].innerText);", |
564 &body_after_back_navigation)); | 564 &body_after_back_navigation)); |
565 EXPECT_EQ("text=value\n", body_after_back_navigation); | 565 EXPECT_EQ("text=value\n", body_after_back_navigation); |
566 } | 566 } |
567 | 567 |
568 } // namespace content | 568 } // namespace content |
OLD | NEW |