Commit 492b6c2f authored by Jay Civelli's avatar Jay Civelli Committed by Commit Bot

Fix SecurityIndicatorTest.CheckIndicatorText with the network service

This CL fixes the SecurityIndicatorTest.CheckIndicatorText with the
network service by using a URLLoaderInterceptor.

Bug: 776589
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo
Change-Id: I25cecf5301b2b963a8c64cb515c45d6cdd74cf31
Reviewed-on: https://chromium-review.googlesource.com/961449Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Jay Civelli <jcivelli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543252}
parent d1986516
......@@ -4,6 +4,7 @@
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/run_loop.h"
......@@ -23,11 +24,14 @@
#include "components/toolbar/toolbar_model_impl.h"
#include "components/zoom/zoom_controller.h"
#include "content/public/common/page_zoom.h"
#include "content/public/test/url_loader_interceptor.h"
#include "net/cert/ct_policy_status.h"
#include "net/ssl/ssl_info.h"
#include "net/test/cert_test_util.h"
#include "net/test/test_data_directory.h"
#include "net/test/url_request/url_request_mock_http_job.h"
#include "net/url_request/url_request_filter.h"
#include "services/network/public/cpp/features.h"
class LocationBarViewBrowserTest : public InProcessBrowserTest {
public:
......@@ -214,22 +218,55 @@ class SecurityIndicatorTest : public InProcessBrowserTest {
}
void SetUpInterceptor(net::CertStatus cert_status) {
base::FilePath serve_file;
PathService::Get(chrome::DIR_TEST_DATA, &serve_file);
serve_file = serve_file.Append(FILE_PATH_LITERAL("title1.html"));
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::BindOnce(&AddUrlHandler, serve_file, cert_, cert_status));
// TODO(crbug.com/821557): Remove the non network service code path once
// the URLLoader intercepts frame requests.
if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
url_loader_interceptor_ = std::make_unique<content::URLLoaderInterceptor>(
base::BindRepeating(&SecurityIndicatorTest::InterceptURLLoad,
base::Unretained(this), cert_status));
} else {
base::FilePath serve_file;
PathService::Get(chrome::DIR_TEST_DATA, &serve_file);
serve_file = serve_file.Append(FILE_PATH_LITERAL("title1.html"));
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::BindOnce(&AddUrlHandler, serve_file, cert_, cert_status));
}
}
void ResetInterceptor() {
content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
base::BindOnce(&RemoveUrlHandler));
if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
url_loader_interceptor_.reset();
} else {
content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
base::BindOnce(&RemoveUrlHandler));
}
}
bool InterceptURLLoad(net::CertStatus cert_status,
content::URLLoaderInterceptor::RequestParams* params) {
if (params->url_request.url.host() != kMockSecureHostname)
return false;
net::SSLInfo ssl_info;
ssl_info.cert = cert_;
ssl_info.cert_status = cert_status;
ssl_info.ct_policy_compliance =
net::ct::CTPolicyCompliance::CT_POLICY_COMPLIES_VIA_SCTS;
network::ResourceResponseHead resource_response;
resource_response.mime_type = "text/html";
params->client->OnReceiveResponse(resource_response, ssl_info,
/*downloaded_file=*/nullptr);
network::URLLoaderCompletionStatus completion_status;
completion_status.ssl_info = ssl_info;
params->client->OnComplete(completion_status);
return true;
}
private:
scoped_refptr<net::X509Certificate> cert_;
std::unique_ptr<content::URLLoaderInterceptor> url_loader_interceptor_;
DISALLOW_COPY_AND_ASSIGN(SecurityIndicatorTest);
};
......
......@@ -101,7 +101,6 @@
-PolicyTest.ForceGoogleSafeSearch
-ProfileBrowserTest.SendHPKPReport
-ProfileBrowserTest.SendHPKPReportServerHangs
-SecurityIndicatorTest.CheckIndicatorText
# https://bugs.chromium.org/p/chromium/issues/detail?id=789670
-DiceBrowserTest.Reauth
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment