OLD | NEW |
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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/string16.h" | 9 #include "base/string16.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 // permissions. | 245 // permissions. |
246 #if defined(OS_CHROMEOS) | 246 #if defined(OS_CHROMEOS) |
247 ASSERT_EQ(0u, warnings.size()); | 247 ASSERT_EQ(0u, warnings.size()); |
248 #else | 248 #else |
249 ASSERT_EQ(1u, warnings.size()); | 249 ASSERT_EQ(1u, warnings.size()); |
250 EXPECT_EQ("Access all data on your computer and the websites you visit", | 250 EXPECT_EQ("Access all data on your computer and the websites you visit", |
251 UTF16ToUTF8(warnings[0])); | 251 UTF16ToUTF8(warnings[0])); |
252 #endif | 252 #endif |
253 } | 253 } |
254 | 254 |
255 TEST(ExtensionPermissionsTest, OptionalOnlyPermission) { | |
256 // Set feature current channel to dev because the only permission that must | |
257 // be optional (usbDevices) is only available on dev channel. | |
258 Feature::ScopedCurrentChannel scoped_channel( | |
259 chrome::VersionInfo::CHANNEL_DEV); | |
260 | |
261 scoped_refptr<Extension> extension; | |
262 std::string error; | |
263 extension = LoadManifestUnchecked("optional_only_permission", | |
264 "manifest1.json", | |
265 Manifest::INTERNAL, Extension::NO_FLAGS, | |
266 &error); | |
267 EXPECT_TRUE(extension == NULL); | |
268 ASSERT_EQ( | |
269 ErrorUtils::FormatErrorMessage( | |
270 extension_manifest_errors::kPermissionMustBeOptional, | |
271 "usbDevices"), | |
272 error); | |
273 | |
274 error.clear(); | |
275 extension = LoadManifestUnchecked("optional_only_permission", | |
276 "manifest2.json", | |
277 Manifest::INTERNAL, Extension::NO_FLAGS, | |
278 &error); | |
279 EXPECT_TRUE(extension != NULL); | |
280 EXPECT_TRUE(error.empty()); | |
281 } | |
282 | |
283 // Base class for testing the CanExecuteScriptOnPage and CanCaptureVisiblePage | 255 // Base class for testing the CanExecuteScriptOnPage and CanCaptureVisiblePage |
284 // methods of Extension for extensions with various permissions. | 256 // methods of Extension for extensions with various permissions. |
285 class ExtensionScriptAndCaptureVisibleTest : public testing::Test { | 257 class ExtensionScriptAndCaptureVisibleTest : public testing::Test { |
286 protected: | 258 protected: |
287 ExtensionScriptAndCaptureVisibleTest() | 259 ExtensionScriptAndCaptureVisibleTest() |
288 : http_url("http://www.google.com"), | 260 : http_url("http://www.google.com"), |
289 http_url_with_path("http://www.google.com/index.html"), | 261 http_url_with_path("http://www.google.com/index.html"), |
290 https_url("https://www.google.com"), | 262 https_url("https://www.google.com"), |
291 file_url("file:///foo/bar"), | 263 file_url("file:///foo/bar"), |
292 favicon_url("chrome://favicon/http://www.google.com"), | 264 favicon_url("chrome://favicon/http://www.google.com"), |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 | 627 |
656 PermissionsData::ClearTabSpecificPermissions(extension, 1); | 628 PermissionsData::ClearTabSpecificPermissions(extension, 1); |
657 EXPECT_FALSE(PermissionsData::GetTabSpecificPermissions(extension, 1).get()); | 629 EXPECT_FALSE(PermissionsData::GetTabSpecificPermissions(extension, 1).get()); |
658 | 630 |
659 EXPECT_TRUE(AllowedExclusivelyOnTab(extension, no_urls, 0)); | 631 EXPECT_TRUE(AllowedExclusivelyOnTab(extension, no_urls, 0)); |
660 EXPECT_TRUE(AllowedExclusivelyOnTab(extension, no_urls, 1)); | 632 EXPECT_TRUE(AllowedExclusivelyOnTab(extension, no_urls, 1)); |
661 EXPECT_TRUE(AllowedExclusivelyOnTab(extension, no_urls, 2)); | 633 EXPECT_TRUE(AllowedExclusivelyOnTab(extension, no_urls, 2)); |
662 } | 634 } |
663 | 635 |
664 } // namespace extensions | 636 } // namespace extensions |
OLD | NEW |