#include "third_party/blink/public/common/permissions_policy/permissions_policy.h"
#include <optional>
#include <unordered_set>
#include "base/containers/contains.h"
#include "base/strings/stringprintf.h"
#include "base/test/gtest_util.h"
#include "base/test/scoped_feature_list.h"
#include "services/network/public/cpp/resource_request.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/common/permissions_policy/permissions_policy_features_internal.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/frame/fenced_frame_permissions_policies.h"
#include "third_party/blink/public/common/permissions_policy/permissions_policy_features.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom-shared.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom.h"
#include "third_party/blink/public/mojom/permissions_policy/policy_value.mojom.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace blink {
namespace {
const mojom::PermissionsPolicyFeature kDefaultOnFeature = …;
const mojom::PermissionsPolicyFeature kDefaultSelfFeature = …;
const mojom::PermissionsPolicyFeature kDefaultOffFeature = …;
const mojom::PermissionsPolicyFeature kUnavailableFeature = …;
}
class PermissionsPolicyTest : public testing::Test { … };
TEST_F(PermissionsPolicyTest, TestInitialPolicy) { … }
TEST_F(PermissionsPolicyTest, TestCanEnableOffFeatureWithAll) { … }
TEST_F(PermissionsPolicyTest, TestCanEnableOffFeatureWithSelf) { … }
TEST_F(PermissionsPolicyTest, TestInitialSameOriginChildPolicy) { … }
TEST_F(PermissionsPolicyTest, TestInitialCrossOriginChildPolicy) { … }
TEST_F(PermissionsPolicyTest, TestCrossOriginChildCannotEnableFeature) { … }
TEST_F(PermissionsPolicyTest, TestSameOriginChildCannotEnableOffFeature) { … }
TEST_F(PermissionsPolicyTest,
TestSameOriginChildWithParentEnabledCannotEnableOffFeature) { … }
TEST_F(PermissionsPolicyTest,
TestSameOriginChildWithParentEnabledCannotEnableOffFeatureWithoutAllow) { … }
TEST_F(PermissionsPolicyTest,
TestSameOriginChildWithParentEnabledCanEnableOffFeatureWithAllow) { … }
TEST_F(PermissionsPolicyTest,
TestCrossOriginChildWithParentEnabledCanEnableOffFeatureWithAllow) { … }
TEST_F(PermissionsPolicyTest, TestFrameSelfInheritance) { … }
TEST_F(PermissionsPolicyTest, TestReflexiveFrameSelfInheritance) { … }
TEST_F(PermissionsPolicyTest, TestReflexiveFrameOriginAInheritance) { … }
TEST_F(PermissionsPolicyTest, TestSelectiveFrameInheritance) { … }
TEST_F(PermissionsPolicyTest, TestSelectiveFrameInheritance2) { … }
TEST_F(PermissionsPolicyTest, TestPolicyCanBlockSelf) { … }
TEST_F(PermissionsPolicyTest, TestParentPolicyBlocksSameOriginChildPolicy) { … }
TEST_F(PermissionsPolicyTest, TestChildPolicyCanBlockSelf) { … }
TEST_F(PermissionsPolicyTest, TestChildPolicyCanBlockChildren) { … }
TEST_F(PermissionsPolicyTest, TestParentPolicyBlocksCrossOriginChildPolicy) { … }
TEST_F(PermissionsPolicyTest, TestEnableForAllOrigins) { … }
TEST_F(PermissionsPolicyTest, TestEnableForAllOriginsAndDelegate) { … }
TEST_F(PermissionsPolicyTest, TestDefaultOnStillNeedsSelf) { … }
TEST_F(PermissionsPolicyTest, TestDefaultOnEnablesForAllDescendants) { … }
TEST_F(PermissionsPolicyTest, TestDefaultSelfRequiresDelegation) { … }
TEST_F(PermissionsPolicyTest, TestDefaultSelfRespectsSameOriginEmbedding) { … }
TEST_F(PermissionsPolicyTest, TestDelegationRequiredAtAllLevels) { … }
TEST_F(PermissionsPolicyTest, TestBlockedFrameCannotReenable) { … }
TEST_F(PermissionsPolicyTest, TestEnabledFrameCanDelegate) { … }
TEST_F(PermissionsPolicyTest, TestEnabledFrameCanDelegateByDefault) { … }
TEST_F(PermissionsPolicyTest, TestFeaturesDontDelegateByDefault) { … }
TEST_F(PermissionsPolicyTest, TestFeaturesAreIndependent) { … }
TEST_F(PermissionsPolicyTest, TestSimpleFramePolicy) { … }
TEST_F(PermissionsPolicyTest, TestAllOriginFramePolicy) { … }
TEST_F(PermissionsPolicyTest, TestFramePolicyCanBeFurtherDelegated) { … }
TEST_F(PermissionsPolicyTest, TestDefaultOnCanBeDisabledByFramePolicy) { … }
TEST_F(PermissionsPolicyTest, TestFramePolicyModifiesHeaderPolicy) { … }
TEST_F(PermissionsPolicyTest, TestCombineFrameAndHeaderPolicies) { … }
TEST_F(PermissionsPolicyTest, TestFeatureDeclinedAtTopLevel) { … }
TEST_F(PermissionsPolicyTest, TestFeatureDelegatedAndAllowed) { … }
TEST_F(PermissionsPolicyTest, TestDefaultSandboxedFramePolicy) { … }
TEST_F(PermissionsPolicyTest, TestSandboxedFramePolicyForAllOrigins) { … }
TEST_F(PermissionsPolicyTest, TestSandboxedFramePolicyForSelf) { … }
TEST_F(PermissionsPolicyTest, TestSandboxedFramePolicyForOpaqueSrcOrigin) { … }
TEST_F(PermissionsPolicyTest, TestSandboxedFrameFromHeaderPolicy) { … }
TEST_F(PermissionsPolicyTest, TestSandboxedPolicyIsNotInherited) { … }
TEST_F(PermissionsPolicyTest, TestSandboxedPolicyCanBePropagated) { … }
TEST_F(PermissionsPolicyTest, TestUndefinedFeaturesInFramePolicy) { … }
TEST_F(PermissionsPolicyTest,
ProposedTestIsFeatureEnabledForSubresourceRequest) { … }
TEST_F(PermissionsPolicyTest,
ProposedTestIsFeatureEnabledForSubresourceRequestAssumingOptIn) { … }
TEST_F(PermissionsPolicyTest, ProposedTestImplicitPolicy) { … }
TEST_F(PermissionsPolicyTest, ProposedTestCompletelyBlockedPolicy) { … }
TEST_F(PermissionsPolicyTest, ProposedTestDisallowedCrossOriginChildPolicy) { … }
TEST_F(PermissionsPolicyTest, ProposedTestAllowedCrossOriginChildPolicy) { … }
TEST_F(PermissionsPolicyTest, ProposedTestAllAllowedCrossOriginChildPolicy) { … }
TEST_F(PermissionsPolicyTest, ProposedTestNestedPolicyPropagates) { … }
TEST_F(PermissionsPolicyTest, CreateFlexibleForFencedFrame) { … }
TEST_F(PermissionsPolicyTest, CreateForFledgeFencedFrame) { … }
TEST_F(PermissionsPolicyTest, CreateForSharedStorageFencedFrame) { … }
TEST_F(PermissionsPolicyTest, CreateFromParsedPolicy) { … }
TEST_F(PermissionsPolicyTest, CreateFromParsedPolicyExcludingSelf) { … }
TEST_F(PermissionsPolicyTest, CreateFromParsedPolicyWithEmptyAllowlist) { … }
TEST_F(PermissionsPolicyTest, OverwriteHeaderPolicyForClientHints) { … }
TEST_F(PermissionsPolicyTest, GetAllowlistForFeatureIfExists) { … }
TEST_F(PermissionsPolicyTest, UnloadDefaultEnabledForAll) { … }
TEST_F(PermissionsPolicyTest, UnloadDefaultEnabledForNone) { … }
blink::PermissionsPolicyFeatureDefault GetDefaultForUnload(
const url::Origin& origin) { … }
TEST_F(PermissionsPolicyTest, GetPermissionsPolicyFeatureListForUnload) { … }
TEST_F(PermissionsPolicyTest, UnloadDeprecationAllowedHosts) { … }
TEST_F(PermissionsPolicyTest, UnloadDeprecationAllowedHostsEmpty) { … }
TEST_F(PermissionsPolicyTest, UnloadDeprecationAllowedForHostHostLists) { … }
TEST_F(PermissionsPolicyTest, UnloadDeprecationAllowedForOrigin_NonHttp) { … }
TEST_F(PermissionsPolicyTest,
UnloadDeprecationAllowedForOrigin_GradualRollout) { … }
}