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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/json/json_file_value_serializer.h" | 6 #include "base/json/json_file_value_serializer.h" |
7 #include "base/memory/linked_ptr.h" | 7 #include "base/memory/linked_ptr.h" |
8 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
9 #include "chrome/common/extensions/csp_handler.h" | 9 #include "chrome/common/extensions/csp_handler.h" |
10 #include "chrome/common/extensions/extension_manifest_constants.h" | 10 #include "chrome/common/extensions/extension_manifest_constants.h" |
11 #include "chrome/common/extensions/incognito_handler.h" | 11 #include "chrome/common/extensions/incognito_handler.h" |
12 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h" | 12 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h" |
13 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" | 13 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" |
| 14 #include "extensions/common/switches.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 namespace errors = extension_manifest_errors; | 17 namespace errors = extension_manifest_errors; |
17 | 18 |
18 namespace extensions { | 19 namespace extensions { |
19 | 20 |
20 class PlatformAppsManifestTest : public ExtensionManifestTest { | 21 class PlatformAppsManifestTest : public ExtensionManifestTest { |
21 }; | 22 }; |
22 | 23 |
23 TEST_F(PlatformAppsManifestTest, PlatformApps) { | 24 TEST_F(PlatformAppsManifestTest, PlatformApps) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 "'app.content_security_policy' is not allowed for specified extension " | 75 "'app.content_security_policy' is not allowed for specified extension " |
75 "ID.") | 76 "ID.") |
76 }; | 77 }; |
77 RunTestcases( | 78 RunTestcases( |
78 warning_testcases, arraysize(warning_testcases), EXPECT_TYPE_WARNING); | 79 warning_testcases, arraysize(warning_testcases), EXPECT_TYPE_WARNING); |
79 | 80 |
80 // Whitelisted ones can (this is the ID corresponding to the base 64 encoded | 81 // Whitelisted ones can (this is the ID corresponding to the base 64 encoded |
81 // key in the init_platform_app_csp.json manifest.) | 82 // key in the init_platform_app_csp.json manifest.) |
82 std::string test_id = "ahplfneplbnjcflhdgkkjeiglkkfeelb"; | 83 std::string test_id = "ahplfneplbnjcflhdgkkjeiglkkfeelb"; |
83 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 84 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
84 switches::kWhitelistedExtensionID, test_id); | 85 ::switches::kWhitelistedExtensionID, test_id); |
85 scoped_refptr<Extension> extension = | 86 scoped_refptr<Extension> extension = |
86 LoadAndExpectSuccess("init_platform_app_csp.json"); | 87 LoadAndExpectSuccess("init_platform_app_csp.json"); |
87 EXPECT_EQ(0U, extension->install_warnings().size()) | 88 EXPECT_EQ(0U, extension->install_warnings().size()) |
88 << "Unexpected warning " << extension->install_warnings()[0].message; | 89 << "Unexpected warning " << extension->install_warnings()[0].message; |
89 EXPECT_TRUE(extension->is_platform_app()); | 90 EXPECT_TRUE(extension->is_platform_app()); |
90 EXPECT_EQ("default-src 'self' https://www.google.com", | 91 EXPECT_EQ("default-src 'self' https://www.google.com", |
91 CSPInfo::GetResourceContentSecurityPolicy(extension.get(), | 92 CSPInfo::GetResourceContentSecurityPolicy(extension.get(), |
92 std::string())); | 93 std::string())); |
93 | 94 |
94 // But even whitelisted ones must specify a secure policy. | 95 // But even whitelisted ones must specify a secure policy. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 136 |
136 // Now try again with the experimental flag set. | 137 // Now try again with the experimental flag set. |
137 CommandLine::ForCurrentProcess()->AppendSwitch( | 138 CommandLine::ForCurrentProcess()->AppendSwitch( |
138 switches::kEnableExperimentalExtensionApis); | 139 switches::kEnableExperimentalExtensionApis); |
139 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { | 140 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { |
140 LoadAndExpectSuccess(Manifest(manifests[i].get(), "")); | 141 LoadAndExpectSuccess(Manifest(manifests[i].get(), "")); |
141 } | 142 } |
142 } | 143 } |
143 | 144 |
144 } // namespace extensions | 145 } // namespace extensions |
OLD | NEW |