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

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

Issue 11826048: Revert 176015 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 URLPatternSet explicit_hosts; 78 URLPatternSet explicit_hosts;
79 AddPattern(&explicit_hosts, "http://*.c.com/*"); 79 AddPattern(&explicit_hosts, "http://*.c.com/*");
80 scoped_refptr<PermissionSet> granted_permissions = 80 scoped_refptr<PermissionSet> granted_permissions =
81 new PermissionSet(apis, explicit_hosts, URLPatternSet()); 81 new PermissionSet(apis, explicit_hosts, URLPatternSet());
82 82
83 extensions::ExtensionPrefs* prefs = 83 extensions::ExtensionPrefs* prefs =
84 browser()->profile()->GetExtensionService()->extension_prefs(); 84 browser()->profile()->GetExtensionService()->extension_prefs();
85 prefs->AddGrantedPermissions("kjmkgkdkpedkejedfhmfcenooemhbpbo", 85 prefs->AddGrantedPermissions("kjmkgkdkpedkejedfhmfcenooemhbpbo",
86 granted_permissions); 86 granted_permissions);
87 87
88 PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); 88 RequestPermissionsFunction::SetIgnoreUserGestureForTests(true);
89 host_resolver()->AddRule("*.com", "127.0.0.1"); 89 host_resolver()->AddRule("*.com", "127.0.0.1");
90 ASSERT_TRUE(StartTestServer()); 90 ASSERT_TRUE(StartTestServer());
91 EXPECT_TRUE(RunExtensionTest("permissions/optional")) << message_; 91 EXPECT_TRUE(RunExtensionTest("permissions/optional")) << message_;
92 } 92 }
93 93
94 // Tests that the optional permissions API works correctly. 94 // Tests that the optional permissions API works correctly.
95 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsAutoConfirm) { 95 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsAutoConfirm) {
96 // Rather than setting the granted permissions, set the UI autoconfirm flag 96 // Rather than setting the granted permissions, set the UI autoconfirm flag
97 // and run the same tests. 97 // and run the same tests.
98 PermissionsRequestFunction::SetAutoConfirmForTests(true); 98 RequestPermissionsFunction::SetAutoConfirmForTests(true);
99 PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); 99 RequestPermissionsFunction::SetIgnoreUserGestureForTests(true);
100 host_resolver()->AddRule("*.com", "127.0.0.1"); 100 host_resolver()->AddRule("*.com", "127.0.0.1");
101 ASSERT_TRUE(StartTestServer()); 101 ASSERT_TRUE(StartTestServer());
102 EXPECT_TRUE(RunExtensionTest("permissions/optional")) << message_; 102 EXPECT_TRUE(RunExtensionTest("permissions/optional")) << message_;
103 } 103 }
104 104
105 // Tests that the optional permissions API works correctly with complex 105 // Tests that the optional permissions API works correctly with complex
106 // permissions. 106 // permissions.
107 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ComplexOptionalPermissions) { 107 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ComplexOptionalPermissions) {
108 // Rather than setting the granted permissions, set the UI autoconfirm flag 108 // Rather than setting the granted permissions, set the UI autoconfirm flag
109 // and run the same tests. 109 // and run the same tests.
110 PermissionsRequestFunction::SetAutoConfirmForTests(true); 110 RequestPermissionsFunction::SetAutoConfirmForTests(true);
111 PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); 111 RequestPermissionsFunction::SetIgnoreUserGestureForTests(true);
112 EXPECT_TRUE(RunExtensionTest("permissions/complex_optional")) << message_; 112 EXPECT_TRUE(RunExtensionTest("permissions/complex_optional")) << message_;
113 } 113 }
114 114
115 // Test that denying the optional permissions confirmation dialog works. 115 // Test that denying the optional permissions confirmation dialog works.
116 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsDeny) { 116 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsDeny) {
117 PermissionsRequestFunction::SetAutoConfirmForTests(false); 117 RequestPermissionsFunction::SetAutoConfirmForTests(false);
118 PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); 118 RequestPermissionsFunction::SetIgnoreUserGestureForTests(true);
119 host_resolver()->AddRule("*.com", "127.0.0.1"); 119 host_resolver()->AddRule("*.com", "127.0.0.1");
120 ASSERT_TRUE(StartTestServer()); 120 ASSERT_TRUE(StartTestServer());
121 EXPECT_TRUE(RunExtensionTest("permissions/optional_deny")) << message_; 121 EXPECT_TRUE(RunExtensionTest("permissions/optional_deny")) << message_;
122 } 122 }
123 123
124 // Tests that the permissions.request function must be called from within a 124 // Tests that the permissions.request function must be called from within a
125 // user gesture. 125 // user gesture.
126 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGesture) { 126 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGesture) {
127 PermissionsRequestFunction::SetIgnoreUserGestureForTests(false); 127 RequestPermissionsFunction::SetIgnoreUserGestureForTests(false);
128 host_resolver()->AddRule("*.com", "127.0.0.1"); 128 host_resolver()->AddRule("*.com", "127.0.0.1");
129 ASSERT_TRUE(StartTestServer()); 129 ASSERT_TRUE(StartTestServer());
130 EXPECT_TRUE(RunExtensionTest("permissions/optional_gesture")) << message_; 130 EXPECT_TRUE(RunExtensionTest("permissions/optional_gesture")) << message_;
131 } 131 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/permissions/permissions_api.cc ('k') | chrome/browser/extensions/api/processes/processes_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698