OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/plugins/npapi/plugin_group.h" | 5 #include "webkit/plugins/npapi/plugin_group.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 plugindefs[i])); | 131 plugindefs[i])); |
132 EXPECT_TRUE(group->Match(plugin3043)); | 132 EXPECT_TRUE(group->Match(plugin3043)); |
133 group->AddPlugin(plugin3043, 0); | 133 group->AddPlugin(plugin3043, 0); |
134 EXPECT_EQ(desc3043, group->description()); | 134 EXPECT_EQ(desc3043, group->description()); |
135 EXPECT_TRUE(group->IsVulnerable()); | 135 EXPECT_TRUE(group->IsVulnerable()); |
136 EXPECT_TRUE(group->Match(plugin3045)); | 136 EXPECT_TRUE(group->Match(plugin3045)); |
137 group->AddPlugin(plugin3045, 1); | 137 group->AddPlugin(plugin3045, 1); |
138 EXPECT_EQ(desc3043, group->description()); | 138 EXPECT_EQ(desc3043, group->description()); |
139 EXPECT_TRUE(group->IsVulnerable()); | 139 EXPECT_TRUE(group->IsVulnerable()); |
140 } | 140 } |
141 | |
142 { | 141 { |
143 // Disable the first plugin. | 142 // Disable the second plugin. |
144 plugin3043.enabled = false; | 143 plugin3045.enabled = |
| 144 webkit::npapi::WebPluginInfo::USER_DISABLED_POLICY_UNMANAGED; |
145 scoped_ptr<PluginGroup> group(PluginGroupTest::CreatePluginGroup( | 145 scoped_ptr<PluginGroup> group(PluginGroupTest::CreatePluginGroup( |
146 plugindefs[i])); | 146 plugindefs[i])); |
147 EXPECT_TRUE(group->Match(plugin3043)); | 147 EXPECT_TRUE(group->Match(plugin3043)); |
148 group->AddPlugin(plugin3043, 0); | |
149 EXPECT_EQ(desc3043, group->description()); | |
150 EXPECT_TRUE(group->IsVulnerable()); | |
151 EXPECT_FALSE(group->Enabled()); | |
152 EXPECT_TRUE(group->Match(plugin3045)); | |
153 group->AddPlugin(plugin3045, 1); | |
154 EXPECT_EQ(desc3045, group->description()); | |
155 EXPECT_FALSE(group->IsVulnerable()); | |
156 } | |
157 | |
158 { | |
159 // Disable the second plugin. | |
160 plugin3045.enabled = false; | |
161 scoped_ptr<PluginGroup> group(PluginGroupTest::CreatePluginGroup( | |
162 plugindefs[i])); | |
163 EXPECT_TRUE(group->Match(plugin3043)); | |
164 group->AddPlugin(plugin3043, 1); | 148 group->AddPlugin(plugin3043, 1); |
165 EXPECT_EQ(desc3043, group->description()); | 149 EXPECT_EQ(desc3043, group->description()); |
166 EXPECT_TRUE(group->IsVulnerable()); | 150 EXPECT_TRUE(group->IsVulnerable()); |
167 EXPECT_TRUE(group->Match(plugin3045)); | 151 EXPECT_TRUE(group->Match(plugin3045)); |
168 group->AddPlugin(plugin3045, 0); | 152 group->AddPlugin(plugin3045, 0); |
169 EXPECT_EQ(desc3043, group->description()); | 153 EXPECT_EQ(desc3043, group->description()); |
170 EXPECT_TRUE(group->IsVulnerable()); | 154 EXPECT_TRUE(group->IsVulnerable()); |
171 } | 155 } |
172 } | 156 } |
173 } | 157 } |
174 | 158 |
175 TEST(PluginGroupTest, PluginGroupDefinition) { | 159 TEST(PluginGroupTest, PluginGroupDefinition) { |
176 const PluginGroupDefinition* definitions = | 160 const PluginGroupDefinition* definitions = |
177 PluginList::GetPluginGroupDefinitions(); | 161 PluginList::GetPluginGroupDefinitions(); |
178 for (size_t i = 0; i < PluginList::GetPluginGroupDefinitionsSize(); ++i) { | 162 for (size_t i = 0; i < PluginList::GetPluginGroupDefinitionsSize(); ++i) { |
179 scoped_ptr<PluginGroup> def_group( | 163 scoped_ptr<PluginGroup> def_group( |
180 PluginGroupTest::CreatePluginGroup(definitions[i])); | 164 PluginGroupTest::CreatePluginGroup(definitions[i])); |
181 ASSERT_TRUE(def_group.get() != NULL); | 165 ASSERT_TRUE(def_group.get() != NULL); |
182 EXPECT_FALSE(def_group->Match(kPlugin2043)); | 166 EXPECT_FALSE(def_group->Match(kPlugin2043)); |
183 } | 167 } |
184 } | 168 } |
185 | 169 |
186 TEST(PluginGroupTest, DisableOutdated) { | 170 TEST(PluginGroupTest, DisableOutdated) { |
187 PluginGroupDefinition plugindefs[] = { kPluginDef3, kPluginDef34 }; | 171 PluginGroupDefinition plugindefs[] = { kPluginDef3, kPluginDef34 }; |
188 for (size_t i = 0; i < 2; ++i) { | 172 for (size_t i = 0; i < 2; ++i) { |
189 scoped_ptr<PluginGroup> group(PluginGroupTest::CreatePluginGroup( | 173 scoped_ptr<PluginGroup> group(PluginGroupTest::CreatePluginGroup( |
190 plugindefs[i])); | 174 plugindefs[i])); |
191 group->AddPlugin(kPlugin3043, 0); | 175 group->AddPlugin(kPlugin3043, 0); |
192 group->AddPlugin(kPlugin3045, 1); | 176 group->AddPlugin(kPlugin3045, 1); |
| 177 |
193 EXPECT_EQ(ASCIIToUTF16("MyPlugin version 3.0.43"), group->description()); | 178 EXPECT_EQ(ASCIIToUTF16("MyPlugin version 3.0.43"), group->description()); |
194 EXPECT_TRUE(group->IsVulnerable()); | 179 EXPECT_TRUE(group->IsVulnerable()); |
195 | 180 |
196 group->DisableOutdatedPlugins(); | 181 group->DisableOutdatedPlugins(); |
197 EXPECT_EQ(ASCIIToUTF16("MyPlugin version 3.0.45"), group->description()); | 182 EXPECT_EQ(ASCIIToUTF16("MyPlugin version 3.0.45"), group->description()); |
198 EXPECT_FALSE(group->IsVulnerable()); | 183 EXPECT_FALSE(group->IsVulnerable()); |
199 } | 184 } |
200 } | 185 } |
201 | 186 |
202 TEST(PluginGroupTest, VersionExtraction) { | 187 TEST(PluginGroupTest, VersionExtraction) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 WebPluginInfo silverlight_plugin(ASCIIToUTF16("Silverlight"), | 257 WebPluginInfo silverlight_plugin(ASCIIToUTF16("Silverlight"), |
273 FilePath(FILE_PATH_LITERAL("/silver.so")), | 258 FilePath(FILE_PATH_LITERAL("/silver.so")), |
274 ASCIIToUTF16("4.0.50917.0"), | 259 ASCIIToUTF16("4.0.50917.0"), |
275 ASCIIToUTF16("silverlight 4")); | 260 ASCIIToUTF16("silverlight 4")); |
276 group.reset(PluginGroupTest::CreatePluginGroup(silverlight_plugin_def)); | 261 group.reset(PluginGroupTest::CreatePluginGroup(silverlight_plugin_def)); |
277 group->AddPlugin(silverlight_plugin, 0); | 262 group->AddPlugin(silverlight_plugin, 0); |
278 EXPECT_FALSE(PluginGroup(*group).IsVulnerable()); | 263 EXPECT_FALSE(PluginGroup(*group).IsVulnerable()); |
279 } | 264 } |
280 } // namespace npapi | 265 } // namespace npapi |
281 } // namespace webkit | 266 } // namespace webkit |
OLD | NEW |