Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: content/browser/session_history_browsertest.cc

Issue 2062523002: Fixing renderer's access to a file from HTTP POST (after a xsite transfer). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: One more test expectation. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698