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

Unified Diff: webkit/plugins/npapi/plugin_list_unittest.cc

Issue 18364005: Don't override application/octet-stream MIME type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with r212359 Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/plugins/npapi/plugin_list.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/npapi/plugin_list_unittest.cc
diff --git a/webkit/plugins/npapi/plugin_list_unittest.cc b/webkit/plugins/npapi/plugin_list_unittest.cc
index 135be62d0a7a819765ffec2c3895740f525af6a8..f86af86e70729dd9c555de5bb7189df632b66e9d 100644
--- a/webkit/plugins/npapi/plugin_list_unittest.cc
+++ b/webkit/plugins/npapi/plugin_list_unittest.cc
@@ -7,6 +7,7 @@
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "url/gurl.h"
namespace webkit {
namespace npapi {
@@ -38,6 +39,8 @@ bool Contains(const std::vector<WebPluginInfo>& list,
base::FilePath::CharType kFooPath[] = FILE_PATH_LITERAL("/plugins/foo.plugin");
base::FilePath::CharType kBarPath[] = FILE_PATH_LITERAL("/plugins/bar.plugin");
const char* kFooName = "Foo Plugin";
+const char* kFooMimeType = "application/x-foo-mime-type";
+const char* kFooFileType = "foo";
class PluginListTest : public testing::Test {
public:
@@ -55,6 +58,8 @@ class PluginListTest : public testing::Test {
virtual void SetUp() {
plugin_list_.DisablePluginsDiscovery();
plugin_list_.RegisterInternalPlugin(bar_plugin_, false);
+ foo_plugin_.mime_types.push_back(
+ WebPluginMimeType(kFooMimeType, kFooFileType, ""));
Bernhard Bauer 2013/07/18 21:17:10 Nit: Using an empty constructor is slightly more e
asanka 2013/07/18 21:23:52 Done.
plugin_list_.RegisterInternalPlugin(foo_plugin_, false);
}
@@ -85,6 +90,53 @@ TEST_F(PluginListTest, BadPluginDescription) {
ASSERT_TRUE(Contains(plugins, plugin_3043));
}
+TEST_F(PluginListTest, GetPluginInfoArray) {
+ const char kTargetUrl[] = "http://example.com/test.foo";
+ GURL target_url(kTargetUrl);
+ std::vector<WebPluginInfo> plugins;
+ std::vector<std::string> actual_mime_types;
+
+ // The file type of the URL is supported by foo_plugin_. However,
+ // GetPluginInfoArray should not match foo_plugin_ because the MIME type is
+ // application/octet-stream.
+ plugin_list_.GetPluginInfoArray(target_url,
+ "application/octet-stream",
+ false, // allow_wildcard
+ NULL, // use_stale
+ &plugins,
+ &actual_mime_types);
+ EXPECT_EQ(0u, plugins.size());
+ EXPECT_EQ(0u, actual_mime_types.size());
+
+ // foo_plugin_ matches due to the MIME type.
+ plugins.clear();
+ actual_mime_types.clear();
+ plugin_list_.GetPluginInfoArray(target_url,
+ kFooMimeType,
+ false, // allow_wildcard
+ NULL, // use_stale
+ &plugins,
+ &actual_mime_types);
+ EXPECT_EQ(1u, plugins.size());
+ EXPECT_TRUE(Contains(plugins, foo_plugin_));
+ ASSERT_EQ(1u, actual_mime_types.size());
+ EXPECT_EQ(kFooMimeType, actual_mime_types.front());
+
+ // foo_plugin_ matches due to the file type and empty MIME type.
+ plugins.clear();
+ actual_mime_types.clear();
+ plugin_list_.GetPluginInfoArray(target_url,
+ "",
+ false, // allow_wildcard
+ NULL, // use_stale
+ &plugins,
+ &actual_mime_types);
+ EXPECT_EQ(1u, plugins.size());
+ EXPECT_TRUE(Contains(plugins, foo_plugin_));
+ ASSERT_EQ(1u, actual_mime_types.size());
+ EXPECT_EQ(kFooMimeType, actual_mime_types.front());
+}
+
#endif
#if defined(OS_POSIX) && !defined(OS_MACOSX)
« no previous file with comments | « webkit/plugins/npapi/plugin_list.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698