Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / common / extensions / manifest_tests / extension_manifests_web_accessible_resources_unittest.cc
blobee6b8d50c3cf444955be00dcc69552d193deb11f
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
3 // found in the LICENSE file.
5 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
6 #include "extensions/common/manifest_handlers/web_accessible_resources_info.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 using extensions::Extension;
10 using extensions::WebAccessibleResourcesInfo;
12 class WebAccessibleResourcesManifestTest : public ChromeManifestTest {
15 TEST_F(WebAccessibleResourcesManifestTest, WebAccessibleResources) {
16 // Manifest version 2 with web accessible resources specified.
17 scoped_refptr<Extension> extension1(
18 LoadAndExpectSuccess("web_accessible_resources_1.json"));
20 // Manifest version 2 with no web accessible resources.
21 scoped_refptr<Extension> extension2(
22 LoadAndExpectSuccess("web_accessible_resources_2.json"));
24 // Default manifest version with web accessible resources specified.
25 scoped_refptr<Extension> extension3(
26 LoadAndExpectSuccess("web_accessible_resources_3.json"));
28 // Default manifest version with no web accessible resources.
29 scoped_refptr<Extension> extension4(
30 LoadAndExpectSuccess("web_accessible_resources_4.json"));
32 // Default manifest version with wildcard web accessible resource.
33 scoped_refptr<Extension> extension5(
34 LoadAndExpectSuccess("web_accessible_resources_5.json"));
36 // Default manifest version with wildcard with specific path and extension.
37 scoped_refptr<Extension> extension6(
38 LoadAndExpectSuccess("web_accessible_resources_6.json"));
40 EXPECT_TRUE(
41 WebAccessibleResourcesInfo::HasWebAccessibleResources(extension1.get()));
42 EXPECT_FALSE(
43 WebAccessibleResourcesInfo::HasWebAccessibleResources(extension2.get()));
44 EXPECT_TRUE(
45 WebAccessibleResourcesInfo::HasWebAccessibleResources(extension3.get()));
46 EXPECT_FALSE(
47 WebAccessibleResourcesInfo::HasWebAccessibleResources(extension4.get()));
48 EXPECT_TRUE(
49 WebAccessibleResourcesInfo::HasWebAccessibleResources(extension5.get()));
50 EXPECT_TRUE(
51 WebAccessibleResourcesInfo::HasWebAccessibleResources(extension6.get()));
53 EXPECT_TRUE(WebAccessibleResourcesInfo::IsResourceWebAccessible(
54 extension1.get(), "test"));
55 EXPECT_FALSE(WebAccessibleResourcesInfo::IsResourceWebAccessible(
56 extension1.get(), "none"));
58 EXPECT_FALSE(WebAccessibleResourcesInfo::IsResourceWebAccessible(
59 extension2.get(), "test"));
61 EXPECT_TRUE(WebAccessibleResourcesInfo::IsResourceWebAccessible(
62 extension3.get(), "test"));
63 EXPECT_FALSE(WebAccessibleResourcesInfo::IsResourceWebAccessible(
64 extension3.get(), "none"));
66 EXPECT_TRUE(WebAccessibleResourcesInfo::IsResourceWebAccessible(
67 extension4.get(), "test"));
68 EXPECT_TRUE(WebAccessibleResourcesInfo::IsResourceWebAccessible(
69 extension4.get(), "none"));
71 EXPECT_TRUE(WebAccessibleResourcesInfo::IsResourceWebAccessible(
72 extension5.get(), "anything"));
73 EXPECT_TRUE(WebAccessibleResourcesInfo::IsResourceWebAccessible(
74 extension5.get(), "path/anything"));
76 EXPECT_TRUE(WebAccessibleResourcesInfo::IsResourceWebAccessible(
77 extension6.get(), "path/anything.ext"));
78 EXPECT_FALSE(WebAccessibleResourcesInfo::IsResourceWebAccessible(
79 extension6.get(), "anything.ext"));
80 EXPECT_FALSE(WebAccessibleResourcesInfo::IsResourceWebAccessible(
81 extension6.get(), "path/anything.badext"));