Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Side by Side Diff: webkit/plugins/npapi/plugin_group_unittest.cc

Issue 6350010: Put some plug-ins behind an infobar, where they have:... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "base/version.h" 14 #include "base/version.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "webkit/plugins/npapi/webplugininfo.h" 16 #include "webkit/plugins/npapi/webplugininfo.h"
17 #include "webkit/plugins/npapi/plugin_list.h" 17 #include "webkit/plugins/npapi/plugin_list.h"
18 18
19 namespace webkit { 19 namespace webkit {
20 namespace npapi { 20 namespace npapi {
21 21
22 static const VersionRangeDefinition kPluginVersionRange[] = { 22 static const VersionRangeDefinition kPluginVersionRange[] = {
23 { "", "", "3.0.44" } 23 { "", "", "3.0.44", false }
24 }; 24 };
25 static const VersionRangeDefinition kPlugin3VersionRange[] = { 25 static const VersionRangeDefinition kPlugin3VersionRange[] = {
26 { "0", "4", "3.0.44" } 26 { "0", "4", "3.0.44", false }
27 }; 27 };
28 static const VersionRangeDefinition kPlugin4VersionRange[] = { 28 static const VersionRangeDefinition kPlugin4VersionRange[] = {
29 { "4", "5", "4.0.44" } 29 { "4", "5", "4.0.44", false }
30 }; 30 };
31 static const VersionRangeDefinition kPlugin34VersionRange[] = { 31 static const VersionRangeDefinition kPlugin34VersionRange[] = {
32 { "0", "4", "3.0.44" }, 32 { "0", "4", "3.0.44", false },
33 { "4", "5", "" } 33 { "4", "5", "", false }
34 }; 34 };
35 35
36 static const PluginGroupDefinition kPluginDef = { 36 static const PluginGroupDefinition kPluginDef = {
37 "myplugin", "MyPlugin", "MyPlugin", kPluginVersionRange, 37 "myplugin", "MyPlugin", "MyPlugin", kPluginVersionRange,
38 arraysize(kPluginVersionRange), "http://latest/" }; 38 arraysize(kPluginVersionRange), "http://latest/" };
39 static const PluginGroupDefinition kPluginDef3 = { 39 static const PluginGroupDefinition kPluginDef3 = {
40 "myplugin-3", "MyPlugin 3", "MyPlugin", kPlugin3VersionRange, 40 "myplugin-3", "MyPlugin 3", "MyPlugin", kPlugin3VersionRange,
41 arraysize(kPlugin3VersionRange), "http://latest" }; 41 arraysize(kPlugin3VersionRange), "http://latest" };
42 static const PluginGroupDefinition kPluginDef4 = { 42 static const PluginGroupDefinition kPluginDef4 = {
43 "myplugin-4", "MyPlugin 4", "MyPlugin", kPlugin4VersionRange, 43 "myplugin-4", "MyPlugin 4", "MyPlugin", kPlugin4VersionRange,
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 EXPECT_FALSE(PluginGroup::IsPluginNameDisabledByPolicy(ASCIIToUTF16("42"))); 220 EXPECT_FALSE(PluginGroup::IsPluginNameDisabledByPolicy(ASCIIToUTF16("42")));
221 EXPECT_TRUE(PluginGroup::IsPluginNameDisabledByPolicy( 221 EXPECT_TRUE(PluginGroup::IsPluginNameDisabledByPolicy(
222 ASCIIToUTF16("Disable this!"))); 222 ASCIIToUTF16("Disable this!")));
223 EXPECT_TRUE(PluginGroup::IsPluginNameDisabledByPolicy( 223 EXPECT_TRUE(PluginGroup::IsPluginNameDisabledByPolicy(
224 ASCIIToUTF16("Google Earth"))); 224 ASCIIToUTF16("Google Earth")));
225 } 225 }
226 226
227 TEST(PluginGroupTest, IsVulnerable) { 227 TEST(PluginGroupTest, IsVulnerable) {
228 // Adobe Reader 10 228 // Adobe Reader 10
229 VersionRangeDefinition adobe_reader_version_range[] = { 229 VersionRangeDefinition adobe_reader_version_range[] = {
230 { "10", "11", "" }, 230 { "10", "11", "", false },
231 { "9", "10", "9.4.1" }, 231 { "9", "10", "9.4.1", false },
232 { "0", "9", "8.2.5" } 232 { "0", "9", "8.2.5", false }
233 }; 233 };
234 PluginGroupDefinition adobe_reader_plugin_def = { 234 PluginGroupDefinition adobe_reader_plugin_def = {
235 "adobe-reader", "Adobe Reader", "Adobe Acrobat", 235 "adobe-reader", "Adobe Reader", "Adobe Acrobat",
236 adobe_reader_version_range, arraysize(adobe_reader_version_range), 236 adobe_reader_version_range, arraysize(adobe_reader_version_range),
237 "http://get.adobe.com/reader/" }; 237 "http://get.adobe.com/reader/" };
238 WebPluginInfo adobe_reader_plugin(ASCIIToUTF16("Adobe Reader"), 238 WebPluginInfo adobe_reader_plugin(ASCIIToUTF16("Adobe Reader"),
239 FilePath(FILE_PATH_LITERAL("/reader.so")), 239 FilePath(FILE_PATH_LITERAL("/reader.so")),
240 ASCIIToUTF16("10.0.0.396"), 240 ASCIIToUTF16("10.0.0.396"),
241 ASCIIToUTF16("adobe reader 10")); 241 ASCIIToUTF16("adobe reader 10"));
242 scoped_ptr<PluginGroup> group(PluginGroupTest::CreatePluginGroup( 242 scoped_ptr<PluginGroup> group(PluginGroupTest::CreatePluginGroup(
243 adobe_reader_plugin_def)); 243 adobe_reader_plugin_def));
244 group->AddPlugin(adobe_reader_plugin); 244 group->AddPlugin(adobe_reader_plugin);
245 PluginGroup group_copy(*group); // Exercise the copy constructor. 245 PluginGroup group_copy(*group); // Exercise the copy constructor.
246 EXPECT_FALSE(group_copy.IsVulnerable()); 246 EXPECT_FALSE(group_copy.IsVulnerable());
247 EXPECT_FALSE(group_copy.RequiresAuthorization());
247 248
248 // Silverlight 4 249 // Silverlight 4
249 VersionRangeDefinition silverlight_version_range[] = { 250 VersionRangeDefinition silverlight_version_range[] = {
250 { "0", "4", "3.0.50106.0" }, 251 { "0", "4", "3.0.50106.0", false },
251 { "4", "5", "" } 252 { "4", "5", "", true }
252 }; 253 };
253 PluginGroupDefinition silverlight_plugin_def = { 254 PluginGroupDefinition silverlight_plugin_def = {
254 "silverlight", "Silverlight", "Silverlight", silverlight_version_range, 255 "silverlight", "Silverlight", "Silverlight", silverlight_version_range,
255 arraysize(silverlight_version_range), 256 arraysize(silverlight_version_range),
256 "http://www.microsoft.com/getsilverlight/" }; 257 "http://www.microsoft.com/getsilverlight/" };
257 WebPluginInfo silverlight_plugin(ASCIIToUTF16("Silverlight"), 258 WebPluginInfo silverlight_plugin(ASCIIToUTF16("Silverlight"),
258 FilePath(FILE_PATH_LITERAL("/silver.so")), 259 FilePath(FILE_PATH_LITERAL("/silver.so")),
259 ASCIIToUTF16("4.0.50917.0"), 260 ASCIIToUTF16("4.0.50917.0"),
260 ASCIIToUTF16("silverlight 4")); 261 ASCIIToUTF16("silverlight 4"));
261 group.reset(PluginGroupTest::CreatePluginGroup(silverlight_plugin_def)); 262 group.reset(PluginGroupTest::CreatePluginGroup(silverlight_plugin_def));
262 group->AddPlugin(silverlight_plugin); 263 group->AddPlugin(silverlight_plugin);
263 EXPECT_FALSE(PluginGroup(*group).IsVulnerable()); 264 EXPECT_FALSE(PluginGroup(*group).IsVulnerable());
265 EXPECT_TRUE(PluginGroup(*group).RequiresAuthorization());
264 } 266 }
265 } // namespace npapi 267 } // namespace npapi
266 } // namespace webkit 268 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698