Commit 54b81ab5 authored by Oleh Lamzin's avatar Oleh Lamzin Committed by Commit Bot

webui: sort CSP directives

Sort CSP directives in url_data_manager_backend.cc.

Change-Id: I1e094121c210458300521a47b949c4dc0228b925
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2302891
Commit-Queue: Oleh Lamzin <lamzin@google.com>
Reviewed-by: default avatarNasko Oskov <nasko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789999}
parent 389658b2
......@@ -163,6 +163,7 @@ scoped_refptr<net::HttpResponseHeaders> URLDataManagerBackend::GetHeaders(
const network::mojom::CSPDirectiveName kAllDirectives[] = {
network::mojom::CSPDirectiveName::ChildSrc,
network::mojom::CSPDirectiveName::ConnectSrc,
network::mojom::CSPDirectiveName::DefaultSrc,
network::mojom::CSPDirectiveName::FrameSrc,
network::mojom::CSPDirectiveName::ImgSrc,
......@@ -170,8 +171,7 @@ scoped_refptr<net::HttpResponseHeaders> URLDataManagerBackend::GetHeaders(
network::mojom::CSPDirectiveName::ObjectSrc,
network::mojom::CSPDirectiveName::ScriptSrc,
network::mojom::CSPDirectiveName::StyleSrc,
network::mojom::CSPDirectiveName::WorkerSrc,
network::mojom::CSPDirectiveName::ConnectSrc};
network::mojom::CSPDirectiveName::WorkerSrc};
for (auto& directive : kAllDirectives) {
csp_header.append(source->GetContentSecurityPolicy(directive));
......
......@@ -277,6 +277,8 @@ TEST_F(WebUIDataSourceTest, SetCspValues) {
EXPECT_EQ("child-src 'none';",
url_data_source->GetContentSecurityPolicy(
network::mojom::CSPDirectiveName::ChildSrc));
EXPECT_EQ("", url_data_source->GetContentSecurityPolicy(
network::mojom::CSPDirectiveName::ConnectSrc));
EXPECT_EQ("", url_data_source->GetContentSecurityPolicy(
network::mojom::CSPDirectiveName::DefaultSrc));
EXPECT_EQ("", url_data_source->GetContentSecurityPolicy(
......@@ -293,8 +295,6 @@ TEST_F(WebUIDataSourceTest, SetCspValues) {
network::mojom::CSPDirectiveName::ScriptSrc));
EXPECT_EQ("", url_data_source->GetContentSecurityPolicy(
network::mojom::CSPDirectiveName::StyleSrc));
EXPECT_EQ("", url_data_source->GetContentSecurityPolicy(
network::mojom::CSPDirectiveName::ConnectSrc));
// Override each directive and test it updates the underlying URLDataSource.
source()->OverrideContentSecurityPolicy(
......@@ -303,6 +303,13 @@ TEST_F(WebUIDataSourceTest, SetCspValues) {
url_data_source->GetContentSecurityPolicy(
network::mojom::CSPDirectiveName::ChildSrc));
source()->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::ConnectSrc,
"connect-src 'self' 'unsafe-inline';");
EXPECT_EQ("connect-src 'self' 'unsafe-inline';",
url_data_source->GetContentSecurityPolicy(
network::mojom::CSPDirectiveName::ConnectSrc));
source()->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::DefaultSrc, "default-src 'self';");
EXPECT_EQ("default-src 'self';",
......@@ -346,13 +353,6 @@ TEST_F(WebUIDataSourceTest, SetCspValues) {
EXPECT_EQ("style-src 'self' 'unsafe-inline';",
url_data_source->GetContentSecurityPolicy(
network::mojom::CSPDirectiveName::StyleSrc));
source()->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::ConnectSrc,
"connect-src 'self' 'unsafe-inline';");
EXPECT_EQ("connect-src 'self' 'unsafe-inline';",
url_data_source->GetContentSecurityPolicy(
network::mojom::CSPDirectiveName::ConnectSrc));
}
} // namespace content
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