| 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([@"foo" dataUsingEncoding:NSUTF8StringEncoding]); | 512 params.post_data.reset( |
| 513 params.extra_headers.reset(@{ @"Content-Type" : @"text/html" }); | 513 [[@"foo" dataUsingEncoding:NSUTF8StringEncoding] retain]); |
| 514 params.extra_headers.reset([@{ @"Content-Type" : @"text/html" } retain]); |
| 514 LoadWithParams(params); | 515 LoadWithParams(params); |
| 515 } | 516 } |
| 516 | 517 |
| 517 // Tests successful navigation to a new page with post HTTP method. | 518 // Tests successful navigation to a new page with post HTTP method. |
| 518 TEST_F(NavigationCallbacksTest, RendererInitiatedPostNavigation) { | 519 TEST_F(NavigationCallbacksTest, RendererInitiatedPostNavigation) { |
| 519 const GURL url = HttpServer::MakeUrl("http://chromium.test"); | 520 const GURL url = HttpServer::MakeUrl("http://chromium.test"); |
| 520 std::map<GURL, std::string> responses; | 521 std::map<GURL, std::string> responses; |
| 521 responses[url] = "<form method='post' id='form'></form>"; | 522 responses[url] = "<form method='post' id='form'></form>"; |
| 522 web::test::SetUpSimpleHttpServer(responses); | 523 web::test::SetUpSimpleHttpServer(responses); |
| 523 | 524 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 // delegate does not run callback for ShowRepostFormWarningDialog. Clearing | 644 // delegate does not run callback for ShowRepostFormWarningDialog. Clearing |
| 644 // the delegate will allow form resubmission. Remove this workaround (clearing | 645 // the delegate will allow form resubmission. Remove this workaround (clearing |
| 645 // the delegate, once |check_for_repost| is supported). | 646 // the delegate, once |check_for_repost| is supported). |
| 646 web_state()->SetDelegate(nullptr); | 647 web_state()->SetDelegate(nullptr); |
| 647 ExecuteBlockAndWaitForLoad(action, ^{ | 648 ExecuteBlockAndWaitForLoad(action, ^{ |
| 648 navigation_manager()->GoForward(); | 649 navigation_manager()->GoForward(); |
| 649 }); | 650 }); |
| 650 } | 651 } |
| 651 | 652 |
| 652 } // namespace web | 653 } // namespace web |
| OLD | NEW |