OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/manifest_constants.h" | 5 #include "extensions/common/manifest_constants.h" |
6 #include "extensions/common/manifest_handlers/csp_info.h" | 6 #include "extensions/common/manifest_handlers/csp_info.h" |
7 #include "extensions/common/manifest_test.h" | 7 #include "extensions/common/manifest_test.h" |
8 | 8 |
9 namespace extensions { | 9 namespace extensions { |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 // Sandboxed pages specified with wildcard, no custom CSP value. | 28 // Sandboxed pages specified with wildcard, no custom CSP value. |
29 scoped_refptr<Extension> extension4( | 29 scoped_refptr<Extension> extension4( |
30 LoadAndExpectSuccess("sandboxed_pages_valid_4.json")); | 30 LoadAndExpectSuccess("sandboxed_pages_valid_4.json")); |
31 | 31 |
32 // Sandboxed pages specified with filename wildcard, no custom CSP value. | 32 // Sandboxed pages specified with filename wildcard, no custom CSP value. |
33 scoped_refptr<Extension> extension5( | 33 scoped_refptr<Extension> extension5( |
34 LoadAndExpectSuccess("sandboxed_pages_valid_5.json")); | 34 LoadAndExpectSuccess("sandboxed_pages_valid_5.json")); |
35 | 35 |
36 const char kSandboxedCSP[] = | 36 const char kSandboxedCSP[] = |
37 "sandbox allow-scripts allow-forms allow-popups allow-modals"; | 37 "sandbox allow-scripts allow-forms allow-popups allow-modals; " |
| 38 "script-src 'self' 'unsafe-inline' 'unsafe-eval'; child-src 'self';"; |
38 const char kDefaultCSP[] = | 39 const char kDefaultCSP[] = |
39 "script-src 'self' blob: filesystem: chrome-extension-resource:; " | 40 "script-src 'self' blob: filesystem: chrome-extension-resource:; " |
40 "object-src 'self' blob: filesystem:;"; | 41 "object-src 'self' blob: filesystem:;"; |
41 const char kCustomSandboxedCSP[] = | 42 const char kCustomSandboxedCSP[] = |
42 "sandbox; script-src: https://www.google.com"; | 43 "sandbox; script-src 'self'; child-src 'self';"; |
43 | 44 |
44 EXPECT_EQ(kSandboxedCSP, CSPInfo::GetResourceContentSecurityPolicy( | 45 EXPECT_EQ(kSandboxedCSP, CSPInfo::GetResourceContentSecurityPolicy( |
45 extension1.get(), "/test")); | 46 extension1.get(), "/test")); |
46 EXPECT_EQ(kDefaultCSP, CSPInfo::GetResourceContentSecurityPolicy( | 47 EXPECT_EQ(kDefaultCSP, CSPInfo::GetResourceContentSecurityPolicy( |
47 extension1.get(), "/none")); | 48 extension1.get(), "/none")); |
48 EXPECT_EQ(kDefaultCSP, CSPInfo::GetResourceContentSecurityPolicy( | 49 EXPECT_EQ(kDefaultCSP, CSPInfo::GetResourceContentSecurityPolicy( |
49 extension2.get(), "/test")); | 50 extension2.get(), "/test")); |
50 EXPECT_EQ(kCustomSandboxedCSP, CSPInfo::GetResourceContentSecurityPolicy( | 51 EXPECT_EQ(kCustomSandboxedCSP, CSPInfo::GetResourceContentSecurityPolicy( |
51 extension3.get(), "/test")); | 52 extension3.get(), "/test")); |
52 EXPECT_EQ(kDefaultCSP, CSPInfo::GetResourceContentSecurityPolicy( | 53 EXPECT_EQ(kDefaultCSP, CSPInfo::GetResourceContentSecurityPolicy( |
(...skipping 12 matching lines...) Expand all Loading... |
65 Testcase("sandboxed_pages_invalid_3.json", | 66 Testcase("sandboxed_pages_invalid_3.json", |
66 errors::kInvalidSandboxedPagesCSP), | 67 errors::kInvalidSandboxedPagesCSP), |
67 Testcase("sandboxed_pages_invalid_4.json", | 68 Testcase("sandboxed_pages_invalid_4.json", |
68 errors::kInvalidSandboxedPagesCSP), | 69 errors::kInvalidSandboxedPagesCSP), |
69 Testcase("sandboxed_pages_invalid_5.json", | 70 Testcase("sandboxed_pages_invalid_5.json", |
70 errors::kInvalidSandboxedPagesCSP)}; | 71 errors::kInvalidSandboxedPagesCSP)}; |
71 RunTestcases(testcases, arraysize(testcases), EXPECT_TYPE_ERROR); | 72 RunTestcases(testcases, arraysize(testcases), EXPECT_TYPE_ERROR); |
72 } | 73 } |
73 | 74 |
74 } // namespace extensions | 75 } // namespace extensions |
OLD | NEW |