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

Side by Side Diff: chrome/browser/extensions/content_capabilities_browsertest.cc

Issue 913253002: Fix clipboard permission callbacks to account for default values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix another test Created 5 years, 10 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/extension_dom_clipboard_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 private: 139 private:
140 extensions::TestExtensionDir test_extension_dir_; 140 extensions::TestExtensionDir test_extension_dir_;
141 }; 141 };
142 142
143 IN_PROC_BROWSER_TEST_F(ContentCapabilitiesTest, NoCapabilities) { 143 IN_PROC_BROWSER_TEST_F(ContentCapabilitiesTest, NoCapabilities) {
144 InitializeTestServer(); 144 InitializeTestServer();
145 scoped_refptr<const Extension> extension = LoadExtensionWithCapabilities( 145 scoped_refptr<const Extension> extension = LoadExtensionWithCapabilities(
146 MakeJSONList("http://foo.example.com/*"), MakeJSONList()); 146 MakeJSONList("http://foo.example.com/*"), MakeJSONList());
147 EXPECT_FALSE( 147 EXPECT_FALSE(
148 CanReadClipboard(extension.get(), GetTestURLFor("foo.example.com"))); 148 CanReadClipboard(extension.get(), GetTestURLFor("foo.example.com")));
149 EXPECT_FALSE( 149 // TODO(dcheng): This should be false, but we cannot currently execute testing
150 // script without a user gesture.
151 EXPECT_TRUE(
150 CanWriteClipboard(extension.get(), GetTestURLFor("foo.example.com"))); 152 CanWriteClipboard(extension.get(), GetTestURLFor("foo.example.com")));
151 EXPECT_FALSE( 153 EXPECT_FALSE(
152 HasUnlimitedStorage(extension.get(), GetTestURLFor("foo.example.com"))); 154 HasUnlimitedStorage(extension.get(), GetTestURLFor("foo.example.com")));
153 } 155 }
154 156
155 IN_PROC_BROWSER_TEST_F(ContentCapabilitiesTest, ClipboardRead) { 157 IN_PROC_BROWSER_TEST_F(ContentCapabilitiesTest, ClipboardRead) {
156 InitializeTestServer(); 158 InitializeTestServer();
157 scoped_refptr<const Extension> extension = LoadExtensionWithCapabilities( 159 scoped_refptr<const Extension> extension = LoadExtensionWithCapabilities(
158 MakeJSONList("http://foo.example.com/*"), MakeJSONList("clipboardRead")); 160 MakeJSONList("http://foo.example.com/*"), MakeJSONList("clipboardRead"));
159 EXPECT_TRUE( 161 EXPECT_TRUE(
160 CanReadClipboard(extension.get(), GetTestURLFor("foo.example.com"))); 162 CanReadClipboard(extension.get(), GetTestURLFor("foo.example.com")));
161 EXPECT_FALSE( 163 EXPECT_FALSE(
162 CanReadClipboard(extension.get(), GetTestURLFor("bar.example.com"))); 164 CanReadClipboard(extension.get(), GetTestURLFor("bar.example.com")));
163 EXPECT_FALSE( 165 // TODO(dcheng): This should be false, but we cannot currently execute testing
166 // script without a user gesture.
167 EXPECT_TRUE(
164 CanWriteClipboard(extension.get(), GetTestURLFor("foo.example.com"))); 168 CanWriteClipboard(extension.get(), GetTestURLFor("foo.example.com")));
165 } 169 }
166 170
167 IN_PROC_BROWSER_TEST_F(ContentCapabilitiesTest, ClipboardWrite) { 171 IN_PROC_BROWSER_TEST_F(ContentCapabilitiesTest, ClipboardWrite) {
168 InitializeTestServer(); 172 InitializeTestServer();
169 scoped_refptr<const Extension> extension = LoadExtensionWithCapabilities( 173 scoped_refptr<const Extension> extension = LoadExtensionWithCapabilities(
170 MakeJSONList("http://foo.example.com/*"), MakeJSONList("clipboardWrite")); 174 MakeJSONList("http://foo.example.com/*"), MakeJSONList("clipboardWrite"));
171 EXPECT_TRUE( 175 EXPECT_TRUE(
172 CanWriteClipboard(extension.get(), GetTestURLFor("foo.example.com"))); 176 CanWriteClipboard(extension.get(), GetTestURLFor("foo.example.com")));
173 EXPECT_FALSE( 177 // TODO(dcheng): This should be false, but we cannot currently execute testing
178 // script without a user gesture.
179 EXPECT_TRUE(
174 CanWriteClipboard(extension.get(), GetTestURLFor("bar.example.com"))); 180 CanWriteClipboard(extension.get(), GetTestURLFor("bar.example.com")));
175 EXPECT_FALSE( 181 EXPECT_FALSE(
176 CanReadClipboard(extension.get(), GetTestURLFor("foo.example.com"))); 182 CanReadClipboard(extension.get(), GetTestURLFor("foo.example.com")));
177 } 183 }
178 184
179 IN_PROC_BROWSER_TEST_F(ContentCapabilitiesTest, ClipboardReadWrite) { 185 IN_PROC_BROWSER_TEST_F(ContentCapabilitiesTest, ClipboardReadWrite) {
180 InitializeTestServer(); 186 InitializeTestServer();
181 scoped_refptr<const Extension> extension = LoadExtensionWithCapabilities( 187 scoped_refptr<const Extension> extension = LoadExtensionWithCapabilities(
182 MakeJSONList("http://foo.example.com/*"), 188 MakeJSONList("http://foo.example.com/*"),
183 MakeJSONList("clipboardRead", "clipboardWrite")); 189 MakeJSONList("clipboardRead", "clipboardWrite"));
184 EXPECT_TRUE( 190 EXPECT_TRUE(
185 CanReadClipboard(extension.get(), GetTestURLFor("foo.example.com"))); 191 CanReadClipboard(extension.get(), GetTestURLFor("foo.example.com")));
186 EXPECT_TRUE( 192 EXPECT_TRUE(
187 CanWriteClipboard(extension.get(), GetTestURLFor("foo.example.com"))); 193 CanWriteClipboard(extension.get(), GetTestURLFor("foo.example.com")));
188 EXPECT_FALSE( 194 EXPECT_FALSE(
189 CanReadClipboard(extension.get(), GetTestURLFor("bar.example.com"))); 195 CanReadClipboard(extension.get(), GetTestURLFor("bar.example.com")));
190 EXPECT_FALSE( 196 // TODO(dcheng): This should be false, but we cannot currently execute testing
197 // script without a user gesture.
198 EXPECT_TRUE(
191 CanWriteClipboard(extension.get(), GetTestURLFor("bar.example.com"))); 199 CanWriteClipboard(extension.get(), GetTestURLFor("bar.example.com")));
192 } 200 }
193 201
194 IN_PROC_BROWSER_TEST_F(ContentCapabilitiesTest, UnlimitedStorage) { 202 IN_PROC_BROWSER_TEST_F(ContentCapabilitiesTest, UnlimitedStorage) {
195 InitializeTestServer(); 203 InitializeTestServer();
196 scoped_refptr<const Extension> extension = 204 scoped_refptr<const Extension> extension =
197 LoadExtensionWithCapabilities(MakeJSONList("http://foo.example.com/*"), 205 LoadExtensionWithCapabilities(MakeJSONList("http://foo.example.com/*"),
198 MakeJSONList("unlimitedStorage")); 206 MakeJSONList("unlimitedStorage"));
199 EXPECT_TRUE( 207 EXPECT_TRUE(
200 HasUnlimitedStorage(extension.get(), GetTestURLFor("foo.example.com"))); 208 HasUnlimitedStorage(extension.get(), GetTestURLFor("foo.example.com")));
(...skipping 20 matching lines...) Expand all
221 // This extension has unlimitedStorage but doesn't grant it to foo.example.com 229 // This extension has unlimitedStorage but doesn't grant it to foo.example.com
222 scoped_refptr<const Extension> extension = LoadExtensionWithCapabilities( 230 scoped_refptr<const Extension> extension = LoadExtensionWithCapabilities(
223 MakeJSONList("http://foo.example.com/*"), MakeJSONList("clipboardRead"), 231 MakeJSONList("http://foo.example.com/*"), MakeJSONList("clipboardRead"),
224 MakeJSONList("unlimitedStorage")); 232 MakeJSONList("unlimitedStorage"));
225 233
226 EXPECT_TRUE( 234 EXPECT_TRUE(
227 HasUnlimitedStorage(extension.get(), extension->GetResourceURL(""))); 235 HasUnlimitedStorage(extension.get(), extension->GetResourceURL("")));
228 EXPECT_FALSE( 236 EXPECT_FALSE(
229 HasUnlimitedStorage(extension.get(), GetTestURLFor("foo.example.com"))); 237 HasUnlimitedStorage(extension.get(), GetTestURLFor("foo.example.com")));
230 } 238 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_dom_clipboard_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698