Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / common / extensions / manifest_tests / extension_manifests_storage_unittest.cc
blob4e731c8904287d82e26f3eabb20062078ec24489
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
3 // found in the LICENSE file.
5 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
7 #include "extensions/common/manifest_constants.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 namespace keys = extensions::manifest_keys;
12 TEST_F(ChromeManifestTest, StorageAPIManifestVersionAvailability) {
13 base::DictionaryValue base_manifest;
15 base_manifest.SetString(keys::kName, "test");
16 base_manifest.SetString(keys::kVersion, "0.1");
17 base::ListValue* permissions = new base::ListValue();
18 permissions->Append(new base::StringValue("storage"));
19 base_manifest.Set(keys::kPermissions, permissions);
22 std::string kManifestVersionError =
23 "'storage' requires manifest version of at least 2.";
25 // Extension with no manifest version cannot use storage API.
27 ManifestData manifest(&base_manifest, "test");
28 LoadAndExpectWarning(manifest, kManifestVersionError);
31 // Extension with manifest version 1 cannot use storage API.
33 base::DictionaryValue manifest_with_version;
34 manifest_with_version.SetInteger(keys::kManifestVersion, 1);
35 manifest_with_version.MergeDictionary(&base_manifest);
37 ManifestData manifest(&manifest_with_version, "test");
38 LoadAndExpectWarning(manifest, kManifestVersionError);
41 // Extension with manifest version 2 *can* use storage API.
43 base::DictionaryValue manifest_with_version;
44 manifest_with_version.SetInteger(keys::kManifestVersion, 2);
45 manifest_with_version.MergeDictionary(&base_manifest);
47 ManifestData manifest(&manifest_with_version, "test");
48 scoped_refptr<extensions::Extension> extension =
49 LoadAndExpectSuccess(manifest);
50 EXPECT_TRUE(extension->install_warnings().empty());