| 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 <memory> | 5 #include <memory> |
| 6 #include <utility> |
| 6 | 7 |
| 7 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/ptr_util.h" |
| 8 #include "base/values.h" | 10 #include "base/values.h" |
| 9 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h" | 11 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h" |
| 10 #include "components/version_info/version_info.h" | 12 #include "components/version_info/version_info.h" |
| 11 #include "extensions/common/constants.h" | 13 #include "extensions/common/constants.h" |
| 12 #include "extensions/common/error_utils.h" | 14 #include "extensions/common/error_utils.h" |
| 13 #include "extensions/common/extension.h" | 15 #include "extensions/common/extension.h" |
| 14 #include "extensions/common/features/feature_channel.h" | 16 #include "extensions/common/features/feature_channel.h" |
| 15 #include "extensions/common/manifest_constants.h" | 17 #include "extensions/common/manifest_constants.h" |
| 16 #include "extensions/common/manifest_handlers/background_info.h" | 18 #include "extensions/common/manifest_handlers/background_info.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 std::unique_ptr<base::DictionaryValue> manifest( | 97 std::unique_ptr<base::DictionaryValue> manifest( |
| 96 LoadManifest("background_page.json", &error)); | 98 LoadManifest("background_page.json", &error)); |
| 97 ASSERT_TRUE(manifest.get()); | 99 ASSERT_TRUE(manifest.get()); |
| 98 manifest->SetBoolean(keys::kBackgroundPersistent, false); | 100 manifest->SetBoolean(keys::kBackgroundPersistent, false); |
| 99 manifest->SetInteger(keys::kManifestVersion, 2); | 101 manifest->SetInteger(keys::kManifestVersion, 2); |
| 100 scoped_refptr<Extension> extension( | 102 scoped_refptr<Extension> extension( |
| 101 LoadAndExpectSuccess(ManifestData(manifest.get(), ""))); | 103 LoadAndExpectSuccess(ManifestData(manifest.get(), ""))); |
| 102 ASSERT_TRUE(extension.get()); | 104 ASSERT_TRUE(extension.get()); |
| 103 EXPECT_TRUE(BackgroundInfo::HasLazyBackgroundPage(extension.get())); | 105 EXPECT_TRUE(BackgroundInfo::HasLazyBackgroundPage(extension.get())); |
| 104 | 106 |
| 105 base::ListValue* permissions = new base::ListValue(); | 107 auto permissions = base::MakeUnique<base::ListValue>(); |
| 106 permissions->AppendString("webRequest"); | 108 permissions->AppendString("webRequest"); |
| 107 manifest->Set(keys::kPermissions, permissions); | 109 manifest->Set(keys::kPermissions, std::move(permissions)); |
| 108 LoadAndExpectError(ManifestData(manifest.get(), ""), | 110 LoadAndExpectError(ManifestData(manifest.get(), ""), |
| 109 errors::kWebRequestConflictsWithLazyBackground); | 111 errors::kWebRequestConflictsWithLazyBackground); |
| 110 } | 112 } |
| 111 | 113 |
| 112 TEST_F(ExtensionManifestBackgroundTest, BackgroundPagePersistentPlatformApp) { | 114 TEST_F(ExtensionManifestBackgroundTest, BackgroundPagePersistentPlatformApp) { |
| 113 scoped_refptr<Extension> extension = | 115 scoped_refptr<Extension> extension = |
| 114 LoadAndExpectSuccess("background_page_persistent_app.json"); | 116 LoadAndExpectSuccess("background_page_persistent_app.json"); |
| 115 ASSERT_TRUE(extension->is_platform_app()); | 117 ASSERT_TRUE(extension->is_platform_app()); |
| 116 ASSERT_TRUE(BackgroundInfo::HasBackgroundPage(extension.get())); | 118 ASSERT_TRUE(BackgroundInfo::HasBackgroundPage(extension.get())); |
| 117 EXPECT_FALSE(BackgroundInfo::HasPersistentBackgroundPage(extension.get())); | 119 EXPECT_FALSE(BackgroundInfo::HasPersistentBackgroundPage(extension.get())); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 136 std::string error; | 138 std::string error; |
| 137 std::vector<InstallWarning> warnings; | 139 std::vector<InstallWarning> warnings; |
| 138 ManifestHandler::ValidateExtension(extension.get(), &error, &warnings); | 140 ManifestHandler::ValidateExtension(extension.get(), &error, &warnings); |
| 139 // The key 'background.persistent' is not supported for packaged apps. | 141 // The key 'background.persistent' is not supported for packaged apps. |
| 140 EXPECT_EQ(1U, warnings.size()); | 142 EXPECT_EQ(1U, warnings.size()); |
| 141 EXPECT_EQ(errors::kBackgroundPersistentInvalidForPlatformApps, | 143 EXPECT_EQ(errors::kBackgroundPersistentInvalidForPlatformApps, |
| 142 warnings[0].message); | 144 warnings[0].message); |
| 143 } | 145 } |
| 144 | 146 |
| 145 } // namespace extensions | 147 } // namespace extensions |
| OLD | NEW |