| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 27 matching lines...) Expand all Loading... |
| 137 | 138 |
| 138 // Now try again with the experimental flag set. | 139 // Now try again with the experimental flag set. |
| 139 CommandLine::ForCurrentProcess()->AppendSwitch( | 140 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 140 switches::kEnableExperimentalExtensionApis); | 141 switches::kEnableExperimentalExtensionApis); |
| 141 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { | 142 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { |
| 142 LoadAndExpectSuccess(ManifestData(manifests[i].get(), "")); | 143 LoadAndExpectSuccess(ManifestData(manifests[i].get(), "")); |
| 143 } | 144 } |
| 144 } | 145 } |
| 145 | 146 |
| 146 } // namespace extensions | 147 } // namespace extensions |
| OLD | NEW |