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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 class NavigationHandleImplTest : public RenderViewHostImplTestHarness { | 62 class NavigationHandleImplTest : public RenderViewHostImplTestHarness { |
63 public: | 63 public: |
64 NavigationHandleImplTest() | 64 NavigationHandleImplTest() |
65 : was_callback_called_(false), | 65 : was_callback_called_(false), |
66 callback_result_(NavigationThrottle::DEFER) {} | 66 callback_result_(NavigationThrottle::DEFER) {} |
67 | 67 |
68 void SetUp() override { | 68 void SetUp() override { |
69 RenderViewHostImplTestHarness::SetUp(); | 69 RenderViewHostImplTestHarness::SetUp(); |
70 test_handle_ = NavigationHandleImpl::Create( | 70 test_handle_ = NavigationHandleImpl::Create( |
71 GURL(), main_test_rfh()->frame_tree_node(), true, false, false, | 71 GURL(), main_test_rfh()->frame_tree_node(), |
72 base::TimeTicks::Now(), 0, false); | 72 true, // is_renderer_initiated |
| 73 false, // is_same_page |
| 74 false, // is_srcdoc |
| 75 base::TimeTicks::Now(), 0, NavigationGestureAuto, |
| 76 false); // started_from_context_menu |
73 EXPECT_EQ(REQUEST_CONTEXT_TYPE_UNSPECIFIED, | 77 EXPECT_EQ(REQUEST_CONTEXT_TYPE_UNSPECIFIED, |
74 test_handle_->request_context_type_); | 78 test_handle_->request_context_type_); |
75 contents()->GetMainFrame()->InitializeRenderFrameIfNeeded(); | 79 contents()->GetMainFrame()->InitializeRenderFrameIfNeeded(); |
76 } | 80 } |
77 | 81 |
78 void TearDown() override { | 82 void TearDown() override { |
79 // Release the |test_handle_| before destroying the WebContents, to match | 83 // Release the |test_handle_| before destroying the WebContents, to match |
80 // the WebContentsObserverSanityChecker expectations. | 84 // the WebContentsObserverSanityChecker expectations. |
81 test_handle_.reset(); | 85 test_handle_.reset(); |
82 RenderViewHostImplTestHarness::TearDown(); | 86 RenderViewHostImplTestHarness::TearDown(); |
(...skipping 18 matching lines...) Expand all Loading... |
101 // Helper function to call WillStartRequest on |handle|. If this function | 105 // Helper function to call WillStartRequest on |handle|. If this function |
102 // returns DEFER, |callback_result_| will be set to the actual result of | 106 // returns DEFER, |callback_result_| will be set to the actual result of |
103 // the throttle checks when they are finished. | 107 // the throttle checks when they are finished. |
104 void SimulateWillStartRequest() { | 108 void SimulateWillStartRequest() { |
105 was_callback_called_ = false; | 109 was_callback_called_ = false; |
106 callback_result_ = NavigationThrottle::DEFER; | 110 callback_result_ = NavigationThrottle::DEFER; |
107 | 111 |
108 // It's safe to use base::Unretained since the NavigationHandle is owned by | 112 // It's safe to use base::Unretained since the NavigationHandle is owned by |
109 // the NavigationHandleImplTest. | 113 // the NavigationHandleImplTest. |
110 test_handle_->WillStartRequest( | 114 test_handle_->WillStartRequest( |
111 "GET", nullptr, Referrer(), false, ui::PAGE_TRANSITION_LINK, false, | 115 "GET", nullptr, Referrer(), ui::PAGE_TRANSITION_LINK, false, |
112 REQUEST_CONTEXT_TYPE_LOCATION, | 116 REQUEST_CONTEXT_TYPE_LOCATION, |
113 base::Bind(&NavigationHandleImplTest::UpdateThrottleCheckResult, | 117 base::Bind(&NavigationHandleImplTest::UpdateThrottleCheckResult, |
114 base::Unretained(this))); | 118 base::Unretained(this))); |
115 } | 119 } |
116 | 120 |
117 // Helper function to call WillRedirectRequest on |handle|. If this function | 121 // Helper function to call WillRedirectRequest on |handle|. If this function |
118 // returns DEFER, |callback_result_| will be set to the actual result of the | 122 // returns DEFER, |callback_result_| will be set to the actual result of the |
119 // throttle checks when they are finished. | 123 // throttle checks when they are finished. |
120 // TODO(clamy): this should also simulate that WillStartRequest was called if | 124 // TODO(clamy): this should also simulate that WillStartRequest was called if |
121 // it has not been called before. | 125 // it has not been called before. |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 EXPECT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, callback_result()); | 689 EXPECT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, callback_result()); |
686 EXPECT_EQ(0, cancel_throttle->will_start_calls()); | 690 EXPECT_EQ(0, cancel_throttle->will_start_calls()); |
687 EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); | 691 EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); |
688 EXPECT_EQ(1, cancel_throttle->will_process_response_calls()); | 692 EXPECT_EQ(1, cancel_throttle->will_process_response_calls()); |
689 EXPECT_EQ(0, proceed_throttle->will_start_calls()); | 693 EXPECT_EQ(0, proceed_throttle->will_start_calls()); |
690 EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); | 694 EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); |
691 EXPECT_EQ(0, proceed_throttle->will_process_response_calls()); | 695 EXPECT_EQ(0, proceed_throttle->will_process_response_calls()); |
692 } | 696 } |
693 | 697 |
694 } // namespace content | 698 } // namespace content |
OLD | NEW |