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

Unified Diff: net/base/mime_sniffer_unittest.cc

Issue 160254: Merge 21612 - Implement mimetype sniffing for extensions.... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 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 | « 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
===================================================================
--- net/base/mime_sniffer_unittest.cc (revision 21813)
+++ net/base/mime_sniffer_unittest.cc (working copy)
@@ -90,6 +90,70 @@
TestArray(tests, arraysize(tests));
}
+TEST(MimeSnifferTest, ChromeExtensionsTest) {
+ SnifferTest tests[] = {
+ // schemes
+ { "Cr24\x02\x00\x00\x00", sizeof("Cr24\x02\x00\x00\x00")-1,
+ "http://www.example.com/foo.crx",
+ "", "application/x-chrome-extension" },
+ { "Cr24\x02\x00\x00\x00", sizeof("Cr24\x02\x00\x00\x00")-1,
+ "https://www.example.com/foo.crx",
+ "", "application/x-chrome-extension" },
+ { "Cr24\x02\x00\x00\x00", sizeof("Cr24\x02\x00\x00\x00")-1,
+ "ftp://www.example.com/foo.crx",
+ "", "application/x-chrome-extension" },
+
+ // some other mimetypes that should get converted
+ { "Cr24\x02\x00\x00\x00", sizeof("Cr24\x02\x00\x00\x00")-1,
+ "http://www.example.com/foo.crx",
+ "text/plain", "application/x-chrome-extension" },
+ { "Cr24\x02\x00\x00\x00", sizeof("Cr24\x02\x00\x00\x00")-1,
+ "http://www.example.com/foo.crx",
+ "application/octet-stream", "application/x-chrome-extension" },
+
+ // success edge cases
+ { "Cr24\x02\x00\x00\x00", sizeof("Cr24\x02\x00\x00\x00")-1,
+ "http://www.example.com/foo.crx?query=string",
+ "", "application/x-chrome-extension" },
+ { "Cr24\x02\x00\x00\x00", sizeof("Cr24\x02\x00\x00\x00")-1,
+ "http://www.example.com/foo..crx",
+ "", "application/x-chrome-extension" },
+
+ // wrong file extension
+ { "Cr24\x02\x00\x00\x00", sizeof("Cr24\x02\x00\x00\x00")-1,
+ "http://www.example.com/foo.bin",
+ "", "application/octet-stream" },
+ { "Cr24\x02\x00\x00\x00", sizeof("Cr24\x02\x00\x00\x00")-1,
+ "http://www.example.com/foo.bin?monkey",
+ "", "application/octet-stream" },
+ { "Cr24\x02\x00\x00\x00", sizeof("Cr24\x02\x00\x00\x00")-1,
+ "invalid-url",
+ "", "application/octet-stream" },
+ { "Cr24\x02\x00\x00\x00", sizeof("Cr24\x02\x00\x00\x00")-1,
+ "http://www.example.com",
+ "", "application/octet-stream" },
+ { "Cr24\x02\x00\x00\x00", sizeof("Cr24\x02\x00\x00\x00")-1,
+ "http://www.example.com/",
+ "", "application/octet-stream" },
+ { "Cr24\x02\x00\x00\x00", sizeof("Cr24\x02\x00\x00\x00")-1,
+ "http://www.example.com/foo",
+ "", "application/octet-stream" },
+ { "Cr24\x02\x00\x00\x00", sizeof("Cr24\x02\x00\x00\x00")-1,
+ "http://www.example.com/foocrx",
+ "", "application/octet-stream" },
+ { "Cr24\x02\x00\x00\x00", sizeof("Cr24\x02\x00\x00\x00")-1,
+ "http://www.example.com/foo.crx.blech",
+ "", "application/octet-stream" },
+
+ // wrong magic
+ { "Cr24\x02\x00\x00\x01", sizeof("Cr24\x02\x00\x00\x01")-1,
+ "http://www.example.com/foo.crx?monkey",
+ "", "application/octet-stream" },
+ };
+
+ TestArray(tests, arraysize(tests));
+}
+
TEST(MimeSnifferTest, MozillaCompatibleTest) {
SnifferTest tests[] = {
{ " \n <hTmL>\n <hea", sizeof(" \n <hTmL>\n <hea")-1,
Property changes on: net\base\mime_sniffer_unittest.cc
___________________________________________________________________
Modified: svn:mergeinfo
Merged /trunk/src/net/base/mime_sniffer_unittest.cc:r21612
« 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