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

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

Issue 9222013: Prevent unnecessary prompts when unpacked extensions use chrome.permissions.request. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 11 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/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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 ASSERT_TRUE(RunExtensionTest("permissions/favicon")) << message_; 58 ASSERT_TRUE(RunExtensionTest("permissions/favicon")) << message_;
59 } 59 }
60 60
61 // Test functions and APIs that are always allowed (even if you ask for no 61 // Test functions and APIs that are always allowed (even if you ask for no
62 // permissions). 62 // permissions).
63 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, AlwaysAllowed) { 63 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, AlwaysAllowed) {
64 ASSERT_TRUE(RunExtensionTest("permissions/always_allowed")) << message_; 64 ASSERT_TRUE(RunExtensionTest("permissions/always_allowed")) << message_;
65 } 65 }
66 66
67 // Tests that the optional permissions API works correctly. 67 // Tests that the optional permissions API works correctly.
68 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGranted) { 68 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGranted) {
Yoyo Zhou 2012/01/24 19:42:23 Does this test exercise the new functionality? It
jstritar 2012/01/25 17:34:18 Yes, because it will only succeed if we've stored
69 // Mark all the tested APIs as granted to bypass the confirmation UI. 69 // Mark all the tested APIs as granted to bypass the confirmation UI.
70 ExtensionAPIPermissionSet apis; 70 ExtensionAPIPermissionSet apis;
71 apis.insert(ExtensionAPIPermission::kTab); 71 apis.insert(ExtensionAPIPermission::kTab);
72 apis.insert(ExtensionAPIPermission::kManagement);
73 URLPatternSet explicit_hosts; 72 URLPatternSet explicit_hosts;
74 AddPattern(&explicit_hosts, "http://a.com/*");
75 AddPattern(&explicit_hosts, "http://*.c.com/*"); 73 AddPattern(&explicit_hosts, "http://*.c.com/*");
76 scoped_refptr<ExtensionPermissionSet> granted_permissions = 74 scoped_refptr<ExtensionPermissionSet> granted_permissions =
77 new ExtensionPermissionSet(apis, explicit_hosts, URLPatternSet()); 75 new ExtensionPermissionSet(apis, explicit_hosts, URLPatternSet());
78 76
79 ExtensionPrefs* prefs = 77 ExtensionPrefs* prefs =
80 browser()->profile()->GetExtensionService()->extension_prefs(); 78 browser()->profile()->GetExtensionService()->extension_prefs();
81 prefs->AddGrantedPermissions("kjmkgkdkpedkejedfhmfcenooemhbpbo", 79 prefs->AddGrantedPermissions("kjmkgkdkpedkejedfhmfcenooemhbpbo",
82 granted_permissions); 80 granted_permissions);
83 81
84 RequestPermissionsFunction::SetIgnoreUserGestureForTests(true); 82 RequestPermissionsFunction::SetIgnoreUserGestureForTests(true);
(...skipping 23 matching lines...) Expand all
108 } 106 }
109 107
110 // Tests that the permissions.request function must be called from within a 108 // Tests that the permissions.request function must be called from within a
111 // user gesture. 109 // user gesture.
112 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGesture) { 110 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGesture) {
113 RequestPermissionsFunction::SetIgnoreUserGestureForTests(false); 111 RequestPermissionsFunction::SetIgnoreUserGestureForTests(false);
114 host_resolver()->AddRule("*.com", "127.0.0.1"); 112 host_resolver()->AddRule("*.com", "127.0.0.1");
115 ASSERT_TRUE(StartTestServer()); 113 ASSERT_TRUE(StartTestServer());
116 EXPECT_TRUE(RunExtensionTest("permissions/optional_gesture")) << message_; 114 EXPECT_TRUE(RunExtensionTest("permissions/optional_gesture")) << message_;
117 } 115 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/crx_installer.cc » ('j') | chrome/common/extensions/extension.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698