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

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

Issue 51433002: Enable permission warnings from ManifestHandlers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing. Created 7 years, 1 month 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
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_prefs.h" 7 #include "chrome/browser/extensions/extension_prefs.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // Disabled: http://crbug.com/125193 65 // Disabled: http://crbug.com/125193
66 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_AlwaysAllowed) { 66 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_AlwaysAllowed) {
67 ASSERT_TRUE(RunExtensionTest("permissions/always_allowed")) << message_; 67 ASSERT_TRUE(RunExtensionTest("permissions/always_allowed")) << message_;
68 } 68 }
69 69
70 // Tests that the optional permissions API works correctly. 70 // Tests that the optional permissions API works correctly.
71 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGranted) { 71 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGranted) {
72 // Mark all the tested APIs as granted to bypass the confirmation UI. 72 // Mark all the tested APIs as granted to bypass the confirmation UI.
73 APIPermissionSet apis; 73 APIPermissionSet apis;
74 apis.insert(APIPermission::kBookmark); 74 apis.insert(APIPermission::kBookmark);
75 ManifestPermissionSet manifest_permissions;
75 URLPatternSet explicit_hosts; 76 URLPatternSet explicit_hosts;
76 AddPattern(&explicit_hosts, "http://*.c.com/*"); 77 AddPattern(&explicit_hosts, "http://*.c.com/*");
77 scoped_refptr<PermissionSet> granted_permissions = 78 scoped_refptr<PermissionSet> granted_permissions =
78 new PermissionSet(apis, explicit_hosts, URLPatternSet()); 79 new PermissionSet(apis, manifest_permissions,
80 explicit_hosts, URLPatternSet());
79 81
80 ExtensionPrefs* prefs = 82 ExtensionPrefs* prefs =
81 browser()->profile()->GetExtensionService()->extension_prefs(); 83 browser()->profile()->GetExtensionService()->extension_prefs();
82 prefs->AddGrantedPermissions("kjmkgkdkpedkejedfhmfcenooemhbpbo", 84 prefs->AddGrantedPermissions("kjmkgkdkpedkejedfhmfcenooemhbpbo",
83 granted_permissions.get()); 85 granted_permissions.get());
84 86
85 PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); 87 PermissionsRequestFunction::SetIgnoreUserGestureForTests(true);
86 host_resolver()->AddRule("*.com", "127.0.0.1"); 88 host_resolver()->AddRule("*.com", "127.0.0.1");
87 ASSERT_TRUE(StartEmbeddedTestServer()); 89 ASSERT_TRUE(StartEmbeddedTestServer());
88 EXPECT_TRUE(RunExtensionTest("permissions/optional")) << message_; 90 EXPECT_TRUE(RunExtensionTest("permissions/optional")) << message_;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 147
146 // Test requesting, querying, and removing host permissions for host 148 // Test requesting, querying, and removing host permissions for host
147 // permissions that are a subset of the optional permissions. 149 // permissions that are a subset of the optional permissions.
148 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, HostSubsets) { 150 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, HostSubsets) {
149 PermissionsRequestFunction::SetAutoConfirmForTests(true); 151 PermissionsRequestFunction::SetAutoConfirmForTests(true);
150 PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); 152 PermissionsRequestFunction::SetIgnoreUserGestureForTests(true);
151 EXPECT_TRUE(RunExtensionTest("permissions/host_subsets")) << message_; 153 EXPECT_TRUE(RunExtensionTest("permissions/host_subsets")) << message_;
152 } 154 }
153 155
154 } // namespace extensions 156 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698