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