diff options
author | cdn@chromium.org <cdn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-21 21:15:22 +0000 |
---|---|---|
committer | cdn@chromium.org <cdn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-21 21:15:22 +0000 |
commit | 8f270be43ff51e35d4493e377c18bfca1c6b5be6 (patch) | |
tree | 458e91415cef21d52481e2aea9d660f080ff0465 /chrome/common/extensions/extension_manifests_unittest.cc | |
parent | 283fb25624bf253d120708152e23cf9143519198 (diff) | |
download | chromium_src-8f270be43ff51e35d4493e377c18bfca1c6b5be6.zip chromium_src-8f270be43ff51e35d4493e377c18bfca1c6b5be6.tar.gz chromium_src-8f270be43ff51e35d4493e377c18bfca1c6b5be6.tar.bz2 |
Add 'web_accessible_resource" keyword for version 2 extension manifests. This makes extension resources web accessible only when explicitly intended. Behavior is unaffected unless an extension specifies a manifest_version of 2 or more.
BUG=46002
TEST=ExtensionResourceRequestPolicyTest.WebAccessibleResources
Review URL: http://codereview.chromium.org/8849010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115401 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/extension_manifests_unittest.cc')
-rw-r--r-- | chrome/common/extensions/extension_manifests_unittest.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/chrome/common/extensions/extension_manifests_unittest.cc b/chrome/common/extensions/extension_manifests_unittest.cc index 1a54e03..6fd314e 100644 --- a/chrome/common/extensions/extension_manifests_unittest.cc +++ b/chrome/common/extensions/extension_manifests_unittest.cc @@ -844,6 +844,40 @@ TEST_F(ExtensionManifestTest, PortsInPermissions) { LoadAndExpectSuccess("ports_in_permissions.json"); } +TEST_F(ExtensionManifestTest, WebAccessibleResources) { + // Manifest version 2 with web accessible resources specified. + scoped_refptr<Extension> extension1( + LoadAndExpectSuccess("web_accessible_resources_1.json")); + + // Manifest version 2 with no web accessible resources. + scoped_refptr<Extension> extension2( + LoadAndExpectSuccess("web_accessible_resources_2.json")); + + // Default manifest version with web accessible resources specified. + scoped_refptr<Extension> extension3( + LoadAndExpectSuccess("web_accessible_resources_3.json")); + + // Default manifest version with no web accessible resources. + scoped_refptr<Extension> extension4( + LoadAndExpectSuccess("web_accessible_resources_4.json")); + + EXPECT_TRUE(extension1->HasWebAccessibleResources()); + EXPECT_FALSE(extension2->HasWebAccessibleResources()); + EXPECT_TRUE(extension3->HasWebAccessibleResources()); + EXPECT_FALSE(extension4->HasWebAccessibleResources()); + + EXPECT_TRUE(extension1->IsResourceWebAccessible("/test")); + EXPECT_FALSE(extension1->IsResourceWebAccessible("/none")); + + EXPECT_FALSE(extension2->IsResourceWebAccessible("/test")); + + EXPECT_TRUE(extension3->IsResourceWebAccessible("/test")); + EXPECT_FALSE(extension3->IsResourceWebAccessible("/none")); + + EXPECT_TRUE(extension4->IsResourceWebAccessible("/test")); + EXPECT_TRUE(extension4->IsResourceWebAccessible("/none")); +} + TEST_F(ExtensionManifestTest, IsolatedApps) { // Requires --enable-experimental-extension-apis LoadAndExpectError("isolated_app_valid.json", |