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

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

Issue 20593003: Move kEnableExperimentalExtensionApis switch to extensions/common/switches.cc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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/chrome_switches.h"
11 #include "chrome/common/extensions/background_info.h" 10 #include "chrome/common/extensions/background_info.h"
12 #include "chrome/common/extensions/extension.h" 11 #include "chrome/common/extensions/extension.h"
13 #include "chrome/common/extensions/extension_manifest_constants.h" 12 #include "chrome/common/extensions/extension_manifest_constants.h"
14 #include "chrome/common/extensions/features/base_feature_provider.h" 13 #include "chrome/common/extensions/features/base_feature_provider.h"
15 #include "chrome/common/extensions/features/feature.h" 14 #include "chrome/common/extensions/features/feature.h"
16 #include "extensions/common/constants.h" 15 #include "extensions/common/constants.h"
17 #include "extensions/common/error_utils.h" 16 #include "extensions/common/error_utils.h"
18 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
19 18
20 namespace errors = extension_manifest_errors; 19 namespace errors = extension_manifest_errors;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 extension = LoadAndExpectSuccess("background_allow_no_js_access.json"); 82 extension = LoadAndExpectSuccess("background_allow_no_js_access.json");
84 ASSERT_TRUE(extension.get()); 83 ASSERT_TRUE(extension.get());
85 EXPECT_FALSE(BackgroundInfo::AllowJSAccess(extension.get())); 84 EXPECT_FALSE(BackgroundInfo::AllowJSAccess(extension.get()));
86 85
87 extension = LoadAndExpectSuccess("background_allow_no_js_access2.json"); 86 extension = LoadAndExpectSuccess("background_allow_no_js_access2.json");
88 ASSERT_TRUE(extension.get()); 87 ASSERT_TRUE(extension.get());
89 EXPECT_FALSE(BackgroundInfo::AllowJSAccess(extension.get())); 88 EXPECT_FALSE(BackgroundInfo::AllowJSAccess(extension.get()));
90 } 89 }
91 90
92 TEST_F(ExtensionManifestBackgroundTest, BackgroundPageWebRequest) { 91 TEST_F(ExtensionManifestBackgroundTest, BackgroundPageWebRequest) {
93 CommandLine::ForCurrentProcess()->AppendSwitch(
94 switches::kEnableExperimentalExtensionApis);
95 Feature::ScopedCurrentChannel current_channel( 92 Feature::ScopedCurrentChannel current_channel(
96 chrome::VersionInfo::CHANNEL_DEV); 93 chrome::VersionInfo::CHANNEL_DEV);
97 94
98 std::string error; 95 std::string error;
99 scoped_ptr<base::DictionaryValue> manifest( 96 scoped_ptr<base::DictionaryValue> manifest(
100 LoadManifest("background_page.json", &error)); 97 LoadManifest("background_page.json", &error));
101 ASSERT_TRUE(manifest.get()); 98 ASSERT_TRUE(manifest.get());
102 manifest->SetBoolean(keys::kBackgroundPersistent, false); 99 manifest->SetBoolean(keys::kBackgroundPersistent, false);
103 manifest->SetInteger(keys::kManifestVersion, 2); 100 manifest->SetInteger(keys::kManifestVersion, 2);
104 scoped_refptr<Extension> extension( 101 scoped_refptr<Extension> extension(
105 LoadAndExpectSuccess(Manifest(manifest.get(), ""))); 102 LoadAndExpectSuccess(Manifest(manifest.get(), "")));
106 ASSERT_TRUE(extension.get()); 103 ASSERT_TRUE(extension.get());
107 EXPECT_TRUE(BackgroundInfo::HasLazyBackgroundPage(extension.get())); 104 EXPECT_TRUE(BackgroundInfo::HasLazyBackgroundPage(extension.get()));
108 105
109 base::ListValue* permissions = new base::ListValue(); 106 base::ListValue* permissions = new base::ListValue();
110 permissions->Append(new base::StringValue("webRequest")); 107 permissions->Append(new base::StringValue("webRequest"));
111 manifest->Set(keys::kPermissions, permissions); 108 manifest->Set(keys::kPermissions, permissions);
112 LoadAndExpectError(Manifest(manifest.get(), ""), 109 LoadAndExpectError(Manifest(manifest.get(), ""),
113 errors::kWebRequestConflictsWithLazyBackground); 110 errors::kWebRequestConflictsWithLazyBackground);
114 } 111 }
115 112
116 } // namespace extensions 113 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698