OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/common/extensions/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
6 | 6 |
7 #if defined(TOOLKIT_GTK) | 7 #if defined(TOOLKIT_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 LoadAndExpectSuccess("forbid_ports_in_permissions.json"); | 869 LoadAndExpectSuccess("forbid_ports_in_permissions.json"); |
870 | 870 |
871 // Ideally, loading as a developer would give an error. | 871 // Ideally, loading as a developer would give an error. |
872 // To ensure that we do not error out on a valid permission | 872 // To ensure that we do not error out on a valid permission |
873 // in a future version of chrome, validation is to loose | 873 // in a future version of chrome, validation is to loose |
874 // to flag this case. | 874 // to flag this case. |
875 LoadAndExpectSuccess("forbid_ports_in_permissions.json", | 875 LoadAndExpectSuccess("forbid_ports_in_permissions.json", |
876 Extension::INTERNAL, Extension::STRICT_ERROR_CHECKS); | 876 Extension::INTERNAL, Extension::STRICT_ERROR_CHECKS); |
877 } | 877 } |
878 | 878 |
| 879 TEST_F(ExtensionManifestTest, WebAccessibleResources) { |
| 880 // Manifest version 2 with web accessible resources specified. |
| 881 scoped_refptr<Extension> extension1( |
| 882 LoadAndExpectSuccess("web_accessible_resources_1.json")); |
| 883 |
| 884 // Manifest version 2 with no web accessible resources. |
| 885 scoped_refptr<Extension> extension2( |
| 886 LoadAndExpectSuccess("web_accessible_resources_2.json")); |
| 887 |
| 888 // Default manifest version with web accessible resources specified. |
| 889 scoped_refptr<Extension> extension3( |
| 890 LoadAndExpectSuccess("web_accessible_resources_3.json")); |
| 891 |
| 892 // Default manifest version with no web accessible resources. |
| 893 scoped_refptr<Extension> extension4( |
| 894 LoadAndExpectSuccess("web_accessible_resources_4.json")); |
| 895 |
| 896 EXPECT_TRUE(extension1->HasWebAccessibleResources()); |
| 897 EXPECT_FALSE(extension2->HasWebAccessibleResources()); |
| 898 EXPECT_TRUE(extension3->HasWebAccessibleResources()); |
| 899 EXPECT_FALSE(extension4->HasWebAccessibleResources()); |
| 900 |
| 901 EXPECT_TRUE(extension1->IsResourceWebAccessible("/test")); |
| 902 EXPECT_FALSE(extension1->IsResourceWebAccessible("/none")); |
| 903 |
| 904 EXPECT_FALSE(extension2->IsResourceWebAccessible("/test")); |
| 905 |
| 906 EXPECT_TRUE(extension3->IsResourceWebAccessible("/test")); |
| 907 EXPECT_FALSE(extension3->IsResourceWebAccessible("/none")); |
| 908 |
| 909 EXPECT_TRUE(extension4->IsResourceWebAccessible("/test")); |
| 910 EXPECT_TRUE(extension4->IsResourceWebAccessible("/none")); |
| 911 } |
| 912 |
879 TEST_F(ExtensionManifestTest, IsolatedApps) { | 913 TEST_F(ExtensionManifestTest, IsolatedApps) { |
880 // Requires --enable-experimental-extension-apis | 914 // Requires --enable-experimental-extension-apis |
881 LoadAndExpectError("isolated_app_valid.json", | 915 LoadAndExpectError("isolated_app_valid.json", |
882 errors::kExperimentalFlagRequired); | 916 errors::kExperimentalFlagRequired); |
883 | 917 |
884 CommandLine::ForCurrentProcess()->AppendSwitch( | 918 CommandLine::ForCurrentProcess()->AppendSwitch( |
885 switches::kEnableExperimentalExtensionApis); | 919 switches::kEnableExperimentalExtensionApis); |
886 scoped_refptr<Extension> extension2( | 920 scoped_refptr<Extension> extension2( |
887 LoadAndExpectSuccess("isolated_app_valid.json")); | 921 LoadAndExpectSuccess("isolated_app_valid.json")); |
888 EXPECT_TRUE(extension2->is_storage_isolated()); | 922 EXPECT_TRUE(extension2->is_storage_isolated()); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 // This guy is identical to the previous but doesn't ask for any | 1022 // This guy is identical to the previous but doesn't ask for any |
989 // platform-app-only permissions. We should be able to load him and ask | 1023 // platform-app-only permissions. We should be able to load him and ask |
990 // questions about his permissions. | 1024 // questions about his permissions. |
991 scoped_refptr<Extension> extension( | 1025 scoped_refptr<Extension> extension( |
992 LoadAndExpectSuccess("not_platform_app.json")); | 1026 LoadAndExpectSuccess("not_platform_app.json")); |
993 ExtensionAPIPermissionSet apis = extension->GetActivePermissions()->apis(); | 1027 ExtensionAPIPermissionSet apis = extension->GetActivePermissions()->apis(); |
994 for (ExtensionAPIPermissionSet::const_iterator i = apis.begin(); | 1028 for (ExtensionAPIPermissionSet::const_iterator i = apis.begin(); |
995 i != apis.end(); ++i) | 1029 i != apis.end(); ++i) |
996 EXPECT_NE(platform_app, info->GetByID(*i)->type_restrictions()); | 1030 EXPECT_NE(platform_app, info->GetByID(*i)->type_restrictions()); |
997 } | 1031 } |
OLD | NEW |