| 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 "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 Loading... |
| 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); |
| 67 Feature* feature = SimpleFeatureProvider::GetManifestFeatures()-> |
| 68 GetFeature("background_page"); |
| 64 LoadAndExpectError( | 69 LoadAndExpectError( |
| 65 Manifest(manifest.get(), ""), | 70 Manifest(manifest.get(), ""), |
| 66 ExtensionErrorUtils::FormatErrorMessage( | 71 feature->GetErrorMessage(Feature::INVALID_MAX_MANIFEST_VERSION), |
| 67 errors::kFeatureNotAllowed, "background_page"), | |
| 68 Extension::INTERNAL, Extension::STRICT_ERROR_CHECKS); | 72 Extension::INTERNAL, Extension::STRICT_ERROR_CHECKS); |
| 69 } | 73 } |
| 70 | 74 |
| 71 TEST_F(ExtensionManifestTest, BackgroundAllowNoJsAccess) { | 75 TEST_F(ExtensionManifestTest, BackgroundAllowNoJsAccess) { |
| 72 scoped_refptr<Extension> extension; | 76 scoped_refptr<Extension> extension; |
| 73 extension = LoadAndExpectSuccess("background_allow_no_js_access.json"); | 77 extension = LoadAndExpectSuccess("background_allow_no_js_access.json"); |
| 74 ASSERT_TRUE(extension); | 78 ASSERT_TRUE(extension); |
| 75 EXPECT_FALSE(extension->allow_background_js_access()); | 79 EXPECT_FALSE(extension->allow_background_js_access()); |
| 76 | 80 |
| 77 extension = LoadAndExpectSuccess("background_allow_no_js_access2.json"); | 81 extension = LoadAndExpectSuccess("background_allow_no_js_access2.json"); |
| 78 ASSERT_TRUE(extension); | 82 ASSERT_TRUE(extension); |
| 79 EXPECT_FALSE(extension->allow_background_js_access()); | 83 EXPECT_FALSE(extension->allow_background_js_access()); |
| 80 } | 84 } |
| 85 |
| 86 } // namespace extensions |
| OLD | NEW |