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

Side by Side Diff: chrome/common/extensions/extension_unittest.cc

Issue 15836003: Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/format_macros.h" 6 #include "base/format_macros.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "chrome/common/chrome_paths.h" 10 #include "chrome/common/chrome_paths.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 scoped_refptr<Extension> extension; 163 scoped_refptr<Extension> extension;
164 GURL file_url("file:///etc/passwd"); 164 GURL file_url("file:///etc/passwd");
165 165
166 // Ignore the policy delegate for this test. 166 // Ignore the policy delegate for this test.
167 PermissionsData::SetPolicyDelegate(NULL); 167 PermissionsData::SetPolicyDelegate(NULL);
168 168
169 // <all_urls> permission 169 // <all_urls> permission
170 extension = LoadManifest("permissions", "permissions_all_urls.json"); 170 extension = LoadManifest("permissions", "permissions_all_urls.json");
171 EXPECT_TRUE(extension->wants_file_access()); 171 EXPECT_TRUE(extension->wants_file_access());
172 EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage( 172 EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage(
173 extension, file_url, file_url, -1, NULL, -1, NULL)); 173 extension.get(), file_url, file_url, -1, NULL, -1, NULL));
174 extension = LoadManifest( 174 extension = LoadManifest(
175 "permissions", "permissions_all_urls.json", Extension::ALLOW_FILE_ACCESS); 175 "permissions", "permissions_all_urls.json", Extension::ALLOW_FILE_ACCESS);
176 EXPECT_TRUE(extension->wants_file_access()); 176 EXPECT_TRUE(extension->wants_file_access());
177 EXPECT_TRUE(PermissionsData::CanExecuteScriptOnPage( 177 EXPECT_TRUE(PermissionsData::CanExecuteScriptOnPage(
178 extension, file_url, file_url, -1, NULL, -1, NULL)); 178 extension.get(), file_url, file_url, -1, NULL, -1, NULL));
179 179
180 // file:///* permission 180 // file:///* permission
181 extension = LoadManifest("permissions", "permissions_file_scheme.json"); 181 extension = LoadManifest("permissions", "permissions_file_scheme.json");
182 EXPECT_TRUE(extension->wants_file_access()); 182 EXPECT_TRUE(extension->wants_file_access());
183 EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage( 183 EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage(
184 extension, file_url, file_url, -1, NULL, -1, NULL)); 184 extension.get(), file_url, file_url, -1, NULL, -1, NULL));
185 extension = LoadManifest("permissions", "permissions_file_scheme.json", 185 extension = LoadManifest("permissions",
186 Extension::ALLOW_FILE_ACCESS); 186 "permissions_file_scheme.json",
187 Extension::ALLOW_FILE_ACCESS);
187 EXPECT_TRUE(extension->wants_file_access()); 188 EXPECT_TRUE(extension->wants_file_access());
188 EXPECT_TRUE(PermissionsData::CanExecuteScriptOnPage( 189 EXPECT_TRUE(PermissionsData::CanExecuteScriptOnPage(
189 extension, file_url, file_url, -1, NULL, -1, NULL)); 190 extension.get(), file_url, file_url, -1, NULL, -1, NULL));
190 191
191 // http://* permission 192 // http://* permission
192 extension = LoadManifest("permissions", "permissions_http_scheme.json"); 193 extension = LoadManifest("permissions", "permissions_http_scheme.json");
193 EXPECT_FALSE(extension->wants_file_access()); 194 EXPECT_FALSE(extension->wants_file_access());
194 EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage( 195 EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage(
195 extension, file_url, file_url, -1, NULL, -1, NULL)); 196 extension.get(), file_url, file_url, -1, NULL, -1, NULL));
196 extension = LoadManifest("permissions", "permissions_http_scheme.json", 197 extension = LoadManifest("permissions",
197 Extension::ALLOW_FILE_ACCESS); 198 "permissions_http_scheme.json",
199 Extension::ALLOW_FILE_ACCESS);
198 EXPECT_FALSE(extension->wants_file_access()); 200 EXPECT_FALSE(extension->wants_file_access());
199 EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage( 201 EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage(
200 extension, file_url, file_url, -1, NULL, -1, NULL)); 202 extension.get(), file_url, file_url, -1, NULL, -1, NULL));
201 203
202 // <all_urls> content script match 204 // <all_urls> content script match
203 extension = LoadManifest("permissions", "content_script_all_urls.json"); 205 extension = LoadManifest("permissions", "content_script_all_urls.json");
204 EXPECT_TRUE(extension->wants_file_access()); 206 EXPECT_TRUE(extension->wants_file_access());
205 EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage( 207 EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage(
206 extension, 208 extension.get(),
207 file_url, 209 file_url,
208 file_url, 210 file_url,
209 -1, 211 -1,
210 &ContentScriptsInfo::GetContentScripts(extension)[0], 212 &ContentScriptsInfo::GetContentScripts(extension.get())[0],
211 -1, 213 -1,
212 NULL)); 214 NULL));
213 extension = LoadManifest("permissions", "content_script_all_urls.json", 215 extension = LoadManifest("permissions", "content_script_all_urls.json",
214 Extension::ALLOW_FILE_ACCESS); 216 Extension::ALLOW_FILE_ACCESS);
215 EXPECT_TRUE(extension->wants_file_access()); 217 EXPECT_TRUE(extension->wants_file_access());
216 EXPECT_TRUE(PermissionsData::CanExecuteScriptOnPage( 218 EXPECT_TRUE(PermissionsData::CanExecuteScriptOnPage(
217 extension, 219 extension.get(),
218 file_url, 220 file_url,
219 file_url, 221 file_url,
220 -1, 222 -1,
221 &ContentScriptsInfo::GetContentScripts(extension)[0], 223 &ContentScriptsInfo::GetContentScripts(extension.get())[0],
222 -1, 224 -1,
223 NULL)); 225 NULL));
224 226
225 // file:///* content script match 227 // file:///* content script match
226 extension = LoadManifest("permissions", "content_script_file_scheme.json"); 228 extension = LoadManifest("permissions", "content_script_file_scheme.json");
227 EXPECT_TRUE(extension->wants_file_access()); 229 EXPECT_TRUE(extension->wants_file_access());
228 EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage( 230 EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage(
229 extension, 231 extension.get(),
230 file_url, 232 file_url,
231 file_url, 233 file_url,
232 -1, 234 -1,
233 &ContentScriptsInfo::GetContentScripts(extension)[0], 235 &ContentScriptsInfo::GetContentScripts(extension.get())[0],
234 -1, 236 -1,
235 NULL)); 237 NULL));
236 extension = LoadManifest("permissions", "content_script_file_scheme.json", 238 extension = LoadManifest("permissions", "content_script_file_scheme.json",
237 Extension::ALLOW_FILE_ACCESS); 239 Extension::ALLOW_FILE_ACCESS);
238 EXPECT_TRUE(extension->wants_file_access()); 240 EXPECT_TRUE(extension->wants_file_access());
239 EXPECT_TRUE(PermissionsData::CanExecuteScriptOnPage( 241 EXPECT_TRUE(PermissionsData::CanExecuteScriptOnPage(
240 extension, 242 extension.get(),
241 file_url, 243 file_url,
242 file_url, 244 file_url,
243 -1, 245 -1,
244 &ContentScriptsInfo::GetContentScripts(extension)[0], 246 &ContentScriptsInfo::GetContentScripts(extension.get())[0],
245 -1, 247 -1,
246 NULL)); 248 NULL));
247 249
248 // http://* content script match 250 // http://* content script match
249 extension = LoadManifest("permissions", "content_script_http_scheme.json"); 251 extension = LoadManifest("permissions", "content_script_http_scheme.json");
250 EXPECT_FALSE(extension->wants_file_access()); 252 EXPECT_FALSE(extension->wants_file_access());
251 EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage( 253 EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage(
252 extension, 254 extension.get(),
253 file_url, 255 file_url,
254 file_url, 256 file_url,
255 -1, 257 -1,
256 &ContentScriptsInfo::GetContentScripts(extension)[0], 258 &ContentScriptsInfo::GetContentScripts(extension.get())[0],
257 -1, 259 -1,
258 NULL)); 260 NULL));
259 extension = LoadManifest("permissions", "content_script_http_scheme.json", 261 extension = LoadManifest("permissions", "content_script_http_scheme.json",
260 Extension::ALLOW_FILE_ACCESS); 262 Extension::ALLOW_FILE_ACCESS);
261 EXPECT_FALSE(extension->wants_file_access()); 263 EXPECT_FALSE(extension->wants_file_access());
262 EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage( 264 EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage(
263 extension, 265 extension.get(),
264 file_url, 266 file_url,
265 file_url, 267 file_url,
266 -1, 268 -1,
267 &ContentScriptsInfo::GetContentScripts(extension)[0], 269 &ContentScriptsInfo::GetContentScripts(extension.get())[0],
268 -1, 270 -1,
269 NULL)); 271 NULL));
270 } 272 }
271 273
272 TEST(ExtensionTest, ExtraFlags) { 274 TEST(ExtensionTest, ExtraFlags) {
273 scoped_refptr<Extension> extension; 275 scoped_refptr<Extension> extension;
274 extension = LoadManifest("app", "manifest.json", Extension::FROM_WEBSTORE); 276 extension = LoadManifest("app", "manifest.json", Extension::FROM_WEBSTORE);
275 EXPECT_TRUE(extension->from_webstore()); 277 EXPECT_TRUE(extension->from_webstore());
276 278
277 extension = LoadManifest("app", "manifest.json", Extension::FROM_BOOKMARK); 279 extension = LoadManifest("app", "manifest.json", Extension::FROM_BOOKMARK);
278 EXPECT_TRUE(extension->from_bookmark()); 280 EXPECT_TRUE(extension->from_bookmark());
279 281
280 extension = LoadManifest("app", "manifest.json", Extension::NO_FLAGS); 282 extension = LoadManifest("app", "manifest.json", Extension::NO_FLAGS);
281 EXPECT_FALSE(extension->from_bookmark()); 283 EXPECT_FALSE(extension->from_bookmark());
282 EXPECT_FALSE(extension->from_webstore()); 284 EXPECT_FALSE(extension->from_webstore());
283 } 285 }
284 286
285 } // namespace extensions 287 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_test_util.cc ('k') | chrome/common/extensions/manifest_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698