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/extensions/manifest_handlers/app_isolation_info.h" | 8 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h" |
9 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h" | 9 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h" |
10 #include "extensions/common/error_utils.h" | 10 #include "extensions/common/error_utils.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // Whitelisted ones can (this is the ID corresponding to the base 64 encoded | 82 // Whitelisted ones can (this is the ID corresponding to the base 64 encoded |
83 // key in the init_platform_app_csp.json manifest.) | 83 // key in the init_platform_app_csp.json manifest.) |
84 std::string test_id = "ahplfneplbnjcflhdgkkjeiglkkfeelb"; | 84 std::string test_id = "ahplfneplbnjcflhdgkkjeiglkkfeelb"; |
85 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 85 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
86 switches::kWhitelistedExtensionID, test_id); | 86 switches::kWhitelistedExtensionID, test_id); |
87 scoped_refptr<Extension> extension = | 87 scoped_refptr<Extension> extension = |
88 LoadAndExpectSuccess("init_platform_app_csp.json"); | 88 LoadAndExpectSuccess("init_platform_app_csp.json"); |
89 EXPECT_EQ(0U, extension->install_warnings().size()) | 89 EXPECT_EQ(0U, extension->install_warnings().size()) |
90 << "Unexpected warning " << extension->install_warnings()[0].message; | 90 << "Unexpected warning " << extension->install_warnings()[0].message; |
91 EXPECT_TRUE(extension->is_platform_app()); | 91 EXPECT_TRUE(extension->is_platform_app()); |
92 EXPECT_EQ("default-src 'self' https://www.google.com", | 92 EXPECT_EQ("default-src 'self' https://www.google.com;", |
93 CSPInfo::GetResourceContentSecurityPolicy(extension.get(), | 93 CSPInfo::GetResourceContentSecurityPolicy(extension.get(), |
94 std::string())); | 94 std::string())); |
95 | 95 |
96 // But even whitelisted ones must specify a secure policy. | 96 // But even whitelisted ones must specify a secure policy. |
97 LoadAndExpectError( | 97 LoadAndExpectWarning( |
98 "init_platform_app_csp_insecure.json", | 98 "init_platform_app_csp_insecure.json", |
99 errors::kInsecureContentSecurityPolicy); | 99 ErrorUtils::FormatErrorMessage(errors::kInvalidCSPInsecureValue, |
| 100 "http://www.google.com", "default-src")); |
100 } | 101 } |
101 | 102 |
102 TEST_F(PlatformAppsManifestTest, CertainApisRequirePlatformApps) { | 103 TEST_F(PlatformAppsManifestTest, CertainApisRequirePlatformApps) { |
103 // Put APIs here that should be restricted to platform apps, but that haven't | 104 // Put APIs here that should be restricted to platform apps, but that haven't |
104 // yet graduated from experimental. | 105 // yet graduated from experimental. |
105 const char* const kPlatformAppExperimentalApis[] = { | 106 const char* const kPlatformAppExperimentalApis[] = { |
106 "dns", | 107 "dns", |
107 "serial", | 108 "serial", |
108 }; | 109 }; |
109 // TODO(miket): When the first platform-app API leaves experimental, write | 110 // TODO(miket): When the first platform-app API leaves experimental, write |
(...skipping 29 matching lines...) Expand all Loading... |
139 | 140 |
140 // Now try again with the experimental flag set. | 141 // Now try again with the experimental flag set. |
141 CommandLine::ForCurrentProcess()->AppendSwitch( | 142 CommandLine::ForCurrentProcess()->AppendSwitch( |
142 switches::kEnableExperimentalExtensionApis); | 143 switches::kEnableExperimentalExtensionApis); |
143 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { | 144 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { |
144 LoadAndExpectSuccess(ManifestData(manifests[i].get(), "")); | 145 LoadAndExpectSuccess(ManifestData(manifests[i].get(), "")); |
145 } | 146 } |
146 } | 147 } |
147 | 148 |
148 } // namespace extensions | 149 } // namespace extensions |
OLD | NEW |