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

Side by Side Diff: chrome/browser/extensions/api/permissions/permissions_apitest.cc

Issue 2820333003: Revert of Communicate ExtensionSettings policy to renderers (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/extensions/content_script_apitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/browser/extensions/api/permissions/permissions_api.h" 5 #include "chrome/browser/extensions/api/permissions/permissions_api.h"
6 #include "chrome/browser/extensions/extension_apitest.h" 6 #include "chrome/browser/extensions/extension_apitest.h"
7 #include "chrome/browser/extensions/extension_management_test_util.h" 7 #include "chrome/browser/extensions/extension_management_test_util.h"
8 #include "chrome/browser/extensions/extension_with_management_policy_apitest.h"
9 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
11 #include "components/policy/core/browser/browser_policy_connector.h" 10 #include "components/policy/core/browser/browser_policy_connector.h"
12 #include "components/policy/core/common/mock_configuration_policy_provider.h" 11 #include "components/policy/core/common/mock_configuration_policy_provider.h"
13 #include "extensions/browser/extension_prefs.h" 12 #include "extensions/browser/extension_prefs.h"
14 #include "extensions/common/permissions/permission_set.h" 13 #include "extensions/common/permissions/permission_set.h"
15 #include "extensions/common/switches.h" 14 #include "extensions/common/switches.h"
16 #include "net/dns/mock_host_resolver.h" 15 #include "net/dns/mock_host_resolver.h"
17 16
18 namespace extensions { 17 namespace extensions {
19 18
20 namespace { 19 namespace {
21 20
22 static void AddPattern(URLPatternSet* extent, const std::string& pattern) { 21 static void AddPattern(URLPatternSet* extent, const std::string& pattern) {
23 int schemes = URLPattern::SCHEME_ALL; 22 int schemes = URLPattern::SCHEME_ALL;
24 extent->AddPattern(URLPattern(schemes, pattern)); 23 extent->AddPattern(URLPattern(schemes, pattern));
25 } 24 }
26 25
27 } // namespace 26 } // namespace
28 27
29 class ExperimentalApiTest : public ExtensionApiTest { 28 class ExperimentalApiTest : public ExtensionApiTest {
30 public: 29 public:
31 void SetUpCommandLine(base::CommandLine* command_line) override { 30 void SetUpCommandLine(base::CommandLine* command_line) override {
32 ExtensionApiTest::SetUpCommandLine(command_line); 31 ExtensionApiTest::SetUpCommandLine(command_line);
33 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); 32 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
34 } 33 }
35 }; 34 };
36 35
36 class ExtensionApiTestWithManagementPolicy : public ExtensionApiTest {
37 public:
38 void SetUpInProcessBrowserTestFixture() override {
39 ExtensionApiTest::SetUpInProcessBrowserTestFixture();
40 EXPECT_CALL(policy_provider_, IsInitializationComplete(testing::_))
41 .WillRepeatedly(testing::Return(true));
42 policy_provider_.SetAutoRefresh();
43 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(
44 &policy_provider_);
45 }
46
47 protected:
48 policy::MockConfigurationPolicyProvider policy_provider_;
49 };
50
37 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PermissionsFail) { 51 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PermissionsFail) {
38 ASSERT_TRUE(RunExtensionTest("permissions/disabled")) << message_; 52 ASSERT_TRUE(RunExtensionTest("permissions/disabled")) << message_;
39 53
40 // Since the experimental APIs require a flag, this will fail even though 54 // Since the experimental APIs require a flag, this will fail even though
41 // it's enabled. 55 // it's enabled.
42 // TODO(erikkay) This test is currently broken because LoadExtension in 56 // TODO(erikkay) This test is currently broken because LoadExtension in
43 // ExtensionBrowserTest doesn't actually fail, it just times out. To fix this 57 // ExtensionBrowserTest doesn't actually fail, it just times out. To fix this
44 // I'll need to add an EXTENSION_LOAD_ERROR notification, which is probably 58 // I'll need to add an EXTENSION_LOAD_ERROR notification, which is probably
45 // too much for the branch. I'll enable this on trunk later. 59 // too much for the branch. I'll enable this on trunk later.
46 // ASSERT_FALSE(RunExtensionTest("permissions/enabled"))) << message_; 60 // ASSERT_FALSE(RunExtensionTest("permissions/enabled"))) << message_;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // Tests that requesting an optional permission from a background page, with 195 // Tests that requesting an optional permission from a background page, with
182 // another window open, grants the permission and updates the bindings 196 // another window open, grants the permission and updates the bindings
183 // (chrome.whatever, in this case chrome.alarms). Regression test for 197 // (chrome.whatever, in this case chrome.alarms). Regression test for
184 // crbug.com/435141, see details there for trickiness. 198 // crbug.com/435141, see details there for trickiness.
185 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsUpdatesBindings) { 199 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsUpdatesBindings) {
186 ASSERT_TRUE(RunExtensionTest("permissions/optional_updates_bindings")) 200 ASSERT_TRUE(RunExtensionTest("permissions/optional_updates_bindings"))
187 << message_; 201 << message_;
188 } 202 }
189 203
190 } // namespace extensions 204 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/content_script_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698