| 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 "extensions/common/manifest.h" | 5 #include "extensions/common/manifest.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 EXPECT_TRUE(manifest->GetString(keys::kBackgroundPageLegacy, &value)); | 85 EXPECT_TRUE(manifest->GetString(keys::kBackgroundPageLegacy, &value)); |
| 86 EXPECT_EQ("bg.html", value); | 86 EXPECT_EQ("bg.html", value); |
| 87 | 87 |
| 88 // The unknown key 'unknown_key' should be accesible. | 88 // The unknown key 'unknown_key' should be accesible. |
| 89 value.clear(); | 89 value.clear(); |
| 90 EXPECT_TRUE(manifest->GetString("unknown_key", &value)); | 90 EXPECT_TRUE(manifest->GetString("unknown_key", &value)); |
| 91 EXPECT_EQ("foo", value); | 91 EXPECT_EQ("foo", value); |
| 92 | 92 |
| 93 // Set the manifest_version to 2; background_page should stop working. | 93 // Set the manifest_version to 2; background_page should stop working. |
| 94 value.clear(); | 94 value.clear(); |
| 95 MutateManifest( | 95 MutateManifest(&manifest, keys::kManifestVersion, new base::Value(2)); |
| 96 &manifest, keys::kManifestVersion, new base::FundamentalValue(2)); | |
| 97 EXPECT_FALSE(manifest->GetString("background_page", &value)); | 96 EXPECT_FALSE(manifest->GetString("background_page", &value)); |
| 98 EXPECT_EQ("", value); | 97 EXPECT_EQ("", value); |
| 99 | 98 |
| 100 // Validate should also give a warning. | 99 // Validate should also give a warning. |
| 101 warnings.clear(); | 100 warnings.clear(); |
| 102 EXPECT_TRUE(manifest->ValidateManifest(&error, &warnings)); | 101 EXPECT_TRUE(manifest->ValidateManifest(&error, &warnings)); |
| 103 EXPECT_TRUE(error.empty()); | 102 EXPECT_TRUE(error.empty()); |
| 104 ASSERT_EQ(2u, warnings.size()); | 103 ASSERT_EQ(2u, warnings.size()); |
| 105 { | 104 { |
| 106 SimpleFeature feature; | 105 SimpleFeature feature; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 EXPECT_TRUE(error.empty()); | 189 EXPECT_TRUE(error.empty()); |
| 191 EXPECT_TRUE(warnings.empty()); | 190 EXPECT_TRUE(warnings.empty()); |
| 192 | 191 |
| 193 // "Commands" requires manifest version 2. | 192 // "Commands" requires manifest version 2. |
| 194 const base::Value* output = NULL; | 193 const base::Value* output = NULL; |
| 195 MutateManifest( | 194 MutateManifest( |
| 196 &manifest, keys::kCommands, new base::DictionaryValue()); | 195 &manifest, keys::kCommands, new base::DictionaryValue()); |
| 197 EXPECT_FALSE(manifest->HasKey(keys::kCommands)); | 196 EXPECT_FALSE(manifest->HasKey(keys::kCommands)); |
| 198 EXPECT_FALSE(manifest->Get(keys::kCommands, &output)); | 197 EXPECT_FALSE(manifest->Get(keys::kCommands, &output)); |
| 199 | 198 |
| 200 MutateManifest( | 199 MutateManifest(&manifest, keys::kManifestVersion, new base::Value(2)); |
| 201 &manifest, keys::kManifestVersion, new base::FundamentalValue(2)); | |
| 202 EXPECT_TRUE(manifest->HasKey(keys::kCommands)); | 200 EXPECT_TRUE(manifest->HasKey(keys::kCommands)); |
| 203 EXPECT_TRUE(manifest->Get(keys::kCommands, &output)); | 201 EXPECT_TRUE(manifest->Get(keys::kCommands, &output)); |
| 204 | 202 |
| 205 MutateManifest( | 203 MutateManifest( |
| 206 &manifest, keys::kPageAction, new base::DictionaryValue()); | 204 &manifest, keys::kPageAction, new base::DictionaryValue()); |
| 207 AssertType(manifest.get(), Manifest::TYPE_EXTENSION); | 205 AssertType(manifest.get(), Manifest::TYPE_EXTENSION); |
| 208 EXPECT_TRUE(manifest->HasKey(keys::kPageAction)); | 206 EXPECT_TRUE(manifest->HasKey(keys::kPageAction)); |
| 209 EXPECT_TRUE(manifest->Get(keys::kPageAction, &output)); | 207 EXPECT_TRUE(manifest->Get(keys::kPageAction, &output)); |
| 210 | 208 |
| 211 // Platform apps cannot have a "page_action" key. | 209 // Platform apps cannot have a "page_action" key. |
| 212 MutateManifest( | 210 MutateManifest( |
| 213 &manifest, keys::kPlatformAppBackground, new base::DictionaryValue()); | 211 &manifest, keys::kPlatformAppBackground, new base::DictionaryValue()); |
| 214 AssertType(manifest.get(), Manifest::TYPE_PLATFORM_APP); | 212 AssertType(manifest.get(), Manifest::TYPE_PLATFORM_APP); |
| 215 EXPECT_FALSE(manifest->HasKey(keys::kPageAction)); | 213 EXPECT_FALSE(manifest->HasKey(keys::kPageAction)); |
| 216 EXPECT_FALSE(manifest->Get(keys::kPageAction, &output)); | 214 EXPECT_FALSE(manifest->Get(keys::kPageAction, &output)); |
| 217 MutateManifest( | 215 MutateManifest( |
| 218 &manifest, keys::kPlatformAppBackground, NULL); | 216 &manifest, keys::kPlatformAppBackground, NULL); |
| 219 | 217 |
| 220 // Platform apps also can't have a "Commands" key. | 218 // Platform apps also can't have a "Commands" key. |
| 221 EXPECT_FALSE(manifest->HasKey(keys::kCommands)); | 219 EXPECT_FALSE(manifest->HasKey(keys::kCommands)); |
| 222 EXPECT_FALSE(manifest->Get(keys::kCommands, &output)); | 220 EXPECT_FALSE(manifest->Get(keys::kCommands, &output)); |
| 223 } | 221 } |
| 224 | 222 |
| 225 } // namespace extensions | 223 } // namespace extensions |
| OLD | NEW |