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 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 EXPECT_EQ("", UTF16ToUTF8(extension->intents_services()[0].title)); | 841 EXPECT_EQ("", UTF16ToUTF8(extension->intents_services()[0].title)); |
842 EXPECT_EQ(webkit_glue::WebIntentServiceData::DISPOSITION_WINDOW, | 842 EXPECT_EQ(webkit_glue::WebIntentServiceData::DISPOSITION_WINDOW, |
843 extension->intents_services()[0].disposition); | 843 extension->intents_services()[0].disposition); |
844 } | 844 } |
845 | 845 |
846 TEST_F(ExtensionManifestTest, PortsInPermissions) { | 846 TEST_F(ExtensionManifestTest, PortsInPermissions) { |
847 // Loading as a user would shoud not trigger an error. | 847 // Loading as a user would shoud not trigger an error. |
848 LoadAndExpectSuccess("ports_in_permissions.json"); | 848 LoadAndExpectSuccess("ports_in_permissions.json"); |
849 } | 849 } |
850 | 850 |
| 851 TEST_F(ExtensionManifestTest, WebAccessibleResources) { |
| 852 // Manifest version 2 with web accessible resources specified. |
| 853 scoped_refptr<Extension> extension1( |
| 854 LoadAndExpectSuccess("web_accessible_resources_1.json")); |
| 855 |
| 856 // Manifest version 2 with no web accessible resources. |
| 857 scoped_refptr<Extension> extension2( |
| 858 LoadAndExpectSuccess("web_accessible_resources_2.json")); |
| 859 |
| 860 // Default manifest version with web accessible resources specified. |
| 861 scoped_refptr<Extension> extension3( |
| 862 LoadAndExpectSuccess("web_accessible_resources_3.json")); |
| 863 |
| 864 // Default manifest version with no web accessible resources. |
| 865 scoped_refptr<Extension> extension4( |
| 866 LoadAndExpectSuccess("web_accessible_resources_4.json")); |
| 867 |
| 868 EXPECT_TRUE(extension1->HasWebAccessibleResources()); |
| 869 EXPECT_FALSE(extension2->HasWebAccessibleResources()); |
| 870 EXPECT_TRUE(extension3->HasWebAccessibleResources()); |
| 871 EXPECT_FALSE(extension4->HasWebAccessibleResources()); |
| 872 |
| 873 EXPECT_TRUE(extension1->IsResourceWebAccessible("/test")); |
| 874 EXPECT_FALSE(extension1->IsResourceWebAccessible("/none")); |
| 875 |
| 876 EXPECT_FALSE(extension2->IsResourceWebAccessible("/test")); |
| 877 |
| 878 EXPECT_TRUE(extension3->IsResourceWebAccessible("/test")); |
| 879 EXPECT_FALSE(extension3->IsResourceWebAccessible("/none")); |
| 880 |
| 881 EXPECT_TRUE(extension4->IsResourceWebAccessible("/test")); |
| 882 EXPECT_TRUE(extension4->IsResourceWebAccessible("/none")); |
| 883 } |
| 884 |
851 TEST_F(ExtensionManifestTest, IsolatedApps) { | 885 TEST_F(ExtensionManifestTest, IsolatedApps) { |
852 // Requires --enable-experimental-extension-apis | 886 // Requires --enable-experimental-extension-apis |
853 LoadAndExpectError("isolated_app_valid.json", | 887 LoadAndExpectError("isolated_app_valid.json", |
854 errors::kExperimentalFlagRequired); | 888 errors::kExperimentalFlagRequired); |
855 | 889 |
856 CommandLine::ForCurrentProcess()->AppendSwitch( | 890 CommandLine::ForCurrentProcess()->AppendSwitch( |
857 switches::kEnableExperimentalExtensionApis); | 891 switches::kEnableExperimentalExtensionApis); |
858 scoped_refptr<Extension> extension2( | 892 scoped_refptr<Extension> extension2( |
859 LoadAndExpectSuccess("isolated_app_valid.json")); | 893 LoadAndExpectSuccess("isolated_app_valid.json")); |
860 EXPECT_TRUE(extension2->is_storage_isolated()); | 894 EXPECT_TRUE(extension2->is_storage_isolated()); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 // This guy is identical to the previous but doesn't ask for any | 994 // This guy is identical to the previous but doesn't ask for any |
961 // platform-app-only permissions. We should be able to load him and ask | 995 // platform-app-only permissions. We should be able to load him and ask |
962 // questions about his permissions. | 996 // questions about his permissions. |
963 scoped_refptr<Extension> extension( | 997 scoped_refptr<Extension> extension( |
964 LoadAndExpectSuccess("not_platform_app.json")); | 998 LoadAndExpectSuccess("not_platform_app.json")); |
965 ExtensionAPIPermissionSet apis = extension->GetActivePermissions()->apis(); | 999 ExtensionAPIPermissionSet apis = extension->GetActivePermissions()->apis(); |
966 for (ExtensionAPIPermissionSet::const_iterator i = apis.begin(); | 1000 for (ExtensionAPIPermissionSet::const_iterator i = apis.begin(); |
967 i != apis.end(); ++i) | 1001 i != apis.end(); ++i) |
968 EXPECT_NE(platform_app, info->GetByID(*i)->type_restrictions()); | 1002 EXPECT_NE(platform_app, info->GetByID(*i)->type_restrictions()); |
969 } | 1003 } |
OLD | NEW |