Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(511)

Side by Side Diff: chrome/common/extensions/manifest_tests/extension_manifests_background_unittest.cc

Issue 10217017: Allow features to refer to subkeys in _manifest_features.json. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix theme test Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/common/extensions/manifest_tests/extension_manifest_test.h" 5 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/common/extensions/extension.h" 9 #include "chrome/common/extensions/extension.h"
10 #include "chrome/common/extensions/extension_error_utils.h" 10 #include "chrome/common/extensions/extension_error_utils.h"
11 #include "chrome/common/extensions/extension_manifest_constants.h" 11 #include "chrome/common/extensions/extension_manifest_constants.h"
12 #include "chrome/common/extensions/simple_feature_provider.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 namespace errors = extension_manifest_errors; 15 namespace errors = extension_manifest_errors;
15 16
17 namespace extensions {
18
16 TEST_F(ExtensionManifestTest, BackgroundPermission) { 19 TEST_F(ExtensionManifestTest, BackgroundPermission) {
17 LoadAndExpectError("background_permission.json", 20 LoadAndExpectError("background_permission.json",
18 errors::kBackgroundPermissionNeeded); 21 errors::kBackgroundPermissionNeeded);
19 22
20 scoped_refptr<Extension> extension; 23 scoped_refptr<Extension> extension;
21 extension = LoadAndExpectSuccess("background_permission_alias.json"); 24 extension = LoadAndExpectSuccess("background_permission_alias.json");
22 EXPECT_TRUE(extension->HasAPIPermission(ExtensionAPIPermission::kBackground)); 25 EXPECT_TRUE(extension->HasAPIPermission(ExtensionAPIPermission::kBackground));
23 } 26 }
24 27
25 TEST_F(ExtensionManifestTest, BackgroundScripts) { 28 TEST_F(ExtensionManifestTest, BackgroundScripts) {
(...skipping 28 matching lines...) Expand all
54 57
55 std::string error; 58 std::string error;
56 scoped_ptr<DictionaryValue> manifest( 59 scoped_ptr<DictionaryValue> manifest(
57 LoadManifestFile("background_page_legacy.json", &error)); 60 LoadManifestFile("background_page_legacy.json", &error));
58 ASSERT_TRUE(manifest.get()); 61 ASSERT_TRUE(manifest.get());
59 extension = LoadAndExpectSuccess(Manifest(manifest.get(), "")); 62 extension = LoadAndExpectSuccess(Manifest(manifest.get(), ""));
60 ASSERT_TRUE(extension); 63 ASSERT_TRUE(extension);
61 EXPECT_EQ("/foo.html", extension->GetBackgroundURL().path()); 64 EXPECT_EQ("/foo.html", extension->GetBackgroundURL().path());
62 65
63 manifest->SetInteger(keys::kManifestVersion, 2); 66 manifest->SetInteger(keys::kManifestVersion, 2);
64 LoadAndExpectError( 67 Feature* feature = SimpleFeatureProvider::GetManifestFeatures()->
65 Manifest(manifest.get(), ""), 68 GetFeature("background_page");
66 ExtensionErrorUtils::FormatErrorMessage( 69 extension = LoadAndExpectSuccess(Manifest(manifest.get(), ""));
67 errors::kFeatureNotAllowed, "background_page"), 70 ASSERT_TRUE(extension);
68 Extension::INTERNAL, Extension::STRICT_ERROR_CHECKS); 71 ASSERT_EQ(1u, extension->install_warnings().size());
72 EXPECT_EQ(feature->GetErrorMessage(Feature::INVALID_MAX_MANIFEST_VERSION),
73 extension->install_warnings()[0]);
69 } 74 }
70 75
71 TEST_F(ExtensionManifestTest, BackgroundAllowNoJsAccess) { 76 TEST_F(ExtensionManifestTest, BackgroundAllowNoJsAccess) {
72 scoped_refptr<Extension> extension; 77 scoped_refptr<Extension> extension;
73 extension = LoadAndExpectSuccess("background_allow_no_js_access.json"); 78 extension = LoadAndExpectSuccess("background_allow_no_js_access.json");
74 ASSERT_TRUE(extension); 79 ASSERT_TRUE(extension);
75 EXPECT_FALSE(extension->allow_background_js_access()); 80 EXPECT_FALSE(extension->allow_background_js_access());
76 81
77 extension = LoadAndExpectSuccess("background_allow_no_js_access2.json"); 82 extension = LoadAndExpectSuccess("background_allow_no_js_access2.json");
78 ASSERT_TRUE(extension); 83 ASSERT_TRUE(extension);
79 EXPECT_FALSE(extension->allow_background_js_access()); 84 EXPECT_FALSE(extension->allow_background_js_access());
80 } 85 }
86
87 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698