chromium/chrome/browser/tpcd/support/top_level_trial_service_browsertest.cc

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

#include "chrome/browser/tpcd/support/top_level_trial_service.h"

#include "base/strings/strcat.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/tpcd/support/trial_test_utils.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/test/base/chrome_test_utils.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "components/content_settings/core/browser/content_settings_observer.h"
#include "components/content_settings/core/browser/cookie_settings.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/content_settings/core/common/features.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/network_session_configurator/common/network_switches.h"
#include "components/prefs/pref_service.h"
#include "components/privacy_sandbox/tracking_protection_prefs.h"
#include "components/ukm/test_ukm_recorder.h"
#include "components/user_prefs/user_prefs.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/content_features.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/url_loader_interceptor.h"
#include "net/base/features.h"
#include "net/cookies/cookie_util.h"
#include "net/dns/mock_host_resolver.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/network/public/mojom/url_response_head.mojom.h"

URLLoaderInterceptor;
WebContents;

namespace tpcd::trial {

class TopLevelTpcdTrialBrowserTest : public InProcessBrowserTest {};

IN_PROC_BROWSER_TEST_F(TopLevelTpcdTrialBrowserTest, EnabledAfterHttpResponse) {}

IN_PROC_BROWSER_TEST_F(TopLevelTpcdTrialBrowserTest,
                       EnabledAfterHttpResponseWithEtldSubdomainMatchingToken) {}

IN_PROC_BROWSER_TEST_F(TopLevelTpcdTrialBrowserTest, EnabledUsingMetaTag) {}

IN_PROC_BROWSER_TEST_F(TopLevelTpcdTrialBrowserTest,
                       EnabledUsingMetaTagWithEtldSubdomainMatchingToken) {}

// This test verifies (when enabled using a subdomain matching token) the trial
// is only disabled if a document from the token origin is loaded, even if one
// of its subdomains originally enabled the trial.
IN_PROC_BROWSER_TEST_F(TopLevelTpcdTrialBrowserTest,
                       OnlyTokenOriginCanDisableTrial) {}

IN_PROC_BROWSER_TEST_F(TopLevelTpcdTrialBrowserTest,
                       NoSettingCreatedIfTrialEnabledCrossSite) {}

// Since the TopLevelTpcd origin trial itself can be enabled/disabled in a
// cross-site context despite the trial only being intended to support top-level
// sites, this test verifies that changes to the status of the trial for an
// origin when in a cross-site context doesn't affect an existing content
// setting created for it in a top-level context.
IN_PROC_BROWSER_TEST_F(TopLevelTpcdTrialBrowserTest,
                       CrossSiteOriginTrialStateChangesIgnored) {}

IN_PROC_BROWSER_TEST_F(TopLevelTpcdTrialBrowserTest,
                       UkmEmittedWhenTrialConfiguredViaResponseHeader) {}

IN_PROC_BROWSER_TEST_F(TopLevelTpcdTrialBrowserTest,
                       UkmEmittedWhenTrialEnabledViaMetaTag) {}

IN_PROC_BROWSER_TEST_F(
    TopLevelTpcdTrialBrowserTest,
    UkmNotDuplicatedWhenResponseToNavigationRequestHasCriticalOriginTrialHeader) {}

IN_PROC_BROWSER_TEST_F(TopLevelTpcdTrialBrowserTest,
                       UkmNotEmittedWhenRedirectResponseHasTokenInHeader) {}

IN_PROC_BROWSER_TEST_F(
    TopLevelTpcdTrialBrowserTest,
    UkmNotEmittedWhenRedirectResponseHasCriticalHeaderAndTokenInHeader) {}

}  // namespace tpcd::trial