Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: extensions/common/csp_validator_unittest.cc

Issue 673183003: Allow *.googleapis.com to be used in CSP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update docs (googleapis.com -> cloudfront.net) Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/common/csp_validator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/common/csp_validator.h" 5 #include "extensions/common/csp_validator.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 7
8 using extensions::csp_validator::ContentSecurityPolicyIsLegal; 8 using extensions::csp_validator::ContentSecurityPolicyIsLegal;
9 using extensions::csp_validator::ContentSecurityPolicyIsSecure; 9 using extensions::csp_validator::ContentSecurityPolicyIsSecure;
10 using extensions::csp_validator::ContentSecurityPolicyIsSandboxed; 10 using extensions::csp_validator::ContentSecurityPolicyIsSandboxed;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 EXPECT_TRUE(ContentSecurityPolicyIsSecure( 155 EXPECT_TRUE(ContentSecurityPolicyIsSecure(
156 "default-src 'self' blob:", Manifest::TYPE_EXTENSION)); 156 "default-src 'self' blob:", Manifest::TYPE_EXTENSION));
157 EXPECT_FALSE(ContentSecurityPolicyIsSecure( 157 EXPECT_FALSE(ContentSecurityPolicyIsSecure(
158 "default-src 'self' blob:http://example.com/XXX", 158 "default-src 'self' blob:http://example.com/XXX",
159 Manifest::TYPE_EXTENSION)); 159 Manifest::TYPE_EXTENSION));
160 EXPECT_TRUE(ContentSecurityPolicyIsSecure( 160 EXPECT_TRUE(ContentSecurityPolicyIsSecure(
161 "default-src 'self' filesystem:", Manifest::TYPE_EXTENSION)); 161 "default-src 'self' filesystem:", Manifest::TYPE_EXTENSION));
162 EXPECT_FALSE(ContentSecurityPolicyIsSecure( 162 EXPECT_FALSE(ContentSecurityPolicyIsSecure(
163 "default-src 'self' filesystem:http://example.com/XXX", 163 "default-src 'self' filesystem:http://example.com/XXX",
164 Manifest::TYPE_EXTENSION)); 164 Manifest::TYPE_EXTENSION));
165
166 EXPECT_TRUE(ContentSecurityPolicyIsSecure(
167 "default-src 'self' https://*.googleapis.com", Manifest::TYPE_EXTENSION));
168 EXPECT_TRUE(ContentSecurityPolicyIsSecure(
169 "default-src 'self' https://x.googleapis.com", Manifest::TYPE_EXTENSION));
165 } 170 }
166 171
167 TEST(ExtensionCSPValidator, IsSandboxed) { 172 TEST(ExtensionCSPValidator, IsSandboxed) {
168 EXPECT_FALSE(ContentSecurityPolicyIsSandboxed(std::string(), 173 EXPECT_FALSE(ContentSecurityPolicyIsSandboxed(std::string(),
169 Manifest::TYPE_EXTENSION)); 174 Manifest::TYPE_EXTENSION));
170 EXPECT_FALSE(ContentSecurityPolicyIsSandboxed("img-src https://google.com", 175 EXPECT_FALSE(ContentSecurityPolicyIsSandboxed("img-src https://google.com",
171 Manifest::TYPE_EXTENSION)); 176 Manifest::TYPE_EXTENSION));
172 177
173 // Sandbox directive is required. 178 // Sandbox directive is required.
174 EXPECT_TRUE(ContentSecurityPolicyIsSandboxed( 179 EXPECT_TRUE(ContentSecurityPolicyIsSandboxed(
(...skipping 15 matching lines...) Expand all
190 "sandbox allow-top-navigation", Manifest::TYPE_EXTENSION)); 195 "sandbox allow-top-navigation", Manifest::TYPE_EXTENSION));
191 EXPECT_FALSE(ContentSecurityPolicyIsSandboxed( 196 EXPECT_FALSE(ContentSecurityPolicyIsSandboxed(
192 "sandbox allow-top-navigation", Manifest::TYPE_PLATFORM_APP)); 197 "sandbox allow-top-navigation", Manifest::TYPE_PLATFORM_APP));
193 198
194 // Popups are OK. 199 // Popups are OK.
195 EXPECT_TRUE(ContentSecurityPolicyIsSandboxed( 200 EXPECT_TRUE(ContentSecurityPolicyIsSandboxed(
196 "sandbox allow-popups", Manifest::TYPE_EXTENSION)); 201 "sandbox allow-popups", Manifest::TYPE_EXTENSION));
197 EXPECT_TRUE(ContentSecurityPolicyIsSandboxed( 202 EXPECT_TRUE(ContentSecurityPolicyIsSandboxed(
198 "sandbox allow-popups", Manifest::TYPE_PLATFORM_APP)); 203 "sandbox allow-popups", Manifest::TYPE_PLATFORM_APP));
199 } 204 }
OLDNEW
« no previous file with comments | « extensions/common/csp_validator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698