#include <map>
#include <string>
#include "base/ranges/algorithm.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/permissions_policy/origin_with_possible_wildcards.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy.mojom-blink.h"
#include "third_party/blink/renderer/core/execution_context/agent.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/loader/empty_clients.h"
#include "third_party/blink/renderer/core/permissions_policy/permissions_policy_parser.h"
#include "third_party/blink/renderer/core/permissions_policy/policy_helper.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "url/gurl.h"
#include "url/origin.h"
#define ORIGIN_A …
#define ORIGIN_A_SUBDOMAIN_WILDCARD …
#define ORIGIN_A_SUBDOMAIN_ESCAPED …
#define ORIGIN_B …
#define ORIGIN_C …
#define OPAQUE_ORIGIN …
#define NOT_APPLICABLE …
class GURL;
namespace blink {
namespace {
const char* const kValidHeaderPolicies[] = …;
const char* const kInvalidHeaderPolicies[] = …;
}
class PermissionsPolicyParserTest : public ::testing::Test { … };
struct OriginWithPossibleWildcardsForTest { … };
struct ParsedPolicyDeclarationForTest { … };
ParsedPolicyForTest;
struct PermissionsPolicyParserTestCase { … };
class PermissionsPolicyParserParsingTest
: public PermissionsPolicyParserTest,
public ::testing::WithParamInterface<PermissionsPolicyParserTestCase> { … };
const PermissionsPolicyParserTestCase
PermissionsPolicyParserParsingTest::kCases[] = …;
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(PermissionsPolicyParserParsingTest, FeaturePolicyParsedCorrectly) { … }
TEST_P(PermissionsPolicyParserParsingTest, PermissionsPolicyParsedCorrectly) { … }
TEST_F(PermissionsPolicyParserParsingTest,
FeaturePolicyDuplicatedFeatureDeclaration) { … }
TEST_F(PermissionsPolicyParserParsingTest,
PermissionsPolicyDuplicatedFeatureDeclaration) { … }
TEST_F(PermissionsPolicyParserParsingTest,
FeaturePolicyHeaderPermissionsPolicyHeaderCoExistConflictEntry) { … }
TEST_F(PermissionsPolicyParserParsingTest,
OverlapDeclarationSingleWarningMessage) { … }
TEST_F(PermissionsPolicyParserParsingTest,
FeaturePolicyHeaderPermissionsPolicyHeaderCoExistSeparateLogger) { … }
TEST_F(PermissionsPolicyParserParsingTest, CommaSeparatorInAttribute) { … }
TEST_F(PermissionsPolicyParserTest, ParseValidHeaderPolicy) { … }
TEST_F(PermissionsPolicyParserTest, ParseInvalidHeaderPolicy) { … }
TEST_F(PermissionsPolicyParserTest, ParseTooLongPolicy) { … }
TEST_F(PermissionsPolicyParserTest, HeaderHistogram) { … }
TEST_F(PermissionsPolicyParserTest, HistogramMultiple) { … }
TEST_F(PermissionsPolicyParserTest, CommaSeparatedUseCounter) { … }
TEST_F(PermissionsPolicyParserTest, SemicolonSeparatedUseCounter) { … }
class FeaturePolicyMutationTest : public testing::Test { … };
TEST_F(FeaturePolicyMutationTest, TestIsFeatureDeclared) { … }
TEST_F(FeaturePolicyMutationTest, TestIsFeatureDeclaredWithEmptyPolicy) { … }
TEST_F(FeaturePolicyMutationTest, TestRemoveAbsentFeature) { … }
TEST_F(FeaturePolicyMutationTest, TestRemoveFromEmptyPolicy) { … }
TEST_F(FeaturePolicyMutationTest, TestRemoveFeatureIfPresent) { … }
TEST_F(FeaturePolicyMutationTest, TestRemoveFeatureIfPresentOnSecondFeature) { … }
TEST_F(FeaturePolicyMutationTest, TestRemoveAllFeatures) { … }
TEST_F(FeaturePolicyMutationTest, TestDisallowIfNotPresent) { … }
TEST_F(FeaturePolicyMutationTest, TestAllowEverywhereIfNotPresent) { … }
TEST_F(FeaturePolicyMutationTest, TestDisallowUnconditionally) { … }
TEST_F(FeaturePolicyMutationTest, TestDisallowNewFeatureUnconditionally) { … }
TEST_F(FeaturePolicyMutationTest, TestAllowUnconditionally) { … }
TEST_F(FeaturePolicyMutationTest, TestAllowNewFeatureUnconditionally) { … }
class FeaturePolicyVisibilityTest
: public testing::Test,
public testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(FeaturePolicyVisibilityTest, VerifyIsolated) { … }
}