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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/common/extensions/extension.h" | 11 #include "chrome/common/extensions/extension.h" |
12 #include "chrome/common/extensions/extension_error_utils.h" | 12 #include "chrome/common/extensions/extension_error_utils.h" |
13 #include "chrome/common/extensions/extension_manifest_constants.h" | 13 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 14 #include "chrome/common/extensions/features/feature.h" |
14 #include "chrome/common/extensions/features/simple_feature_provider.h" | 15 #include "chrome/common/extensions/features/simple_feature_provider.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 | 17 |
17 namespace errors = extension_manifest_errors; | 18 namespace errors = extension_manifest_errors; |
18 | 19 |
19 namespace extensions { | 20 namespace extensions { |
20 | 21 |
21 TEST_F(ExtensionManifestTest, BackgroundPermission) { | 22 TEST_F(ExtensionManifestTest, BackgroundPermission) { |
22 LoadAndExpectError("background_permission.json", | 23 LoadAndExpectError("background_permission.json", |
23 errors::kBackgroundPermissionNeeded); | 24 errors::kBackgroundPermissionNeeded); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 EXPECT_FALSE(extension->allow_background_js_access()); | 82 EXPECT_FALSE(extension->allow_background_js_access()); |
82 | 83 |
83 extension = LoadAndExpectSuccess("background_allow_no_js_access2.json"); | 84 extension = LoadAndExpectSuccess("background_allow_no_js_access2.json"); |
84 ASSERT_TRUE(extension); | 85 ASSERT_TRUE(extension); |
85 EXPECT_FALSE(extension->allow_background_js_access()); | 86 EXPECT_FALSE(extension->allow_background_js_access()); |
86 } | 87 } |
87 | 88 |
88 TEST_F(ExtensionManifestTest, BackgroundPageWebRequest) { | 89 TEST_F(ExtensionManifestTest, BackgroundPageWebRequest) { |
89 CommandLine::ForCurrentProcess()->AppendSwitch( | 90 CommandLine::ForCurrentProcess()->AppendSwitch( |
90 switches::kEnableExperimentalExtensionApis); | 91 switches::kEnableExperimentalExtensionApis); |
| 92 Feature::SetChannelForTesting(chrome::VersionInfo::CHANNEL_UNKNOWN); |
91 | 93 |
92 std::string error; | 94 std::string error; |
93 scoped_ptr<DictionaryValue> manifest( | 95 scoped_ptr<DictionaryValue> manifest( |
94 LoadManifestFile("background_page.json", &error)); | 96 LoadManifestFile("background_page.json", &error)); |
95 ASSERT_TRUE(manifest.get()); | 97 ASSERT_TRUE(manifest.get()); |
96 manifest->SetBoolean(keys::kBackgroundPersistent, false); | 98 manifest->SetBoolean(keys::kBackgroundPersistent, false); |
97 manifest->SetInteger(keys::kManifestVersion, 2); | 99 manifest->SetInteger(keys::kManifestVersion, 2); |
98 scoped_refptr<Extension> extension( | 100 scoped_refptr<Extension> extension( |
99 LoadAndExpectSuccess(Manifest(manifest.get(), ""))); | 101 LoadAndExpectSuccess(Manifest(manifest.get(), ""))); |
100 ASSERT_TRUE(extension); | 102 ASSERT_TRUE(extension); |
101 EXPECT_TRUE(extension->has_lazy_background_page()); | 103 EXPECT_TRUE(extension->has_lazy_background_page()); |
102 | 104 |
103 ListValue* permissions = new ListValue(); | 105 ListValue* permissions = new ListValue(); |
104 permissions->Append(Value::CreateStringValue("webRequest")); | 106 permissions->Append(Value::CreateStringValue("webRequest")); |
105 manifest->Set(keys::kPermissions, permissions); | 107 manifest->Set(keys::kPermissions, permissions); |
106 LoadAndExpectError(Manifest(manifest.get(), ""), | 108 LoadAndExpectError(Manifest(manifest.get(), ""), |
107 errors::kWebRequestConflictsWithLazyBackground); | 109 errors::kWebRequestConflictsWithLazyBackground); |
108 } | 110 } |
109 | 111 |
110 } // namespace extensions | 112 } // namespace extensions |
OLD | NEW |