| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "content/browser/frame_host/navigation_handle_impl.h" | 6 #include "content/browser/frame_host/navigation_handle_impl.h" |
| 7 #include "content/public/browser/navigation_throttle.h" | 7 #include "content/public/browser/navigation_throttle.h" |
| 8 #include "content/public/browser/ssl_status.h" | 8 #include "content/public/browser/ssl_status.h" |
| 9 #include "content/public/common/request_context_type.h" | 9 #include "content/public/common/request_context_type.h" |
| 10 #include "content/test/test_render_frame_host.h" | 10 #include "content/test/test_render_frame_host.h" |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 TestNavigationThrottle* proceed_throttle = | 672 TestNavigationThrottle* proceed_throttle = |
| 673 CreateTestNavigationThrottle(NavigationThrottle::PROCEED); | 673 CreateTestNavigationThrottle(NavigationThrottle::PROCEED); |
| 674 EXPECT_FALSE(IsDeferringStart()); | 674 EXPECT_FALSE(IsDeferringStart()); |
| 675 EXPECT_FALSE(IsDeferringRedirect()); | 675 EXPECT_FALSE(IsDeferringRedirect()); |
| 676 EXPECT_EQ(0, cancel_throttle->will_start_calls()); | 676 EXPECT_EQ(0, cancel_throttle->will_start_calls()); |
| 677 EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); | 677 EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); |
| 678 EXPECT_EQ(0, cancel_throttle->will_process_response_calls()); | 678 EXPECT_EQ(0, cancel_throttle->will_process_response_calls()); |
| 679 EXPECT_EQ(0, proceed_throttle->will_start_calls()); | 679 EXPECT_EQ(0, proceed_throttle->will_start_calls()); |
| 680 EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); | 680 EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); |
| 681 | 681 |
| 682 // Simulate WillRedirectRequest. The request should not be deferred. The | 682 // Simulate WillProcessResponse. The request should not be deferred. The |
| 683 // callback should have been called. The second throttle should not have | 683 // callback should have been called. The second throttle should not have |
| 684 // been notified. | 684 // been notified. |
| 685 SimulateWillProcessResponse(); | 685 SimulateWillProcessResponse(); |
| 686 EXPECT_FALSE(IsDeferringStart()); | 686 EXPECT_FALSE(IsDeferringStart()); |
| 687 EXPECT_FALSE(IsDeferringRedirect()); | 687 EXPECT_FALSE(IsDeferringRedirect()); |
| 688 EXPECT_FALSE(IsDeferringResponse()); |
| 688 EXPECT_TRUE(was_callback_called()); | 689 EXPECT_TRUE(was_callback_called()); |
| 690 EXPECT_TRUE(IsCanceling()); |
| 689 EXPECT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, callback_result()); | 691 EXPECT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, callback_result()); |
| 690 EXPECT_EQ(0, cancel_throttle->will_start_calls()); | 692 EXPECT_EQ(0, cancel_throttle->will_start_calls()); |
| 691 EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); | 693 EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); |
| 692 EXPECT_EQ(1, cancel_throttle->will_process_response_calls()); | 694 EXPECT_EQ(1, cancel_throttle->will_process_response_calls()); |
| 693 EXPECT_EQ(0, proceed_throttle->will_start_calls()); | 695 EXPECT_EQ(0, proceed_throttle->will_start_calls()); |
| 694 EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); | 696 EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); |
| 695 EXPECT_EQ(0, proceed_throttle->will_process_response_calls()); | 697 EXPECT_EQ(0, proceed_throttle->will_process_response_calls()); |
| 696 } | 698 } |
| 697 | 699 |
| 700 // Checks that a NavigationThrottle asking to block the response followed by a |
| 701 // NavigationThrottle asking to proceed behave correctly in WillProcessResponse. |
| 702 // The navigation will be canceled directly, and the second throttle will not |
| 703 // be called. |
| 704 TEST_F(NavigationHandleImplTest, BlockResponseThenProceedWillProcessResponse) { |
| 705 TestNavigationThrottle* cancel_throttle = |
| 706 CreateTestNavigationThrottle(NavigationThrottle::BLOCK_RESPONSE); |
| 707 TestNavigationThrottle* proceed_throttle = |
| 708 CreateTestNavigationThrottle(NavigationThrottle::PROCEED); |
| 709 EXPECT_FALSE(IsDeferringStart()); |
| 710 EXPECT_FALSE(IsDeferringRedirect()); |
| 711 EXPECT_EQ(0, cancel_throttle->will_start_calls()); |
| 712 EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); |
| 713 EXPECT_EQ(0, cancel_throttle->will_process_response_calls()); |
| 714 EXPECT_EQ(0, proceed_throttle->will_start_calls()); |
| 715 EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); |
| 716 |
| 717 // Simulate WillRedirectRequest. The request should not be deferred. The |
| 718 // callback should have been called. The second throttle should not have |
| 719 // been notified. |
| 720 SimulateWillProcessResponse(); |
| 721 EXPECT_FALSE(IsDeferringStart()); |
| 722 EXPECT_FALSE(IsDeferringRedirect()); |
| 723 EXPECT_FALSE(IsDeferringResponse()); |
| 724 EXPECT_TRUE(was_callback_called()); |
| 725 EXPECT_TRUE(IsCanceling()); |
| 726 EXPECT_EQ(NavigationThrottle::BLOCK_RESPONSE, callback_result()); |
| 727 EXPECT_EQ(0, cancel_throttle->will_start_calls()); |
| 728 EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); |
| 729 EXPECT_EQ(1, cancel_throttle->will_process_response_calls()); |
| 730 EXPECT_EQ(0, proceed_throttle->will_start_calls()); |
| 731 EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); |
| 732 EXPECT_EQ(0, proceed_throttle->will_process_response_calls()); |
| 733 } |
| 734 |
| 698 } // namespace content | 735 } // namespace content |
| OLD | NEW |