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

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

Issue 22299009: Move channel-related (Chrome-specific) global state out of Feature. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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/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/extensions/background_info.h" 10 #include "chrome/common/extensions/background_info.h"
11 #include "chrome/common/extensions/extension.h" 11 #include "chrome/common/extensions/extension.h"
12 #include "chrome/common/extensions/extension_manifest_constants.h" 12 #include "chrome/common/extensions/extension_manifest_constants.h"
13 #include "chrome/common/extensions/features/base_feature_provider.h" 13 #include "chrome/common/extensions/features/feature_channel.h"
14 #include "chrome/common/extensions/features/feature.h"
15 #include "extensions/common/constants.h" 14 #include "extensions/common/constants.h"
16 #include "extensions/common/error_utils.h" 15 #include "extensions/common/error_utils.h"
17 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
18 17
19 namespace errors = extension_manifest_errors; 18 namespace errors = extension_manifest_errors;
20 namespace keys = extension_manifest_keys; 19 namespace keys = extension_manifest_keys;
21 20
22 namespace extensions { 21 namespace extensions {
23 22
24 class ExtensionManifestBackgroundTest : public ExtensionManifestTest { 23 class ExtensionManifestBackgroundTest : public ExtensionManifestTest {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 extension = LoadAndExpectSuccess("background_allow_no_js_access.json"); 81 extension = LoadAndExpectSuccess("background_allow_no_js_access.json");
83 ASSERT_TRUE(extension.get()); 82 ASSERT_TRUE(extension.get());
84 EXPECT_FALSE(BackgroundInfo::AllowJSAccess(extension.get())); 83 EXPECT_FALSE(BackgroundInfo::AllowJSAccess(extension.get()));
85 84
86 extension = LoadAndExpectSuccess("background_allow_no_js_access2.json"); 85 extension = LoadAndExpectSuccess("background_allow_no_js_access2.json");
87 ASSERT_TRUE(extension.get()); 86 ASSERT_TRUE(extension.get());
88 EXPECT_FALSE(BackgroundInfo::AllowJSAccess(extension.get())); 87 EXPECT_FALSE(BackgroundInfo::AllowJSAccess(extension.get()));
89 } 88 }
90 89
91 TEST_F(ExtensionManifestBackgroundTest, BackgroundPageWebRequest) { 90 TEST_F(ExtensionManifestBackgroundTest, BackgroundPageWebRequest) {
92 Feature::ScopedCurrentChannel current_channel( 91 ScopedCurrentChannel current_channel(chrome::VersionInfo::CHANNEL_DEV);
93 chrome::VersionInfo::CHANNEL_DEV);
94 92
95 std::string error; 93 std::string error;
96 scoped_ptr<base::DictionaryValue> manifest( 94 scoped_ptr<base::DictionaryValue> manifest(
97 LoadManifest("background_page.json", &error)); 95 LoadManifest("background_page.json", &error));
98 ASSERT_TRUE(manifest.get()); 96 ASSERT_TRUE(manifest.get());
99 manifest->SetBoolean(keys::kBackgroundPersistent, false); 97 manifest->SetBoolean(keys::kBackgroundPersistent, false);
100 manifest->SetInteger(keys::kManifestVersion, 2); 98 manifest->SetInteger(keys::kManifestVersion, 2);
101 scoped_refptr<Extension> extension( 99 scoped_refptr<Extension> extension(
102 LoadAndExpectSuccess(Manifest(manifest.get(), ""))); 100 LoadAndExpectSuccess(Manifest(manifest.get(), "")));
103 ASSERT_TRUE(extension.get()); 101 ASSERT_TRUE(extension.get());
104 EXPECT_TRUE(BackgroundInfo::HasLazyBackgroundPage(extension.get())); 102 EXPECT_TRUE(BackgroundInfo::HasLazyBackgroundPage(extension.get()));
105 103
106 base::ListValue* permissions = new base::ListValue(); 104 base::ListValue* permissions = new base::ListValue();
107 permissions->Append(new base::StringValue("webRequest")); 105 permissions->Append(new base::StringValue("webRequest"));
108 manifest->Set(keys::kPermissions, permissions); 106 manifest->Set(keys::kPermissions, permissions);
109 LoadAndExpectError(Manifest(manifest.get(), ""), 107 LoadAndExpectError(Manifest(manifest.get(), ""),
110 errors::kWebRequestConflictsWithLazyBackground); 108 errors::kWebRequestConflictsWithLazyBackground);
111 } 109 }
112 110
113 } // namespace extensions 111 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698