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

Side by Side Diff: chrome/common/extensions/permissions/permission_set_unittest.cc

Issue 10829186: Tabs API is usable without tabs permission. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: ETU now SetString()'s for empty values Created 8 years, 3 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
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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/json/json_file_value_serializer.h" 6 #include "base/json/json_file_value_serializer.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/common/chrome_paths.h" 10 #include "chrome/common/chrome_paths.h"
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 { "devtools", true }, 760 { "devtools", true },
761 { "extension", true }, 761 { "extension", true },
762 { "i18n", true }, 762 { "i18n", true },
763 { "pageAction", true }, 763 { "pageAction", true },
764 { "pageActions", true }, 764 { "pageActions", true },
765 { "test", true }, 765 { "test", true },
766 // Some negative tests. 766 // Some negative tests.
767 { "bookmarks", false }, 767 { "bookmarks", false },
768 { "cookies", false }, 768 { "cookies", false },
769 { "history", false }, 769 { "history", false },
770 { "tabs.onUpdated", false },
771 // Make sure we find the module name after stripping '.' and '/'. 770 // Make sure we find the module name after stripping '.' and '/'.
772 { "browserAction/abcd/onClick", true }, 771 { "browserAction/abcd/onClick", true },
773 { "browserAction.abcd.onClick", true }, 772 { "browserAction.abcd.onClick", true },
774 // Test Tabs functions. 773 // Test Tabs functions.
775 { "tabs.create", true}, 774 { "tabs.create", true},
776 { "tabs.update", true}, 775 { "tabs.update", true},
777 { "tabs.getSelected", false}, 776 { "tabs.getSelected", true},
777 { "tabs.onUpdated", true },
778 }; 778 };
779 779
780 scoped_refptr<PermissionSet> empty = new PermissionSet(); 780 scoped_refptr<PermissionSet> empty = new PermissionSet();
781 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTests); ++i) { 781 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTests); ++i) {
782 EXPECT_EQ(kTests[i].expect_success, 782 EXPECT_EQ(kTests[i].expect_success,
783 empty->HasAccessToFunction(kTests[i].permission_name)); 783 empty->HasAccessToFunction(kTests[i].permission_name))
784 << "Permission being tested: " << kTests[i].permission_name;
784 } 785 }
785 } 786 }
786 787
787 // Tests the default permissions (empty API permission set). 788 // Tests the default permissions (empty API permission set).
788 TEST(PermissionsTest, DefaultAnyAPIAccess) { 789 TEST(PermissionsTest, DefaultAnyAPIAccess) {
789 const struct { 790 const struct {
790 const char* api_name; 791 const char* api_name;
791 bool expect_success; 792 bool expect_success;
792 } kTests[] = { 793 } kTests[] = {
793 // Negative test. 794 // Negative test.
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 apis.insert(APIPermission::kWebRequest); 1268 apis.insert(APIPermission::kWebRequest);
1268 apis.insert(APIPermission::kFileBrowserHandler); 1269 apis.insert(APIPermission::kFileBrowserHandler);
1269 EXPECT_EQ(2U, apis.size()); 1270 EXPECT_EQ(2U, apis.size());
1270 1271
1271 scoped_refptr<PermissionSet> perm_set; 1272 scoped_refptr<PermissionSet> perm_set;
1272 perm_set = new PermissionSet(apis, empty_extent, empty_extent); 1273 perm_set = new PermissionSet(apis, empty_extent, empty_extent);
1273 EXPECT_EQ(4U, perm_set->apis().size()); 1274 EXPECT_EQ(4U, perm_set->apis().size());
1274 } 1275 }
1275 1276
1276 } // namespace extensions 1277 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/permissions/permission_set.cc ('k') | chrome/renderer/extensions/dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698