#include "components/variations/net/variations_http_headers.h"
#include <map>
#include <memory>
#include <optional>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/metrics/field_trial.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/escape.h"
#include "base/strings/strcat.h"
#include "base/strings/stringprintf.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_browser_main.h"
#include "chrome/browser/chrome_browser_main_extra_parts.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/optimization_guide/optimization_guide_keyed_service.h"
#include "chrome/browser/optimization_guide/optimization_guide_keyed_service_factory.h"
#include "chrome/browser/predictors/predictors_features.h"
#include "chrome/browser/predictors/predictors_switches.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/metrics/metrics_pref_names.h"
#include "components/metrics_services_manager/metrics_services_manager.h"
#include "components/network_session_configurator/common/network_switches.h"
#include "components/optimization_guide/core/optimization_guide_features.h"
#include "components/optimization_guide/proto/hints.pb.h"
#include "components/prefs/pref_service.h"
#include "components/signin/public/identity_manager/identity_test_utils.h"
#include "components/variations/proto/study.pb.h"
#include "components/variations/variations.mojom.h"
#include "components/variations/variations_associated_data.h"
#include "components/variations/variations_features.h"
#include "components/variations/variations_ids_provider.h"
#include "components/variations/variations_test_utils.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/network_connection_change_simulator.h"
#include "content/public/test/simple_url_loader_test_helper.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "url/gurl.h"
namespace {
constexpr char kTrialName[] = …;
class VariationHeaderSetter : public ChromeBrowserMainExtraParts { … };
class VariationsHttpHeadersBrowserTest
: public InProcessBrowserTest,
public testing::WithParamInterface<bool> { … };
std::unique_ptr<net::test_server::HttpResponse>
VariationsHttpHeadersBrowserTest::RequestHandler(
const net::test_server::HttpRequest& request) { … }
void CreateGoogleSignedInFieldTrial(variations::VariationID id) { … }
void CreateFieldTrialsWithDifferentVisibilities() { … }
void SetUpLimitedEntropyRandomizationSource() { … }
void CreateFieldTrial(const base::FieldTrial::EntropyProvider& entropy_provider,
bool with_google_web_experiment_ids) { … }
}
IN_PROC_BROWSER_TEST_P(VariationsHttpHeadersBrowserTest,
TestStrippingHeadersFromResourceRequest) { … }
IN_PROC_BROWSER_TEST_P(VariationsHttpHeadersBrowserTest,
TestStrippingHeadersFromSubresourceRequest) { … }
IN_PROC_BROWSER_TEST_P(VariationsHttpHeadersBrowserTest, Incognito) { … }
IN_PROC_BROWSER_TEST_P(VariationsHttpHeadersBrowserTest, UserSignedIn) { … }
IN_PROC_BROWSER_TEST_P(VariationsHttpHeadersBrowserTest, UserNotSignedIn) { … }
IN_PROC_BROWSER_TEST_P(VariationsHttpHeadersBrowserTest,
PRE_CheckLowEntropySourceValue) { … }
IN_PROC_BROWSER_TEST_P(VariationsHttpHeadersBrowserTest,
CheckLowEntropySourceValue) { … }
IN_PROC_BROWSER_TEST_P(VariationsHttpHeadersBrowserTest,
PRE_LimitedEntropyRandomization_ExperimentLogging) { … }
IN_PROC_BROWSER_TEST_P(VariationsHttpHeadersBrowserTest,
LimitedEntropyRandomization_ExperimentLogging) { … }
IN_PROC_BROWSER_TEST_P(
VariationsHttpHeadersBrowserTest,
PRE_LimitedEntropyRandomization_ExperimentLoggingWithoutGoogleWebExperimentationId) { … }
IN_PROC_BROWSER_TEST_P(
VariationsHttpHeadersBrowserTest,
LimitedEntropyRandomization_ExperimentLoggingWithoutGoogleWebExperimentationId) { … }
void VariationsHttpHeadersBrowserTest::GoogleWebVisibilityTopFrameTest(
bool top_frame_is_first_party) { … }
IN_PROC_BROWSER_TEST_P(VariationsHttpHeadersBrowserTest,
TestGoogleWebVisibilityInFirstPartyContexts) { … }
IN_PROC_BROWSER_TEST_P(VariationsHttpHeadersBrowserTest,
TestGoogleWebVisibilityInThirdPartyContexts) { … }
IN_PROC_BROWSER_TEST_P(
VariationsHttpHeadersBrowserTest,
TestStrippingHeadersFromRequestUsingSimpleURLLoaderWithProfileNetworkContext) { … }
IN_PROC_BROWSER_TEST_P(
VariationsHttpHeadersBrowserTest,
TestStrippingHeadersFromRequestUsingSimpleURLLoaderWithGlobalSystemNetworkContext) { … }
IN_PROC_BROWSER_TEST_P(VariationsHttpHeadersBrowserTest,
ServiceWorkerNavigationPreload) { … }
IN_PROC_BROWSER_TEST_P(VariationsHttpHeadersBrowserTest,
ServiceWorkerNetworkFallback) { … }
IN_PROC_BROWSER_TEST_P(VariationsHttpHeadersBrowserTest,
ServiceWorkerDoesNotSeeHeader) { … }
IN_PROC_BROWSER_TEST_P(VariationsHttpHeadersBrowserTest,
ServiceWorkerRespondWithFetch) { … }
IN_PROC_BROWSER_TEST_P(VariationsHttpHeadersBrowserTest, ServiceWorkerScript) { … }
IN_PROC_BROWSER_TEST_P(VariationsHttpHeadersBrowserTest, SharedWorkerScript) { … }
IN_PROC_BROWSER_TEST_P(VariationsHttpHeadersBrowserTest,
DedicatedWorkerScript) { … }
INSTANTIATE_TEST_SUITE_P(…);
namespace {
class VariationsHttpHeadersBrowserTestWithOptimizationGuide
: public VariationsHttpHeadersBrowserTest { … };
}
IN_PROC_BROWSER_TEST_P(VariationsHttpHeadersBrowserTestWithOptimizationGuide,
Prefetch) { … }
INSTANTIATE_TEST_SUITE_P(…);