summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/frame/csp/require_trusted_types_for_directive_test.cc
blob: c2a48f4a3cb90d7b2f9edcfc1a6eb2eb3a5cce10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/core/frame/csp/require_trusted_types_for_directive.h"

#include "testing/gtest/include/gtest/gtest.h"

namespace blink {

TEST(RequireTrustedTypesForDirectiveTest, TestSinks) {
  struct {
    const char* directive;
    const bool result;
  } test_cases[] = {{"'script'", true},
                    {"*", false},
                    {"", false},
                    {"''", false},
                    {"script", false},
                    {"'script' 'css'", true},
                    {"'script' 'script'", true}};

  for (const auto& test_case : test_cases) {
    RequireTrustedTypesForDirective directive("require-trusted-types-for",
                                              test_case.directive, nullptr);
    SCOPED_TRACE(testing::Message() << " require-trusted-types-for "
                                    << test_case.directive << ";");
    EXPECT_EQ(directive.require(), test_case.result);
  }
}
}  // namespace blink