Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Side by Side Diff: content/browser/frame_host/navigation_handle_impl_unittest.cc

Issue 2557233002: Revert of Set user_gesture bit at NavigationHandle creation time. (Closed)
Patch Set: rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(), 71 GURL(), main_test_rfh()->frame_tree_node(),
72 true, // is_renderer_initiated 72 true, // is_renderer_initiated
73 false, // is_same_page 73 false, // is_same_page
74 base::TimeTicks::Now(), 0, NavigationGestureAuto, 74 base::TimeTicks::Now(), 0,
75 false); // started_from_context_menu 75 false); // started_from_context_menu
76 EXPECT_EQ(REQUEST_CONTEXT_TYPE_UNSPECIFIED, 76 EXPECT_EQ(REQUEST_CONTEXT_TYPE_UNSPECIFIED,
77 test_handle_->request_context_type_); 77 test_handle_->request_context_type_);
78 contents()->GetMainFrame()->InitializeRenderFrameIfNeeded(); 78 contents()->GetMainFrame()->InitializeRenderFrameIfNeeded();
79 } 79 }
80 80
81 void TearDown() override { 81 void TearDown() override {
82 // Release the |test_handle_| before destroying the WebContents, to match 82 // Release the |test_handle_| before destroying the WebContents, to match
83 // the WebContentsObserverSanityChecker expectations. 83 // the WebContentsObserverSanityChecker expectations.
84 test_handle_.reset(); 84 test_handle_.reset();
(...skipping 19 matching lines...) Expand all
104 // Helper function to call WillStartRequest on |handle|. If this function 104 // Helper function to call WillStartRequest on |handle|. If this function
105 // returns DEFER, |callback_result_| will be set to the actual result of 105 // returns DEFER, |callback_result_| will be set to the actual result of
106 // the throttle checks when they are finished. 106 // the throttle checks when they are finished.
107 void SimulateWillStartRequest() { 107 void SimulateWillStartRequest() {
108 was_callback_called_ = false; 108 was_callback_called_ = false;
109 callback_result_ = NavigationThrottle::DEFER; 109 callback_result_ = NavigationThrottle::DEFER;
110 110
111 // It's safe to use base::Unretained since the NavigationHandle is owned by 111 // It's safe to use base::Unretained since the NavigationHandle is owned by
112 // the NavigationHandleImplTest. 112 // the NavigationHandleImplTest.
113 test_handle_->WillStartRequest( 113 test_handle_->WillStartRequest(
114 "GET", nullptr, Referrer(), ui::PAGE_TRANSITION_LINK, false, 114 "GET", nullptr, Referrer(), false, ui::PAGE_TRANSITION_LINK, false,
115 REQUEST_CONTEXT_TYPE_LOCATION, 115 REQUEST_CONTEXT_TYPE_LOCATION,
116 base::Bind(&NavigationHandleImplTest::UpdateThrottleCheckResult, 116 base::Bind(&NavigationHandleImplTest::UpdateThrottleCheckResult,
117 base::Unretained(this))); 117 base::Unretained(this)));
118 } 118 }
119 119
120 // Helper function to call WillRedirectRequest on |handle|. If this function 120 // Helper function to call WillRedirectRequest on |handle|. If this function
121 // returns DEFER, |callback_result_| will be set to the actual result of the 121 // returns DEFER, |callback_result_| will be set to the actual result of the
122 // throttle checks when they are finished. 122 // throttle checks when they are finished.
123 // TODO(clamy): this should also simulate that WillStartRequest was called if 123 // TODO(clamy): this should also simulate that WillStartRequest was called if
124 // it has not been called before. 124 // it has not been called before.
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 EXPECT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, callback_result()); 688 EXPECT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, callback_result());
689 EXPECT_EQ(0, cancel_throttle->will_start_calls()); 689 EXPECT_EQ(0, cancel_throttle->will_start_calls());
690 EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); 690 EXPECT_EQ(0, cancel_throttle->will_redirect_calls());
691 EXPECT_EQ(1, cancel_throttle->will_process_response_calls()); 691 EXPECT_EQ(1, cancel_throttle->will_process_response_calls());
692 EXPECT_EQ(0, proceed_throttle->will_start_calls()); 692 EXPECT_EQ(0, proceed_throttle->will_start_calls());
693 EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); 693 EXPECT_EQ(0, proceed_throttle->will_redirect_calls());
694 EXPECT_EQ(0, proceed_throttle->will_process_response_calls()); 694 EXPECT_EQ(0, proceed_throttle->will_process_response_calls());
695 } 695 }
696 696
697 } // namespace content 697 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_handle_impl.cc ('k') | content/browser/frame_host/navigation_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698