-
Notifications
You must be signed in to change notification settings - Fork 873
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't process HTTPSE when adblock and TP already sets URL
- Loading branch information
Showing
3 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
browser/net/brave_httpse_network_delegate_helper_unittest.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/browser/net/brave_httpse_network_delegate_helper.h" | ||
|
||
#include "brave/browser/net/url_context.h" | ||
#include "brave/common/network_constants.h" | ||
#include "chrome/test/base/chrome_render_view_host_test_harness.h" | ||
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h" | ||
#include "net/url_request/url_request_test_util.h" | ||
|
||
namespace { | ||
|
||
class BraveHTTPSENetworkDelegateHelperTest: public testing::Test { | ||
public: | ||
BraveHTTPSENetworkDelegateHelperTest() | ||
: thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), | ||
context_(new net::TestURLRequestContext(true)) { | ||
} | ||
~BraveHTTPSENetworkDelegateHelperTest() override {} | ||
void SetUp() override { | ||
context_->Init(); | ||
} | ||
net::TestURLRequestContext* context() { return context_.get(); } | ||
|
||
private: | ||
content::TestBrowserThreadBundle thread_bundle_; | ||
std::unique_ptr<net::TestURLRequestContext> context_; | ||
}; | ||
|
||
|
||
TEST_F(BraveHTTPSENetworkDelegateHelperTest, AlreadySetNewURLNoOp) { | ||
net::TestDelegate test_delegate; | ||
GURL url("http://bradhatesprimes.brave.com/composite_numbers_ftw"); | ||
std::unique_ptr<net::URLRequest> request = | ||
context()->CreateRequest(url, net::IDLE, &test_delegate, | ||
TRAFFIC_ANNOTATION_FOR_TESTS); | ||
std::shared_ptr<brave::BraveRequestInfo> | ||
brave_request_info(new brave::BraveRequestInfo()); | ||
request->set_site_for_cookies( | ||
GURL("http://brad.brave.com/hide_all_primes_in_ui/composites_forever")); | ||
brave_request_info->new_url_spec = "data:image/png;base64,iVB"; | ||
brave::ResponseCallback callback; | ||
GURL new_url; | ||
int ret = | ||
OnBeforeURLRequest_HttpsePreFileWork(request.get(), &new_url, callback, | ||
brave_request_info); | ||
EXPECT_TRUE(new_url.is_empty()); | ||
EXPECT_EQ(ret, net::OK); | ||
} | ||
|
||
} // namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters