Commit 6182e653 authored by Andy Paicu's avatar Andy Paicu Committed by Commit Bot

Putting `report-to` behind the Reporting API feature flag

This basically ties in the launch of `report-to` to the launch
of the Reporting API.

I2S: https://groups.google.com/a/chromium.org/d/msg/blink-dev/eYCm_qnf9BA/KLkMRkjcBwAJ
Spec: https://w3c.github.io/webappsec-csp/#directive-report-to

Bug: 726634
Change-Id: If5a3891f5cf2eb14fcbb3d0386b5262a6fc39230
Reviewed-on: https://chromium-review.googlesource.com/1221218Reviewed-by: default avatarMike West <mkwst@chromium.org>
Commit-Queue: Andy Paicu <andypaicu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#591356}
parent eed04c98
......@@ -8,6 +8,7 @@
#include <utility>
#include <vector>
#include "services/network/public/cpp/features.h"
#include "third_party/blink/renderer/bindings/core/v8/source_location.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/space_split_string.h"
......@@ -1452,11 +1453,12 @@ void CSPDirectiveList::AddDirective(const String& name, const String& value) {
} else if (type ==
ContentSecurityPolicy::DirectiveType::kTreatAsPublicAddress) {
TreatAsPublicAddress(name, value);
} else if (type == ContentSecurityPolicy::DirectiveType::kReportTo &&
base::FeatureList::IsEnabled(network::features::kReporting)) {
ParseReportTo(name, value);
} else if (policy_->ExperimentalFeaturesEnabled()) {
if (type == ContentSecurityPolicy::DirectiveType::kRequireSRIFor) {
ParseRequireSRIFor(name, value);
} else if (type == ContentSecurityPolicy::DirectiveType::kReportTo) {
ParseReportTo(name, value);
} else if (type == ContentSecurityPolicy::DirectiveType::kTrustedTypes &&
RuntimeEnabledFeatures::TrustedDOMTypesEnabled()) {
RequireTrustedTypes(name, value);
......
......@@ -8,6 +8,8 @@
#include <string>
#include <vector>
#include "base/test/scoped_feature_list.h"
#include "services/network/public/cpp/features.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/frame/csp/content_security_policy.h"
#include "third_party/blink/renderer/core/frame/csp/source_list_directive.h"
......@@ -24,6 +26,7 @@ class CSPDirectiveListTest : public testing::Test {
public:
CSPDirectiveListTest() : csp(ContentSecurityPolicy::Create()) {}
void SetUp() override {
scoped_feature_list_.InitWithFeatures({network::features::kReporting}, {});
csp->SetupSelf(
*SecurityOrigin::CreateFromString("https://example.test/image.png"));
}
......@@ -42,6 +45,7 @@ class CSPDirectiveListTest : public testing::Test {
protected:
Persistent<ContentSecurityPolicy> csp;
base::test::ScopedFeatureList scoped_feature_list_;
};
TEST_F(CSPDirectiveListTest, Header) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment