| 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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 .WillOnce(VerifyReloadStartedContext(web_state(), url, &context)); | 479 .WillOnce(VerifyReloadStartedContext(web_state(), url, &context)); |
| 480 EXPECT_CALL(*observer_, DidStartLoading()); | 480 EXPECT_CALL(*observer_, DidStartLoading()); |
| 481 EXPECT_CALL(*observer_, DidFinishNavigation(_)) | 481 EXPECT_CALL(*observer_, DidFinishNavigation(_)) |
| 482 .WillOnce(VerifyReloadFinishedContext(web_state(), url, &context, | 482 .WillOnce(VerifyReloadFinishedContext(web_state(), url, &context, |
| 483 false /* is_web_page */)); | 483 false /* is_web_page */)); |
| 484 EXPECT_CALL(*observer_, DidStopLoading()); | 484 EXPECT_CALL(*observer_, DidStopLoading()); |
| 485 navigation_manager()->Reload(ReloadType::NORMAL, false /*check_for_repost*/); | 485 navigation_manager()->Reload(ReloadType::NORMAL, false /*check_for_repost*/); |
| 486 } | 486 } |
| 487 | 487 |
| 488 // Tests successful navigation to a new page with post HTTP method. | 488 // Tests successful navigation to a new page with post HTTP method. |
| 489 TEST_F(NavigationCallbacksTest, UserInitiatedPostNavigation) { | 489 // TODO (crbug/729602): This test is disabled due to failing on iOS 9.3 devices. |
| 490 #if TARGET_IPHONE_SIMULATOR |
| 491 #define MAYBE_UserInitiatedPostNavigation UserInitiatedPostNavigation |
| 492 #else |
| 493 #define MAYBE_UserInitiatedPostNavigation DISABLED_UserInitiatedPostNavigation |
| 494 #endif |
| 495 TEST_F(NavigationCallbacksTest, MAYBE_UserInitiatedPostNavigation) { |
| 490 const GURL url = HttpServer::MakeUrl("http://chromium.test"); | 496 const GURL url = HttpServer::MakeUrl("http://chromium.test"); |
| 491 std::map<GURL, std::string> responses; | 497 std::map<GURL, std::string> responses; |
| 492 responses[url] = "Chromium Test"; | 498 responses[url] = "Chromium Test"; |
| 493 web::test::SetUpSimpleHttpServer(responses); | 499 web::test::SetUpSimpleHttpServer(responses); |
| 494 | 500 |
| 495 // Perform new page navigation. | 501 // Perform new page navigation. |
| 496 NavigationContext* context = nullptr; | 502 NavigationContext* context = nullptr; |
| 497 EXPECT_CALL(*observer_, DidStartNavigation(_)) | 503 EXPECT_CALL(*observer_, DidStartNavigation(_)) |
| 498 .WillOnce(VerifyPostStartedContext(web_state(), url, &context)); | 504 .WillOnce(VerifyPostStartedContext(web_state(), url, &context)); |
| 499 EXPECT_CALL(*observer_, DidStartLoading()); | 505 EXPECT_CALL(*observer_, DidStartLoading()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 528 EXPECT_CALL(*observer_, DidStartNavigation(_)) | 534 EXPECT_CALL(*observer_, DidStartNavigation(_)) |
| 529 .WillOnce(VerifyPostStartedContext(web_state(), url, &context)); | 535 .WillOnce(VerifyPostStartedContext(web_state(), url, &context)); |
| 530 EXPECT_CALL(*observer_, DidStartLoading()); | 536 EXPECT_CALL(*observer_, DidStartLoading()); |
| 531 EXPECT_CALL(*observer_, DidFinishNavigation(_)) | 537 EXPECT_CALL(*observer_, DidFinishNavigation(_)) |
| 532 .WillOnce(VerifyPostFinishedContext(web_state(), url, &context)); | 538 .WillOnce(VerifyPostFinishedContext(web_state(), url, &context)); |
| 533 EXPECT_CALL(*observer_, DidStopLoading()); | 539 EXPECT_CALL(*observer_, DidStopLoading()); |
| 534 ExecuteJavaScript(@"window.document.getElementById('form').submit();"); | 540 ExecuteJavaScript(@"window.document.getElementById('form').submit();"); |
| 535 } | 541 } |
| 536 | 542 |
| 537 // Tests successful reload of a page returned for post request. | 543 // Tests successful reload of a page returned for post request. |
| 538 TEST_F(NavigationCallbacksTest, ReloadPostNavigation) { | 544 // TODO (crbug/729602): This test is disabled due to failing on iOS 9.3 devices. |
| 545 #if TARGET_IPHONE_SIMULATOR |
| 546 #define MAYBE_ReloadPostNavigation ReloadPostNavigation |
| 547 #else |
| 548 #define MAYBE_ReloadPostNavigation DISABLED_ReloadPostNavigation |
| 549 #endif |
| 550 TEST_F(NavigationCallbacksTest, MAYBE_ReloadPostNavigation) { |
| 539 const GURL url = HttpServer::MakeUrl("http://chromium.test"); | 551 const GURL url = HttpServer::MakeUrl("http://chromium.test"); |
| 540 std::map<GURL, std::string> responses; | 552 std::map<GURL, std::string> responses; |
| 541 const GURL action = HttpServer::MakeUrl("http://action.test"); | 553 const GURL action = HttpServer::MakeUrl("http://action.test"); |
| 542 responses[url] = | 554 responses[url] = |
| 543 base::StringPrintf("<form method='post' id='form' action='%s'></form>", | 555 base::StringPrintf("<form method='post' id='form' action='%s'></form>", |
| 544 action.spec().c_str()); | 556 action.spec().c_str()); |
| 545 web::test::SetUpSimpleHttpServer(responses); | 557 web::test::SetUpSimpleHttpServer(responses); |
| 546 | 558 |
| 547 // Perform new page navigation. | 559 // Perform new page navigation. |
| 548 NavigationContext* context = nullptr; | 560 NavigationContext* context = nullptr; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 573 // the delegate will allow form resubmission. Remove this workaround (clearing | 585 // the delegate will allow form resubmission. Remove this workaround (clearing |
| 574 // the delegate, once |check_for_repost| is supported). | 586 // the delegate, once |check_for_repost| is supported). |
| 575 web_state()->SetDelegate(nullptr); | 587 web_state()->SetDelegate(nullptr); |
| 576 ExecuteBlockAndWaitForLoad(action, ^{ | 588 ExecuteBlockAndWaitForLoad(action, ^{ |
| 577 navigation_manager()->Reload(ReloadType::NORMAL, | 589 navigation_manager()->Reload(ReloadType::NORMAL, |
| 578 false /*check_for_repost*/); | 590 false /*check_for_repost*/); |
| 579 }); | 591 }); |
| 580 } | 592 } |
| 581 | 593 |
| 582 // Tests going forward to a page rendered from post response. | 594 // Tests going forward to a page rendered from post response. |
| 583 TEST_F(NavigationCallbacksTest, ForwardPostNavigation) { | 595 // TODO (crbug/729602): This test is disabled due to failing on iOS 9.3 devices. |
| 596 #if TARGET_IPHONE_SIMULATOR |
| 597 #define MAYBE_ForwardPostNavigation ForwardPostNavigation |
| 598 #else |
| 599 #define MAYBE_ForwardPostNavigation DISABLED_ForwardPostNavigation |
| 600 #endif |
| 601 TEST_F(NavigationCallbacksTest, MAYBE_ForwardPostNavigation) { |
| 584 const GURL url = HttpServer::MakeUrl("http://chromium.test"); | 602 const GURL url = HttpServer::MakeUrl("http://chromium.test"); |
| 585 std::map<GURL, std::string> responses; | 603 std::map<GURL, std::string> responses; |
| 586 const GURL action = HttpServer::MakeUrl("http://action.test"); | 604 const GURL action = HttpServer::MakeUrl("http://action.test"); |
| 587 responses[url] = | 605 responses[url] = |
| 588 base::StringPrintf("<form method='post' id='form' action='%s'></form>", | 606 base::StringPrintf("<form method='post' id='form' action='%s'></form>", |
| 589 action.spec().c_str()); | 607 action.spec().c_str()); |
| 590 web::test::SetUpSimpleHttpServer(responses); | 608 web::test::SetUpSimpleHttpServer(responses); |
| 591 | 609 |
| 592 // Perform new page navigation. | 610 // Perform new page navigation. |
| 593 NavigationContext* context = nullptr; | 611 NavigationContext* context = nullptr; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 // delegate does not run callback for ShowRepostFormWarningDialog. Clearing | 644 // delegate does not run callback for ShowRepostFormWarningDialog. Clearing |
| 627 // the delegate will allow form resubmission. Remove this workaround (clearing | 645 // the delegate will allow form resubmission. Remove this workaround (clearing |
| 628 // the delegate, once |check_for_repost| is supported). | 646 // the delegate, once |check_for_repost| is supported). |
| 629 web_state()->SetDelegate(nullptr); | 647 web_state()->SetDelegate(nullptr); |
| 630 ExecuteBlockAndWaitForLoad(action, ^{ | 648 ExecuteBlockAndWaitForLoad(action, ^{ |
| 631 navigation_manager()->GoForward(); | 649 navigation_manager()->GoForward(); |
| 632 }); | 650 }); |
| 633 } | 651 } |
| 634 | 652 |
| 635 } // namespace web | 653 } // namespace web |
| OLD | NEW |