| 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/background_info.h" | 9 #include "chrome/common/extensions/background_info.h" |
| 10 #include "chrome/common/extensions/csp_handler.h" | 10 #include "chrome/common/extensions/csp_handler.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 std::string test_id = "ahplfneplbnjcflhdgkkjeiglkkfeelb"; | 91 std::string test_id = "ahplfneplbnjcflhdgkkjeiglkkfeelb"; |
| 92 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 92 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 93 switches::kWhitelistedExtensionID, test_id); | 93 switches::kWhitelistedExtensionID, test_id); |
| 94 scoped_refptr<Extension> extension = | 94 scoped_refptr<Extension> extension = |
| 95 LoadAndExpectSuccess("init_platform_app_csp.json"); | 95 LoadAndExpectSuccess("init_platform_app_csp.json"); |
| 96 EXPECT_EQ(0U, extension->install_warnings().size()) | 96 EXPECT_EQ(0U, extension->install_warnings().size()) |
| 97 << "Unexpected warning " << extension->install_warnings()[0].message; | 97 << "Unexpected warning " << extension->install_warnings()[0].message; |
| 98 EXPECT_TRUE(extension->is_platform_app()); | 98 EXPECT_TRUE(extension->is_platform_app()); |
| 99 EXPECT_EQ( | 99 EXPECT_EQ( |
| 100 "default-src 'self' https://www.google.com", | 100 "default-src 'self' https://www.google.com", |
| 101 CSPInfo::GetResourceContentSecurityPolicy(extension, "")); | 101 CSPInfo::GetResourceContentSecurityPolicy(extension, std::string())); |
| 102 | 102 |
| 103 // But even whitelisted ones must specify a secure policy. | 103 // But even whitelisted ones must specify a secure policy. |
| 104 LoadAndExpectError( | 104 LoadAndExpectError( |
| 105 "init_platform_app_csp_insecure.json", | 105 "init_platform_app_csp_insecure.json", |
| 106 errors::kInsecureContentSecurityPolicy); | 106 errors::kInsecureContentSecurityPolicy); |
| 107 } | 107 } |
| 108 | 108 |
| 109 TEST_F(PlatformAppsManifestTest, CertainApisRequirePlatformApps) { | 109 TEST_F(PlatformAppsManifestTest, CertainApisRequirePlatformApps) { |
| 110 // Put APIs here that should be restricted to platform apps, but that haven't | 110 // Put APIs here that should be restricted to platform apps, but that haven't |
| 111 // yet graduated from experimental. | 111 // yet graduated from experimental. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 // Now try again with the experimental flag set. | 145 // Now try again with the experimental flag set. |
| 146 CommandLine::ForCurrentProcess()->AppendSwitch( | 146 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 147 switches::kEnableExperimentalExtensionApis); | 147 switches::kEnableExperimentalExtensionApis); |
| 148 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { | 148 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { |
| 149 LoadAndExpectSuccess(Manifest(manifests[i].get(), "")); | 149 LoadAndExpectSuccess(Manifest(manifests[i].get(), "")); |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 | 152 |
| 153 } // namespace extensions | 153 } // namespace extensions |
| OLD | NEW |