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

Side by Side Diff: chrome/common/extensions/manifest_tests/extension_manifests_sandboxed_unittest.cc

Issue 2571123002: Move sandbox manifest unittests from chrome/ to extensions/ (Closed)
Patch Set: rename file Created 4 years 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 | « no previous file | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/macros.h"
6 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
7 #include "extensions/common/manifest_constants.h"
8 #include "extensions/common/manifest_handlers/csp_info.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace extensions {
12
13 namespace errors = manifest_errors;
14
15 class SandboxedPagesManifestTest : public ChromeManifestTest {
16 };
17
18 TEST_F(SandboxedPagesManifestTest, SandboxedPages) {
19 // Sandboxed pages specified, no custom CSP value.
20 scoped_refptr<Extension> extension1(
21 LoadAndExpectSuccess("sandboxed_pages_valid_1.json"));
22
23 // No sandboxed pages.
24 scoped_refptr<Extension> extension2(
25 LoadAndExpectSuccess("sandboxed_pages_valid_2.json"));
26
27 // Sandboxed pages specified with a custom CSP value.
28 scoped_refptr<Extension> extension3(
29 LoadAndExpectSuccess("sandboxed_pages_valid_3.json"));
30
31 // Sandboxed pages specified with wildcard, no custom CSP value.
32 scoped_refptr<Extension> extension4(
33 LoadAndExpectSuccess("sandboxed_pages_valid_4.json"));
34
35 // Sandboxed pages specified with filename wildcard, no custom CSP value.
36 scoped_refptr<Extension> extension5(
37 LoadAndExpectSuccess("sandboxed_pages_valid_5.json"));
38
39 const char kSandboxedCSP[] =
40 "sandbox allow-scripts allow-forms allow-popups allow-modals";
41 const char kDefaultCSP[] =
42 "script-src 'self' blob: filesystem: chrome-extension-resource:; "
43 "object-src 'self' blob: filesystem:;";
44 const char kCustomSandboxedCSP[] =
45 "sandbox; script-src: https://www.google.com";
46
47 EXPECT_EQ(
48 kSandboxedCSP,
49 CSPInfo::GetResourceContentSecurityPolicy(extension1.get(), "/test"));
50 EXPECT_EQ(
51 kDefaultCSP,
52 CSPInfo::GetResourceContentSecurityPolicy(extension1.get(), "/none"));
53 EXPECT_EQ(
54 kDefaultCSP,
55 CSPInfo::GetResourceContentSecurityPolicy(extension2.get(), "/test"));
56 EXPECT_EQ(
57 kCustomSandboxedCSP,
58 CSPInfo::GetResourceContentSecurityPolicy(extension3.get(), "/test"));
59 EXPECT_EQ(
60 kDefaultCSP,
61 CSPInfo::GetResourceContentSecurityPolicy(extension3.get(), "/none"));
62 EXPECT_EQ(
63 kSandboxedCSP,
64 CSPInfo::GetResourceContentSecurityPolicy(extension4.get(), "/test"));
65 EXPECT_EQ(kSandboxedCSP,
66 CSPInfo::GetResourceContentSecurityPolicy(extension5.get(),
67 "/path/test.ext"));
68 EXPECT_EQ(
69 kDefaultCSP,
70 CSPInfo::GetResourceContentSecurityPolicy(extension5.get(), "/test"));
71
72 Testcase testcases[] = {
73 Testcase("sandboxed_pages_invalid_1.json",
74 errors::kInvalidSandboxedPagesList),
75 Testcase("sandboxed_pages_invalid_2.json",
76 errors::kInvalidSandboxedPage),
77 Testcase("sandboxed_pages_invalid_3.json",
78 errors::kInvalidSandboxedPagesCSP),
79 Testcase("sandboxed_pages_invalid_4.json",
80 errors::kInvalidSandboxedPagesCSP),
81 Testcase("sandboxed_pages_invalid_5.json",
82 errors::kInvalidSandboxedPagesCSP)
83 };
84 RunTestcases(testcases, arraysize(testcases),
85 EXPECT_TYPE_ERROR);
86 }
87
88 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698