| OLD | NEW |
| 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 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 { "devtools", true }, | 640 { "devtools", true }, |
| 641 { "extension", true }, | 641 { "extension", true }, |
| 642 { "i18n", true }, | 642 { "i18n", true }, |
| 643 { "pageAction", true }, | 643 { "pageAction", true }, |
| 644 { "pageActions", true }, | 644 { "pageActions", true }, |
| 645 { "test", true }, | 645 { "test", true }, |
| 646 // Some negative tests. | 646 // Some negative tests. |
| 647 { "bookmarks", false }, | 647 { "bookmarks", false }, |
| 648 { "cookies", false }, | 648 { "cookies", false }, |
| 649 { "history", false }, | 649 { "history", false }, |
| 650 { "tabs.onUpdated", false }, | |
| 651 // Make sure we find the module name after stripping '.' and '/'. | 650 // Make sure we find the module name after stripping '.' and '/'. |
| 652 { "browserAction/abcd/onClick", true }, | 651 { "browserAction/abcd/onClick", true }, |
| 653 { "browserAction.abcd.onClick", true }, | 652 { "browserAction.abcd.onClick", true }, |
| 654 // Test Tabs functions. | 653 // Test Tabs functions. |
| 655 { "tabs.create", true}, | 654 { "tabs.create", true}, |
| 656 { "tabs.update", true}, | 655 { "tabs.update", true}, |
| 657 { "tabs.getSelected", false}, | 656 { "tabs.getSelected", true}, |
| 657 { "tabs.onUpdated", true }, |
| 658 }; | 658 }; |
| 659 | 659 |
| 660 scoped_refptr<PermissionSet> empty = new PermissionSet(); | 660 scoped_refptr<PermissionSet> empty = new PermissionSet(); |
| 661 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTests); ++i) { | 661 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTests); ++i) { |
| 662 EXPECT_EQ(kTests[i].expect_success, | 662 EXPECT_EQ(kTests[i].expect_success, |
| 663 empty->HasAccessToFunction(kTests[i].permission_name)); | 663 empty->HasAccessToFunction(kTests[i].permission_name)) |
| 664 << "Permission being tested: " << kTests[i].permission_name; |
| 664 } | 665 } |
| 665 } | 666 } |
| 666 | 667 |
| 667 // Tests the default permissions (empty API permission set). | 668 // Tests the default permissions (empty API permission set). |
| 668 TEST(PermissionsTest, DefaultAnyAPIAccess) { | 669 TEST(PermissionsTest, DefaultAnyAPIAccess) { |
| 669 const struct { | 670 const struct { |
| 670 const char* api_name; | 671 const char* api_name; |
| 671 bool expect_success; | 672 bool expect_success; |
| 672 } kTests[] = { | 673 } kTests[] = { |
| 673 // Negative test. | 674 // Negative test. |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1147 apis.insert(APIPermission::kWebRequest); | 1148 apis.insert(APIPermission::kWebRequest); |
| 1148 apis.insert(APIPermission::kFileBrowserHandler); | 1149 apis.insert(APIPermission::kFileBrowserHandler); |
| 1149 EXPECT_EQ(2U, apis.size()); | 1150 EXPECT_EQ(2U, apis.size()); |
| 1150 | 1151 |
| 1151 scoped_refptr<PermissionSet> perm_set; | 1152 scoped_refptr<PermissionSet> perm_set; |
| 1152 perm_set = new PermissionSet(apis, empty_extent, empty_extent); | 1153 perm_set = new PermissionSet(apis, empty_extent, empty_extent); |
| 1153 EXPECT_EQ(4U, perm_set->apis().size()); | 1154 EXPECT_EQ(4U, perm_set->apis().size()); |
| 1154 } | 1155 } |
| 1155 | 1156 |
| 1156 } // namespace extensions | 1157 } // namespace extensions |
| OLD | NEW |