OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/common/extensions/manifest_tests/chrome_manifest_test.h" | 5 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h" |
| 6 #include "extensions/common/error_utils.h" |
6 #include "extensions/common/manifest_constants.h" | 7 #include "extensions/common/manifest_constants.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
8 | 9 |
9 namespace errors = extensions::manifest_errors; | 10 namespace errors = extensions::manifest_errors; |
| 11 using extensions::ErrorUtils; |
10 | 12 |
11 class ContentSecurityPolicyManifestTest : public ChromeManifestTest { | 13 class ContentSecurityPolicyManifestTest : public ChromeManifestTest { |
12 }; | 14 }; |
13 | 15 |
14 TEST_F(ContentSecurityPolicyManifestTest, InsecureContentSecurityPolicy) { | 16 TEST_F(ContentSecurityPolicyManifestTest, InsecureContentSecurityPolicy) { |
15 Testcase testcases[] = { | 17 Testcase testcases[] = { |
16 Testcase("insecure_contentsecuritypolicy_1.json", | 18 Testcase( |
17 errors::kInsecureContentSecurityPolicy), | 19 "insecure_contentsecuritypolicy_1.json", |
18 Testcase("insecure_contentsecuritypolicy_2.json", | 20 ErrorUtils::FormatErrorMessage(errors::kInvalidCSPInsecureValue, |
19 errors::kInsecureContentSecurityPolicy), | 21 "http://example.com", "script-src")), |
20 Testcase("insecure_contentsecuritypolicy_3.json", | 22 Testcase("insecure_contentsecuritypolicy_2.json", |
21 errors::kInsecureContentSecurityPolicy), | 23 ErrorUtils::FormatErrorMessage(errors::kInvalidCSPInsecureValue, |
22 }; | 24 "'unsafe-inline'", "script-src")), |
23 RunTestcases(testcases, arraysize(testcases), EXPECT_TYPE_ERROR); | 25 Testcase("insecure_contentsecuritypolicy_3.json", |
| 26 ErrorUtils::FormatErrorMessage( |
| 27 errors::kInvalidCSPMissingSecureSrc, "object-src"))}; |
| 28 RunTestcases(testcases, arraysize(testcases), EXPECT_TYPE_WARNING); |
24 } | 29 } |
OLD | NEW |