chromium/content/browser/system_dns_resolution/system_dns_resolver_browsertest.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <list>

#include "base/functional/callback.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_future.h"
#include "base/threading/platform_thread.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/network_service_util.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_client.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/content_browser_test.h"
#include "content/shell/browser/shell.h"
#include "mojo/public/cpp/bindings/callback_helpers.h"
#include "net/base/address_list.h"
#include "net/base/ip_address.h"
#include "net/base/ip_endpoint.h"
#include "net/base/network_interfaces.h"
#include "net/base/request_priority.h"
#include "net/dns/host_resolver_system_task.h"
#include "net/dns/mock_host_resolver.h"
#include "net/dns/public/host_resolver_results.h"
#include "net/dns/public/resolve_error_info.h"
#include "net/dns/public/secure_dns_policy.h"
#include "sandbox/policy/features.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/simple_host_resolver.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/perf/perf_result_reporter.h"

namespace content {

namespace {

const int kHttpPort =;

const char kHostname1[] =;
const char kIpAddress1[] =;
const char kHostname2[] =;
const char kIpAddress2[] =;
const char kFailHostname[] =;

ResolveHostFuture;

}  // namespace

class SystemDnsResolverBrowserTest : public content::ContentBrowserTest {};

IN_PROC_BROWSER_TEST_F(SystemDnsResolverBrowserTest,
                       NetworkServiceResolvesOneHostname) {}

IN_PROC_BROWSER_TEST_F(SystemDnsResolverBrowserTest,
                       NetworkServiceResolvesTwoHostnames) {}

IN_PROC_BROWSER_TEST_F(SystemDnsResolverBrowserTest,
                       NetworkServiceFailsResolvingBadHostname) {}

// Check if the system's own host name resolves, which is a slightly different
// code path from normal resolution.
IN_PROC_BROWSER_TEST_F(SystemDnsResolverBrowserTest,
                       NetworkServiceResolvesOwnHostname) {}

class SystemDnsResolverPerfTest : public content::ContentBrowserTest {};

namespace {
constexpr char kMetricPrefixSystemDnsResolver[] =;
constexpr char kMetricTimePerSystemDnsResolution[] =;

const size_t kNumResolutions =;
std::atomic<bool> g_finished =;

void PostAnotherTask() {}

perf_test::PerfResultReporter SetUpReporter(const std::string& story_name) {}
}  // namespace

// This benchmark just sends a bunch SYSTEM dns requests to the network service.
// If out-of-process system DNS resolution is enabled, it will send those
// requests back to the browser. So this benchmark adds some mild UI thread
// contention.
// TODO(crbug.com/1312224, crbug.com/1320192): this can probably be removed when
// out-of-process system DNS resolution fully launches.
IN_PROC_BROWSER_TEST_F(SystemDnsResolverPerfTest, MANUAL_ResolveManyHostnames) {}

}  // namespace content