chromium/third_party/blink/renderer/core/permissions_policy/permissions_policy_test.cc

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

#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"

// Origin strings used for tests
#define ORIGIN_A
#define ORIGIN_A_SUBDOMAIN_WILDCARD
#define ORIGIN_A_SUBDOMAIN_ESCAPED
#define ORIGIN_B
#define ORIGIN_C
#define OPAQUE_ORIGIN

// identifier used for feature/permissions policy parsing test.
// when there is a testcase for one syntax but not the other.
#define NOT_APPLICABLE

class GURL;

namespace blink {

namespace {

const char* const kValidHeaderPolicies[] =;

const char* const kInvalidHeaderPolicies[] =;
}  // namespace

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 histogram counting the use of permissions policies in header.
TEST_F(PermissionsPolicyParserTest, HeaderHistogram) {}

// Test counting the use of each permissions policy only once per header.
TEST_F(PermissionsPolicyParserTest, HistogramMultiple) {}

// Tests the use counter for comma separator in declarations.
TEST_F(PermissionsPolicyParserTest, CommaSeparatedUseCounter) {}

// Tests the use counter for semicolon separator in declarations.
TEST_F(PermissionsPolicyParserTest, SemicolonSeparatedUseCounter) {}

// Test policy mutation methods
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</*is_isolated=*/bool> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(FeaturePolicyVisibilityTest, VerifyIsolated) {}

}  // namespace blink