#include "components/origin_trials/browser/origin_trials.h"
#include <memory>
#include <string_view>
#include <utility>
#include <vector>
#include "base/containers/flat_set.h"
#include "base/memory/scoped_refptr.h"
#include "base/time/time.h"
#include "components/origin_trials/common/persisted_trial_token.h"
#include "components/origin_trials/test/test_persistence_provider.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/origin_trials/scoped_test_origin_trial_policy.h"
#include "third_party/blink/public/common/origin_trials/trial_token_validator.h"
#include "third_party/blink/public/mojom/origin_trial_feature/origin_trial_feature.mojom-shared.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace origin_trials {
namespace {
OriginTrialFeature;
const char kPersistentTrialName[] = …;
const char kPersistentThirdPartyDeprecationTrialName[] = …;
const char kNonPersistentTrialName[] = …;
const char kInvalidTrialName[] = …;
const char kTrialEnabledOriginA[] = …;
const char kTrialEnabledOriginASubdomain[] = …;
const char kTrialEnabledOriginASubdomainAlt[] = …;
const char kTrialEnabledOriginB[] = …;
const char kThirdPartyTrialEnabledOrigin[] = …;
const char kThirdPartyTrialEnabledOriginSubdomain[] = …;
const char kThirdPartyTrialEnabledOriginSubdomainAlt[] = …;
const char kDummyTokenSignature[] = …;
const base::Time kValidTime = …;
const base::Time kExpiryTime = …;
const char kFrobulatePersistentToken[] = …;
const char kFrobulatePersistentSubdomainToken[] = …;
const char kFrobulatePersistentTokenAlternate[] = …;
const char kFrobulateToken[] = …;
const char kFrobulateManualCompletionToken[] = …;
const char kFrobulatePersistentExpiryGracePeriodToken[] = …;
const char kFrobulatePersistentThirdPartyToken[] = …;
const char kFrobulatePersistentThirdPartyDeprecationSubdomainToken[] = …;
const char kFrobulatePersistentThirdPartyDeprecationThirdPartyToken[] = …;
const char kFrobulatePersistentThirdPartyDeprecationSubdomainThirdPartyToken[] = …;
const char kFrobulatePersistentInvalidOsToken[] = …;
const ukm::SourceId kFakeSourceId1 = …;
const ukm::SourceId kFakeSourceId2 = …;
class OpenScopedTestOriginTrialPolicy
: public blink::ScopedTestOriginTrialPolicy { … };
class TestStatusObserver
: public content::OriginTrialsControllerDelegate::Observer { … };
}
class OriginTrialsTest : public testing::Test { … };
TEST_F(OriginTrialsTest, CleanObjectHasNoPersistentTrials) { … }
TEST_F(OriginTrialsTest, EnabledTrialsArePersisted) { … }
TEST_F(OriginTrialsTest, OnlyPersistentTrialsAreEnabled) { … }
TEST_F(OriginTrialsTest, ResetClearsPersistedTrials) { … }
TEST_F(OriginTrialsTest, TrialNotEnabledByDefault) { … }
TEST_F(OriginTrialsTest, TrialEnablesFeature) { … }
TEST_F(OriginTrialsTest, TrialDoesNotEnableOtherFeatures) { … }
TEST_F(OriginTrialsTest, TrialIsNotEnabledOrPersistedOnInvalidOs) { … }
TEST_F(OriginTrialsTest, TokensCanBeAppended) { … }
TEST_F(OriginTrialsTest, ThirdPartyTokensCanBeAppendedOnlyIfDeprecation) { … }
TEST_F(OriginTrialsTest, SubdomainTokensEnableTrialForSubdomainsOfTokenOrigin) { … }
TEST_F(OriginTrialsTest,
TrialNotEnabledForNonSubdomainsOfSubdomainTokenOrigin) { … }
TEST_F(OriginTrialsTest, SubdomainTokensEnableTrialForTokenOrigin) { … }
TEST_F(OriginTrialsTest,
ThirdPartySubdomainTokensEnableTrialForSubdomainsOfTokenOrigin) { … }
TEST_F(OriginTrialsTest,
SubdomainTokensProvidedBySubdomainsAppendForTokenOrigin) { … }
TEST_F(OriginTrialsTest, SubdomainTokenNotDisabledBySubdomain) { … }
TEST_F(OriginTrialsTest, SubdomainTokenDisabledByTokenOrigin) { … }
TEST_F(OriginTrialsTest, StoredEnabledTrialNotReturnedIfNoLongerPersistent) { … }
TEST_F(OriginTrialsTest, StatusObserverIsAdded) { … }
TEST_F(OriginTrialsTest, StatusObserverIsRemoved) { … }
TEST_F(OriginTrialsTest, NotifyOnEnable) { … }
TEST_F(OriginTrialsTest, NotifyOnEnableWithSubdomainMatching) { … }
TEST_F(OriginTrialsTest, NotifyOnDisable) { … }
TEST_F(OriginTrialsTest, NotifyOnDisableWithSubdomainMatching) { … }
TEST_F(OriginTrialsTest, NotifyUsingTokenOriginOnEnable) { … }
TEST_F(OriginTrialsTest, DontNotifyOnDisableIfNotPreviouslyEnabled) { … }
TEST_F(OriginTrialsTest, NotifyOnEnabledOnlyIfPreviouslyDisabled) { … }
TEST_F(OriginTrialsTest, NotifyOnStatusChangeMultiplePartitionSites) { … }
TEST_F(OriginTrialsTest, NotifyForCorrectTrial) { … }
TEST_F(OriginTrialsTest, NotifyWithTokenOriginForSubdomainTokens) { … }
TEST_F(OriginTrialsTest, NotifyOnPersistedTokensCleared) { … }
TEST_F(OriginTrialsTest, NotifyOnPersistedTokensClearedNoTokens) { … }
TEST_F(OriginTrialsTest, DisabledTrialsNotReturned) { … }
TEST_F(OriginTrialsTest, DisabledTokensNotReturned) { … }
TEST_F(OriginTrialsTest, UserDisabledTokensNotReturned) { … }
TEST_F(OriginTrialsTest, GracePeriodIsRespected) { … }
TEST_F(OriginTrialsTest, DoNotPersistTokensForOpaqueOrigins) { … }
TEST_F(OriginTrialsTest, PersistTokensInOpaquePartition) { … }
TEST_F(OriginTrialsTest, TokensArePartitionedByTopLevelSite) { … }
TEST_F(OriginTrialsTest, PartitionSiteIsETLDPlusOne) { … }
TEST_F(OriginTrialsTest,
PartitionSiteUsesPrivateRegistryAsEffectiveTopLevelDomain) { … }
TEST_F(OriginTrialsTest, PartitionSiteCanBeIpAddress) { … }
TEST_F(OriginTrialsTest, PartitionSiteCanBeLocalhost) { … }
TEST_F(OriginTrialsTest, PartitionSiteCanHaveNonstandardPort) { … }
TEST_F(OriginTrialsTest, OpaqueOriginAsPartitionSiteSerializesAsSentinelValue) { … }
struct OriginValidationTestCase { … };
std::vector<OriginValidationTestCase> kOriginValidationTestCases = …;
class OriginTrialsTokenOriginValidationTest
: public OriginTrialsTest,
public testing::WithParamInterface<OriginValidationTestCase> { … };
TEST_P(OriginTrialsTokenOriginValidationTest, MatchesTokenOrigin) { … }
INSTANTIATE_TEST_SUITE_P(…);
}