chromium/chrome/browser/tpcd/metadata/manager_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 <cstring>
#include <string>
#include <tuple>
#include <vector>

#include "base/files/file_util.h"
#include "base/path_service.h"
#include "base/strings/stringprintf.h"
#include "base/test/scoped_feature_list.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/browser/net/storage_test_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_test_util.h"
#include "chrome/browser/tpcd/support/top_level_trial_service.h"
#include "chrome/browser/tpcd/support/top_level_trial_service_factory.h"
#include "chrome/browser/tpcd/support/validity_service.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/profile_waiter.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/content_settings/core/browser/cookie_settings.h"
#include "components/content_settings/core/common/content_settings_metadata.h"
#include "components/content_settings/core/common/content_settings_utils.h"
#include "components/content_settings/core/common/features.h"
#include "components/prefs/pref_service.h"
#include "components/privacy_sandbox/tracking_protection_prefs.h"
#include "components/tpcd/metadata/browser/parser.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_paths.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
#include "net/base/features.h"
#include "net/cookies/cookie_setting_override.h"
#include "net/cookies/site_for_cookies.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gmock/include/gmock/gmock-matchers.h"

namespace tpcd::metadata {
namespace {
const base::FilePath::CharType kComponentFileName[] =);

const char* kFirstPartyHost =;
const char* kThirdPartyHost1 =;
const char* kThirdPartyHost1Sub =;
const char* kThirdPartyHost2 =;
const char* kThirdPartyHost3 =;

#if !BUILDFLAG(IS_CHROMEOS_ASH)
// Creates a Original Guest Profile (not OTR Profile) for testing.
Profile& CreateOriginalGuestProfile() {}

// Creates a new regular profile for testing.
Profile* CreateRegularProfile() {}
#endif

const char kThirdPartyCookieAllowMechanismHistogram[] =;
ThirdPartyCookieAllowMechanism;
}  // namespace

class ManagerBrowserTest : public InProcessBrowserTest {};

IN_PROC_BROWSER_TEST_F(ManagerBrowserTest, GetTpcdMetadataGrants_Empty) {}

IN_PROC_BROWSER_TEST_F(ManagerBrowserTest, GetTpcdMetadataGrants) {}

IN_PROC_BROWSER_TEST_F(ManagerBrowserTest, SuccessfullyUpdated) {}

IN_PROC_BROWSER_TEST_F(ManagerBrowserTest,
                       TpcdDtGracePeriodEnforced_ValidDtToken) {}

// This test coverage ensures more specific patterns precede on others.
IN_PROC_BROWSER_TEST_F(ManagerBrowserTest,
                       TpcdDtGracePeriodEnforced_EntryPrecedence_1) {}

// This test coverage ensures more specific patterns precede on others.
IN_PROC_BROWSER_TEST_F(ManagerBrowserTest,
                       TpcdDtGracePeriodEnforced_EntryPrecedence_2) {}

IN_PROC_BROWSER_TEST_F(ManagerBrowserTest,
                       TpcdDtGracePeriodEnforced_InValidDtToken) {}

class ManagerPrefsBrowserTest
    : public ManagerBrowserTest,
      public testing::WithParamInterface<
          std::tuple</*net::features::kThirdPartyStoragePartitioning*/ bool,
                     /*prefs::kBlockAll3pcToggleEnabled*/ bool>> {};

// The first Bool controls the enablement of
// `net::features::kThirdPartyStoragePartitioning`.
//
// The first Bool controls the
// enablement of `prefs::kBlockAll3pcToggleEnabled`.
INSTANTIATE_TEST_SUITE_P();

IN_PROC_BROWSER_TEST_P(ManagerPrefsBrowserTest,
                       RelevantUserCookieSpecsPrecede) {}

IN_PROC_BROWSER_TEST_P(ManagerPrefsBrowserTest, NoSpecificBlockedCookieSpecs) {}

// ChromeOS doesn't support multiple profiles.
#if !BUILDFLAG(IS_CHROMEOS_ASH)
IN_PROC_BROWSER_TEST_P(ManagerPrefsBrowserTest,
                       NoSpecificBlockedCookieSpecs_AltRegularProfile) {}
#endif

IN_PROC_BROWSER_TEST_P(ManagerPrefsBrowserTest,
                       NoSpecificBlockedCookieSpecs_IncognitoProfile) {}

// ChromeOS doesn't support multiple profiles.
#if !BUILDFLAG(IS_CHROMEOS_ASH)
IN_PROC_BROWSER_TEST_P(ManagerPrefsBrowserTest,
                       NoSpecificBlockedCookieSpecs_GuestProfile) {}
#endif

}  // namespace tpcd::metadata