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

Unified Diff: net/base/mime_sniffer_unittest.cc

Issue 6592089: Adding sniffing of MHTML files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding unit-tests Created 9 years, 10 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 | « net/base/mime_sniffer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/mime_sniffer_unittest.cc
diff --git a/net/base/mime_sniffer_unittest.cc b/net/base/mime_sniffer_unittest.cc
index d70cb230cb59c0a6623d07a5b78cb993cdd2be1d..7a9eedccd4725e3e1f5602767bfccd657f5ecc43 100644
--- a/net/base/mime_sniffer_unittest.cc
+++ b/net/base/mime_sniffer_unittest.cc
@@ -157,6 +157,36 @@ TEST(MimeSnifferTest, ChromeExtensionsTest) {
TestArray(tests, arraysize(tests));
}
+TEST(MimeSnifferTest, MHTMLTest) {
+ // Simple MHT file.
+ EXPECT_EQ("multipart/related",
+ SniffMimeType("From: Chrome\r\n",
+ "file://c/Users/Q/foo.mht",
+ ""));
+ // Simple MHTML file.
+ EXPECT_EQ("multipart/related",
+ SniffMimeType("From: Chrome\r\n",
+ "file://c/Users/Q/foo.mhtml",
+ ""));
+ // File with bad extension.
+ EXPECT_EQ("text/plain",
+ SniffMimeType("From: Chrome\r\n",
+ "file://c/Users/Q/foo.mhtm",
+ ""));
+ // MHTML should not be sniffed, regardless of the extension.
+ EXPECT_FALSE(net::ShouldSniffMimeType(
+ GURL("http://www.example.com/foo.mht"), "multipart/related"));
+ EXPECT_FALSE(net::ShouldSniffMimeType(
+ GURL("http://www.example.com/foo.mhtml"), "multipart/related"));
+ EXPECT_FALSE(net::ShouldSniffMimeType(
+ GURL("http://www.example.com/foo"), "multipart/related"));
+ // MHTML served as plain-text is not recognized.
+ EXPECT_EQ("text/plain",
+ SniffMimeType("From: Chrome\r\n",
+ "http://www.example.com/foo",
+ "text/plain"));
+}
+
TEST(MimeSnifferTest, MozillaCompatibleTest) {
SnifferTest tests[] = {
{ " \n <hTmL>\n <hea", sizeof(" \n <hTmL>\n <hea")-1,
« no previous file with comments | « net/base/mime_sniffer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698