OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 <memory> | 5 #include <memory> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #import "ios/web/public/navigation_item.h" | 10 #import "ios/web/public/navigation_item.h" |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 NavigationContext* context = nullptr; | 502 NavigationContext* context = nullptr; |
503 EXPECT_CALL(*observer_, DidStartNavigation(_)) | 503 EXPECT_CALL(*observer_, DidStartNavigation(_)) |
504 .WillOnce(VerifyPostStartedContext(web_state(), url, &context)); | 504 .WillOnce(VerifyPostStartedContext(web_state(), url, &context)); |
505 EXPECT_CALL(*observer_, DidStartLoading()); | 505 EXPECT_CALL(*observer_, DidStartLoading()); |
506 EXPECT_CALL(*observer_, DidFinishNavigation(_)) | 506 EXPECT_CALL(*observer_, DidFinishNavigation(_)) |
507 .WillOnce(VerifyPostFinishedContext(web_state(), url, &context)); | 507 .WillOnce(VerifyPostFinishedContext(web_state(), url, &context)); |
508 EXPECT_CALL(*observer_, DidStopLoading()); | 508 EXPECT_CALL(*observer_, DidStopLoading()); |
509 | 509 |
510 // Load request using POST HTTP method. | 510 // Load request using POST HTTP method. |
511 web::NavigationManager::WebLoadParams params(url); | 511 web::NavigationManager::WebLoadParams params(url); |
512 params.post_data.reset( | 512 params.post_data.reset([@"foo" dataUsingEncoding:NSUTF8StringEncoding]); |
513 [[@"foo" dataUsingEncoding:NSUTF8StringEncoding] retain]); | 513 params.extra_headers.reset(@{ @"Content-Type" : @"text/html" }); |
514 params.extra_headers.reset([@{ @"Content-Type" : @"text/html" } retain]); | |
515 LoadWithParams(params); | 514 LoadWithParams(params); |
516 } | 515 } |
517 | 516 |
518 // Tests successful navigation to a new page with post HTTP method. | 517 // Tests successful navigation to a new page with post HTTP method. |
519 TEST_F(NavigationCallbacksTest, RendererInitiatedPostNavigation) { | 518 TEST_F(NavigationCallbacksTest, RendererInitiatedPostNavigation) { |
520 const GURL url = HttpServer::MakeUrl("http://chromium.test"); | 519 const GURL url = HttpServer::MakeUrl("http://chromium.test"); |
521 std::map<GURL, std::string> responses; | 520 std::map<GURL, std::string> responses; |
522 responses[url] = "<form method='post' id='form'></form>"; | 521 responses[url] = "<form method='post' id='form'></form>"; |
523 web::test::SetUpSimpleHttpServer(responses); | 522 web::test::SetUpSimpleHttpServer(responses); |
524 | 523 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 // delegate does not run callback for ShowRepostFormWarningDialog. Clearing | 643 // delegate does not run callback for ShowRepostFormWarningDialog. Clearing |
645 // the delegate will allow form resubmission. Remove this workaround (clearing | 644 // the delegate will allow form resubmission. Remove this workaround (clearing |
646 // the delegate, once |check_for_repost| is supported). | 645 // the delegate, once |check_for_repost| is supported). |
647 web_state()->SetDelegate(nullptr); | 646 web_state()->SetDelegate(nullptr); |
648 ExecuteBlockAndWaitForLoad(action, ^{ | 647 ExecuteBlockAndWaitForLoad(action, ^{ |
649 navigation_manager()->GoForward(); | 648 navigation_manager()->GoForward(); |
650 }); | 649 }); |
651 } | 650 } |
652 | 651 |
653 } // namespace web | 652 } // namespace web |
OLD | NEW |