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

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

Issue 227413008: Add the feature to retain the user gesture in the extension callback (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/permissions/optional_retain_gesture/background.js » ('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/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "extensions/browser/extension_prefs.h" 9 #include "extensions/browser/extension_prefs.h"
10 #include "extensions/common/permissions/permission_set.h" 10 #include "extensions/common/permissions/permission_set.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 // Tests that the permissions.request function must be called from within a 111 // Tests that the permissions.request function must be called from within a
112 // user gesture. 112 // user gesture.
113 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGesture) { 113 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGesture) {
114 PermissionsRequestFunction::SetIgnoreUserGestureForTests(false); 114 PermissionsRequestFunction::SetIgnoreUserGestureForTests(false);
115 host_resolver()->AddRule("*.com", "127.0.0.1"); 115 host_resolver()->AddRule("*.com", "127.0.0.1");
116 ASSERT_TRUE(StartEmbeddedTestServer()); 116 ASSERT_TRUE(StartEmbeddedTestServer());
117 EXPECT_TRUE(RunExtensionTest("permissions/optional_gesture")) << message_; 117 EXPECT_TRUE(RunExtensionTest("permissions/optional_gesture")) << message_;
118 } 118 }
119 119
120 // Tests that the user gesture is retained in the permissions.request function
121 // callback.
122 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsRetainGesture) {
123 PermissionsRequestFunction::SetAutoConfirmForTests(true);
124 PermissionsRequestFunction::SetIgnoreUserGestureForTests(false);
125 host_resolver()->AddRule("*.com", "127.0.0.1");
126 ASSERT_TRUE(StartEmbeddedTestServer());
127 EXPECT_TRUE(RunExtensionTest("permissions/optional_retain_gesture"))
128 << message_;
129 }
130
120 // Tests that an extension can't gain access to file: URLs without the checkbox 131 // Tests that an extension can't gain access to file: URLs without the checkbox
121 // entry in prefs. There shouldn't be a warning either. 132 // entry in prefs. There shouldn't be a warning either.
122 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsFileAccess) { 133 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsFileAccess) {
123 // There shouldn't be a warning, so we shouldn't need to autoconfirm. 134 // There shouldn't be a warning, so we shouldn't need to autoconfirm.
124 PermissionsRequestFunction::SetAutoConfirmForTests(false); 135 PermissionsRequestFunction::SetAutoConfirmForTests(false);
125 PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); 136 PermissionsRequestFunction::SetIgnoreUserGestureForTests(true);
126 137
127 ExtensionPrefs* prefs = ExtensionPrefs::Get(browser()->profile()); 138 ExtensionPrefs* prefs = ExtensionPrefs::Get(browser()->profile());
128 139
129 EXPECT_TRUE( 140 EXPECT_TRUE(
(...skipping 14 matching lines...) Expand all
144 155
145 // Test requesting, querying, and removing host permissions for host 156 // Test requesting, querying, and removing host permissions for host
146 // permissions that are a subset of the optional permissions. 157 // permissions that are a subset of the optional permissions.
147 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, HostSubsets) { 158 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, HostSubsets) {
148 PermissionsRequestFunction::SetAutoConfirmForTests(true); 159 PermissionsRequestFunction::SetAutoConfirmForTests(true);
149 PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); 160 PermissionsRequestFunction::SetIgnoreUserGestureForTests(true);
150 EXPECT_TRUE(RunExtensionTest("permissions/host_subsets")) << message_; 161 EXPECT_TRUE(RunExtensionTest("permissions/host_subsets")) << message_;
151 } 162 }
152 163
153 } // namespace extensions 164 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/permissions/optional_retain_gesture/background.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698