Update CrOS OOBE throbber to MD throbber; delete old asset
[chromium-blink-merge.git] / chrome / common / extensions / manifest_tests / extension_manifests_sandboxed_unittest.cc
blobf0771d428cd90de8f4b08a76b1949a87582c8f1b
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.
5 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
6 #include "extensions/common/manifest_constants.h"
7 #include "extensions/common/manifest_handlers/csp_info.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 namespace extensions {
12 namespace errors = manifest_errors;
14 class SandboxedPagesManifestTest : public ChromeManifestTest {
17 TEST_F(SandboxedPagesManifestTest, SandboxedPages) {
18 // Sandboxed pages specified, no custom CSP value.
19 scoped_refptr<Extension> extension1(
20 LoadAndExpectSuccess("sandboxed_pages_valid_1.json"));
22 // No sandboxed pages.
23 scoped_refptr<Extension> extension2(
24 LoadAndExpectSuccess("sandboxed_pages_valid_2.json"));
26 // Sandboxed pages specified with a custom CSP value.
27 scoped_refptr<Extension> extension3(
28 LoadAndExpectSuccess("sandboxed_pages_valid_3.json"));
30 // Sandboxed pages specified with wildcard, no custom CSP value.
31 scoped_refptr<Extension> extension4(
32 LoadAndExpectSuccess("sandboxed_pages_valid_4.json"));
34 // Sandboxed pages specified with filename wildcard, no custom CSP value.
35 scoped_refptr<Extension> extension5(
36 LoadAndExpectSuccess("sandboxed_pages_valid_5.json"));
38 const char kSandboxedCSP[] = "sandbox allow-scripts allow-forms allow-popups";
39 const char kDefaultCSP[] =
40 "script-src 'self' blob: filesystem: chrome-extension-resource:; "
41 "object-src 'self' blob: filesystem:;";
42 const char kCustomSandboxedCSP[] =
43 "sandbox; script-src: https://www.google.com";
45 EXPECT_EQ(
46 kSandboxedCSP,
47 CSPInfo::GetResourceContentSecurityPolicy(extension1.get(), "/test"));
48 EXPECT_EQ(
49 kDefaultCSP,
50 CSPInfo::GetResourceContentSecurityPolicy(extension1.get(), "/none"));
51 EXPECT_EQ(
52 kDefaultCSP,
53 CSPInfo::GetResourceContentSecurityPolicy(extension2.get(), "/test"));
54 EXPECT_EQ(
55 kCustomSandboxedCSP,
56 CSPInfo::GetResourceContentSecurityPolicy(extension3.get(), "/test"));
57 EXPECT_EQ(
58 kDefaultCSP,
59 CSPInfo::GetResourceContentSecurityPolicy(extension3.get(), "/none"));
60 EXPECT_EQ(
61 kSandboxedCSP,
62 CSPInfo::GetResourceContentSecurityPolicy(extension4.get(), "/test"));
63 EXPECT_EQ(kSandboxedCSP,
64 CSPInfo::GetResourceContentSecurityPolicy(extension5.get(),
65 "/path/test.ext"));
66 EXPECT_EQ(
67 kDefaultCSP,
68 CSPInfo::GetResourceContentSecurityPolicy(extension5.get(), "/test"));
70 Testcase testcases[] = {
71 Testcase("sandboxed_pages_invalid_1.json",
72 errors::kInvalidSandboxedPagesList),
73 Testcase("sandboxed_pages_invalid_2.json",
74 errors::kInvalidSandboxedPage),
75 Testcase("sandboxed_pages_invalid_3.json",
76 errors::kInvalidSandboxedPagesCSP),
77 Testcase("sandboxed_pages_invalid_4.json",
78 errors::kInvalidSandboxedPagesCSP),
79 Testcase("sandboxed_pages_invalid_5.json",
80 errors::kInvalidSandboxedPagesCSP)
82 RunTestcases(testcases, arraysize(testcases),
83 EXPECT_TYPE_ERROR);
86 } // namespace extensions